// UR2D — Home v2: live standings wall, road ahead, league ladder, footer.
// Loaded after ur2d-home2-hero.jsx.

// ─── shared section header ───────────────────────────────────────────────────
const UR2SectionHead = ({ kicker, title, accent, right }) => (
  <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', gap: 32, marginBottom: 44, flexWrap: 'wrap' }}>
    <div>
      <div style={{ fontFamily: 'JetBrains Mono', fontSize: 11, letterSpacing: '0.32em', color: accent || COLORS.red, textTransform: 'uppercase', marginBottom: 16 }}>◆ {kicker}</div>
      <h2 style={{ margin: 0, fontFamily: 'Archivo', fontWeight: 900, fontSize: 64, color: COLORS.text, letterSpacing: '-0.03em', lineHeight: 0.95 }}>{title}</h2>
    </div>
    {right || null}
  </div>
);

// ─── STANDINGS WALL — four leagues side by side, live from the sheets ────────
const UR2_STATUS_CHIP = {
  ready: { label: 'Live', color: '#22c55e' },
  loading: { label: 'Sync', color: '#FFD300' },
  error: { label: 'Cached', color: '#FF7A1A' },
  empty: { label: 'TBA', color: '#6c6c75' }
};

// livery path for a driver's team, e.g. assets/UL S25 Liveries/UL_S25_ONE.png
const ur2LiveryFor = (leagueShort, label, teamShort) =>
  (leagueShort && label && teamShort)
    ? `assets/${leagueShort} ${label} Liveries/${leagueShort}_${label}_${teamShort}.png`
    : null;

// one starting-grid slot — the car livery is the hero, position numeral behind it
const UR2GridSlot = ({ d, pos, accent, livery, flag, teamColor, offset }) => (
  <div style={{
    position: 'relative', display: 'flex', alignItems: 'center', gap: 10,
    padding: '9px 20px 9px 16px', marginLeft: offset,
    borderLeft: `2px solid ${pos === 1 ? accent : COLORS.hairline}`
  }}>
    {/* ghost position numeral */}
    <span aria-hidden style={{
      fontFamily: 'Archivo', fontWeight: 900, fontSize: pos === 1 ? 46 : 38, lineHeight: 0.8,
      color: pos === 1 ? accent : 'transparent', WebkitTextStroke: pos === 1 ? 'none' : `1px ${COLORS.textDim}`,
      fontVariantNumeric: 'tabular-nums', flexShrink: 0, width: 34, textAlign: 'center'
    }}>{pos}</span>
    {/* car */}
    <div style={{ flex: 1, minWidth: 0, display: 'flex', alignItems: 'center', height: pos === 1 ? 52 : 44 }}>
      {livery
        ? <img src={livery} alt="" onError={(e) => { e.target.style.display = 'none'; }} style={{ maxHeight: '100%', maxWidth: '100%', width: 'auto', objectFit: 'contain', imageRendering: 'pixelated', filter: 'drop-shadow(0 8px 10px rgba(0,0,0,0.55))' }} />
        : <span aria-hidden style={{ width: 12, height: 12, background: teamColor, transform: 'rotate(45deg)', opacity: 0.7 }}></span>}
    </div>
    {/* driver id */}
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 4, flexShrink: 0, maxWidth: 108 }}>
      <span style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
        <span style={{ fontFamily: 'Archivo', fontWeight: 900, fontSize: pos === 1 ? 16 : 14, textTransform: 'uppercase', color: COLORS.text, letterSpacing: '-0.01em', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{d.name}</span>
        {flag && <FlagSvg kind={flag} w={18} h={12} />}
      </span>
      {d.team ? <span style={{ fontFamily: 'JetBrains Mono', fontWeight: 700, fontSize: 9, letterSpacing: '0.16em', color: teamColor }}>{d.team}</span> : null}
    </div>
  </div>
);

const UR2StandingsCol = ({ league }) => {
  const L = LEAGUE_BY_ID[league];
  const sid = defaultDataSeasonId(league);
  const data = useStandings(league, sid);
  const chip = UR2_STATUS_CHIP[data.status] || UR2_STATUS_CHIP.empty;
  const rows = (data.drivers || []).slice(0, 3);
  const label = data.season ? data.season.label : null;
  const maxPts = rows[0] ? Math.max(rows[0].pts, 1) : 1;
  const teamColor = (short) => {
    const t = (data.teams || []).find((x) => x.short === short);
    return (t && t.color) || L.accent;
  };
  const flagOf = (name) => (typeof getRosterCountry === 'function' ? getRosterCountry(name) : null);
  const gridOffset = [18, 0, 0]; // P1 indented, P2-P3 flush

  return (
    <article style={{ background: COLORS.surface, border: `1px solid ${COLORS.hairline}`, position: 'relative', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
      <span style={{ position: 'absolute', left: 0, right: 0, top: 0, height: 2, background: L.accent }}></span>
      {/* header — league title */}
      <div style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '18px 20px', borderBottom: `1px solid ${COLORS.hairline}` }}>
        <span style={{ display: 'inline-flex', width: 34, height: 34, background: COLORS.ink, padding: 4, flexShrink: 0 }}>
          <img src={L.logo} alt={L.short} style={{ maxWidth: '100%', maxHeight: '100%', objectFit: 'contain' }} />
        </span>
        <span style={{ display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0, flex: 1 }}>
          <span style={{ fontFamily: 'Archivo', fontWeight: 900, fontSize: 15, letterSpacing: '0.02em', textTransform: 'uppercase', color: COLORS.text, whiteSpace: 'nowrap' }}>{L.name}</span>
          <span style={{ fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.24em', color: COLORS.textDim, textTransform: 'uppercase' }}>{label || '—'}</span>
        </span>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7, fontFamily: 'JetBrains Mono', fontSize: 9, letterSpacing: '0.24em', textTransform: 'uppercase', color: chip.color }}>
          <span style={{ width: 7, height: 7, borderRadius: '50%', background: chip.color, boxShadow: `0 0 8px ${chip.color}aa`, animation: data.status === 'loading' ? 'ur2-blink 1s ease-in-out infinite' : 'none' }}></span>
          {chip.label}
        </span>
      </div>

      {rows.length === 0 ? (
        <div style={{ padding: '44px 20px', textAlign: 'center', fontFamily: 'JetBrains Mono', fontSize: 11, letterSpacing: '0.2em', color: COLORS.textDim, textTransform: 'uppercase', lineHeight: 2 }}>
          {data.status === 'loading' ? 'Syncing standings…' : 'Season pending — the grid forms soon'}
        </div>
      ) : (
        <React.Fragment>
          {/* drivers at the front — top-3 cars in a staggered starting grid */}
          <div style={{ position: 'relative', padding: '20px 0 22px', display: 'flex', flexDirection: 'column', gap: 6, background: `linear-gradient(180deg, ${L.accent}12, transparent 70%)` }}>
            <span style={{ padding: '0 20px 4px', fontFamily: 'JetBrains Mono', fontSize: 9, letterSpacing: '0.28em', textTransform: 'uppercase', color: COLORS.textDim }}>Drivers at the front</span>
            {rows.map((d, i) => (
              <UR2GridSlot key={d.name + i} d={d} pos={d.pos ?? i + 1} accent={L.accent}
                livery={ur2LiveryFor(L.short, label, d.team)} flag={flagOf(d.name)}
                teamColor={teamColor(d.team)} offset={gridOffset[i] || 0} />
            ))}
          </div>
          {/* standings — top 3, beneath the liveries */}
          <div style={{ display: 'flex', flexDirection: 'column', borderTop: `1px solid ${COLORS.hairline}` }}>
            {rows.map((d, i) => (
              <div key={d.name + i} style={{ display: 'grid', gridTemplateColumns: '30px 1fr auto', gap: 10, alignItems: 'center', padding: '11px 20px', borderBottom: `1px solid ${COLORS.hairline}`, position: 'relative' }}>
                <span aria-hidden style={{ position: 'absolute', left: 0, bottom: 0, height: 2, width: `${d.pts / maxPts * 100}%`, background: `${teamColor(d.team)}55` }}></span>
                <span style={{ fontFamily: 'JetBrains Mono', fontWeight: 700, fontSize: 13, color: (d.pos ?? i + 1) === 1 ? L.accent : COLORS.textDim }}>{String(d.pos ?? i + 1).padStart(2, '0')}</span>
                <span style={{ fontFamily: 'Archivo', fontWeight: 700, fontSize: 15, color: COLORS.text, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
                  {d.name}
                  {d.team ? <span style={{ marginLeft: 9, fontFamily: 'JetBrains Mono', fontWeight: 700, fontSize: 10, letterSpacing: '0.14em', color: teamColor(d.team) }}>{d.team}</span> : null}
                </span>
                <span style={{ fontFamily: 'Archivo', fontWeight: 800, fontSize: 15, color: COLORS.textMute, fontVariantNumeric: 'tabular-nums' }}>{d.pts}</span>
              </div>
            ))}
          </div>
        </React.Fragment>
      )}
    </article>
  );
};

const UR2StandingsWall = ({ kicker, title, onFullStandings }) => (
  <section id="standings" data-screen-label="Home v2 — Standings wall" style={{ background: '#000', padding: '96px 44px 90px', position: 'relative', overflow: 'hidden' }}>
    <div aria-hidden style={{ position: 'absolute', top: 26, right: -30, fontFamily: 'Archivo', fontWeight: 900, fontSize: 280, lineHeight: 0.8, color: 'transparent', WebkitTextStroke: `1px ${COLORS.red}26`, letterSpacing: '-0.04em', pointerEvents: 'none' }}>LIVE</div>
    <UR2SectionHead
      kicker={kicker || 'Race control · synced from the timing sheets'}
      title={title || <span>Drivers at the front <span style={{ color: COLORS.red }}></span></span>}
      right={onFullStandings
        ? <button onClick={onFullStandings} style={{ all: 'unset', cursor: 'pointer', fontFamily: 'Archivo', fontWeight: 700, fontSize: 12, letterSpacing: '0.22em', textTransform: 'uppercase', color: COLORS.text, borderBottom: `1px solid ${COLORS.red}`, paddingBottom: 5 }}>Full standings →</button>
        : <a href="Ultimate Racing Esports.html" style={{ fontFamily: 'Archivo', fontWeight: 700, fontSize: 12, letterSpacing: '0.22em', textTransform: 'uppercase', color: COLORS.text, textDecoration: 'none', borderBottom: `1px solid ${COLORS.red}`, paddingBottom: 5 }}>Full standings →</a>
      } />
    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))', gap: 16, position: 'relative' }}>
      {LEAGUES.map((L) => <UR2StandingsCol key={L.id} league={L.id} />)}
    </div>
    <style>{`@keyframes ur2-blink { 0%,100% { opacity: .35 } 50% { opacity: 1 } }`}</style>
  </section>
);

// ─── ROAD AHEAD — S25 calendar rail ──────────────────────────────────────────
const UR2_HOME_MINIMAP = {
  'Japanese Grand Prix': 'assets/minimaps/sm/suzuka.png',
  'Belgian Grand Prix': 'assets/minimaps/sm/spa.png',
  'Qatar Grand Prix': 'assets/minimaps/sm/qatar.png',
  'South African Grand Prix': 'assets/minimaps/sm/southafrica.png',
  'Spanish Grand Prix': 'assets/minimaps/sm/spain.png',
  'Ukrainian Grand Prix': 'assets/minimaps/sm/ukraine.png',
  'German Grand Prix': 'assets/minimaps/sm/germany.png',
  'Indonesian Grand Prix': 'assets/minimaps/sm/batavia.png',
  'Slovakian Grand Prix': 'assets/minimaps/sm/fatra.png',
  'British Grand Prix': 'assets/minimaps/sm/britain.png',
  'Malaysian Grand Prix': 'assets/minimaps/sm/malaysia.png',
  'Welsh Grand Prix': 'assets/minimaps/sm/wales.png',
  'French Grand Prix': 'assets/minimaps/sm/lutetia.png'
};

// Country flag per grand prix (flagcdn ISO) — used as a faint tile background.
const UR2_HOME_FLAG = {
  'French Grand Prix': 'fr',
  'Japanese Grand Prix': 'jp', 'Belgian Grand Prix': 'be', 'Swedish Grand Prix': 'se',
  'Dutch Grand Prix': 'nl', 'Italian Grand Prix': 'it', 'Gold Coast Grand Prix': 'au-qld',
  'Sapporo International Grand Prix': 'jp-01', 'Canadian Grand Prix': 'ca',
  'Australian Grand Prix': 'au', 'Arcana East Flanders Grand Prix': 'be-vov',
  'Qatar Grand Prix': 'qa', 'South African Grand Prix': 'za', 'Spanish Grand Prix': 'es',
  'Ukrainian Grand Prix': 'ua', 'German Grand Prix': 'de', 'Indonesian Grand Prix': 'id',
  'Slovakian Grand Prix': 'sk', 'British Grand Prix': 'gb', 'Malaysian Grand Prix': 'my',
  'Welsh Grand Prix': 'gb-wls',
  'Russian Grand Prix': 'ru', 'United States Grand Prix': 'us', 'Romanian Grand Prix': 'ro',
  'Canarian Grand Prix': 'ic', 'Monaco Grand Prix': 'mc'
};

const UR2RoundCard = ({ race, winner }) => {
  const isNext = race.status === 'next';
  const isDone = race.status === 'done';
  const isTba = !race.date;
  const map = race.minimap || UR2_HOME_MINIMAP[race.grandPrix] || null;
  const flag = UR2_HOME_FLAG[race.grandPrix] || null;
  return (
    <div style={{
      scrollSnapAlign: 'start', flexShrink: 0, width: 236, position: 'relative', overflow: 'hidden',
      background: isNext ? `linear-gradient(180deg, ${COLORS.red}17, ${COLORS.surface})` : COLORS.surface,
      border: `1px solid ${isNext ? COLORS.red : COLORS.hairline}`,
      boxShadow: isNext ? `0 0 40px -10px ${COLORS.red}66` : 'none',
      padding: '18px 18px 16px', display: 'flex', flexDirection: 'column', gap: 12,
      opacity: isDone ? 0.66 : 1
    }}>
      {flag && !isTba && (
        <div aria-hidden style={{
          position: 'absolute', inset: 0, zIndex: 0,
          backgroundImage: `url(${urFlagImg(flag, 320)})`,
          backgroundSize: 'contain', backgroundRepeat: 'no-repeat', backgroundPosition: 'top right',
          opacity: 0.16, filter: 'saturate(1.1)',
          maskImage: 'linear-gradient(225deg, #000 0%, transparent 65%)',
          WebkitMaskImage: 'linear-gradient(225deg, #000 0%, transparent 65%)'
        }}></div>
      )}
      <div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', position: 'relative', zIndex: 1 }}>
        <span style={{ fontFamily: 'Archivo', fontWeight: 900, fontSize: 44, lineHeight: 1, color: isTba ? COLORS.textDim : isNext ? COLORS.red : COLORS.text }}>{String(race.round).padStart(2, '0')}</span>
        <span style={{
          fontFamily: 'JetBrains Mono', fontSize: 9, letterSpacing: '0.22em', textTransform: 'uppercase',
          padding: '4px 8px', marginTop: 4,
          background: isNext ? COLORS.red : 'transparent',
          border: isNext ? 'none' : `1px solid ${COLORS.hairline}`,
          color: isNext ? '#fff' : isDone ? COLORS.textMute : COLORS.textDim
        }}>{isNext ? 'Next' : isDone ? 'Done' : isTba ? 'TBA' : 'Soon'}</span>
      </div>
      <div style={{ height: 84, display: 'flex', alignItems: 'center', justifyContent: 'center', position: 'relative', zIndex: 1 }}>
        {map
          ? <img src={map} alt={race.track} style={{ maxHeight: '100%', maxWidth: '86%', objectFit: 'contain', opacity: 0.95 }} />
          : <span style={{ fontFamily: 'JetBrains Mono', fontSize: 20, color: COLORS.textDim }}>◇</span>}
      </div>
      <div style={{ position: 'relative', zIndex: 1 }}>
        <div style={{ fontFamily: 'Archivo', fontWeight: 800, fontSize: 17, color: COLORS.text, letterSpacing: '-0.005em', lineHeight: 1.1 }}>{isTba ? 'To be announced' : race.track}</div>
        <div style={{ fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.16em', color: COLORS.textDim, textTransform: 'uppercase', marginTop: 6 }}>
          {isTba ? '· · ·' : `${race.grandPrix !== 'TBA' ? race.grandPrix + ' · ' : ''}${ur2FmtDate(race.date)}`}
        </div>
        {isDone && winner && (
          <div style={{ fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.14em', color: '#FFD24A', textTransform: 'uppercase', marginTop: 7 }}>Win · {winner}</div>
        )}
      </div>
    </div>
  );
};

const UR2RoadAhead = ({ onOpenCalendar }) => {
  const cal = getCalendar('ul');
  const results = typeof useRaceResults === 'function' ? useRaceResults('ul', cal.season) : {};
  const breakAfter = UR2D_CALENDAR.midSeasonBreakAfter || null;
  const winnerOf = (round) => {
    const rr = results && results[round];
    return rr && rr[0] ? rr[0].name : null;
  };
  const done = cal.races.filter((r) => r.status === 'done').length;
  // Start the rail at the most recent race (last completed; falls back to the next round).
  const railRef = React.useRef(null);
  const focusRef = React.useRef(null);
  const focusRound = (() => {
    const doneRaces = cal.races.filter((r) => r.status === 'done');
    if (doneRaces.length) return doneRaces[doneRaces.length - 1].round;
    const next = cal.races.find((r) => r.status === 'next');
    return next ? next.round : null;
  })();
  React.useEffect(() => {
    if (railRef.current && focusRef.current) railRef.current.scrollLeft = Math.max(0, focusRef.current.offsetLeft - 44);
  }, []);
  return (
    <section id="calendar" data-screen-label="Home v2 — Road ahead" style={{ background: COLORS.base, padding: '96px 0 90px', borderTop: `1px solid ${COLORS.hairline}` }}>
      <div style={{ padding: '0 44px' }}>
        <UR2SectionHead
          kicker={`Season ${cal.season} · every league, same track, same Sunday`}
          title={<span>The road <span style={{ color: COLORS.red }}>ahead.</span></span>}
          right={
            <div style={{ textAlign: 'right', display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 14 }}>
              <div>
                <div style={{ fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.26em', color: COLORS.textDim, textTransform: 'uppercase' }}>Rounds complete</div>
                <div style={{ fontFamily: 'Archivo', fontWeight: 900, fontSize: 46, color: COLORS.text, lineHeight: 1 }}>{done}<span style={{ color: COLORS.textDim, fontSize: 24 }}>/{cal.races.length}</span></div>
              </div>
              {onOpenCalendar ? <button onClick={onOpenCalendar} style={{ all: 'unset', cursor: 'pointer', fontFamily: 'Archivo', fontWeight: 700, fontSize: 12, letterSpacing: '0.22em', textTransform: 'uppercase', color: COLORS.text, borderBottom: `1px solid ${COLORS.red}`, paddingBottom: 5 }}>{'Calendar & results →'}</button> : null}
            </div>
          } />
      </div>
      <div ref={railRef} style={{ display: 'flex', gap: 14, overflowX: 'auto', scrollSnapType: 'x proximity', padding: '4px 44px 18px', scrollbarWidth: 'thin' }}>
        {cal.races.map((race, i) => (
          <React.Fragment key={race.round}>
            <span ref={race.round === focusRound ? focusRef : null} style={{ flexShrink: 0, width: 0, marginRight: -14 }}></span>
            <UR2RoundCard race={race} winner={winnerOf(race.round)} />
            {breakAfter === race.round && i < cal.races.length - 1 && (
              <div style={{ flexShrink: 0, width: 44, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                <span style={{ writingMode: 'vertical-rl', fontFamily: 'JetBrains Mono', fontSize: 9, letterSpacing: '0.34em', color: COLORS.textDim, textTransform: 'uppercase' }}>Mid-season break</span>
              </div>
            )}
          </React.Fragment>
        ))}
      </div>
    </section>
  );
};

// ─── LADDER — how the four leagues stack, plus the join CTA ──────────────────
const UR2_LADDER = [
  { id: 'ul', num: '01', line: 'The summit. Ten rounds, nine constructors, the sharpest field in UR2D.', meta: '10 rounds · Constructors · Invitation by promotion' },
  { id: 'hl', num: '02', line: 'The proving ground — the only tier that races a full sprint format.', meta: '10 rounds · Sprint weekends · Constructors' },
  { id: 'jl', num: '03', line: 'Half-season championships that come at you twice as fast.', meta: '5 rounds · A/B half-seasons · Constructors' },
  { id: 'al', num: '04', line: 'Where everyone starts. No teams, no pressure — just you and the track.', meta: '5 rounds · A/B half-seasons · Solo drivers' }
];

const UR2Ladder = () => (
  <section id="leagues" data-screen-label="Home v2 — League ladder" style={{ background: '#000', padding: '96px 44px 100px', borderTop: `1px solid ${COLORS.hairline}`, position: 'relative', overflow: 'hidden' }}>
    <UR2SectionHead
      kicker="The structure"
      title={<span>Start in Apprentice.<br /><span style={{ color: COLORS.red }}>Finish in Ultimate.</span></span>} />
    <div style={{ display: 'flex', flexDirection: 'column', border: `1px solid ${COLORS.hairline}`, borderBottom: 'none' }}>
      {UR2_LADDER.map((row) => {
        const L = LEAGUE_BY_ID[row.id];
        return (
          <div key={row.id} style={{
            display: 'grid', gridTemplateColumns: '110px 64px minmax(200px, 1fr) minmax(240px, 1.4fr) auto',
            gap: 26, alignItems: 'center', padding: '26px 28px',
            borderBottom: `1px solid ${COLORS.hairline}`, position: 'relative'
          }}>
            <span aria-hidden style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 3, background: L.accent }}></span>
            <span style={{ fontFamily: 'Archivo', fontWeight: 900, fontSize: 46, color: 'transparent', WebkitTextStroke: `1.5px ${L.accent}`, lineHeight: 1 }}>{row.num}</span>
            <span style={{ display: 'inline-flex', width: 52, height: 52, background: COLORS.ink, padding: 6 }}>
              <img src={L.logo} alt={L.short} style={{ maxWidth: '100%', maxHeight: '100%', objectFit: 'contain' }} />
            </span>
            <span style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
              <span style={{ fontFamily: 'Archivo', fontWeight: 900, fontSize: 24, textTransform: 'uppercase', color: COLORS.text, letterSpacing: '-0.01em' }}>{L.name}</span>
              <span style={{ fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.24em', color: L.accent, textTransform: 'uppercase' }}>{L.tier}</span>
            </span>
            <span style={{ fontFamily: 'Archivo', fontSize: 15, color: COLORS.textMute, lineHeight: 1.5, maxWidth: 460 }}>{row.line}</span>
            <span style={{ fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.18em', color: COLORS.textDim, textTransform: 'uppercase', textAlign: 'right', whiteSpace: 'nowrap' }}>{row.meta}</span>
          </div>
        );
      })}
    </div>
    <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 24, marginTop: 40, flexWrap: 'wrap' }}>
      <span style={{ fontSize: 26, color: COLORS.textMute }}>Every driver on the UL grid started at the bottom rung.</span>
      <a href={URL_LEAGUE.brand.discord} target="_blank" rel="noopener" style={{
        background: COLORS.red, color: '#fff', padding: '16px 30px', textDecoration: 'none',
        fontFamily: 'Archivo', fontWeight: 800, fontSize: 13, letterSpacing: '0.22em', textTransform: 'uppercase'
      }}>Join the grid — Discord →</a>
    </div>
  </section>
);

// ─── FOOTER — slim ───────────────────────────────────────────────────────────
const UR2Footer = () => (
  <footer style={{ background: '#000', borderTop: `1px solid ${COLORS.hairline}`, padding: '38px 44px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 24, flexWrap: 'wrap' }}>
    <LogoLockup size={34} />
    <span style={{ fontFamily: 'JetBrains Mono', fontSize: 10, letterSpacing: '0.22em', textTransform: 'uppercase', color: COLORS.textDim }}>© 2026 Ultimate Racing Esports · Est. {URL_LEAGUE.brand.estab}</span>
    <a href="Ultimate Racing Esports.html" style={{ fontFamily: 'JetBrains Mono', fontSize: 11, letterSpacing: '0.2em', textTransform: 'uppercase', color: COLORS.textMute, textDecoration: 'none', borderBottom: `1px solid ${COLORS.hairline}`, paddingBottom: 3 }}>Classic site →</a>
  </footer>
);

Object.assign(window, { UR2StandingsWall, UR2RoadAhead, UR2Ladder, UR2Footer, UR2SectionHead });
