// video-scenes.jsx — VikingHeat infografik: per-scene captions & focus visuals

// ── Scene 1: Title (0..3) ──────────────────────────────────────────────────
function SceneTitle() {
  const t = useTime();
  if (t > 3.4) return null;

  const op = fadeWindow(t, 0.0, 0.6, 2.6, 3.2);
  const subOp = fadeWindow(t, 0.6, 1.2, 2.6, 3.2);
  const rule  = smooth(ramp(t, 0.4, 1.4));

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
      {/* Eyebrow */}
      <div style={{
        position: 'absolute', left: '50%', top: 380,
        transform: 'translateX(-50%)',
        fontFamily: VC.fontMono, fontSize: 16, letterSpacing: '0.22em',
        color: VC.copper, textTransform: 'uppercase', opacity: subOp,
        display: 'flex', alignItems: 'center', gap: 14,
      }}>
        <span style={{ width: 28, height: 1, background: VC.copper }}/>
        Sådan optimerer vi din varmepumpe
        <span style={{ width: 28, height: 1, background: VC.copper }}/>
      </div>

      <Headline x={W/2} y={460} size={108} weight={500} align="center"
        color={VC.paper} opacity={op}>
        1.000 digitale twins.{'\n'}Ét sweet spot.
      </Headline>

      {/* horizontal accent rule */}
      <div style={{
        position: 'absolute', left: '50%', top: 720,
        transform: 'translateX(-50%)',
        width: 480 * rule, height: 1,
        background: VC.copper, opacity: subOp,
      }}/>

      <MonoLabel x={W/2} y={748} align="center" size={16} color={VC.muted} opacity={subOp}>
        EDGE COMPUTING · LOKAL BEREGNING · INGEN CLOUD
      </MonoLabel>
    </div>
  );
}

// ── Scene 2: Comfort core caption (3..7) ──────────────────────────────────
// House is rendered globally by CenterHouse; here we add the top headline.
function SceneComfort() {
  const t = useTime();
  if (t < 3.0 || t > 7.4) return null;
  const eOp = fadeWindow(t, 3.6, 4.2, 6.6, 7.2);

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
      <Tag x={W/2} y={120} align="center" color={VC.copper} opacity={eOp}>
        Trin 01 · Komfort‑kernen
      </Tag>
      <Headline x={W/2} y={170} size={64} weight={500} align="center"
        color={VC.paper} opacity={eOp}>
        Boligens komfort er ukrænkelig.
      </Headline>
      <div style={{
        position: 'absolute', left: '50%', top: 990,
        transform: 'translateX(-50%)',
        fontFamily: VC.fontSans, fontSize: 22, color: VC.muted,
        opacity: eOp, fontWeight: 400, textAlign: 'center', maxWidth: 900,
      }}>
        Den ønskede temperatur holdes — altid. VikingHeat optimerer kun rundt om den.
      </div>
    </div>
  );
}

// ── Scene 3: Triangle reveal caption (7..11) ──────────────────────────────
function SceneTriangle() {
  const t = useTime();
  if (t < 7.0 || t > 11.2) return null;
  const eOp = fadeWindow(t, 7.4, 8.0, 10.6, 11.2);

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
      <Tag x={120} y={70} align="left" color={VC.copper} opacity={eOp}>
        Trin 02 · Tre datakilder
      </Tag>
      <Headline x={120} y={114} size={50} weight={500} align="left" maxWidth={680}
        color={VC.paper} opacity={eOp}>
        Optimering rundt om komforten — aldrig imod den.
      </Headline>

      {/* Bottom caption row */}
      <div style={{
        position: 'absolute', left: '50%', bottom: 90,
        transform: 'translateX(-50%)',
        opacity: eOp, display: 'flex', gap: 56,
        fontFamily: VC.fontMono, fontSize: 14, letterSpacing: '0.14em',
        textTransform: 'uppercase',
      }}>
        <span style={{ color: VC.copper }}>● A · BYGNINGENS ENERGI</span>
        <span style={{ color: VC.blue   }}>● B · VEJRPROGNOSER</span>
        <span style={{ color: VC.green  }}>● C · SPOTPRIS + SOLCELLE</span>
      </div>
    </div>
  );
}

// ── Scene 4: A — Indvendig data (11..15) ──────────────────────────────────
function SceneA() {
  const t = useTime();
  if (t < 10.8 || t > 15.4) return null;
  const eOp = fadeWindow(t, 11.0, 11.6, 14.6, 15.2);

  // Small "sensor list" on left side
  const items = [
    { lbl: 'Frem‑ / retur',     v: '32° / 28°' },
    { lbl: 'Udetemperatur',     v: '−2°C'      },
    { lbl: 'COP nu',            v: '4.2'       },
    { lbl: 'Termisk inerti',    v: '4.2 timer' },
  ];

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
      <Tag x={120} y={70} color={VC.copper} opacity={eOp}>
        A · BYGNINGENS ENERGI
      </Tag>
      <Headline x={120} y={114} size={50} weight={500} maxWidth={680}
        color={VC.paper} opacity={eOp}>
        Bygningens energiforbrug og klimaskærm.
      </Headline>
      <div style={{
        position: 'absolute', left: 120, top: 290,
        fontFamily: VC.fontSans, fontSize: 22, lineHeight: 1.5,
        color: VC.muted, opacity: eOp, maxWidth: 620,
      }}>
        Tilpasser sig altid bygningen uden forudgående programmering. Lærer klimaskærmen i bygningen ud fra data fra rumtermostater. <span style={{color: VC.copper}}>Den laveste mulige fremløbstemperatur</span> beregnes ud fra dette.
      </div>

      {/* Data panel */}
      <div style={{
        position: 'absolute', left: 120, top: 520, opacity: eOp,
        width: 480,
        border: `1px solid ${VC.line}`, borderRadius: 6,
        padding: 24, background: VC.ink2,
        fontFamily: VC.fontMono, fontSize: 14,
      }}>
        <div style={{
          color: VC.copper, letterSpacing: '0.14em',
          fontSize: 12, textTransform: 'uppercase', marginBottom: 16,
        }}>Live datastrøm</div>
        {items.map((it, i) => {
          const rowOp = smooth(ramp(t, 11.6 + i * 0.2, 12.2 + i * 0.2));
          return (
            <div key={i} style={{
              display: 'flex', justifyContent: 'space-between',
              padding: '10px 0', borderBottom: i < items.length-1 ? `1px solid ${VC.line}` : 'none',
              opacity: rowOp,
            }}>
              <span style={{ color: VC.muted }}>{it.lbl}</span>
              <span style={{ color: VC.paper }}>{it.v}</span>
            </div>
          );
        })}
      </div>
    </div>
  );
}

// ── Scene 5: B — Eksterne signaler (15..19) ──────────────────────────────
function SceneB() {
  const t = useTime();
  if (t < 14.8 || t > 19.4) return null;
  const eOp = fadeWindow(t, 15.0, 15.6, 18.6, 19.2);

  // Weather strip — 8 hours, with sun/cloud/wind icons
  const hours = Array.from({ length: 8 }).map((_, i) => {
    const tempC = Math.round(2 + 4 * Math.sin(i * 0.7) + Math.cos(i * 1.1));
    return { h: `${(6 + i * 3) % 24}:00`, t: tempC, kind: i < 3 ? 'sun' : i < 5 ? 'cloud' : 'wind' };
  });

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
      <Tag x={120} y={70} color={VC.blue} opacity={eOp}>
        B · EKSTERNE SIGNALER
      </Tag>
      <Headline x={120} y={114} size={50} weight={500} maxWidth={680}
        color={VC.paper} opacity={eOp}>
        Vejrprognoser og udendørsdata.
      </Headline>
      <div style={{
        position: 'absolute', left: 120, top: 290,
        fontFamily: VC.fontSans, fontSize: 22, lineHeight: 1.5,
        color: VC.muted, opacity: eOp, maxWidth: 620,
      }}>
        Lokale prognoser, solindstråling, vind og udetemperatur fortæller systemet, hvornår COP‑værdien er højest. <span style={{color: VC.blue}}>De timer matches mod laveste prispunkt.</span>
      </div>

      {/* Weather forecast strip */}
      <div style={{
        position: 'absolute', left: 120, top: 520, opacity: eOp,
        width: 720,
        border: `1px solid ${VC.line}`, borderRadius: 6,
        padding: '18px 8px', background: VC.ink2,
        display: 'flex', justifyContent: 'space-around',
      }}>
        {hours.map((h, i) => {
          const rowOp = smooth(ramp(t, 15.6 + i * 0.1, 16.0 + i * 0.1));
          const wob = 4 * Math.sin((t + i) * 1.5);
          return (
            <div key={i} style={{
              display: 'flex', flexDirection: 'column', alignItems: 'center',
              gap: 8, opacity: rowOp,
            }}>
              <div style={{
                fontFamily: VC.fontMono, fontSize: 10, color: VC.muted,
                letterSpacing: '0.08em',
              }}>{h.h}</div>
              <svg width="34" height="34" viewBox="0 0 34 34">
                {h.kind === 'sun' && (
                  <g>
                    <circle cx="17" cy="17" r="6" fill={VC.yellow}/>
                    {Array.from({ length: 8 }).map((_, k) => {
                      const a = (k / 8) * Math.PI * 2;
                      const x1 = 17 + Math.cos(a) * 9, y1 = 17 + Math.sin(a) * 9;
                      const x2 = 17 + Math.cos(a) * 13, y2 = 17 + Math.sin(a) * 13;
                      return <line key={k} x1={x1} y1={y1} x2={x2} y2={y2} stroke={VC.yellow} strokeWidth="1.5" strokeLinecap="round"/>;
                    })}
                  </g>
                )}
                {h.kind === 'cloud' && (
                  <g fill={VC.blue}>
                    <ellipse cx="13" cy="20" rx="6" ry="5"/>
                    <ellipse cx="21" cy="18" rx="7" ry="6"/>
                  </g>
                )}
                {h.kind === 'wind' && (
                  <g stroke={VC.blue} strokeWidth="1.6" fill="none" strokeLinecap="round">
                    <path d={`M 6 ${14 + wob * 0.3} Q 14 ${10 + wob * 0.3} 22 ${14 + wob * 0.3} T 30 ${14 + wob * 0.3}`}/>
                    <path d={`M 6 ${20 + wob * 0.3} Q 14 ${16 + wob * 0.3} 22 ${20 + wob * 0.3} T 30 ${20 + wob * 0.3}`}/>
                  </g>
                )}
              </svg>
              <div style={{
                fontFamily: VC.fontMono, fontSize: 14, color: VC.paper,
              }}>{h.t}°</div>
            </div>
          );
        })}
      </div>

      {/* small badges */}
      <div style={{
        position: 'absolute', left: 120, top: 700, opacity: eOp,
        display: 'flex', gap: 12,
      }}>
        {['DMI prognose', 'Solindstråling', 'Vindkast'].map((b, i) => (
          <div key={i} style={{
            fontFamily: VC.fontMono, fontSize: 12, letterSpacing: '0.06em',
            padding: '8px 14px', border: `1px solid ${VC.line}`,
            borderRadius: 4, color: VC.muted, textTransform: 'uppercase',
            background: VC.ink2,
            opacity: smooth(ramp(t, 16.6 + i * 0.2, 17.0 + i * 0.2)),
          }}>{b}</div>
        ))}
      </div>
    </div>
  );
}

// ── Scene 6: C — Markedssignaler (19..23) ─────────────────────────────────
function SceneC() {
  const t = useTime();
  if (t < 18.8 || t > 23.4) return null;
  const eOp = fadeWindow(t, 19.0, 19.6, 22.6, 23.2);

  // 24 spot price bars (DKK/kWh-ish), generated deterministic
  const bars = Array.from({ length: 24 }, (_, i) =>
    1.4 + 0.9 * Math.sin(i * 0.55) + 0.5 * Math.cos(i * 1.3 + 1)
  );
  const maxBar = Math.max(...bars);

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
      <Tag x={120} y={70} color={VC.green} opacity={eOp}>
        C · MARKEDSSIGNALER
      </Tag>
      <Headline x={120} y={114} size={50} weight={500} maxWidth={680}
        color={VC.paper} opacity={eOp}>
        Spotpriser og evt. solcelleoverskud.
      </Headline>
      <div style={{
        position: 'absolute', left: 120, top: 290,
        fontFamily: VC.fontSans, fontSize: 22, lineHeight: 1.5,
        color: VC.muted, opacity: eOp, maxWidth: 620,
      }}>
        <span style={{color: VC.green}}>Elpriserne</span> indgår som et bærende element. <span style={{color: VC.yellow}}>Har bygningen solceller</span>, udnyttes denne strøm også og indgår i beregningerne.
      </div>

      {/* Spot price chart */}
      <div style={{
        position: 'absolute', left: 120, top: 510, opacity: eOp,
        width: 720, height: 220,
        border: `1px solid ${VC.line}`, borderRadius: 6,
        padding: 20, background: VC.ink2,
      }}>
        <div style={{
          fontFamily: VC.fontMono, fontSize: 11, letterSpacing: '0.12em',
          color: VC.muted, textTransform: 'uppercase',
          display: 'flex', justifyContent: 'space-between', marginBottom: 10,
        }}>
          <span>Spotpris · DK1 · 24t</span>
          <span style={{ color: VC.yellow, opacity: smooth(ramp(t, 20.4, 21.2)) }}>● Solcelleoverskud</span>
        </div>
        <svg width="680" height="150" viewBox="0 0 680 150">
          {/* baseline */}
          <line x1="0" y1="130" x2="680" y2="130" stroke={VC.line} strokeWidth="1"/>
          {/* bars */}
          {bars.map((b, i) => {
            const barW = 24, gap = 4;
            const x = i * (barW + gap);
            const h = Math.max(0, (b / maxBar) * 110);
            const lit = smooth(ramp(t, 19.6 + i * 0.04, 20.0 + i * 0.04));
            // sweet hours = lowest bars get green stripe
            const isCheap = b < 1.0;
            return (
              <rect key={i} x={x} y={130 - h * lit} width={barW} height={h * lit}
                fill={isCheap ? VC.green : VC.blue}
                opacity={isCheap ? 0.95 : 0.55}
                rx="1"/>
            );
          })}
          {/* solar curve overlay */}
          <path
            d={(() => {
              const pts = Array.from({ length: 25 }, (_, i) => {
                const x = i * 28;
                const sun = Math.max(0, Math.sin(((i - 6) / 12) * Math.PI));
                const y = 130 - sun * 90;
                return `${i === 0 ? 'M' : 'L'} ${x} ${y}`;
              });
              return pts.join(' ');
            })()}
            fill="none" stroke={VC.yellow} strokeWidth="2.5"
            strokeDasharray="900"
            strokeDashoffset={900 * (1 - smooth(ramp(t, 20.4, 21.6)))}
            opacity="0.95"/>
        </svg>
      </div>

      {/* Legend tiles */}
      <div style={{
        position: 'absolute', left: 120, top: 760, opacity: eOp,
        display: 'flex', gap: 12,
      }}>
        {['Time-for-time afregning', 'Eget PV-overskud', 'Sweet-window'].map((b, i) => (
          <div key={i} style={{
            fontFamily: VC.fontMono, fontSize: 12, letterSpacing: '0.06em',
            padding: '8px 14px', border: `1px solid ${VC.line}`,
            borderRadius: 4, color: VC.muted, textTransform: 'uppercase',
            background: VC.ink2,
            opacity: smooth(ramp(t, 20.6 + i * 0.2, 21.0 + i * 0.2)),
          }}>{b}</div>
        ))}
      </div>
    </div>
  );
}

// ── Scene 7: 1.000 digitale twins (23..27) ────────────────────────────────
function SceneTwins() {
  const t = useTime();
  if (t < 22.8 || t > 27.4) return null;
  const eOp = fadeWindow(t, 23.0, 23.6, 26.6, 27.2);

  // Counter ticks 0 → 1000 over 23.4..25.6
  const counter = Math.floor(smooth(ramp(t, 23.4, 25.8)) * 1000);

  // One unified grid. The candidate cells (~15) are visible from the very start
  // of the scene; over time, all of them fade out except the sweet-spot cell,
  // which is one of the original 15 — it lights up as the chosen one.
  const cols = 50, rows = 14;
  const cellW = 22, cellH = 18, pad = 4;
  const gridW = cols * (cellW + pad) - pad;
  const gridH = rows * (cellH + pad) - pad;
  const originX = (W - gridW) / 2;
  const originY = 540;

  // Sweet-spot cell — chosen to be one of the deterministic candidates below.
  const sweetCol = 26, sweetRow = 6;
  const sweetIdx = sweetRow * cols + sweetCol;

  // Phase progress
  // Each candidate fades out at its own staggered time, not all at once.
  // Sweet spot lights up after the others have cleared.
  const sweetP  = smooth(ramp(t, 25.9, 26.6)); // sweet spot lights up
  const sweetPulse = 0.5 + 0.5 * Math.sin((t - 25.9) * 6);

  const renderGrid = () => (
    <div style={{
      position: 'absolute', left: originX, top: originY,
      width: gridW, height: gridH,
    }}>
      {Array.from({ length: rows * cols }).map((_, i) => {
        const r = Math.floor(i / cols), c = i % cols;
        const x = c * (cellW + pad), y = r * (cellH + pad);

        // Deterministic ~15 candidates. Hash threshold tuned to ~15/700.
        const h = ((r * 131 + c * 41 + 17) * 9301 + 49297) % 233280;
        const hN = h / 233280;
        const isSweet = i === sweetIdx;
        const isCandidate = isSweet || hN < 0.022; // ~15 candidates incl. sweet

        // Visible from start — fade out one-by-one in a quick staggered cascade
        // (stagger derived from per-cell hash so order is deterministic but mixed)
        const stagger = ((hN * 47.13) % 1);          // 0..1 per candidate
        const dimStart = 24.6 + stagger * 1.20;       // spread over 1.2s
        const dimP = smooth(ramp(t, dimStart, dimStart + 0.22));
        const dimAmount = isSweet ? 0 : dimP;
        const aliveBase = isCandidate ? (1 - dimAmount) : 0;

        // green strength
        const green = aliveBase;

        // Sweet-spot lighting
        const sw = isSweet ? sweetP : 0;
        const sweetFlash = isSweet ? (0.85 + 0.15 * sweetPulse) : 1;

        // Background: dark base → green when active → copper when chosen
        let bg;
        if (isSweet && sw > 0.05) {
          bg = `oklch(${lerp(0.62, 0.78, sw)} ${lerp(0.10, 0.20, sw)} 50)`;
        } else if (green > 0.02) {
          // green = signal accent
          bg = `oklch(${lerp(0.22, 0.66, green)} ${lerp(0.02, 0.14, green)} 155)`;
        } else {
          bg = VC.ink2;
        }

        const borderCol = isSweet && sw > 0.1
          ? VC.copper
          : (green > 0.4 ? `oklch(0.7 0.14 155 / ${green})` : VC.line);

        const scale = isSweet ? 1 + sw * 0.6 * sweetFlash : 1 + green * 0.05;
        const glow = isSweet
          ? `0 0 ${28 * sw * sweetFlash}px ${VC.copper}, 0 0 ${60 * sw}px ${VC.copper}66`
          : (green > 0.5 ? `0 0 ${8 * green}px oklch(0.7 0.14 155 / 0.6)` : 'none');

        return (
          <div key={i} style={{
            position: 'absolute', left: x, top: y, width: cellW, height: cellH,
            background: bg,
            border: `1px solid ${borderCol}`,
            borderRadius: 2,
            transform: `scale(${scale})`,
            transformOrigin: 'center',
            boxShadow: glow,
            zIndex: isSweet ? 5 : 1,
          }}/>
        );
      })}
    </div>
  );

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none', opacity: eOp }}>
      <Tag x={W/2} y={70} align="center" color={VC.copper}>
        Trin 03 · Sweet‑spot search
      </Tag>
      <Headline x={W/2} y={114} size={52} weight={500} align="center"
        color={VC.paper}>
        1.000 digitale twins beregner det bedste forløb.
      </Headline>

      {/* Counter */}
      <div style={{
        position: 'absolute', left: '50%', top: 230,
        transform: 'translateX(-50%)',
        fontFamily: VC.fontMono, fontSize: 84, color: VC.copper,
        letterSpacing: '-0.02em', fontVariantNumeric: 'tabular-nums',
        fontWeight: 500,
      }}>
        {counter.toString().padStart(4, '0')}
        <span style={{
          fontSize: 20, color: VC.muted, marginLeft: 16, letterSpacing: '0.1em',
        }}>SCENARIER</span>
      </div>

      {/* Unified grid of twins below the headline */}
      {renderGrid()}

      {/* Sweet spot label, anchored above the chosen cell */}
      <div style={{
        position: 'absolute',
        left: originX + sweetCol * (cellW + pad) + cellW / 2,
        top: originY - 28,
        transform: 'translateX(-50%)',
        fontFamily: VC.fontMono, fontSize: 14, letterSpacing: '0.14em',
        color: VC.copper, textTransform: 'uppercase',
        opacity: sweetP,
        display: 'flex', alignItems: 'center', gap: 10, whiteSpace: 'nowrap',
      }}>
        <span style={{ width: 28, height: 1, background: VC.copper }}/>
        Sweet spot
        <span style={{ width: 28, height: 1, background: VC.copper }}/>
      </div>

      {/* Vertical pointer line down to the chosen cell */}
      <div style={{
        position: 'absolute',
        left: originX + sweetCol * (cellW + pad) + cellW / 2 - 0.5,
        top: originY - 14,
        width: 1, height: 14,
        background: VC.copper,
        opacity: sweetP * 0.7,
      }}/>

      {/* Bottom statement */}
      <div style={{
        position: 'absolute', left: '50%', bottom: 100,
        transform: 'translateX(-50%)',
        fontFamily: VC.fontSans, fontSize: 22, color: VC.muted,
        textAlign: 'center', maxWidth: 1100,
      }}>
        Hvert minut afprøves 1.000 mulige varmeforløb — <span style={{color: VC.copper}}>lokalt på enheden, ikke i cloud</span>. VikingHeat vælger det med højeste COP, laveste pris og bibeholdt komfort.
      </div>
    </div>
  );
}

// ── Scene 8: Resultat (27..30) ────────────────────────────────────────────
function SceneResult() {
  const t = useTime();
  if (t < 26.8) return null;
  const eOp = fadeWindow(t, 27.0, 27.6, 33.4, 33.95);

  const items = [
    { n: '1', h: '100% komfort.',  s: 'Sikker drift uden unødig start‑stop.' },
    { n: '2', h: 'Højeste COP.',   s: 'Mindre strømforbrug — mere varme.' },
    { n: '3', h: 'Laveste pris.',  s: 'Et lavere elforbrug til bedste spotpris incl. afgifter.' },
    { n: '4', h: 'Netbalancering (aFRR)',  s: 'Kommer snart.', soon: true },
  ];

  // Crossfade OPTIMERET → "Det kloge valg til din varmepumpe" between 30.0 → 31.4
  const optOp   = 1 - smooth(ramp(t, 30.0, 31.4));
  const tagOp   = smooth(ramp(t, 30.6, 32.0));
  const cx = 1160, cy = H/2 + 30;

  return (
    <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none', opacity: eOp }}>
      {/* Optimised ring — larger */}
      <svg width={W} height={H} style={{ position: 'absolute', inset: 0 }}>
        <circle cx={cx} cy={cy} r={420 + 10 * Math.sin(t * 2)}
          fill="none" stroke={VC.copper} strokeOpacity="0.18" strokeWidth="2"/>
        <circle cx={cx} cy={cy} r={300}
          fill="none" stroke={VC.copper} strokeOpacity="0.45" strokeWidth="1.5"/>
        <circle cx={cx} cy={cy} r={210} fill={VC.copper}/>
      </svg>
      {/* HTML overlays for the centered text — clean crossfade between two strings */}
      <div style={{
        position: 'absolute', left: cx, top: cy,
        transform: 'translate(-50%, -50%)',
        fontFamily: VC.fontMono, fontWeight: 600, fontSize: 36,
        letterSpacing: '0.18em', color: VC.paper,
        opacity: optOp, whiteSpace: 'nowrap',
      }}>OPTIMERET</div>
      <div style={{
        position: 'absolute', left: cx, top: cy,
        transform: 'translate(-50%, -50%)',
        fontFamily: VC.fontSans, fontWeight: 500, fontSize: 28,
        letterSpacing: '-0.01em', color: VC.paper,
        opacity: tagOp, textAlign: 'center',
        lineHeight: 1.2, maxWidth: 360, padding: '0 24px',
      }}>Det kloge valg<br/>til din varmepumpe</div>

      <Tag x={120} y={140} align="left" color={VC.copper}>
        Resultatet
      </Tag>

      {/* Numbered result list, anchored to the left of the optimised ring */}
      <div style={{
        position: 'absolute', left: 120, top: 200,
        display: 'flex', flexDirection: 'column', gap: 28,
      }}>
        {items.map((it, i) => {
          const op = smooth(ramp(t, 27.4 + i * 0.95, 28.3 + i * 0.95));
          const dim = it.soon ? 0.55 : 1;
          return (
            <div key={i} style={{
              opacity: op * dim,
              display: 'grid',
              gridTemplateColumns: '60px 1fr',
              columnGap: 18, alignItems: 'baseline',
              maxWidth: 880,
            }}>
              <div style={{
                fontFamily: VC.fontMono, fontWeight: 500, fontSize: 26,
                color: it.soon ? VC.muted : VC.copper,
                lineHeight: 1, letterSpacing: '-0.01em',
              }}>{it.n}.</div>
              <div>
                <div style={{
                  fontFamily: VC.fontSans, fontWeight: 500,
                  fontSize: it.soon ? 40 : 52,
                  color: it.soon ? VC.muted : VC.paper,
                  lineHeight: 1.05, letterSpacing: '-0.025em',
                  marginBottom: 8,
                }}>{it.h}</div>
                <div style={{
                  fontFamily: VC.fontSans, fontSize: 18,
                  color: it.soon ? VC.mutedDim : VC.muted,
                  lineHeight: 1.45, maxWidth: 720,
                  fontStyle: it.soon ? 'italic' : 'normal',
                }}>{it.s}</div>
              </div>
            </div>
          );
        })}
      </div>

    </div>
  );
}

// ── Persistent logo (bottom‑right, all scenes) ─────────────────────────────
function PersistentLogo() {
  // Always visible — no fade, so it stays on screen across the loop.
  return <Logo x={W - 360} y={H - 60} opacity={1} />;
}

Object.assign(window, {
  PersistentLogo,
  SceneTitle, SceneComfort, SceneTriangle,
  SceneA, SceneB, SceneC, SceneTwins, SceneResult,
});
