/* ============================================================
   Hero Sequence Demo — 縮時森林
   森林 → Crossfade → 孩子
   ============================================================ */

/* Hero 區：300vh 給滾動驅動序列幀，裡面的 #hero-pin sticky 釘住 100vh */
#hero-sequence *, #hero-sequence *::before, #hero-sequence *::after { box-sizing: border-box; }

/* 覆蓋 kaneyama t-mask-area 可能的限制（避免 overflow hidden / transform / contain 讓 sticky 失效）*/
.t-mask-area:has(#hero-sequence) {
  position: relative !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  transform: none !important;
  clip-path: none !important;
  contain: none !important;
}

/* GSAP pin 模式：高度由 ScrollTrigger pin spacer 自動計算（含 hero 動畫 + 1500px 轉場）*/
#hero-sequence {
  position: relative;
  width: 100%;
  z-index: 10;
  background: #0b0f10;
}

/* GSAP pin 接管釘住行為：position relative 讓 GSAP 把它變 fixed-like pin */
#hero-pin {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: #0b0f10;
}

/* 雙保險：覆蓋 GSAP ScrollTrigger pin 寫進去的 inline width/max-width，
   避免拖視窗或進入全螢幕時 hero-pin 寬度卡在中間值。
   高 specificity (html body #hero-pin) + !important 確保勝過 inline style */
html body #hero-pin {
  width: 100% !important;
  max-width: none !important;
}

/* ============================================================
   電影級視覺氛圍層（B 方案：CSS filter + vignette + grain）
   ============================================================ */

/* 強化 canvas filter：電影感的對比/飽和、微暗、柔化 AI 升頻偽影 */
#forest-canvas,
#child-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  will-change: opacity;
  filter:
    contrast(1.06)
    saturate(1.10)
    brightness(0.96)
    blur(0.5px);
}

/* Vignette 暗角：聚焦視線到畫面中央，加強電影感 */
#hero-pin::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 30%,
    rgba(0, 0, 0, 0.28) 65%,
    rgba(0, 0, 0, 0.60) 100%
  );
  z-index: 1;
}

/* Film grain 顆粒感：消除 AI 升頻塑膠感，營造底片質地 */
#hero-pin::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 200px 200px;
}

/* 初始狀態：森林顯示、孩子隱藏 */
#forest-canvas { opacity: 1; }
#child-canvas  { opacity: 0; }

/* 文字內容層 */
.hero-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  pointer-events: none; /* 父容器不擋 hit-test；child 強制 auto 見檔尾 v0.3 規則 */
  color: #f5efe7;
  /* 雙層柔光：像文字浮在森林霧氣中，而非銳利疊加 */
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.55), 0 0 60px rgba(0, 0, 0, 0.35);
  will-change: opacity, transform;
  z-index: 3; /* 壓在 scrim、vignette 之上 */
}

/* 電影調色 overlay：深森林綠 soft-light，統一色調、弱化壓縮感 */
.hero-color-overlay {
  position: absolute;
  inset: 0;
  background: #0d2b1a;
  mix-blend-mode: soft-light;
  opacity: 0.22;
  pointer-events: none;
  z-index: 1;
}

/* 孩子階段文字襯底：黑色漸層 scrim，scroll-linked 淡入（由 JS 控制 opacity）*/
.hero-scrim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 65%;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.55) 35%,
    rgba(0, 0, 0, 0.25) 70%,
    rgba(0, 0, 0, 0) 100%
  );
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
  z-index: 2; /* 高於 canvas、vignette；低於 hero-content（3）*/
}

.hero-content[data-layer="forest"] {
  opacity: 1;
}
.hero-content[data-layer="child"] {
  opacity: 0;
}

/* 孩子層作為情感收尾，字級比森林層再大一階 */
/* transform：往上推避開小孩的臉（畫面主角）*/
/* text-shadow：底部更深的近距離陰影，避免字在陽光灑下處讀不到 */
.hero-content[data-layer="child"] .hero-lead {
  font-size: clamp(20px, 5vw, 42px); /* 手機上不會擠出畫面 */
  color: #EEEAE7;
  transform: translateY(-10vh);
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.95),
    0 6px 18px rgba(0, 0, 0, 0.75),
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(0, 0, 0, 0.35);
}

.hero-lead {
  font-family: "Noto Serif TC", "Cormorant Garamond", serif;
  font-size: clamp(16px, 3.2vw, 25px);
  color: #EEEAE7;
  letter-spacing: 0.25em;
  font-weight: 400;
  margin: 0 0 36px;
  line-height: 2;
}

.hero-title {
  font-family: "Noto Serif TC", "Fraunces", serif;
  font-size: clamp(48px, 8vw, 112px);
  color: #E8E5DA;
  font-weight: 300;
  letter-spacing: 0.22em;
  margin: 0;
  line-height: 1.3;
}

/* 開場標語：preloader 結束後逐行淡入，scroll 1739px 後淡出 */
.hero-tagline {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 8vw;
  margin: 0;
  pointer-events: none;
  will-change: opacity;
}

.hero-tagline__line {
  display: block;
  color: #E8E5DA;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.55), 0 0 60px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(16px);
  will-change: opacity, transform;
}

.hero-tagline__line:first-child {
  font-family: 'Noto Serif TC', serif;
  font-size: 45px;
  font-weight: 500;
  letter-spacing: 0.25em;
  margin-bottom: 28px;
  line-height: 2;
}

.hero-tagline__line:nth-child(2) {
  font-family: 'Noto Serif TC', serif;
  font-size: 121px;
  font-weight: 800;
  letter-spacing: 0.22em;
  line-height: 1.3;
  margin-bottom: 32px;
}

.hero-tagline__line:nth-child(3) {
  font-family: 'Noto Serif TC', serif;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: 0.2em;
  line-height: 2;
  opacity: 0;
  width: 434px;
  height: 128px;
}

/* v0.3：父層 pointer-events:none，子文字補回 auto 讓 devtools 可點選 */
.hero-tagline__line {
  pointer-events: auto;
}

/* 第二段標語：scroll 1984 → 3531 px 出現 → 消失（由 initHeroTagline2 控制 opacity） */
.hero-tagline-2 {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 8vw;
  margin: 0;
  pointer-events: none;
  opacity: 0;
  will-change: opacity;
}

.hero-tagline-2__line {
  display: block;
  font-family: 'Noto Serif TC', serif;
  font-size: 56px;
  font-weight: 600;
  letter-spacing: 0.22em;
  line-height: 1.6;
  color: #E8E5DA;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.7),
    0 6px 30px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(0, 0, 0, 0.35);
  opacity: 0;
  will-change: opacity;
  pointer-events: auto;
}

.hero-tagline-2__line + .hero-tagline-2__line {
  margin-top: 24px;
}

/* ============================================================
   Hero 響應式（手機 + 平板，不影響桌機，2026-05-21 新增）
   桌機原規則（.hero-tagline__line first/2nd/3rd 寫死 45/121/32px、width 434px）
   不修改，只在 768px 以下用 @media 覆蓋。
   ============================================================ */
@media (max-width: 768px) {
  .hero-tagline__line:first-child {
    font-size: clamp(20px, 4.4vw, 30px);
    letter-spacing: 0.2em;
    margin-bottom: 18px;
    line-height: 1.8;
  }
  .hero-tagline__line:nth-child(2) {
    font-size: clamp(56px, 16vw, 88px);
    letter-spacing: 0.18em;
    margin-bottom: 22px;
  }
  .hero-tagline__line:nth-child(3) {
    font-size: clamp(15px, 3.8vw, 22px);
    width: auto;
    max-width: 92vw;
    height: auto;
    letter-spacing: 0.15em;
    line-height: 1.8;
  }
  .hero-tagline-2__line {
    font-size: clamp(26px, 6.2vw, 40px);
    letter-spacing: 0.18em;
    line-height: 1.5;
  }
  .hero-tagline-2__line + .hero-tagline-2__line {
    margin-top: 16px;
  }
}
@media (max-width: 480px) {
  .hero-tagline__line:nth-child(2) {
    font-size: clamp(44px, 14vw, 62px);
    letter-spacing: 0.14em;
  }
}
/* 平板（iPad 直/橫 769–1024px）：原本落在「桌機寫死大字」與「≤768 手機」之間沒人管，
   導致 hero1「林」、hero2「小孩/抱」單字落單換行。此區把字級/字距調小至單行可容，
   不影響桌機（>1024）與手機（≤768）。2026-06-01 新增。 */
@media (min-width: 769px) and (max-width: 1024px) {
  .hero-tagline__line:first-child {
    font-size: clamp(30px, 4.4vw, 42px);
    letter-spacing: 0.2em;
    margin-bottom: 24px;
    line-height: 1.9;
    max-width: 92vw;
  }
  .hero-tagline__line:nth-child(2) {
    font-size: clamp(72px, 10vw, 104px);
    letter-spacing: 0.18em;
    margin-bottom: 28px;
  }
  .hero-tagline__line:nth-child(3) {
    font-size: clamp(22px, 3vw, 30px);
    width: auto;
    max-width: 92vw;
    height: auto;
    letter-spacing: 0.18em;
    line-height: 1.9;
  }
  .hero-tagline-2__line {
    font-size: clamp(34px, 5vw, 48px);
    letter-spacing: 0.16em;
    line-height: 1.5;
    max-width: 92vw;
  }
  .hero-tagline-2__line + .hero-tagline-2__line {
    margin-top: 20px;
  }
}

/* Stack 全黑期標語：scroll 12697 → 15040 px 逐字 fade in（blur + scale）→ 整段淡出 */
/* z-index 必須 > .page-veil 的 500（page-veil 是 #000 全黑覆蓋），不然文字會被吃掉 */
.stack-tagline {
  position: fixed;
  inset: 0;
  z-index: 510;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 6vw;
  margin: 0;
  pointer-events: none;
  opacity: 0;
  will-change: opacity;
}

.stack-tagline__line {
  margin: 0;
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 500;
  letter-spacing: 0.22em;
  line-height: 1.5;
  color: #FFFFFF;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.85),
    0 8px 32px rgba(0, 0, 0, 0.6);
}

.stack-tagline__line + .stack-tagline__line {
  margin-top: 24px;
}

.stack-tagline__char {
  display: inline-block;
  opacity: 0;
  transform: translate(-2px, 4px) scale(0.9);
  filter: blur(6px);
  will-change: opacity, transform, filter;
}

/* Stack-tagline 手機 + 平板：從中央改頂部、縮字級（讓 ROOT 內文中央有空間，桌機保留中央） */
@media (max-width: 768px) {
  .stack-tagline {
    justify-content: flex-start;
    padding-top: 14vh;
  }
  .stack-tagline__line {
    font-size: clamp(22px, 5.6vw, 32px);
    letter-spacing: 0.16em;
    line-height: 1.5;
  }
  .stack-tagline__line + .stack-tagline__line {
    margin-top: 14px;
  }
}

/* FIVE-SENSES 進場前標語：scroll 23521 → 24777 px 逐字 fade in（blur + scale）→ 整段淡出 */
/* z-index 510，同 stack-tagline 浮在 page-veil 之上 */
.senses-tagline {
  position: fixed;
  inset: 0;
  z-index: 510;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 6vw;
  margin: 0;
  pointer-events: none;
  opacity: 0;
  will-change: opacity;
}

.senses-tagline__line {
  margin: 0;
  font-family: 'Crimson Text', 'Noto Serif TC', serif;
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.8;
  color: #eee;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.85),
    0 8px 32px rgba(0, 0, 0, 0.6);
}

.senses-tagline__line + .senses-tagline__line {
  margin-top: 20px;
}

.senses-tagline__char {
  display: inline-block;
  opacity: 0;
  transform: translate(-2px, 4px) scale(0.9);
  filter: blur(6px);
  will-change: opacity, transform, filter;
}

/* Senses-tagline 手機 + 平板：從中央改頂部、縮字級（同 stack-tagline 風格，桌機保留中央） */
@media (max-width: 768px) {
  .senses-tagline {
    justify-content: flex-start;
    padding-top: 14vh;
  }
  .senses-tagline__line {
    font-size: clamp(18px, 4.8vw, 26px);
    letter-spacing: 0.12em;
    line-height: 1.6;
  }
  .senses-tagline__line + .senses-tagline__line {
    margin-top: 12px;
  }
}

/* TOOLS 進場前標語：scroll 33546 → 34570 px 逐字 fade in（blur + scale）→ 整段淡出 */
/* z-index 510，同 senses-tagline 浮在 page-veil 之上 */
.tools-tagline {
  position: fixed;
  inset: 0;
  z-index: 510;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 6vw;
  margin: 0;
  pointer-events: none;
  opacity: 0;
  will-change: opacity;
}

.tools-tagline__line {
  margin: 0;
  font-family: 'Crimson Text', 'Noto Serif TC', serif;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.8;
  color: #eee;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.85),
    0 8px 32px rgba(0, 0, 0, 0.6);
}

.tools-tagline__line + .tools-tagline__line {
  margin-top: 20px;
}

.tools-tagline__char {
  display: inline-block;
  opacity: 0;
  transform: translate(-2px, 4px) scale(0.9);
  filter: blur(6px);
  will-change: opacity, transform, filter;
}

/* Tools-tagline 手機 + 平板：從中央改頂部、縮字級（同 stack-tagline 風格，桌機保留中央） */
@media (max-width: 768px) {
  .tools-tagline {
    justify-content: flex-start;
    padding-top: 14vh;
  }
  .tools-tagline__line {
    font-size: clamp(20px, 5vw, 30px);
    letter-spacing: 0.12em;
    line-height: 1.6;
  }
  .tools-tagline__line + .tools-tagline__line {
    margin-top: 12px;
  }
}

.hero-scroll-hint {
  position: fixed;
  bottom: clamp(20px, 4vh, 40px);
  left: 50%;
  margin: 0;
  z-index: 200;
  font-size: clamp(11px, 1.6vw, 13px);
  letter-spacing: 0.4em;
  opacity: 0.7;
  color: var(--ts-cream, #EEEAE7);
  pointer-events: none;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, 8px); }
}

/* v0.3：父層 .hero-content 維持 pointer-events: none（兩個 layer 重疊只有 visible 那個該被選），
   給內部文字 child (h1, p) 強制 auto。但有 opacity:0 layer 也會被命中——
   故再對 .hero-content[data-layer="child"] 的 child 加 :not(.is-visible) 控制
   先簡化：直接 child auto，重疊問題交給 elementsFromPoint stack[0/1] + Alt+↑/↓ 切層處理 */
.hero-content > * {
  pointer-events: auto;
}

