// Scenes 1-3: Problem, Intro, Magic

// ─────────────────────────────────────────────────────────────
// SCENE 1 — The Problem (0-5s)
// Awkward laptop translator scene
// ─────────────────────────────────────────────────────────────
function Scene1Problem() {
  const { localTime, duration, progress } = useSprite();
  const t = localTime;

  // typed text reveals char by char (0 → ~1.2s)
  const typed = "how do i flirt in japanese";
  const typeP = clamp((t - 0.25) / 1.0, 0, 1);
  const typedShown = typed.slice(0, Math.floor(typed.length * typeP));

  // translator output appears at 1.6s
  const outputT = clamp((t - 1.6) / 0.6, 0, 1);

  // girl's reaction — long silent stare, then close laptop
  const reactionT = clamp((t - 2.6) / 0.5, 0, 1);
  const closeT = clamp((t - 3.6) / 0.9, 0, 1);

  // tagline pops in last
  const tagT = clamp((t - 4.0) / 0.5, 0, 1);

  // overall camera: slow zoom-in
  const camScale = 1 + 0.04 * Easing.easeOutQuad(progress);

  return (
    <div style={{
      position: 'absolute', inset: 0,
      background: V.paper2,
      transform: `scale(${camScale})`,
      transformOrigin: '50% 50%',
    }}>
      <VPaperTexture />

      {/* Chapter chip — small pill, top-center.
          Replaces the earlier heavy double-bordered stamp which
          (a) competed with the central translator UI for attention
          and (b) duplicated the SceneMarker at bottom-left. */}
      <div style={{
        position: 'absolute', top: 44, left: '50%',
        transform: `translateX(-50%) rotate(-1.5deg) scale(${0.94 + 0.06 * Easing.easeOutBack(clamp((t - 0.1) / 0.4, 0, 1))})`,
        opacity: clamp((t - 0.1) / 0.3, 0, 1),
        display: 'inline-flex', alignItems: 'center', gap: 12,
        padding: '10px 22px',
        border: `2px solid ${V.red}`,
        borderRadius: 999,
        background: 'rgba(192,57,43,0.05)',
        boxShadow: '3px 4px 0 rgba(192,57,43,0.08)',
      }}>
        <span style={{
          fontFamily: fontMono, fontSize: 15, fontWeight: 700, letterSpacing: 3,
          color: V.red, lineHeight: 1,
        }}>
          BEFORE
        </span>
        <HuggieLogo size={24} color={V.red} heartColor={V.red} noHeart />
        <span style={{
          fontFamily: fontMono, fontSize: 11, color: V.red, opacity: 0.55, letterSpacing: 2,
          paddingLeft: 10, borderLeft: `1.5px solid rgba(192,57,43,0.3)`, lineHeight: 1,
        }}>
          THE OLD WAY
        </span>
      </div>

      {/* SPLIT — guy laptop left, girl laptop right */}
      <div style={{
        position: 'absolute', inset: 0,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        gap: 80,
      }}>
        {/* LEFT — guy's translator */}
        <div style={{
          opacity: clamp((t - 0.1) / 0.4, 0, 1),
          transform: `translateY(${(1 - clamp((t - 0.1) / 0.4, 0, 1)) * 20}px)`,
        }}>
          <div style={{
            width: 620, background: V.paper,
            border: `3px solid ${V.ink}`, borderRadius: 24,
            boxShadow: '8px 12px 0 rgba(0,0,0,0.08)',
            overflow: 'hidden',
          }}>
            <div style={{
              padding: '12px 20px', display: 'flex', alignItems: 'center', gap: 8,
              borderBottom: `2px solid ${V.ink}`, fontFamily: fontMono, fontSize: 16,
            }}>
              <div style={{ width: 14, height: 14, borderRadius: 7, background: V.red, border: `1.5px solid ${V.ink}` }} />
              <div style={{ width: 14, height: 14, borderRadius: 7, background: '#f1c40f', border: `1.5px solid ${V.ink}` }} />
              <div style={{ width: 14, height: 14, borderRadius: 7, background: V.green, border: `1.5px solid ${V.ink}` }} />
              <div style={{ marginLeft: 16, color: V.ink3 }}>translate.totally-not-google.com</div>
            </div>
            <div style={{ padding: '24px 28px', display: 'flex', flexDirection: 'column', gap: 18 }}>
              <div>
                <div style={{ fontFamily: fontMono, fontSize: 14, color: V.ink3, letterSpacing: 2, marginBottom: 6 }}>ENGLISH</div>
                <div style={{
                  fontFamily: fontHand, fontSize: 32, fontWeight: 700,
                  background: V.paper2, border: `2px dashed ${V.ink3}`, borderRadius: 12,
                  padding: '16px 18px', minHeight: 80,
                }}>
                  {typedShown}
                  {typeP < 1 && <span style={{ opacity: 0.6, animation: 'vBlink 0.5s steps(2) infinite' }}>|</span>}
                </div>
              </div>
              <div style={{ fontSize: 28, textAlign: 'center', color: V.accent, fontFamily: fontMono, opacity: outputT }}>↓</div>
              <div style={{ opacity: outputT, transform: `translateY(${(1 - outputT) * 12}px)` }}>
                <div style={{ fontFamily: fontMono, fontSize: 14, color: V.ink3, letterSpacing: 2, marginBottom: 6 }}>JAPANESE (ROMAJI)</div>
                <div style={{
                  fontFamily: fontHand, fontSize: 28, fontWeight: 700, color: V.ink,
                  background: V.accent2, border: `2px solid ${V.accent}`, borderRadius: 12,
                  padding: '16px 18px', minHeight: 80, lineHeight: 1.35,
                }}>
                  "honorable potato, your eyes resemble moonlight"
                </div>
                <div style={{ marginTop: 8, fontFamily: fontMono, fontSize: 13, color: V.ink3, fontStyle: 'italic' }}>
                  ↳ confidence: 12% · tone: alarming
                </div>
              </div>
            </div>
          </div>
        </div>

        {/* RIGHT — girl receiving, slowly closing */}
        <div style={{
          opacity: clamp((t - 2.2) / 0.4, 0, 1),
          position: 'relative',
        }}>
          {/* "laptop" — collapses on close */}
          <div style={{
            width: 520, height: 360,
            transformOrigin: 'center bottom',
            transform: `perspective(900px) rotateX(${closeT * 92}deg)`,
            transition: 'transform 0.1s linear',
          }}>
            <div style={{
              width: '100%', height: '100%', background: V.paper,
              border: `3px solid ${V.ink}`, borderRadius: 18,
              padding: '24px 28px', display: 'flex', flexDirection: 'column', gap: 14,
              boxShadow: '6px 10px 0 rgba(0,0,0,0.08)',
            }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
                <VAvatar size={56} label="Y" color={V.accent2} />
                <div>
                  <div style={{ fontFamily: fontHead, fontSize: 22, fontWeight: 700 }}>Yuki</div>
                  <div style={{ fontFamily: fontMono, fontSize: 13, color: V.ink3 }}>online · Tokyo</div>
                </div>
                <div style={{ marginLeft: 'auto', fontFamily: fontMono, fontSize: 13, color: V.ink3 }}>3:42 AM</div>
              </div>
              {/* incoming message */}
              <div style={{
                alignSelf: 'flex-start', maxWidth: '90%',
                background: V.paper2, border: `2px solid ${V.ink}`,
                borderRadius: '20px 20px 20px 4px', padding: '12px 16px',
                fontSize: 22, fontWeight: 700,
              }}>
                敬愛するじゃがいも、君の瞳は月光のよう
              </div>
              <div style={{
                alignSelf: 'flex-start', fontFamily: fontMono, fontSize: 13, color: V.ink3,
                fontStyle: 'italic', marginLeft: 4,
              }}>
                ↳ translated from english · ??? confidence
              </div>

              {/* her reaction sticker */}
              <div style={{
                position: 'absolute', right: 24, bottom: 28,
                transform: `translateY(${(1 - reactionT) * 30}px) rotate(${-8 + reactionT * 4}deg)`,
                opacity: reactionT,
                fontFamily: "'Caveat', cursive", fontSize: 30,
                color: V.red, fontWeight: 700,
              }}>
                ……えっ？
                <div style={{ fontFamily: fontMono, fontSize: 14, marginTop: 4 }}>"…huh?"</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* Punchline tagline */}
      <div style={{
        position: 'absolute', bottom: 80, left: 0, right: 0, textAlign: 'center',
        opacity: tagT,
        transform: `translateY(${(1 - tagT) * 24}px)`,
      }}>
        <div style={{
          fontFamily: fontHead, fontSize: 76, fontWeight: 700, color: V.ink,
          letterSpacing: '-0.03em',
        }}>
          talking across languages
          <span style={{ fontFamily: fontSerif, fontStyle: 'italic', color: V.red, fontWeight: 400 }}>
            {' is hard.'}
          </span>
        </div>
        <div style={{ display: 'inline-block', marginTop: 4 }}>
          <VUnderline w={280} thick={6} color={V.red} />
        </div>
      </div>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// SCENE 2 — Phone lights up: Huggie incoming (5-10s)
// ─────────────────────────────────────────────────────────────
function Scene2Intro() {
  const { localTime, progress } = useSprite();
  const t = localTime;

  // 0.0-0.4   black hold
  // 0.4-1.4   huggie wordmark BIG, fades in centered
  // 1.4-2.0   logo shrinks + moves up; phone slides in from bottom
  // 2.0-3.4   phone holds with ringing animation
  // 3.4-5.0   "or... just talk." callout, then bleed

  const logoBigT = clamp((t - 0.3) / 0.7, 0, 1);
  // logo transitions to small/top between 1.4 and 2.0
  const logoMoveT = clamp((t - 1.3) / 0.7, 0, 1);
  // phone enters with logo move
  const phoneIn = clamp((t - 1.5) / 0.7, 0, 1);
  const phoneScale = 0.85 + 0.15 * Easing.easeOutBack(phoneIn);
  const phoneY = (1 - phoneIn) * 240;

  // logo position blend: centered/large → top/small
  const logoScale = 1.0 - 0.78 * Easing.easeInOutCubic(logoMoveT);
  const logoTop   = 480 - 410 * Easing.easeInOutCubic(logoMoveT); // px from center area to near-top

  const ringStartT = 1.8;

  // tagline beat
  const tagT = clamp((t - 3.2) / 0.5, 0, 1);

  return (
    <div style={{
      position: 'absolute', inset: 0,
      background: '#0e0e0e',
      display: 'flex', alignItems: 'flex-start', justifyContent: 'center',
    }}>
      {/* warm gradient glow */}
      <div style={{
        position: 'absolute', inset: 0,
        background: `radial-gradient(circle at 50% 45%, rgba(255,107,74,0.18), transparent 55%)`,
      }} />

      {/* HUGGIE LOGO — starts huge centered, shrinks + parks at top */}
      <div style={{
        position: 'absolute', left: '50%', top: logoTop,
        transform: `translate(-50%, -50%) scale(${logoScale})`,
        opacity: logoBigT,
        transformOrigin: 'center',
      }}>
        <div style={{ textAlign: 'center' }}>
          <HuggieLogo size={220} color="#fff" heartColor={V.accent} />
          {/* tagline below, fades out as it shrinks */}
          <div style={{
            marginTop: 4,
            fontFamily: fontSerif, fontStyle: 'italic',
            fontSize: 44, color: V.accent2, opacity: 1 - logoMoveT,
            letterSpacing: '-0.01em',
          }}>
            every call, in the language of your heart.
          </div>
        </div>
      </div>

      {/* PHONE — slides up + scales in once logo parks */}
      <div style={{
        position: 'absolute', left: '50%', top: 290,
        transform: `translateX(-50%) translateY(${phoneY}px) scale(${phoneScale})`,
        opacity: phoneIn,
      }}>
        <VPhone width={460} height={920} dark>
          <div style={{
            height: '100%', padding: '32px 26px 24px',
            display: 'flex', flexDirection: 'column', color: '#fff',
          }}>
            <div style={{ display: 'flex', justifyContent: 'center' }}>
              <HuggieBug size={22} color="#fff" heartColor={V.accent} label="incoming" />
            </div>

            <div style={{
              flex: 1, display: 'flex', flexDirection: 'column',
              alignItems: 'center', justifyContent: 'center', gap: 22,
              position: 'relative',
            }}>
              {/* avatar with ripples */}
              <div style={{ position: 'relative' }}>
                {[0, 1, 2].map(i => {
                  const phase = (t - ringStartT - i * 0.5) % 2.4;
                  if (phase < 0) return null;
                  const s = 1 + (phase / 2.4) * 1.6;
                  const o = Math.max(0, 0.55 - phase / 2.4 * 0.55);
                  return (
                    <div key={i} style={{
                      position: 'absolute', inset: 0,
                      width: 200, height: 200, borderRadius: '50%',
                      border: `3px solid ${V.accent}`,
                      transform: `scale(${s})`,
                      opacity: o,
                    }} />
                  );
                })}
                <VAvatar size={200} label="Y" color={V.accent2} />
              </div>
              <div style={{
                fontFamily: fontHead, fontSize: 46, fontWeight: 700,
              }}>
                Yuki Tanaka
              </div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
                <VLang code="JP" color={V.accent} style={{ background: V.accent, color: '#fff' }} size={40} />
                <div style={{ fontFamily: fontHead, fontSize: 20, color: 'rgba(255,255,255,0.75)', fontWeight: 500 }}>
                  japanese · tokyo
                </div>
              </div>
              <div style={{
                padding: '10px 20px',
                background: 'rgba(255,107,74,0.18)',
                border: `2px dashed ${V.accent}`,
                borderRadius: 14,
                fontFamily: fontHand, fontSize: 24, color: '#fff',
                fontStyle: 'italic',
              }}>
                ✦ will translate live · JP → EN
              </div>
            </div>

            {/* decline / accept */}
            <div style={{ display: 'flex', justifyContent: 'space-around', alignItems: 'center', marginBottom: 24 }}>
              <div style={{ textAlign: 'center' }}>
                <div style={{
                  width: 104, height: 104, borderRadius: '50%',
                  background: V.red, color: '#fff',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  fontSize: 42,
                }}>✕</div>
                <div style={{ fontFamily: fontMono, fontSize: 15, color: 'rgba(255,255,255,0.6)', marginTop: 12 }}>decline</div>
              </div>
              <div style={{ textAlign: 'center' }}>
                <div style={{
                  width: 104, height: 104, borderRadius: '50%',
                  background: V.green, color: '#fff',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  fontSize: 42,
                  animation: 'vFloat 1.6s ease-in-out infinite',
                }}>☎</div>
                <div style={{ fontFamily: fontMono, fontSize: 15, color: V.accent2, marginTop: 12, fontWeight: 700 }}>accept</div>
              </div>
            </div>
          </div>
        </VPhone>
      </div>

      {/* Left-side problem statement — balances the right callout
          so the canvas reads edge-to-edge instead of pooling all
          composition into the centre + right. The two pieces of text
          plus the phone together tell the full Scene 2 micro-story:
            problem (left)  →  trigger (phone)  →  resolution (right) */}
      <div style={{
        position: 'absolute', left: 110, top: '34%',
        opacity: tagT,
        transform: `translateX(${-(1 - tagT) * 60}px) rotate(3deg)`,
        fontFamily: "'Caveat', cursive", color: V.accent2,
        textAlign: 'right', maxWidth: 420,
      }}>
        <div style={{
          fontFamily: fontMono, fontSize: 22, color: V.accent2, opacity: 0.85,
          letterSpacing: 4, lineHeight: 1,
        }}>3:42 AM</div>
        <div style={{
          fontSize: 64, fontWeight: 700, lineHeight: 1.05, marginTop: 14,
          color: V.accent2,
        }}>
          she calls.<br/>
          <span style={{ color: V.accent }}>you don't speak<br/>japanese.</span>
        </div>
        <svg width="260" height="42" style={{ marginTop: 8, marginLeft: 'auto', display: 'block' }}>
          <path d="M 10 22 Q 100 6, 180 22 Q 220 32, 248 22 L 240 14 M 248 22 L 240 30"
                stroke={V.accent} strokeWidth="3" fill="none" strokeLinecap="round" />
        </svg>
      </div>

      {/* "Or… just talk." callout — only appears once phone is in */}
      <div style={{
        position: 'absolute', right: 130, top: '45%',
        opacity: tagT,
        transform: `translateX(${(1 - tagT) * 60}px) rotate(-3deg)`,
        fontFamily: fontSerif, color: V.accent2,
        textAlign: 'left', fontStyle: 'italic',
      }}>
        <div style={{ fontSize: 88, fontWeight: 400, lineHeight: 1.0 }}>or…</div>
        <div style={{ fontSize: 88, fontWeight: 400, lineHeight: 1.0, marginTop: 6, color: V.accent }}>just talk.</div>
        <svg width="200" height="60" style={{ marginTop: 4 }}>
          <path d="M 10 30 Q 80 50, 140 25 Q 170 14, 188 30 L 180 22 M 188 30 L 178 36"
                stroke={V.accent} strokeWidth="3" fill="none" strokeLinecap="round" />
        </svg>
      </div>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// SCENE 3 — The Magic: split-screen call (10-25s)
// ─────────────────────────────────────────────────────────────
function Scene3Magic() {
  const { localTime, progress } = useSprite();
  const t = localTime;

  // Phones slide in from sides 0-0.6s
  const enterT = clamp(t / 0.7, 0, 1);

  // Yuki speaks 0.8-3.5s (JP)
  const yukiCapP = clamp((t - 1.0) / 1.5, 0, 1);
  const yukiCapAlive = t > 0.8 && t < 5.5;

  // Latency badge pops 1.5
  const latT = clamp((t - 1.5) / 0.4, 0, 1);

  // Guy hears EN, responds 4-7s
  const guyCapP = clamp((t - 4.6) / 1.4, 0, 1);
  const guyCapAlive = t > 4.4 && t < 8.5;

  // Reverse: girl hears JP 7-9.5s
  const yukiHearP = clamp((t - 8.0) / 1.3, 0, 1);
  const yukiHearAlive = t > 7.8 && t < 11.5;

  // Headlines: "Real-time voice translation." 9.5-12s, "In your own voice." 12-15s
  const head1T = t > 11.5 && t < 14.0 ? clamp((t - 11.5) / 0.4, 0, 1) - clamp((t - 13.5) / 0.4, 0, 1) : 0;
  const head2T = t > 13.5 ? clamp((t - 13.5) / 0.4, 0, 1) : 0;

  // who's speaking (for waveform intensity)
  const yukiSpeaking = (t > 0.8 && t < 3.5) || (t > 8.0 && t < 10.5);
  const guySpeaking = (t > 4.4 && t < 7.0);

  return (
    <div style={{ position: 'absolute', inset: 0, background: V.paper2 }}>
      <VPaperTexture />

      {/* Chapter chip — mirrors the BEFORE chip in Scene 1.
          Top-center placement keeps it clear of the phone-side
          "on the guy's phone" / "on yuki's phone" annotations. */}
      <div style={{
        position: 'absolute', top: 44, left: '50%',
        transform: `translateX(-50%) rotate(-1deg) scale(${0.94 + 0.06 * Easing.easeOutBack(clamp((t - 0.4) / 0.5, 0, 1))})`,
        opacity: clamp((t - 0.4) / 0.4, 0, 1) * (1 - clamp((t - 10.5) / 0.6, 0, 1)),
        display: 'inline-flex', alignItems: 'center', gap: 12,
        padding: '10px 22px',
        border: `2px solid ${V.accent}`,
        borderRadius: 999,
        background: 'rgba(255,107,74,0.07)',
        boxShadow: '3px 4px 0 rgba(255,107,74,0.1)',
      }}>
        <span style={{
          fontFamily: fontMono, fontSize: 15, fontWeight: 700, letterSpacing: 3,
          color: V.accent, lineHeight: 1,
        }}>
          WITH
        </span>
        <HuggieLogo size={24} color={V.accent} heartColor={V.accent} noHeart />
        <span style={{
          fontFamily: fontMono, fontSize: 11, color: V.accent, opacity: 0.7, letterSpacing: 2,
          paddingLeft: 10, borderLeft: `1.5px solid rgba(255,107,74,0.3)`, lineHeight: 1,
        }}>
          A REAL CONVERSATION
        </span>
      </div>

      {/* Connecting "thread" between phones — lowered so it sits
          BELOW the caption stack (which occupies roughly y=200–680)
          and forms a calm lens near the phone bottoms instead of
          slicing through the middle of the conversation. */}
      <svg style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }} width="100%" height="100%">
        <path d="M 580 920 Q 960 870, 1340 920"
              stroke={V.accent} strokeWidth="3" fill="none"
              strokeDasharray="8 10" opacity={enterT * 0.55} />
        <path d="M 580 920 Q 960 970, 1340 920"
              stroke={V.accent} strokeWidth="3" fill="none"
              strokeDasharray="8 10" opacity={enterT * 0.4} />
      </svg>

      {/* LEFT PHONE — Yuki (the one being shown to "us", the guy) */}
      <div style={{
        position: 'absolute', left: 120, top: 90,
        transform: `translateX(${(1 - enterT) * -200}px)`,
        opacity: enterT,
      }}>
        <CallScreen
          name="Yuki Tanaka"
          lang="JP"
          langName="japanese → english"
          avatarLabel="Y"
          time={t}
          speaking={yukiSpeaking}
          dark={false}
        />
        <div style={{
          position: 'absolute', top: -78, left: 24,
          fontFamily: "'Caveat', cursive", color: V.accent, fontSize: 36, fontWeight: 700,
          transform: 'rotate(-3deg)',
        }}>↓ on the guy's phone</div>
      </div>

      {/* RIGHT PHONE — Guy's voice, Yuki's view */}
      <div style={{
        position: 'absolute', right: 120, top: 90,
        transform: `translateX(${(1 - enterT) * 200}px)`,
        opacity: enterT,
      }}>
        <CallScreen
          name="Alex Chen"
          lang="EN"
          langName="english → japanese"
          avatarLabel="A"
          time={t}
          speaking={guySpeaking}
          dark
        />
        <div style={{
          position: 'absolute', top: -78, right: 24,
          fontFamily: "'Caveat', cursive", color: V.accent, fontSize: 36, fontWeight: 700,
          transform: 'rotate(3deg)',
        }}>on yuki's phone ↓</div>
      </div>

      {/* CENTER stack — captions, latency, headlines */}
      <div style={{
        position: 'absolute', left: '50%', top: 200,
        transform: 'translateX(-50%)',
        width: 640, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 22,
      }}>
        {/* Latency */}
        <div style={{
          opacity: latT,
          transform: `scale(${0.85 + 0.15 * Easing.easeOutBack(latT)})`,
        }}>
          <VLatency ms={400} time={t} />
        </div>

        {/* Yuki caption (JP → EN) */}
        {yukiCapAlive && (
          <div style={{ opacity: clamp((t - 0.8) / 0.3, 0, 1) * (1 - clamp((t - 5.0) / 0.5, 0, 1)) }}>
            <VCaption who="YUKI" lang="JP→EN" original="ねえ、声がほんとに優しいね…"
                      progress={yukiCapP} width={580}>
              {"\"hey… your voice is really gentle.\""}
            </VCaption>
          </div>
        )}

        {/* Guy caption (EN → JP) */}
        {guyCapAlive && (
          <div style={{ opacity: clamp((t - 4.4) / 0.3, 0, 1) * (1 - clamp((t - 8.0) / 0.4, 0, 1)) }}>
            <VCaption who="ALEX" lang="EN→JP" original="やめてよ、照れるじゃん"
                      progress={guyCapP} width={580}>
              {"\"stop it — you're gonna make me blush.\""}
            </VCaption>
          </div>
        )}

        {/* Yuki responds */}
        {yukiHearAlive && (
          <div style={{ opacity: clamp((t - 7.8) / 0.3, 0, 1) * (1 - clamp((t - 11.0) / 0.4, 0, 1)) }}>
            <VCaption who="YUKI" lang="JP→EN" original="ふふ、本気で言ってるんだけど"
                      progress={yukiHearP} width={580}>
              {"\"haha — i actually mean it though.\""}
            </VCaption>
          </div>
        )}

        {/* Headline 1: Real-time voice translation. */}
        {head1T > 0 && (
          <div style={{
            opacity: head1T,
            transform: `translateY(${(1 - head1T) * 20}px)`,
            textAlign: 'center', marginTop: 30,
          }}>
            <div style={{
              fontFamily: fontHead, fontSize: 88, fontWeight: 700,
              letterSpacing: '-0.035em', lineHeight: 1.0, color: V.ink,
            }}>
              real-time voice
            </div>
            <div style={{
              fontFamily: fontHead, fontSize: 88, fontWeight: 700,
              letterSpacing: '-0.035em', lineHeight: 1.0, color: V.accent,
              marginTop: 6,
            }}>
              translation.
            </div>
          </div>
        )}

        {head2T > 0 && (
          <div style={{
            opacity: head2T,
            transform: `translateY(${(1 - head2T) * 20}px)`,
            textAlign: 'center', marginTop: 30,
          }}>
            <div style={{
              fontFamily: fontHead, fontSize: 76, fontWeight: 700, color: V.ink,
              letterSpacing: '-0.035em',
            }}>
              in your <span style={{ color: V.accent, fontStyle: 'italic' }}>own</span> voice.
            </div>
            <div style={{ display: 'flex', justifyContent: 'center', marginTop: 8 }}>
              <VUnderline w={260} thick={6} />
            </div>
          </div>
        )}
      </div>
    </div>
  );
}

// ── Single phone call screen used inside Scene 3 ─────────────────────────────
function CallScreen({ name, lang, langName, avatarLabel, time, speaking, dark }) {
  return (
    <VPhone width={460} height={940} dark={dark}>
      <div style={{
        height: '100%', padding: '28px 28px 20px',
        display: 'flex', flexDirection: 'column',
        color: dark ? '#fff' : V.ink,
      }}>
        <div style={{
          alignSelf: 'center',
          display: 'inline-block',
          padding: '4px 12px',
          border: `1.5px solid ${dark ? 'rgba(255,255,255,0.5)' : V.ink3}`,
          borderRadius: 6, fontFamily: fontMono, fontSize: 14,
          color: dark ? 'rgba(255,255,255,0.7)' : V.ink3,
        }}>● 02:14</div>

        <div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 14 }}>
          <div style={{ position: 'relative' }}>
            <VAvatar size={180} label={avatarLabel} color={V.accent2} />
            {speaking && (
              <div style={{
                position: 'absolute', inset: -14, borderRadius: '50%',
                border: `3px solid ${V.accent}`,
                animation: 'vRing 1.4s ease-out infinite',
              }} />
            )}
          </div>
          <div style={{ fontFamily: fontHead, fontSize: 36, fontWeight: 700, marginTop: 6 }}>{name}</div>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
            <VLang code={lang} size={38} color={V.accent2} />
            <div style={{ fontFamily: fontMono, fontSize: 16, color: dark ? 'rgba(255,255,255,0.7)' : V.ink3 }}>
              {langName}
            </div>
          </div>

          {/* Waveform */}
          <div style={{ marginTop: 14 }}>
            <VWaveform width={340} height={64} time={time}
                       intensity={speaking ? 1 : 0.18}
                       color={dark ? V.accent2 : V.accent} />
          </div>

          {/* small live tag */}
          <div style={{
            display: 'flex', alignItems: 'center', gap: 8,
            fontFamily: fontMono, fontSize: 14, letterSpacing: 1.5,
            color: dark ? 'rgba(255,255,255,0.7)' : V.ink3,
          }}>
            <span style={{ width: 9, height: 9, borderRadius: 5, background: V.accent }} />
            {speaking ? 'TRANSLATING…' : 'LISTENING'}
          </div>
        </div>

        {/* Controls */}
        <div style={{
          display: 'flex', justifyContent: 'space-around', alignItems: 'center',
          paddingTop: 16, paddingBottom: 4,
        }}>
          {[
            { i: '🎙', label: 'mute' },
            { i: '◐', label: 'speaker', on: true },
            { i: 'cc', label: 'captions', on: true },
            { i: '☎', label: 'end', danger: true },
          ].map((b, i) => (
            <div key={i} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 6 }}>
              <div style={{
                width: 58, height: 58, borderRadius: '50%',
                border: `2px solid ${b.danger ? V.red : (dark ? '#fff' : V.ink)}`,
                background: b.danger ? V.red : (b.on ? V.accent : 'transparent'),
                color: b.danger || b.on ? '#fff' : (dark ? '#fff' : V.ink),
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                fontFamily: fontMono, fontSize: 18, fontWeight: 700,
              }}>{b.i}</div>
              <div style={{ fontFamily: fontMono, fontSize: 11, color: b.danger ? V.red : (dark ? 'rgba(255,255,255,0.7)' : V.ink3) }}>
                {b.label}
              </div>
            </div>
          ))}
        </div>
      </div>
    </VPhone>
  );
}

Object.assign(window, { Scene1Problem, Scene2Intro, Scene3Magic, CallScreen });
