// scenes.jsx — AI Content Team promo video
// 16:9 (1920×1080), 43s total. Story: "chat isn't enough → cockpit + 13 agents".
// Copy lives in strings.js (en / pt-BR / es), selected via ?lang=.

// ── Brand tokens (mirror site/index.html :root) ─────────────────────────────
const BRAND = {
  bg:       '#0A0A0A',
  bgElev:   '#111111',
  panel:    '#1A1A1A',
  panel2:   '#222222',
  stroke:   '#2A2A2A',
  strokeSoft: 'rgba(255,255,255,0.06)',
  text:     '#FAFAF9',
  textMute: '#A8A29E',
  textDim:  '#57534E',
  blue:     '#3B82F6',
  blueDark: '#1D4ED8',
  green:    '#22C55E',
  amber:    '#F59E0B',
  red:      '#EF4444',
  purple:   '#8B5CF6',
};

const FONT_SANS = 'Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif';
const FONT_MONO = 'JetBrains Mono, ui-monospace, monospace';
const W = 1920, H = 1080;

// ── Logo (matches site favicon: blue dot + A peak + bar) ────────────────────
function LogoMark({ size = 40, color = BRAND.blue }) {
  return (
    <svg width={size} height={size} viewBox="0 0 30 30" fill="none">
      <circle cx="15" cy="5" r="3" fill={color}/>
      <path d="M5 26 L15 6 L25 26" stroke={color} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" fill="none"/>
      <line x1="8" y1="20" x2="22" y2="20" stroke={color} strokeWidth="2" strokeLinecap="round"/>
    </svg>
  );
}

// Subtle grid background used across scenes
function GridBg({ opacity = 0.5, size = 80, mask = null }) {
  return (
    <div style={{
      position: 'absolute', inset: 0,
      backgroundImage: `
        linear-gradient(${BRAND.strokeSoft} 1px, transparent 1px),
        linear-gradient(90deg, ${BRAND.strokeSoft} 1px, transparent 1px)
      `,
      backgroundSize: `${size}px ${size}px`,
      opacity,
      maskImage: mask || undefined,
      WebkitMaskImage: mask || undefined,
      pointerEvents: 'none',
    }}/>
  );
}

// ────────────────────────────────────────────────────────────────────────────
// SCENE 1 — HOOK (0 → 5s)
// A chat window types a question, then dissolves into the line
// "To actually produce video, chat isn't enough."
// ────────────────────────────────────────────────────────────────────────────
function SceneHook() {
  const t = useTime();
  const local = t;
  const S = PT();

  // Chat bubble timeline — copy comes from strings.js (localized)
  const bubbleDelays = [0.0, 0.55, 1.15, 1.75];
  const bubbles = S.hook.chatBubbles.map((b, i) => ({ ...b, delay: bubbleDelays[i] }));

  // Chat window stays through the whole scene; headline fades in below
  const headlineIn  = clamp((local - 2.8) / 0.5, 0, 1);
  const kickerIn    = clamp((local - 2.5) / 0.4, 0, 1);

  return (
    <div style={{ position: 'absolute', inset: 0, background: BRAND.bg, overflow: 'hidden', fontFamily: FONT_SANS }}>
      <GridBg opacity={0.4} />

      {/* Chat window mockup (centered, top half) — stays through whole scene */}
      <div style={{
        position: 'absolute', left: '50%', top: 100,
        transform: 'translateX(-50%)',
        width: 880, minHeight: 480,
        background: BRAND.bgElev,
        border: `1px solid ${BRAND.stroke}`,
        borderRadius: 16,
        boxShadow: `0 30px 90px rgba(0,0,0,0.6)`,
        overflow: 'hidden',
      }}>
        {/* Window chrome */}
        <div style={{
          height: 42, background: BRAND.panel,
          borderBottom: `1px solid ${BRAND.stroke}`,
          display: 'flex', alignItems: 'center', padding: '0 16px', gap: 8,
        }}>
          <div style={{ width: 10, height: 10, borderRadius: 5, background: '#FF5F57' }}/>
          <div style={{ width: 10, height: 10, borderRadius: 5, background: '#FEBC2E' }}/>
          <div style={{ width: 10, height: 10, borderRadius: 5, background: '#28C840' }}/>
          <div style={{
            marginLeft: 14, fontSize: 13, color: BRAND.textMute,
            fontFamily: FONT_MONO, letterSpacing: '0.05em',
          }}>{S.hook.chatTitle}</div>
        </div>

        {/* Bubbles */}
        <div style={{ padding: '28px 32px', display: 'flex', flexDirection: 'column', gap: 14 }}>
          {bubbles.map((b, i) => {
            const ap = clamp((local - b.delay) / 0.3, 0, 1);
            const isUser = b.from === 'user';
            return (
              <div key={i} style={{
                display: 'flex', justifyContent: isUser ? 'flex-end' : 'flex-start',
                opacity: ap,
                transform: `translateY(${(1 - ap) * 14}px)`,
              }}>
                <div style={{
                  maxWidth: 560,
                  padding: '14px 20px',
                  borderRadius: 14,
                  background: isUser ? BRAND.blue : BRAND.panel2,
                  color: isUser ? '#FFFFFF' : BRAND.text,
                  border: isUser ? 'none' : `1px solid ${BRAND.stroke}`,
                  fontSize: 22, lineHeight: 1.4, fontWeight: 500,
                }}>
                  {b.text}
                </div>
              </div>
            );
          })}
        </div>
      </div>

      {/* Kicker label */}
      <div style={{
        position: 'absolute', left: 0, right: 0, top: 640,
        textAlign: 'center',
        fontSize: 20, letterSpacing: '0.3em', textTransform: 'uppercase',
        color: BRAND.amber, fontWeight: 600,
        opacity: kickerIn * (1 - clamp((local - 4.6) / 0.4, 0, 1)),
      }}>
        {S.hook.kicker}
      </div>

      {/* Headline (the punch) */}
      <div style={{
        position: 'absolute', left: 0, right: 0, top: 700,
        textAlign: 'center',
        opacity: headlineIn,
        transform: `translateY(${(1 - headlineIn) * 30}px)`,
      }}>
        <div style={{
          fontSize: 72, fontWeight: 600, color: BRAND.textMute,
          letterSpacing: '-0.02em', lineHeight: 1.1,
          marginBottom: 8,
        }}>
          {S.hook.lineA}
        </div>
        <div style={{
          fontSize: 128, fontWeight: 800, color: BRAND.text,
          letterSpacing: '-0.04em', lineHeight: 1,
          background: `linear-gradient(180deg, ${BRAND.text} 0%, ${BRAND.blue} 110%)`,
          WebkitBackgroundClip: 'text',
          WebkitTextFillColor: 'transparent',
          backgroundClip: 'text',
        }}>
          {S.hook.lineB}
        </div>
      </div>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────────────────
// SCENE 2 — PROBLEM (8 → 16s)
// Title + 4 pain cards in 2x2, all about what chat can't do
// ────────────────────────────────────────────────────────────────────────────
function SceneProblem() {
  const t = useTime();
  const local = t - 8;
  const S = PT();

  const pains = S.problem.pains;
  const delays = [0.5, 0.8, 1.1, 1.4];

  return (
    <div style={{
      position: 'absolute', inset: 0, background: BRAND.bg, fontFamily: FONT_SANS,
      padding: '90px 120px',
      display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
      textAlign: 'center',
    }}>
      <GridBg opacity={0.35} />

      {/* Label */}
      <div style={{
        fontSize: 20, color: BRAND.red,
        letterSpacing: '0.3em', textTransform: 'uppercase',
        marginBottom: 20, fontWeight: 600,
        opacity: clamp(local / 0.3, 0, 1),
      }}>
        {S.problem.label}
      </div>

      {/* Title */}
      <div style={{
        fontSize: 64, fontWeight: 700, color: BRAND.text,
        letterSpacing: '-0.02em', lineHeight: 1.08,
        marginBottom: 56,
        opacity: clamp((local - 0.1) / 0.4, 0, 1),
        transform: `translateY(${(1 - clamp((local - 0.1) / 0.4, 0, 1)) * 18}px)`,
      }}>
        {S.problem.title}{' '}
        <span style={{ color: BRAND.red, fontStyle: 'italic' }}>{S.problem.titleEm}</span>
      </div>

      {/* 2x2 pain grid */}
      <div style={{
        display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 20,
        width: '100%', maxWidth: 1440,
        textAlign: 'left',
      }}>
        {pains.map((p, i) => {
          const ap = clamp((local - delays[i]) / 0.4, 0, 1);
          return (
            <div key={i} style={{
              background: BRAND.panel,
              border: `1px solid ${BRAND.stroke}`,
              borderRadius: 16,
              padding: '28px 32px',
              display: 'flex', alignItems: 'center', gap: 24,
              opacity: ap,
              transform: `translateX(${(1 - ap) * (i % 2 === 0 ? -40 : 40)}px)`,
            }}>
              {/* X badge */}
              <div style={{
                width: 64, height: 64, borderRadius: 16,
                background: 'rgba(239,68,68,0.12)',
                border: `1px solid rgba(239,68,68,0.3)`,
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                flexShrink: 0,
              }}>
                <svg width="28" height="28" viewBox="0 0 24 24" fill="none">
                  <path d="M6 6l12 12M18 6L6 18" stroke={BRAND.red} strokeWidth="2.5" strokeLinecap="round"/>
                </svg>
              </div>
              <div style={{ flex: 1 }}>
                <div style={{ fontSize: 28, fontWeight: 600, color: BRAND.text, marginBottom: 6 }}>
                  {p.title}
                </div>
                <div style={{ fontSize: 18, color: BRAND.textMute }}>{p.sub}</div>
              </div>
            </div>
          );
        })}
      </div>

      {/* Kicker */}
      <Sprite start={8 + 2.4} end={16}>
        {({ localTime }) => {
          const ap = clamp(localTime / 0.4, 0, 1);
          return (
            <div style={{
              marginTop: 44,
              textAlign: 'center',
              fontSize: 32, color: BRAND.text, fontWeight: 600,
              letterSpacing: '-0.01em',
              opacity: ap,
              transform: `translateY(${(1 - ap) * 16}px)`,
            }}>
              {S.problem.kicker}
            </div>
          );
        }}
      </Sprite>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────────────────
// SCENE 3 — SOLUTION (16 → 23s)
// Reveal of the cockpit: orbit of dots, big "13 AI agents work" line
// ────────────────────────────────────────────────────────────────────────────
function SceneSolution() {
  const t = useTime();
  const local = t - 16;
  const S = PT();

  // Flash transition into the reveal
  const flash = local < 0.3 ? 1 - (local / 0.3) : 0;

  const kickerIn = clamp((local - 0.4) / 0.4, 0, 1);
  const lineAIn  = clamp((local - 1.0) / 0.5, 0, 1);
  const lineBIn  = clamp((local - 1.7) / 0.5, 0, 1);
  const taglineIn = clamp((local - 2.6) / 0.4, 0, 1);

  return (
    <div style={{
      position: 'absolute', inset: 0,
      background: `radial-gradient(circle at 50% 50%, #0F1A2E 0%, ${BRAND.bg} 70%)`,
      fontFamily: FONT_SANS,
      overflow: 'hidden',
    }}>
      {/* Flash */}
      <div style={{ position: 'absolute', inset: 0, background: BRAND.text, opacity: flash, pointerEvents: 'none' }}/>

      {/* 13 orbiting dots representing the agents */}
      {Array.from({ length: 13 }).map((_, i) => {
        const angle = (i / 13) * Math.PI * 2 + local * 0.5;
        const radius = 360 + Math.sin(local * 1.5 + i) * 24;
        const x = 960 + Math.cos(angle) * radius;
        const y = 540 + Math.sin(angle) * radius;
        const ap = clamp((local - 0.6 - i * 0.04) / 0.3, 0, 1);
        const pulse = 0.7 + 0.3 * Math.sin(local * 2 + i * 0.8);
        return (
          <div key={i} style={{
            position: 'absolute',
            left: x - 7, top: y - 7,
            width: 14, height: 14, borderRadius: 7,
            background: BRAND.blue,
            boxShadow: `0 0 ${20 * pulse}px ${BRAND.blue}`,
            opacity: ap * 0.85,
          }}/>
        );
      })}

      {/* Center cockpit logo halo */}
      <div style={{
        position: 'absolute', left: 960 - 80, top: 540 - 80,
        width: 160, height: 160, borderRadius: 80,
        background: `radial-gradient(circle, rgba(59,130,246,0.35) 0%, transparent 70%)`,
        opacity: clamp((local - 0.8) / 0.5, 0, 1),
      }}/>
      <div style={{
        position: 'absolute', left: 960 - 40, top: 540 - 40,
        opacity: clamp((local - 0.9) / 0.5, 0, 1),
        transform: `scale(${0.5 + 0.5 * Easing.easeOutBack(clamp((local - 0.9) / 0.6, 0, 1))})`,
      }}>
        <LogoMark size={80} />
      </div>

      {/* Kicker */}
      <div style={{
        position: 'absolute', top: 200, left: 0, right: 0,
        textAlign: 'center',
        fontSize: 22, color: BRAND.blue,
        letterSpacing: '0.3em', textTransform: 'uppercase',
        fontWeight: 600,
        opacity: kickerIn,
      }}>
        {S.solution.kicker}
      </div>

      {/* Line A */}
      <div style={{
        position: 'absolute', top: 720, left: 0, right: 0,
        textAlign: 'center',
        fontSize: 64, fontWeight: 600, color: BRAND.textMute,
        letterSpacing: '-0.02em',
        opacity: lineAIn,
        transform: `translateY(${(1 - lineAIn) * 20}px)`,
      }}>
        {S.solution.lineA}
      </div>

      {/* Line B (bold accent) */}
      <div style={{
        position: 'absolute', top: 800, left: 0, right: 0,
        textAlign: 'center',
        fontSize: 88, fontWeight: 800, color: BRAND.text,
        letterSpacing: '-0.03em', lineHeight: 1.05,
        opacity: lineBIn,
        transform: `translateY(${(1 - lineBIn) * 24}px)`,
      }}>
        <span style={{
          background: `linear-gradient(180deg, ${BRAND.text} 0%, ${BRAND.blue} 110%)`,
          WebkitBackgroundClip: 'text',
          WebkitTextFillColor: 'transparent',
          backgroundClip: 'text',
        }}>{S.solution.lineB}</span>
      </div>

      {/* Tagline */}
      <div style={{
        position: 'absolute', top: 940, left: 0, right: 0,
        textAlign: 'center',
        fontSize: 24, color: BRAND.textMute,
        letterSpacing: '-0.01em',
        opacity: taglineIn,
        padding: '0 200px',
      }}>
        {S.solution.tagline}
      </div>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────────────────
// SCENE 4 — PIPELINE (23 → 37s)
// 13 stages arranged in a row, with Teleprompter and Render highlighted.
// Below: cascade of 13 mini screenshots.
// ────────────────────────────────────────────────────────────────────────────
const STAGE_ICONS = ['📁','📈','🗓','✍','🎤','🎭','🖼','🎬','✂','🎞','📤','📬','⚙'];
const STAGE_SHOTS = [
  's-canal.png','s-tendencias.png','s-calendario.png','s-roteiro.png','s-teleprompter.png',
  's-avatar.png','s-thumbnail.png','s-broll.png','s-roughcut.png','s-edicao.png',
  's-publicar.png','s-email.png','s-config.png',
];
const HIGHLIGHTS = { 4: 'teleprompter', 9: 'render' }; // indices into the 13-stage array

function ScenePipeline() {
  const t = useTime();
  const local = t - 23;
  const S = PT();

  const stages = S.pipeline.stages;
  const total = stages.length;

  // Spread 13 nodes across the screen width
  const padX = 110;
  const slotW = (W - padX * 2) / (total - 1);
  const nodeY = 360;

  // Title fade
  const titleIn = clamp(local / 0.4, 0, 1);

  // Stage cascade — 0.25s/each, starting at 0.4s
  const stageDelay = (i) => 0.45 + i * 0.18;

  // Highlight pulses
  const highlightShow = clamp((local - 4.5) / 0.5, 0, 1);

  return (
    <div style={{ position: 'absolute', inset: 0, background: BRAND.bg, fontFamily: FONT_SANS, overflow: 'hidden' }}>
      <GridBg opacity={0.3} size={60} />

      {/* Header */}
      <div style={{
        textAlign: 'center', marginTop: 70,
        opacity: titleIn,
      }}>
        <div style={{
          fontSize: 20, color: BRAND.blue,
          letterSpacing: '0.3em', textTransform: 'uppercase',
          marginBottom: 14, fontWeight: 600,
        }}>
          {S.pipeline.label}
        </div>
        <div style={{
          fontSize: 56, fontWeight: 700, color: BRAND.text,
          letterSpacing: '-0.02em',
        }}>
          {S.pipeline.titleA}{' '}
          <span style={{ color: BRAND.blue }}>{S.pipeline.titleB}</span>
        </div>
      </div>

      {/* Spine line */}
      <div style={{
        position: 'absolute', left: padX, right: padX, top: nodeY + 30, height: 3,
        background: BRAND.stroke, borderRadius: 2,
      }}/>
      {/* Animated progress fill on the spine */}
      <div style={{
        position: 'absolute', left: padX, top: nodeY + 30, height: 3,
        width: `${clamp((local - 0.5) / 4.5, 0, 1) * (W - padX * 2)}px`,
        background: `linear-gradient(90deg, ${BRAND.blue}, ${BRAND.green})`,
        boxShadow: `0 0 18px ${BRAND.blue}`,
        borderRadius: 2,
      }}/>

      {/* 13 stage nodes */}
      {stages.map((label, i) => {
        const cx = padX + i * slotW;
        const ap = clamp((local - stageDelay(i)) / 0.35, 0, 1);
        const eased = Easing.easeOutBack(ap);
        const isHighlight = HIGHLIGHTS[i] !== undefined;
        const pulse = isHighlight ? (0.6 + 0.4 * Math.sin(local * 4 + i)) : 0;

        return (
          <div key={i} style={{
            position: 'absolute',
            left: cx - 60, top: nodeY - 30,
            width: 120, textAlign: 'center',
            opacity: ap,
            transform: `scale(${0.5 + 0.5 * eased}) translateY(${(1 - ap) * -12}px)`,
          }}>
            {/* Node circle */}
            <div style={{
              width: 72, height: 72, margin: '0 auto',
              borderRadius: 36,
              background: isHighlight ? BRAND.blue : BRAND.panel,
              border: `2px solid ${isHighlight ? BRAND.green : BRAND.stroke}`,
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              fontSize: 28,
              boxShadow: isHighlight
                ? `0 0 ${20 + pulse * 30}px rgba(59,130,246,${0.4 + pulse * 0.5})`
                : `0 6px 18px rgba(0,0,0,0.4)`,
            }}>
              {STAGE_ICONS[i]}
            </div>
            {/* Number */}
            <div style={{
              fontFamily: FONT_MONO, fontSize: 12,
              color: BRAND.textDim, marginTop: 8,
              letterSpacing: '0.1em',
            }}>
              {String(i + 1).padStart(2, '0')}
            </div>
            {/* Label */}
            <div style={{
              fontSize: 16, fontWeight: 600,
              color: isHighlight ? BRAND.text : BRAND.textMute,
              marginTop: 4, lineHeight: 1.15,
              whiteSpace: 'nowrap',
            }}>
              {label}
            </div>
          </div>
        );
      })}

      {/* Highlight callouts for Teleprompter + Render */}
      {Object.entries(HIGHLIGHTS).map(([idx, key]) => {
        const i = Number(idx);
        const cx = padX + i * slotW;
        const text = key === 'teleprompter'
          ? S.pipeline.highlightTeleprompter
          : S.pipeline.highlightRender;
        const isTop = key === 'teleprompter';
        return (
          <div key={key} style={{
            position: 'absolute',
            left: cx - 110, width: 220,
            top: isTop ? nodeY - 130 : nodeY - 130, // both above
            textAlign: 'center',
            opacity: highlightShow,
            transform: `translateY(${(1 - highlightShow) * 10}px)`,
          }}>
            <div style={{
              display: 'inline-block',
              background: 'rgba(34,197,94,0.12)',
              border: `1px solid ${BRAND.green}`,
              color: BRAND.green,
              padding: '6px 12px',
              borderRadius: 999,
              fontSize: 14, fontWeight: 700,
              letterSpacing: '0.05em', textTransform: 'uppercase',
            }}>
              ★ {text}
            </div>
            {/* connector arrow */}
            <svg width="24" height="40" viewBox="0 0 24 40" style={{
              display: 'block', margin: '4px auto 0',
            }}>
              <line x1="12" y1="0" x2="12" y2="34" stroke={BRAND.green} strokeWidth="2" strokeDasharray="4 4"/>
              <path d="M6 30 L12 38 L18 30" stroke={BRAND.green} strokeWidth="2" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
          </div>
        );
      })}

      {/* Mini screenshot strip — cascades in after stages */}
      <div style={{
        position: 'absolute', left: 80, right: 80, top: 600,
        display: 'grid', gridTemplateColumns: 'repeat(13, 1fr)', gap: 10,
      }}>
        {STAGE_SHOTS.map((src, i) => {
          const ap = clamp((local - 3.0 - i * 0.1) / 0.35, 0, 1);
          const isHighlight = HIGHLIGHTS[i] !== undefined;
          return (
            <div key={i} style={{
              opacity: ap,
              transform: `translateY(${(1 - ap) * 24}px)`,
              borderRadius: 8,
              overflow: 'hidden',
              border: `1px solid ${isHighlight ? BRAND.green : BRAND.stroke}`,
              background: BRAND.panel,
              aspectRatio: '16 / 10',
              boxShadow: isHighlight
                ? `0 8px 24px rgba(34,197,94,0.25)`
                : `0 6px 18px rgba(0,0,0,0.5)`,
            }}>
              <img src={PROMO_ASSET(src)} alt={stages[i]} style={{
                width: '100%', height: '100%',
                objectFit: 'cover', objectPosition: 'top left',
                display: 'block',
              }}/>
            </div>
          );
        })}
      </div>

      {/* Caption */}
      <Sprite start={23 + 6.5} end={37}>
        {({ localTime }) => {
          const ap = clamp(localTime / 0.4, 0, 1);
          return (
            <div style={{
              position: 'absolute', left: 0, right: 0, bottom: 60,
              textAlign: 'center',
              fontSize: 32, color: BRAND.text, fontWeight: 500,
              letterSpacing: '-0.01em',
              opacity: ap,
            }}>
              {S.pipeline.caption}
            </div>
          );
        }}
      </Sprite>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────────────────
// SCENE 5 — FEATURES (37 → 47s)
// 4 feature cards in a 2x2 grid, each with a small screenshot + copy.
// Bottom: "the cockpit is ours, the APIs are yours — no markup".
// ────────────────────────────────────────────────────────────────────────────
const FEATURE_SHOTS = ['s-teleprompter.png', 's-studio.png', 's-canal.png', 's-channel-selector.png'];
const FEATURE_ICONS = ['🎤', '🖥', '📚', '🔀'];
const FEATURE_ACCENT = [BRAND.green, BRAND.blue, BRAND.purple, BRAND.amber];

function SceneFeatures() {
  const t = useTime();
  const local = t - 37;
  const S = PT();

  const items = S.features.items.map((it, i) => ({
    ...it,
    shot: PROMO_ASSET(FEATURE_SHOTS[i]),
    icon: FEATURE_ICONS[i],
    accent: FEATURE_ACCENT[i],
  }));

  const delays = [0.4, 0.7, 1.0, 1.3];

  return (
    <div style={{ position: 'absolute', inset: 0, background: BRAND.bg, fontFamily: FONT_SANS, overflow: 'hidden' }}>
      <div style={{
        position: 'absolute', inset: 0,
        background: `radial-gradient(circle at 90% 10%, rgba(59,130,246,0.18) 0%, transparent 55%)`,
      }}/>
      <GridBg opacity={0.25} />

      {/* Header */}
      <div style={{
        position: 'absolute', top: 64, left: 0, right: 0,
        textAlign: 'center',
        opacity: clamp(local / 0.4, 0, 1),
      }}>
        <div style={{
          fontSize: 18, color: BRAND.blue,
          letterSpacing: '0.3em', textTransform: 'uppercase',
          fontWeight: 600, marginBottom: 10,
        }}>
          {S.features.label}
        </div>
        <div style={{
          fontSize: 48, fontWeight: 700, color: BRAND.text,
          letterSpacing: '-0.02em',
        }}>
          {S.features.title}
        </div>
      </div>

      {/* 2x2 grid of feature cards */}
      <div style={{
        position: 'absolute', left: 100, right: 100, top: 200,
        display: 'grid', gridTemplateColumns: '1fr 1fr', gridTemplateRows: '1fr 1fr',
        gap: 20,
        height: 700,
      }}>
        {items.map((it, i) => {
          const ap = clamp((local - delays[i]) / 0.4, 0, 1);
          return (
            <div key={i} style={{
              background: BRAND.panel,
              border: `1px solid ${BRAND.stroke}`,
              borderRadius: 18,
              padding: 24,
              display: 'flex', gap: 24,
              opacity: ap,
              transform: `translateY(${(1 - ap) * 20}px)`,
              overflow: 'hidden',
              position: 'relative',
            }}>
              {/* Screenshot */}
              <div style={{
                width: 380, flexShrink: 0,
                borderRadius: 12,
                overflow: 'hidden',
                border: `1px solid ${BRAND.stroke}`,
                background: BRAND.bg,
                position: 'relative',
              }}>
                <img src={it.shot} alt={it.title} style={{
                  width: '100%', height: '100%',
                  objectFit: 'cover', objectPosition: 'top left',
                  display: 'block',
                }}/>
              </div>

              {/* Text */}
              <div style={{ flex: 1, display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
                <div style={{
                  width: 48, height: 48,
                  borderRadius: 12,
                  background: `${it.accent}1F`,
                  border: `1px solid ${it.accent}66`,
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  fontSize: 24,
                  marginBottom: 14,
                }}>
                  {it.icon}
                </div>
                <div style={{
                  fontSize: 26, fontWeight: 700, color: BRAND.text,
                  letterSpacing: '-0.01em', marginBottom: 8, lineHeight: 1.15,
                }}>
                  {it.title}
                </div>
                <div style={{
                  fontSize: 17, color: BRAND.textMute,
                  lineHeight: 1.45,
                }}>
                  {it.desc}
                </div>
              </div>
            </div>
          );
        })}
      </div>

      {/* Bottom pricing line */}
      <Sprite start={37 + 5.5} end={47}>
        {({ localTime }) => {
          const ap = clamp(localTime / 0.4, 0, 1);
          return (
            <div style={{
              position: 'absolute', left: 0, right: 0, bottom: 36,
              textAlign: 'center',
              opacity: ap,
              transform: `translateY(${(1 - ap) * 14}px)`,
            }}>
              <span style={{
                fontSize: 24, color: BRAND.textMute, fontWeight: 500,
              }}>{S.features.pricingLine}</span>{' '}
              <span style={{
                fontSize: 26, color: BRAND.green, fontWeight: 700,
                letterSpacing: '-0.01em',
              }}>{S.features.pricingHighlight}</span>
            </div>
          );
        }}
      </Sprite>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────────────────
// SCENE 6 — CTA (47 → 54s)
// Logo, big "Download free." + bring your own keys, 3 bullets, URL
// ────────────────────────────────────────────────────────────────────────────
function SceneCTA() {
  const t = useTime();
  const local = t - 47;
  const S = PT();

  const pulse = 0.5 + 0.5 * Math.sin(local * 3);

  const logoIn   = clamp(local / 0.4, 0, 1);
  const titleIn  = clamp((local - 0.4) / 0.5, 0, 1);
  const bulletsIn = clamp((local - 1.4) / 0.4, 0, 1);
  const buttonIn = clamp((local - 2.0) / 0.5, 0, 1);

  return (
    <div style={{
      position: 'absolute', inset: 0,
      background: `radial-gradient(circle at 50% 60%, #0F2A4D 0%, ${BRAND.bg} 70%)`,
      fontFamily: FONT_SANS,
      overflow: 'hidden',
    }}>
      <GridBg opacity={0.3} size={60}
        mask="radial-gradient(circle at 50% 60%, black 0%, transparent 70%)" />

      {/* Logo + wordmark */}
      <div style={{
        position: 'absolute', top: 100, left: 0, right: 0,
        display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 18,
        opacity: logoIn,
        transform: `translateY(${(1 - logoIn) * -16}px)`,
      }}>
        <LogoMark size={70} />
        <div style={{
          fontSize: 52, fontWeight: 700, color: BRAND.text,
          letterSpacing: '-0.02em',
        }}>
          AI Content Team
        </div>
      </div>

      {/* Kicker */}
      <div style={{
        position: 'absolute', top: 230, left: 0, right: 0,
        textAlign: 'center',
        fontSize: 18, color: BRAND.blue,
        letterSpacing: '0.3em', textTransform: 'uppercase',
        fontWeight: 600,
        opacity: titleIn,
      }}>
        {S.cta.kicker}
      </div>

      {/* Big title */}
      <div style={{
        position: 'absolute', top: 290, left: 0, right: 0,
        textAlign: 'center',
        opacity: titleIn,
        transform: `scale(${0.85 + 0.15 * Easing.easeOutBack(titleIn)})`,
      }}>
        <div style={{
          fontSize: 130, fontWeight: 800, color: BRAND.text,
          letterSpacing: '-0.05em', lineHeight: 1,
          background: `linear-gradient(180deg, ${BRAND.text} 0%, ${BRAND.blue} 110%)`,
          WebkitBackgroundClip: 'text',
          WebkitTextFillColor: 'transparent',
          backgroundClip: 'text',
        }}>
          {S.cta.titleA}
        </div>
        <div style={{
          fontSize: 56, fontWeight: 600, color: BRAND.textMute,
          letterSpacing: '-0.02em',
          marginTop: 14,
        }}>
          {S.cta.titleB}
        </div>
      </div>

      {/* Bullets */}
      <div style={{
        position: 'absolute', top: 620, left: 0, right: 0,
        display: 'flex', justifyContent: 'center', gap: 50,
        fontSize: 22, color: BRAND.textMute,
        opacity: bulletsIn,
        transform: `translateY(${(1 - bulletsIn) * 14}px)`,
      }}>
        {S.cta.bullets.map((b, i) => (
          <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
            <svg width="20" height="20" viewBox="0 0 24 24" fill="none">
              <circle cx="12" cy="12" r="11" fill={BRAND.green} fillOpacity="0.2"/>
              <path d="M7 12l3.5 3.5L17 9" stroke={BRAND.green} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            {b}
          </div>
        ))}
      </div>

      {/* CTA button */}
      <div style={{
        position: 'absolute', top: 740, left: 0, right: 0,
        display: 'flex', justifyContent: 'center',
        opacity: buttonIn,
        transform: `scale(${0.7 + 0.3 * Easing.easeOutBack(buttonIn)})`,
      }}>
        <div style={{
          background: BRAND.blue,
          color: BRAND.text,
          padding: '24px 56px',
          borderRadius: 16,
          fontSize: 38, fontWeight: 700,
          letterSpacing: '-0.01em',
          boxShadow: `0 20px 60px rgba(59,130,246,${0.3 + pulse * 0.3}), 0 0 0 4px rgba(59,130,246,${pulse * 0.18})`,
          display: 'flex', alignItems: 'center', gap: 16,
        }}>
          <svg width="32" height="32" viewBox="0 0 24 24" fill="none">
            <path d="M12 3v14M5 12l7 7 7-7M5 21h14" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
          </svg>
          {S.cta.button}
        </div>
      </div>

      {/* URL */}
      <div style={{
        position: 'absolute', bottom: 80, left: 0, right: 0,
        textAlign: 'center',
        fontFamily: FONT_MONO, fontSize: 26, color: BRAND.blue,
        letterSpacing: '0.05em',
        opacity: clamp((local - 2.6) / 0.4, 0, 1),
      }}>
        {S.cta.url}
      </div>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────────────────
// TIMESTAMP LABEL (used by snapshot tooling)
// ────────────────────────────────────────────────────────────────────────────
function TimestampLabel() {
  const t = useTime();
  const sec = Math.floor(t);
  React.useEffect(() => {
    const root = document.getElementById('video-root');
    if (root) root.setAttribute('data-screen-label', `t=${sec}s`);
  }, [sec]);
  return null;
}

// ────────────────────────────────────────────────────────────────────────────
// MAIN VIDEO — 43s total
// ────────────────────────────────────────────────────────────────────────────
function Video() {
  return (
    <>
      <TimestampLabel />
      <Sprite start={0}  end={8}  keepMounted={false}><SceneHook /></Sprite>
      <Sprite start={8}  end={16} keepMounted={false}><SceneProblem /></Sprite>
      <Sprite start={16} end={23} keepMounted={false}><SceneSolution /></Sprite>
      <Sprite start={23} end={37} keepMounted={false}><ScenePipeline /></Sprite>
      <Sprite start={37} end={47} keepMounted={false}><SceneFeatures /></Sprite>
      <Sprite start={47} end={54} keepMounted={false}><SceneCTA /></Sprite>
    </>
  );
}
