// vsl-reveal.jsx — TEN · scene 6 (90–120s) — the revelation
const { HORUS: Hr, Scene: Sc3, PhaseBg: Bg3, Line: Ln3, HL: Hi3, Kicker: Kc3, Sprite: Sp3, PhaseTag: Tag3, Easing: Er, clamp: clr } = window;

// growing purple light core — eco do núcleo do emblema
function LightCore({ x = 960, y = 540, grow = 0, pulse = 0 }) {
  const base = 60 + grow * 360;
  const r = base * (1 + Math.sin(pulse * Math.PI * 2) * 0.04);
  return (
    <React.Fragment>
      {/* outer bloom */}
      <div style={{ position: 'absolute', left: x, top: y, width: r * 6, height: r * 6, transform: 'translate(-50%,-50%)',
        background: `radial-gradient(circle, hsl(263 80% 55% / ${0.22 + grow * 0.18}) 0%, hsl(263 70% 45% / 0.10) 26%, transparent 60%)`,
        filter: 'blur(8px)', pointerEvents: 'none' }} />
      {/* mid ring */}
      <div style={{ position: 'absolute', left: x, top: y, width: r * 2.2, height: r * 2.2, transform: 'translate(-50%,-50%)',
        borderRadius: '50%', background: `radial-gradient(circle, hsl(263 90% 70% / ${0.5 + grow * 0.4}) 0%, hsl(263 80% 50% / 0.25) 45%, transparent 72%)`,
        boxShadow: `0 0 ${80 + grow * 160}px hsl(263 80% 55% / ${0.4 + grow * 0.4})` }} />
      {/* core */}
      <div style={{ position: 'absolute', left: x, top: y, width: r * 0.8, height: r * 0.8, transform: 'translate(-50%,-50%)',
        borderRadius: '50%', background: `radial-gradient(circle, #fff 0%, hsl(263 90% 78%) 40%, hsl(263 85% 58%) 100%)`,
        boxShadow: `0 0 ${40 + grow * 80}px hsl(263 90% 70%)` }} />
      {/* converging sparks */}
      {Array.from({ length: 10 }).map((_, i) => {
        const a = (i / 10) * Math.PI * 2;
        const dist = 480 * (1 - grow) + 120;
        return <div key={i} style={{ position: 'absolute', left: x + Math.cos(a) * dist, top: y + Math.sin(a) * dist,
          width: 4, height: 4, borderRadius: 4, transform: 'translate(-50%,-50%)',
          background: i % 2 ? Hr.blueLight : Hr.purpleLight, opacity: (1 - grow) * 0.8,
          boxShadow: `0 0 12px ${i % 2 ? Hr.blue : Hr.purple}` }} />;
      })}
    </React.Fragment>
  );
}

// CENA 6 — 90–120s
function TenReveal() {
  return (
    <Sp3 start={90} end={120.2} keepMounted>{({ localTime, visible }) => { if (!visible) return null;
      const lt = localTime;
      const grow = clr(lt / 26, 0, 1);
      // hard-cut flash at entry
      const flash = lt < 0.6 ? (1 - lt / 0.6) : 0;
      return (
        <Sc3 bg="#050507">
          <Bg3 variant="void" />
          <LightCore grow={grow * 0.9} pulse={lt * 0.5} />
          <div style={{ position: 'absolute', inset: 0, background: '#fff', opacity: flash * 0.9, pointerEvents: 'none' }} />
          <Tag3 label="Ten · a virada" idx={2} />
          <Ln3 at={0.7} until={5} cy={520} size={56} color={Hr.dim} weight={500} shadow>E aqui está a virada que mudou o jogo.</Ln3>
          <Ln3 at={5} until={9.2} cy={520} size={58} weight={600}>O problema nunca foi o <Hi3>talento</Hi3> dele.</Ln3>
          <Ln3 at={9.2} until={14} cy={520} size={54} color={Hr.dim} weight={500} maxWidth={1100}>Era a ausência de um <Hi3>sistema</Hi3> em volta do talento.</Ln3>
          <Kc3 at={14.2} until={19} cy={430} color={Hr.purpleLight}>A revelação</Kc3>
          <Ln3 at={14.4} until={19} cy={540} size={104} weight={700} letterSpacing="-0.03em">Visibilidade é <Hi3>engenharia</Hi3>.</Ln3>
          <Ln3 at={19} until={23.6} cy={540} size={50} color={Hr.dim} weight={500} maxWidth={1200}>E dá pra construir esse sistema sem trair a ética.</Ln3>
          <Ln3 at={23.6} until={27} cy={540} size={52} weight={600}>Sem prometer resultado. Sem se expor à OAB.</Ln3>
          <Ln3 at={27} until={30.2} cy={540} size={50} weight={600} maxWidth={1200}>“<Hi3>Entenda</Hi3>”, no lugar de “garanto”.</Ln3>
        </Sc3>
      );
    }}</Sp3>
  );
}

Object.assign(window, { TenReveal, LightCore });
