// scenes.jsx — Individual scene components for the JGE sizzle reel.
// Each scene assumes it is inside a <Sprite start={x} end={y}> that scopes
// its localTime/progress. Scenes fill a 1920×1080 canvas.

// ── Palette helper ──────────────────────────────────────────────────────────
const PALETTES = {
  'black-gold':  { bg: '#0A0A0A', fg: '#F7F1E4', accent: '#D9C9A3', accentDeep: '#B9A573', muted: 'rgba(247,241,228,0.55)', line: 'rgba(247,241,228,0.14)' },
  'black-cream': { bg: '#0A0A0A', fg: '#F7F1E4', accent: '#F7F1E4', accentDeep: '#BDB6A5', muted: 'rgba(247,241,228,0.55)', line: 'rgba(247,241,228,0.14)' },
  'cream-black': { bg: '#F7F1E4', fg: '#0A0A0A', accent: '#B9A573', accentDeep: '#8A6F3C', muted: 'rgba(10,10,10,0.55)', line: 'rgba(10,10,10,0.14)' },
  'red-van':     { bg: '#0A0A0A', fg: '#F7F1E4', accent: '#B33E14', accentDeep: '#922B00', muted: 'rgba(247,241,228,0.55)', line: 'rgba(247,241,228,0.14)' },
};
const usePalette = () => {
  const [p, setP] = React.useState(() => (window.__TWEAKS?.palette) || 'black-gold');
  React.useEffect(() => {
    const on = (e) => setP(e.detail.palette || 'black-gold');
    window.addEventListener('tweaks:change', on);
    return () => window.removeEventListener('tweaks:change', on);
  }, []);
  return PALETTES[p] || PALETTES['black-gold'];
};

const FONT_DISPLAY = "'Cormorant Garamond', 'Trajan Pro', Georgia, serif";
const FONT_WORD = "'Archivo', system-ui, sans-serif";
const FONT_BODY = "'Libre Caslon Text', Georgia, serif";

// ── Utility: blocking backdrop so the scene fills canvas ────────────────────
function SceneBg({ color }) {
  return <div style={{ position: 'absolute', inset: 0, background: color }} />;
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 1 — INTRO / LOGO REVEAL
// Timing: 0–5s. Black. Type flies in letter by letter for "JONAS GROUP"
// (classical roman wordmark), underlined with the ENTERTAINMENT spaced-cap,
// then a fast "flash cut" whiteout exit.
// ══════════════════════════════════════════════════════════════════════════
function SceneIntro() {
  const { progress, localTime, duration } = useSprite();
  const pal = usePalette();

  // Letters animate in sequentially
  const letters = 'JONAS GROUP'.split('');
  const letterStart = 0.4;   // seconds
  const letterStagger = 0.08;
  const entertainmentStart = 1.8;
  const flashStart = duration - 0.45;

  // Flash whiteout at end
  const flashT = localTime < flashStart ? 0 : (localTime - flashStart) / 0.4;

  return (
    <>
      <SceneBg color={pal.bg} />
      {/* Hairline cross */}
      <div style={{ position: 'absolute', left: '50%', top: 0, bottom: 0, width: 1, background: pal.line, transform: 'scaleY(' + Easing.easeOutCubic(clamp(localTime / 0.8, 0, 1)) + ')', transformOrigin: 'top' }} />
      <div style={{ position: 'absolute', top: '50%', left: 0, right: 0, height: 1, background: pal.line, transform: 'scaleX(' + Easing.easeOutCubic(clamp((localTime - 0.15) / 0.8, 0, 1)) + ')', transformOrigin: 'left' }} />

      {/* Wordmark */}
      <div style={{
        position: 'absolute',
        inset: 0,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        flexDirection: 'column',
      }}>
        <div style={{
          fontFamily: FONT_DISPLAY,
          fontWeight: 500,
          fontSize: 220,
          letterSpacing: '0.02em',
          color: pal.fg,
          lineHeight: 1,
          display: 'flex',
          gap: 0,
        }}>
          {letters.map((ch, i) => {
            const t = clamp((localTime - letterStart - i * letterStagger) / 0.5, 0, 1);
            const eased = Easing.easeOutCubic(t);
            return (
              <span key={i} style={{
                opacity: eased,
                transform: `translateY(${(1 - eased) * 30}px)`,
                display: 'inline-block',
                minWidth: ch === ' ' ? 60 : 'auto',
                willChange: 'transform, opacity',
              }}>
                {ch}
              </span>
            );
          })}
        </div>
        {/* ENTERTAINMENT */}
        <div style={{
          marginTop: 48,
          fontFamily: FONT_WORD,
          fontWeight: 400,
          fontSize: 20,
          letterSpacing: '0.45em',
          color: pal.accent,
          paddingLeft: '0.45em',
          whiteSpace: 'nowrap',
          opacity: Easing.easeOutCubic(clamp((localTime - entertainmentStart) / 0.8, 0, 1)),
          transform: `translateY(${(1 - Easing.easeOutCubic(clamp((localTime - entertainmentStart) / 0.8, 0, 1))) * 12}px)`,
        }}>
          ENTERTAINMENT
        </div>
      </div>

      {/* Flash whiteout */}
      <div style={{
        position: 'absolute', inset: 0,
        background: pal.fg,
        opacity: clamp(flashT, 0, 1),
        pointerEvents: 'none',
      }} />
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 2 — THESIS STATEMENT
// Timing: 5–10s. Slab of display type with huge tracking contrast.
// "WE DON'T CHASE CULTURE. / WE WRITE IT."
// ══════════════════════════════════════════════════════════════════════════
function SceneThesis() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();
  const exitStart = duration - 0.4;

  const line1T = clamp((localTime - 0.15) / 0.9, 0, 1);
  const line2T = clamp((localTime - 0.9) / 0.9, 0, 1);
  const exitT = localTime > exitStart ? (localTime - exitStart) / 0.4 : 0;

  return (
    <>
      <SceneBg color={pal.bg} />
      <div style={{
        position: 'absolute', inset: 0,
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        flexDirection: 'column',
        padding: '0 160px',
        opacity: 1 - exitT,
      }}>
        <div style={{
          fontFamily: FONT_WORD,
          fontSize: 14,
          letterSpacing: '0.35em',
          color: pal.accent,
          marginBottom: 48,
          opacity: Easing.easeOutCubic(clamp(localTime / 0.6, 0, 1)),
        }}>
          · &nbsp;&nbsp; THE JONAS GROUP ENTERTAINMENT THESIS &nbsp;&nbsp; ·
        </div>

        <div style={{
          fontFamily: FONT_DISPLAY,
          fontWeight: 400,
          fontStyle: 'italic',
          fontSize: 140,
          color: pal.fg,
          lineHeight: 1.02,
          letterSpacing: '-0.01em',
          textAlign: 'center',
          opacity: line1T,
          transform: `translateY(${(1 - line1T) * 20}px)`,
        }}>
          We don't chase culture.
        </div>
        <div style={{
          fontFamily: FONT_DISPLAY,
          fontWeight: 600,
          fontSize: 180,
          color: pal.accent,
          lineHeight: 1,
          letterSpacing: '-0.02em',
          textAlign: 'center',
          marginTop: 8,
          opacity: line2T,
          transform: `translateY(${(1 - line2T) * 24}px)`,
        }}>
          We write it.
        </div>
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 3 — CATALOG REVEAL
// Timing: 10–19s. "CATALOGS UNDER MANAGEMENT" header.
// Five catalog names punch in stacked with hairline counters on the left.
// ══════════════════════════════════════════════════════════════════════════
const CATALOGS = [
  { name: 'THE JONAS BROTHERS',    sub: 'SELECT CATALOG & SONG RIGHTS · 2025 ACQUISITION' },
  { name: 'JULIA MICHAELS',         sub: 'SONGWRITER CATALOG · ACQUISITION' },
  { name: 'RHETT AKINS',            sub: 'SONGWRITER CATALOG' },
  { name: 'JUSTIN EBACH',           sub: 'SONGWRITER / PRODUCER CATALOG' },
  { name: 'DANGER TWINS',           sub: 'SONGWRITER CATALOG' },
];

function SceneCatalog() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();
  const headerT = Easing.easeOutCubic(clamp(localTime / 0.7, 0, 1));
  const itemStagger = 0.55;
  const itemStart = 1.0;
  const exitStart = duration - 0.5;
  const exitT = localTime > exitStart ? (localTime - exitStart) / 0.5 : 0;

  return (
    <>
      <SceneBg color={pal.bg} />
      {/* vertical rule */}
      <div style={{
        position: 'absolute',
        left: 160, top: 160, bottom: 160,
        width: 1, background: pal.line,
        transform: `scaleY(${Easing.easeOutCubic(clamp(localTime / 0.9, 0, 1))})`,
        transformOrigin: 'top',
      }} />
      <div style={{
        position: 'absolute', inset: 0,
        padding: '140px 160px',
        display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
        opacity: 1 - exitT,
      }}>
        {/* HEADER */}
        <div>
          <div style={{
            fontFamily: FONT_WORD,
            fontSize: 13,
            letterSpacing: '0.35em',
            color: pal.accent,
            opacity: headerT,
            marginBottom: 12,
          }}>
            01 &nbsp;·&nbsp; CATALOG
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY,
            fontWeight: 400,
            fontStyle: 'italic',
            fontSize: 72,
            color: pal.fg,
            lineHeight: 0.95,
            letterSpacing: '-0.02em',
            opacity: headerT,
            transform: `translateY(${(1 - headerT) * 14}px)`,
          }}>
            Catalogs under management
          </div>
        </div>

        {/* LIST */}
        <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
          {CATALOGS.map((cat, i) => {
            const t = clamp((localTime - itemStart - i * itemStagger) / 0.6, 0, 1);
            const eased = Easing.easeOutCubic(t);
            return (
              <div key={i} style={{
                display: 'flex',
                alignItems: 'baseline',
                gap: 32,
                opacity: eased,
                transform: `translateX(${(1 - eased) * 60}px)`,
              }}>
                <div style={{
                  fontFamily: 'JetBrains Mono, ui-monospace, monospace',
                  fontSize: 15,
                  color: pal.accent,
                  letterSpacing: '0.1em',
                  width: 48,
                }}>
                  0{i + 1}
                </div>
                <div style={{
                  fontFamily: FONT_DISPLAY,
                  fontWeight: 500,
                  fontSize: 96,
                  color: pal.fg,
                  lineHeight: 1,
                  letterSpacing: '-0.015em',
                  flex: 1,
                }}>
                  {cat.name}
                </div>
                <div style={{
                  fontFamily: FONT_WORD,
                  fontSize: 11,
                  color: pal.muted,
                  letterSpacing: '0.18em',
                  maxWidth: 320,
                  textAlign: 'right',
                  lineHeight: 1.4,
                }}>
                  {cat.sub}
                </div>
              </div>
            );
          })}
        </div>

        {/* FOOTER STAT */}
        <div style={{
          display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end',
          opacity: Easing.easeOutCubic(clamp((localTime - (itemStart + 5 * itemStagger)) / 0.6, 0, 1)),
        }}>
          <div style={{
            fontFamily: FONT_WORD, fontSize: 11,
            letterSpacing: '0.28em', color: pal.muted,
          }}>
            JONAS CATALOG HOLDINGS
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY, fontStyle: 'italic',
            fontSize: 36, color: pal.fg,
          }}>
            investing in music that outlasts the cycle
          </div>
        </div>
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 4 — ROSTER (full-bleed portraits, each 1.7s, then a grid)
// Timing: 15–30s (15s total; 6 portraits @ 1.7s = 10.2s, then ~4.5s grid)
// ══════════════════════════════════════════════════════════════════════════
const ROSTER = [
  { name: 'RAELYNN',         sub: 'ARTIST · VALORY MUSIC / BIG MACHINE',  img: (window.__ASSETS && window.__ASSETS.raelynn) || '../assets/artist-raelynn.png' },
  { name: 'AARON GILLESPIE', sub: 'ARTIST · FROM UNDEROATH',               img: (window.__ASSETS && window.__ASSETS.aaron) || '../assets/artist-aaron.jpeg' },
  { name: 'BAILEE MADISON',  sub: 'ACTOR → MUSIC ARTIST',                  img: (window.__ASSETS && window.__ASSETS.bailee) || '../assets/artist-bailee.png' },
  { name: 'FRANKLIN JONAS',  sub: 'ARTIST',                                img: (window.__ASSETS && window.__ASSETS.franklin) || '../assets/artist-franklin.jpg' },
  { name: 'DAN MARSHALL',    sub: 'ARTIST',                                img: (window.__ASSETS && window.__ASSETS.dan) || '../assets/artist-dan.jpeg' },
  { name: 'HUNTER HAWKINS',  sub: 'ARTIST',                                img: (window.__ASSETS && window.__ASSETS.hunter) || '../assets/artist-hunter.png' },
  { name: 'AMY STROUP',      sub: 'ARTIST · DANGER TWINS',                 img: (window.__ASSETS && window.__ASSETS.amy) || '../assets/artist-amy.png' },
];

function SceneRoster() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();

  const bleedCount = 6;
  const bleedDur = 1.7;
  const bleedTotal = bleedCount * bleedDur;
  const gridStart = bleedTotal;
  const gridDur = duration - gridStart - 0.3;

  // Which bleed portrait is active right now?
  const bleedIdx = Math.floor(localTime / bleedDur);
  const localInBleed = localTime - bleedIdx * bleedDur;
  const inBleedPhase = localTime < bleedTotal;

  // Transition between bleeds: 0.35s fade
  const fadeIn = clamp(localInBleed / 0.35, 0, 1);
  const fadeOut = localInBleed > bleedDur - 0.35 ? 1 - (localInBleed - (bleedDur - 0.35)) / 0.35 : 1;
  const bleedOpacity = Math.min(fadeIn, fadeOut);

  return (
    <>
      <SceneBg color={pal.bg} />

      {/* --- FULL-BLEED PHASE --- */}
      {inBleedPhase && ROSTER[bleedIdx] && (
        <FullBleedPortrait
          key={bleedIdx}
          artist={ROSTER[bleedIdx]}
          index={bleedIdx}
          localTime={localInBleed}
          dur={bleedDur}
          pal={pal}
          opacity={bleedOpacity}
        />
      )}

      {/* --- GRID PHASE --- */}
      {!inBleedPhase && (
        <RosterGrid
          localTime={localTime - gridStart}
          dur={gridDur}
          pal={pal}
        />
      )}

      {/* Persistent counter bottom-left during bleed phase */}
      {inBleedPhase && (
        <div style={{
          position: 'absolute', left: 64, bottom: 56,
          fontFamily: 'JetBrains Mono, ui-monospace, monospace',
          fontSize: 14,
          letterSpacing: '0.15em',
          color: pal.accent,
        }}>
          {String(bleedIdx + 1).padStart(2, '0')} <span style={{ opacity: 0.5 }}>/ {String(ROSTER.length).padStart(2, '0')}  &nbsp;·&nbsp;  ARTIST ROSTER</span>
        </div>
      )}
    </>
  );
}

function FullBleedPortrait({ artist, index, localTime, dur, pal, opacity }) {
  // Ken Burns slow zoom
  const kbScale = 1.0 + (localTime / dur) * 0.08;
  // Name slides in from left at 0.3s
  const nameT = Easing.easeOutCubic(clamp((localTime - 0.25) / 0.6, 0, 1));

  return (
    <>
      {/* Image — offset to right third so left side is dark for type */}
      <div style={{
        position: 'absolute',
        inset: 0,
        opacity,
      }}>
        <img src={artist.img} style={{
          position: 'absolute',
          right: 0, top: 0, height: '100%', width: '65%',
          objectFit: 'cover',
          transform: `scale(${kbScale})`,
          transformOrigin: 'center',
          willChange: 'transform',
        }} />
        {/* Left side gradient blur to merge with black */}
        <div style={{
          position: 'absolute', left: 0, top: 0, bottom: 0, width: '70%',
          background: `linear-gradient(90deg, ${pal.bg} 0%, ${pal.bg} 30%, transparent 100%)`,
        }} />
        {/* Subtle bottom vignette */}
        <div style={{
          position: 'absolute', inset: 0,
          background: `linear-gradient(180deg, transparent 60%, ${pal.bg} 100%)`,
          opacity: 0.6,
        }} />
      </div>

      {/* Type stack — large italic first name, spaced last name */}
      <div style={{
        position: 'absolute',
        left: 120, top: '50%',
        transform: `translateY(-50%) translateX(${(1 - nameT) * -30}px)`,
        opacity: nameT * opacity,
        maxWidth: 820,
      }}>
        <div style={{
          fontFamily: FONT_WORD,
          fontSize: 13, letterSpacing: '0.3em',
          color: pal.accent,
          marginBottom: 24,
        }}>
          {String(index + 1).padStart(2, '0')} &nbsp; · &nbsp; JGE ROSTER
        </div>
        <div style={{
          fontFamily: FONT_DISPLAY,
          fontWeight: 500,
          fontSize: 180,
          color: pal.fg,
          lineHeight: 0.92,
          letterSpacing: '-0.02em',
        }}>
          {artist.name}
        </div>
        <div style={{
          marginTop: 28,
          fontFamily: FONT_WORD,
          fontSize: 13, letterSpacing: '0.22em',
          color: pal.muted,
        }}>
          {artist.sub}
        </div>
      </div>
    </>
  );
}

function RosterGrid({ localTime, dur, pal }) {
  const headerT = Easing.easeOutCubic(clamp(localTime / 0.5, 0, 1));
  const items = ROSTER;

  return (
    <>
      <SceneBg color={pal.bg} />
      <div style={{ position: 'absolute', inset: 0, padding: '80px 120px 60px' }}>
        <div style={{
          display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end',
          marginBottom: 32,
          opacity: headerT,
        }}>
          <div>
            <div style={{ fontFamily: FONT_WORD, fontSize: 13, letterSpacing: '0.35em', color: pal.accent, marginBottom: 10 }}>
              02 &nbsp;·&nbsp; ROSTER
            </div>
            <div style={{
              fontFamily: FONT_DISPLAY, fontStyle: 'italic',
              fontSize: 64, color: pal.fg, lineHeight: 1,
              letterSpacing: '-0.02em',
              whiteSpace: 'nowrap',
            }}>
              Artists we represent
            </div>
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY,
            fontSize: 42, color: pal.accent,
            lineHeight: 1,
          }}>
            {items.length} artists
          </div>
        </div>

        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(4, 1fr)',
          gridTemplateRows: 'repeat(2, 1fr)',
          gap: 14,
          height: 'calc(100% - 140px)',
        }}>
          {items.map((a, i) => {
            const t = clamp((localTime - 0.4 - i * 0.1) / 0.55, 0, 1);
            const eased = Easing.easeOutCubic(t);
            return (
              <div key={i} style={{
                position: 'relative',
                overflow: 'hidden',
                background: pal.line,
                opacity: eased,
                transform: `translateY(${(1 - eased) * 24}px)`,
                border: `1px solid ${pal.line}`,
              }}>
                <img src={a.img} style={{
                  width: '100%', height: '100%', objectFit: 'cover',
                  filter: 'grayscale(25%) contrast(1.05)',
                }} />
                <div style={{
                  position: 'absolute', left: 0, bottom: 0, right: 0,
                  padding: '16px 18px 14px',
                  background: `linear-gradient(0deg, ${pal.bg} 10%, rgba(10,10,10,0.0) 100%)`,
                  color: pal.fg,
                }}>
                  <div style={{
                    fontFamily: FONT_DISPLAY, fontWeight: 500,
                    fontSize: 22, lineHeight: 1.05,
                    letterSpacing: '-0.01em',
                  }}>{a.name}</div>
                  <div style={{
                    marginTop: 4,
                    fontFamily: FONT_WORD, fontSize: 10,
                    letterSpacing: '0.18em',
                    color: pal.accent,
                  }}>{a.sub}</div>
                </div>
              </div>
            );
          })}
          {/* "& more" placeholder to balance the 8th grid cell */}
          {(() => {
            const i = items.length;
            const t = clamp((localTime - 0.4 - i * 0.1) / 0.55, 0, 1);
            const eased = Easing.easeOutCubic(t);
            return (
              <div style={{
                position: 'relative',
                overflow: 'hidden',
                border: `1px solid ${pal.line}`,
                opacity: eased,
                transform: `translateY(${(1 - eased) * 24}px)`,
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                flexDirection: 'column',
                gap: 10,
                padding: 20,
                textAlign: 'center',
              }}>
                <div style={{
                  fontFamily: FONT_DISPLAY, fontStyle: 'italic',
                  fontSize: 64, color: pal.accent, lineHeight: 1,
                  letterSpacing: '-0.02em',
                }}>&amp;&nbsp;more</div>
                <div style={{
                  fontFamily: FONT_WORD, fontSize: 10,
                  letterSpacing: '0.22em', color: pal.muted,
                  maxWidth: 180,
                }}>
                  ACTIVE ROSTER ACROSS PUBLISHING, RECORDS &amp; MANAGEMENT
                </div>
              </div>
            );
          })()}
        </div>
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 5 — RADIO CHART MOMENT
// Timing: 32–38s. "I DARE YOU" Rascal Flatts × Jonas Brothers moment.
// ══════════════════════════════════════════════════════════════════════════
function SceneRadio() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();

  const t1 = Easing.easeOutCubic(clamp(localTime / 0.6, 0, 1));
  const t2 = Easing.easeOutCubic(clamp((localTime - 0.5) / 0.7, 0, 1));
  const t3 = Easing.easeOutCubic(clamp((localTime - 1.5) / 0.7, 0, 1));
  const t4 = Easing.easeOutCubic(clamp((localTime - 2.3) / 0.7, 0, 1));
  const t5 = Easing.easeOutCubic(clamp((localTime - 3.1) / 0.7, 0, 1));

  // Chart rising bars animate
  const chartProgress = clamp((localTime - 2.5) / (duration - 3.5), 0, 1);

  return (
    <>
      <SceneBg color={pal.bg} />
      <div style={{ position: 'absolute', inset: 0, padding: '100px 120px', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
        <div>
          <div style={{ fontFamily: FONT_WORD, fontSize: 13, letterSpacing: '0.35em', color: pal.accent, marginBottom: 12, opacity: t1 }}>
            04 &nbsp;·&nbsp; RADIO · I DARE YOU
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY, fontStyle: 'italic',
            fontSize: 64, color: pal.fg, lineHeight: 1,
            letterSpacing: '-0.02em',
            opacity: t1,
            transform: `translateY(${(1 - t1) * 14}px)`,
          }}>
            Our songs on the dial
          </div>
        </div>

        {/* BIG STAT */}
        <div style={{ display: 'flex', gap: 64, alignItems: 'flex-end' }}>
          <div style={{
            opacity: t2,
            transform: `translateY(${(1 - t2) * 40}px)`,
            flex: 1,
          }}>
            <div style={{ fontFamily: FONT_WORD, fontSize: 14, letterSpacing: '0.28em', color: pal.accent, marginBottom: 12, fontWeight: 600 }}>
              TOP 10 SMASH · COUNTRY RADIO
            </div>
            <div style={{
              fontFamily: FONT_DISPLAY, fontWeight: 500,
              fontSize: 180, color: pal.fg, lineHeight: 0.92,
              letterSpacing: '-0.03em',
              whiteSpace: 'nowrap',
            }}>
              "I Dare <span style={{ color: pal.accent }}>You.</span>"
            </div>
            <div style={{
              marginTop: 28,
              fontFamily: FONT_BODY, fontStyle: 'italic',
              fontSize: 28, color: pal.fg,
              opacity: t3,
            }}>
              Rascal Flatts × Jonas Brothers
            </div>
            <div style={{
              marginTop: 8,
              fontFamily: FONT_WORD, fontSize: 12, letterSpacing: '0.22em',
              color: pal.muted,
              opacity: t3,
            }}>
              CO-PUBLISHED BY JONAS GROUP PUBLISHING
            </div>
          </div>

          {/* Rising chart bars */}
          <div style={{
            width: 420,
            height: 280,
            opacity: t4,
            display: 'flex', alignItems: 'flex-end', gap: 6,
            borderBottom: `1px solid ${pal.line}`,
            paddingBottom: 40,
            position: 'relative',
          }}>
            {Array.from({ length: 14 }).map((_, i) => {
              const seed = [32, 28, 44, 38, 52, 48, 66, 58, 74, 82, 70, 90, 96, 100][i];
              const barT = clamp((localTime - 2.5 - i * 0.05) / 0.6, 0, 1);
              const h = Easing.easeOutCubic(barT) * seed * 2.2;
              const isPeak = i >= 11;
              return (
                <div key={i} style={{
                  flex: 1,
                  height: h,
                  background: isPeak ? pal.accent : pal.fg,
                  opacity: isPeak ? 1 : 0.4,
                  transition: 'height 60ms linear',
                }} />
              );
            })}
            <div style={{
              position: 'absolute',
              bottom: -26, left: 0,
              fontFamily: 'JetBrains Mono, ui-monospace, monospace',
              fontSize: 10, letterSpacing: '0.15em',
              color: pal.muted,
            }}>WK 1</div>
            <div style={{
              position: 'absolute',
              bottom: -26, right: 0,
              fontFamily: 'JetBrains Mono, ui-monospace, monospace',
              fontSize: 10, letterSpacing: '0.15em',
              color: pal.accent,
            }}>WK 14 · TOP 10</div>
          </div>
        </div>

        {/* Second win */}
        <div style={{
          borderTop: `1px solid ${pal.line}`,
          paddingTop: 24,
          display: 'flex', alignItems: 'baseline', gap: 32,
          opacity: t5,
          transform: `translateY(${(1 - t5) * 16}px)`,
        }}>
          <div style={{
            fontFamily: FONT_WORD, fontSize: 11, letterSpacing: '0.28em', color: pal.muted,
            width: 120,
          }}>
            ALSO CHARTING
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY, fontStyle: 'italic',
            fontSize: 42, color: pal.fg, flex: 1,
          }}>
            John Zach King — <span style={{ color: pal.accent }}>penned by Rhett Akins</span> — climbing Country radio.
          </div>
        </div>
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 6 — AWARDS & WINS (marquee-style headline ticker + pinned wins)
// Timing: 38–46s
// ══════════════════════════════════════════════════════════════════════════
const WINS = [
  { tag: 'NMPA ICON AWARD · 2025',       line: 'Rhett Akins honored as',        big: 'Non-Performing Songwriter Icon' },
  { tag: 'SESAC · 2025',                 line: "Justin Ebach's",                 big: '"Relapse" wins SESAC Award' },
  { tag: 'SIGNING · 2025',               line: 'Aaron Gillespie inks with',     big: 'Jonas Group Publishing' },
];

function SceneAwards() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();

  const headerT = Easing.easeOutCubic(clamp(localTime / 0.5, 0, 1));
  const perCard = (duration - 1) / WINS.length;

  return (
    <>
      <SceneBg color={pal.bg} />
      {/* Marquee band at top */}
      <div style={{
        position: 'absolute', left: 0, right: 0, top: 0,
        height: 72,
        background: pal.accent,
        color: pal.bg,
        display: 'flex', alignItems: 'center',
        overflow: 'hidden',
        opacity: headerT,
      }}>
        <div style={{
          display: 'flex',
          gap: 48,
          whiteSpace: 'nowrap',
          transform: `translateX(${-(localTime * 200) % 1200}px)`,
          fontFamily: FONT_WORD,
          fontSize: 18,
          fontWeight: 600,
          letterSpacing: '0.28em',
        }}>
          {Array(6).fill(0).map((_, i) => (
            <span key={i}>RECENT WINS &nbsp;·&nbsp; 2025 &nbsp;·&nbsp; JONAS GROUP ENTERTAINMENT &nbsp;·&nbsp;</span>
          ))}
        </div>
      </div>

      <div style={{ position: 'absolute', inset: 0, padding: '140px 120px 80px', display: 'flex', flexDirection: 'column', gap: 32 }}>
        <div style={{ opacity: headerT }}>
          <div style={{ fontFamily: FONT_WORD, fontSize: 13, letterSpacing: '0.35em', color: pal.accent, marginBottom: 12 }}>
            05 &nbsp;·&nbsp; WINS
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY, fontStyle: 'italic',
            fontSize: 64, color: pal.fg, lineHeight: 1,
            letterSpacing: '-0.02em',
          }}>
            Headlines from the year
          </div>
        </div>

        <div style={{ flex: 1, display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: 28 }}>
          {WINS.map((w, i) => {
            const start = 0.6 + i * perCard * 0.5;
            const t = clamp((localTime - start) / 0.7, 0, 1);
            const eased = Easing.easeOutCubic(t);
            return (
              <div key={i} style={{
                display: 'grid',
                gridTemplateColumns: '260px 1fr auto',
                alignItems: 'baseline',
                gap: 40,
                opacity: eased,
                transform: `translateX(${(1 - eased) * 40}px)`,
                paddingBottom: 24,
                borderBottom: `1px solid ${pal.line}`,
              }}>
                <div style={{
                  fontFamily: FONT_WORD, fontSize: 18,
                  letterSpacing: '0.22em', color: pal.accent,
                  fontWeight: 700,
                }}>
                  {w.tag}
                </div>
                <div>
                  <div style={{
                    fontFamily: FONT_BODY, fontStyle: 'italic',
                    fontSize: 22, color: pal.muted, marginBottom: 6,
                  }}>
                    {w.line}
                  </div>
                  <div style={{
                    fontFamily: FONT_DISPLAY, fontWeight: 500,
                    fontSize: 68, color: pal.fg, lineHeight: 1,
                    letterSpacing: '-0.015em',
                  }}>
                    {w.big}
                  </div>
                </div>
                <div style={{
                  fontFamily: 'JetBrains Mono, ui-monospace, monospace',
                  fontSize: 14, color: pal.accent,
                  letterSpacing: '0.1em',
                }}>
                  0{i + 1}
                </div>
              </div>
            );
          })}
        </div>
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 7 — THREE PILLARS (Publishing / Red Van Records / Management)
// Timing: 46–54s
// ══════════════════════════════════════════════════════════════════════════
const PILLARS = [
  { roman: 'I',   name: 'JONAS GROUP\nPUBLISHING',  tag: 'Champions acclaimed songwriters and catalogs from Nashville\'s Music Row.', metric: 'ACTIVE ROSTER + CATALOG ACQUISITIONS' },
  { roman: 'II',  name: 'RED VAN\nRECORDS',          tag: 'In-house record label — the home for signings that don\'t fit the major-label mold.', metric: 'ARTIST-FIRST · A&R-LED' },
  { roman: 'III', name: 'ARTIST\nMANAGEMENT',        tag: 'Day-to-day representation for a select roster — creative, business, and team.',  metric: 'FULL-SERVICE · BOUTIQUE SCALE' },
];

function ScenePillars() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();
  const headerT = Easing.easeOutCubic(clamp(localTime / 0.6, 0, 1));

  return (
    <>
      <SceneBg color={pal.bg} />
      <div style={{ position: 'absolute', inset: 0, padding: '100px 120px', display: 'flex', flexDirection: 'column', gap: 48 }}>
        <div style={{ opacity: headerT, transform: `translateY(${(1 - headerT) * 12}px)` }}>
          <div style={{ fontFamily: FONT_WORD, fontSize: 13, letterSpacing: '0.35em', color: pal.accent, marginBottom: 12 }}>
            06 &nbsp;·&nbsp; THE BUSINESS
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY, fontStyle: 'italic',
            fontSize: 72, color: pal.fg, lineHeight: 1,
            letterSpacing: '-0.02em',
          }}>
            Three pillars, one table
          </div>
        </div>

        <div style={{
          flex: 1,
          display: 'grid',
          gridTemplateColumns: 'repeat(3, 1fr)',
          gap: 2,
          background: pal.line,
          border: `1px solid ${pal.line}`,
        }}>
          {PILLARS.map((p, i) => {
            const t = clamp((localTime - 0.6 - i * 0.35) / 0.7, 0, 1);
            const eased = Easing.easeOutCubic(t);
            return (
              <div key={i} style={{
                background: pal.bg,
                padding: '56px 48px',
                display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
                opacity: eased,
                transform: `translateY(${(1 - eased) * 30}px)`,
                position: 'relative',
              }}>
                <div>
                  <div style={{
                    fontFamily: FONT_DISPLAY, fontStyle: 'italic',
                    fontWeight: 400,
                    fontSize: 80, color: pal.accent, lineHeight: 1,
                    marginBottom: 40,
                  }}>
                    {p.roman}.
                  </div>
                  <div style={{
                    fontFamily: FONT_DISPLAY, fontWeight: 500,
                    fontSize: 64, color: pal.fg, lineHeight: 0.95,
                    letterSpacing: '-0.02em',
                    whiteSpace: 'pre-line',
                    marginBottom: 32,
                  }}>
                    {p.name}
                  </div>
                  <div style={{
                    fontFamily: FONT_BODY, fontStyle: 'italic',
                    fontSize: 22, color: pal.muted, lineHeight: 1.4,
                    maxWidth: 380,
                  }}>
                    {p.tag}
                  </div>
                </div>
                <div style={{
                  marginTop: 40,
                  paddingTop: 20,
                  borderTop: `1px solid ${pal.line}`,
                  fontFamily: FONT_WORD, fontSize: 11,
                  letterSpacing: '0.28em', color: pal.accent,
                }}>
                  {p.metric}
                </div>
              </div>
            );
          })}
        </div>
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 8 — CLOSE (logo lockup, address, fade)
// Timing: 54–60s
// ══════════════════════════════════════════════════════════════════════════
function SceneClose() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();

  const t1 = Easing.easeOutCubic(clamp(localTime / 0.8, 0, 1));
  const t2 = Easing.easeOutCubic(clamp((localTime - 0.6) / 0.8, 0, 1));
  const t3 = Easing.easeOutCubic(clamp((localTime - 1.4) / 0.8, 0, 1));
  const t4 = Easing.easeOutCubic(clamp((localTime - 2.2) / 0.8, 0, 1));

  const fadeOut = localTime > duration - 0.8 ? (localTime - (duration - 0.8)) / 0.8 : 0;

  return (
    <>
      <SceneBg color={pal.bg} />
      <div style={{
        position: 'absolute', inset: 0,
        display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
        opacity: 1 - fadeOut,
        gap: 0,
      }}>
        {/* Dividing rule */}
        <div style={{
          width: `${t1 * 480}px`, height: 1,
          background: pal.accent, marginBottom: 56,
        }} />

        <div style={{
          fontFamily: FONT_DISPLAY, fontWeight: 500,
          fontSize: 180, color: pal.fg, lineHeight: 1,
          letterSpacing: '-0.01em',
          whiteSpace: 'nowrap',
          opacity: t1,
          transform: `translateY(${(1 - t1) * 16}px)`,
        }}>
          JONAS GROUP
        </div>
        <div style={{
          marginTop: 32,
          fontFamily: FONT_WORD, fontSize: 22,
          letterSpacing: '0.55em',
          color: pal.accent,
          paddingLeft: '0.55em',
          whiteSpace: 'nowrap',
          opacity: t2,
        }}>
          ENTERTAINMENT
        </div>

        <div style={{
          marginTop: 72,
          fontFamily: FONT_BODY, fontStyle: 'italic',
          fontSize: 28, color: pal.muted,
          opacity: t3,
        }}>
          1600 17th Ave South  ·  Nashville, TN 37212
        </div>

        <div style={{
          marginTop: 40,
          fontFamily: FONT_WORD, fontSize: 11,
          letterSpacing: '0.35em', color: pal.muted,
          opacity: t4,
        }}>
          JONASGROUP.COM
        </div>

        <div style={{
          width: `${t4 * 480}px`, height: 1,
          background: pal.accent, marginTop: 56,
        }} />
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 4.5 — AMY STROUP ARTIST HERO (full-bleed portrait + bio pull-quote)
// Timing: 30–34.5s. Plays after the Roster grid as a "zoom in" deep dive on one artist.
// ══════════════════════════════════════════════════════════════════════════
function SceneAmyHero() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();

  // Ken Burns slow zoom
  const kbScale = 1.0 + (localTime / duration) * 0.08;

  const t1 = Easing.easeOutCubic(clamp(localTime / 0.5, 0, 1));
  const t2 = Easing.easeOutCubic(clamp((localTime - 0.35) / 0.7, 0, 1));
  const t3 = Easing.easeOutCubic(clamp((localTime - 1.0) / 0.7, 0, 1));
  const t4 = Easing.easeOutCubic(clamp((localTime - 1.8) / 0.7, 0, 1));
  const t5 = Easing.easeOutCubic(clamp((localTime - 2.6) / 0.7, 0, 1));

  const fadeOut = localTime > duration - 0.4 ? 1 - (localTime - (duration - 0.4)) / 0.4 : 1;

  return (
    <>
      <SceneBg color={pal.bg} />

      {/* Portrait — right side */}
      <div style={{ position: 'absolute', inset: 0, opacity: fadeOut }}>
        <img src={(window.__ASSETS && window.__ASSETS.amy) || '../assets/artist-amy.png'} style={{
          position: 'absolute',
          right: 0, top: 0, height: '100%', width: '58%',
          objectFit: 'cover',
          transform: `scale(${kbScale})`,
          transformOrigin: 'center',
          opacity: t1,
          willChange: 'transform',
        }} />
        <div style={{
          position: 'absolute', left: 0, top: 0, bottom: 0, width: '68%',
          background: `linear-gradient(90deg, ${pal.bg} 0%, ${pal.bg} 34%, transparent 100%)`,
        }} />
        <div style={{
          position: 'absolute', inset: 0,
          background: `linear-gradient(180deg, transparent 55%, ${pal.bg} 100%)`,
          opacity: 0.5,
        }} />
      </div>

      {/* Type stack left */}
      <div style={{
        position: 'absolute', left: 120, top: 110, bottom: 90,
        width: 920,
        display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
        opacity: fadeOut,
      }}>
        <div>
          <div style={{
            fontFamily: FONT_WORD, fontSize: 14, letterSpacing: '0.32em',
            color: pal.accent, marginBottom: 20, fontWeight: 600,
            opacity: t1,
          }}>
            03 &nbsp;·&nbsp; SONGWRITER SPOTLIGHT
          </div>
          <div style={{
            fontFamily: FONT_BODY, fontStyle: 'italic',
            fontSize: 28, color: pal.muted,
            opacity: t2,
            transform: `translateY(${(1 - t2) * 12}px)`,
          }}>
            The self-proclaimed “song farmer” —
          </div>
        </div>

        <div style={{
          opacity: t3,
          transform: `translateY(${(1 - t3) * 24}px)`,
        }}>
          <div style={{
            fontFamily: FONT_DISPLAY, fontWeight: 500,
            fontSize: 200, color: pal.fg, lineHeight: 0.88,
            letterSpacing: '-0.025em',
          }}>
            Amy<br/>
            <span style={{ color: pal.accent, fontStyle: 'italic', fontWeight: 400 }}>Stroup.</span>
          </div>
        </div>

        <div style={{
          display: 'flex', alignItems: 'flex-end', gap: 56,
          opacity: t4,
          transform: `translateY(${(1 - t4) * 14}px)`,
        }}>
          <div style={{ flex: 1, maxWidth: 620 }}>
            <div style={{
              fontFamily: FONT_BODY, fontStyle: 'italic',
              fontSize: 26, color: pal.fg, lineHeight: 1.35,
            }}>
              Songs recorded by <span style={{ color: pal.accent }}>Chaka Khan</span> &amp; <span style={{ color: pal.accent }}>Ingrid Michaelson.</span>
              <br/>Sync placements in <em>Grey's Anatomy</em>, <em>This Is Us</em>, Disney's <em>Willow</em>.
              <br/>Half of <span style={{ color: pal.accent }}>Danger Twins.</span>
            </div>
          </div>
          <div style={{
            opacity: t5,
            textAlign: 'right',
            flexShrink: 0,
          }}>
            <div style={{
              fontFamily: FONT_DISPLAY, fontWeight: 500,
              fontSize: 88, color: pal.accent, lineHeight: 1,
              letterSpacing: '-0.02em',
            }}>
              2.4B+
            </div>
            <div style={{
              marginTop: 6,
              fontFamily: FONT_WORD, fontSize: 12, letterSpacing: '0.25em',
              color: pal.muted,
            }}>
              TIKTOK · YOUTUBE VIEWS
            </div>
          </div>
        </div>
      </div>

      {/* Corner tag */}
      <div style={{
        position: 'absolute', left: 64, bottom: 56,
        fontFamily: 'JetBrains Mono, ui-monospace, monospace',
        fontSize: 14, letterSpacing: '0.15em',
        color: pal.accent,
        opacity: fadeOut,
      }}>
        JGP ROSTER <span style={{ opacity: 0.5 }}>&nbsp;·&nbsp; CATALOG ACQUIRED 2024</span>
      </div>
    </>
  );
}

// ══════════════════════════════════════════════════════════════════════════
// SCENE 5.5 — "GET TO DRINKIN'" (pull-quote card, mirrors I Dare You)
// Timing: 38–43s
// ══════════════════════════════════════════════════════════════════════════
function SceneGetToDrinkin() {
  const { localTime, duration } = useSprite();
  const pal = usePalette();

  const t1 = Easing.easeOutCubic(clamp(localTime / 0.6, 0, 1));
  const t2 = Easing.easeOutCubic(clamp((localTime - 0.5) / 0.7, 0, 1));
  const t3 = Easing.easeOutCubic(clamp((localTime - 1.5) / 0.7, 0, 1));
  const t4 = Easing.easeOutCubic(clamp((localTime - 2.3) / 0.7, 0, 1));
  const t5 = Easing.easeOutCubic(clamp((localTime - 3.1) / 0.7, 0, 1));

  const fadeOut = localTime > duration - 0.4 ? 1 - (localTime - (duration - 0.4)) / 0.4 : 1;

  return (
    <>
      <SceneBg color={pal.bg} />
      <div style={{
        position: 'absolute', inset: 0, padding: '100px 120px',
        display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
        opacity: fadeOut,
      }}>
        <div>
          <div style={{ fontFamily: FONT_WORD, fontSize: 14, letterSpacing: '0.32em', color: pal.accent, marginBottom: 12, opacity: t1, fontWeight: 600 }}>
            04 &nbsp;·&nbsp; RADIO · GET TO DRINKIN'
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY, fontStyle: 'italic',
            fontSize: 64, color: pal.fg, lineHeight: 1,
            letterSpacing: '-0.02em',
            opacity: t1,
            transform: `translateY(${(1 - t1) * 14}px)`,
          }}>
            The next one climbing
          </div>
        </div>

        <div style={{ display: 'flex', gap: 64, alignItems: 'flex-end' }}>
          <div style={{
            opacity: t2,
            transform: `translateY(${(1 - t2) * 40}px)`,
            flex: 1,
          }}>
            <div style={{ fontFamily: FONT_WORD, fontSize: 14, letterSpacing: '0.28em', color: pal.accent, marginBottom: 12, fontWeight: 600 }}>
              NEW RELEASE · COUNTRY RADIO
            </div>
            <div style={{
              fontFamily: FONT_DISPLAY, fontWeight: 500,
              fontSize: 160, color: pal.fg, lineHeight: 0.92,
              letterSpacing: '-0.03em',
              whiteSpace: 'nowrap',
            }}>
              "Get to <span style={{ color: pal.accent }}>Drinkin'.</span>"
            </div>
            <div style={{
              marginTop: 28,
              fontFamily: FONT_BODY, fontStyle: 'italic',
              fontSize: 28, color: pal.fg,
              opacity: t3,
            }}>
              Penned by Rhett Akins
            </div>
            <div style={{
              marginTop: 8,
              fontFamily: FONT_WORD, fontSize: 12, letterSpacing: '0.22em',
              color: pal.muted,
              opacity: t3,
            }}>
              PUBLISHED BY JONAS GROUP PUBLISHING
            </div>
          </div>

          {/* Rising waveform/bars */}
          <div style={{
            width: 420,
            height: 280,
            opacity: t4,
            display: 'flex', alignItems: 'center', gap: 5,
            borderBottom: `1px solid ${pal.line}`,
            paddingBottom: 40,
            position: 'relative',
          }}>
            {Array.from({ length: 22 }).map((_, i) => {
              const seed = [22, 36, 28, 54, 42, 68, 50, 78, 60, 86, 72, 94, 80, 88, 70, 60, 52, 42, 32, 26, 20, 16][i];
              const barT = clamp((localTime - 2.5 - i * 0.03) / 0.5, 0, 1);
              const h = Easing.easeOutCubic(barT) * seed * 1.9;
              return (
                <div key={i} style={{
                  flex: 1,
                  height: h,
                  background: pal.accent,
                  opacity: 0.55 + (seed / 200),
                  transition: 'height 60ms linear',
                }} />
              );
            })}
            <div style={{
              position: 'absolute',
              bottom: -26, left: 0,
              fontFamily: 'JetBrains Mono, ui-monospace, monospace',
              fontSize: 10, letterSpacing: '0.15em',
              color: pal.muted,
            }}>NOW SPINNING</div>
            <div style={{
              position: 'absolute',
              bottom: -26, right: 0,
              fontFamily: 'JetBrains Mono, ui-monospace, monospace',
              fontSize: 10, letterSpacing: '0.15em',
              color: pal.accent,
            }}>COUNTRY FORMAT</div>
          </div>
        </div>

        {/* Context line */}
        <div style={{
          borderTop: `1px solid ${pal.line}`,
          paddingTop: 24,
          display: 'flex', alignItems: 'baseline', gap: 32,
          opacity: t5,
          transform: `translateY(${(1 - t5) * 16}px)`,
        }}>
          <div style={{
            fontFamily: FONT_WORD, fontSize: 11, letterSpacing: '0.28em', color: pal.muted,
            width: 120,
          }}>
            CATALOG
          </div>
          <div style={{
            fontFamily: FONT_DISPLAY, fontStyle: 'italic',
            fontSize: 42, color: pal.fg, flex: 1,
          }}>
            Another hit from the Akins catalog — <span style={{ color: pal.accent }}>working the dial.</span>
          </div>
        </div>
      </div>
    </>
  );
}

// ── Global exports ──────────────────────────────────────────────────────────
Object.assign(window, {
  PALETTES, usePalette,
  SceneIntro, SceneThesis, SceneCatalog, SceneRoster,
  SceneRadio, SceneAwards, ScenePillars, SceneClose,
  SceneAmyHero, SceneGetToDrinkin,
  FONT_DISPLAY, FONT_WORD, FONT_BODY,
});
