/* f1gures - page styles, stage 3 group c) Race pages and the race-weekend island.
   Moved verbatim out of css/app.css (Sharp stage 2). Linked from BaseLayout after
   app.css and before site.css; tokens live in app.css. Only the owning group edits
   this file (docs/redesign/inventory.md section 4). */

/* ============================================================
   RACE PAGE (RacePage.astro and its bodies), Sharp stage 3c.
   Layout only: every surface is a Sharp component (EntityHero, Card,
   SectionHead, Podium, DataTable, LeaderList, Countdown, SessionList).
   ============================================================ */
.race-detail { display: grid; gap: 16px; }
.race-detail > * { min-width: 0; }
.race-back { margin-bottom: -4px; }
.race-sec { display: grid; gap: 12px; margin-top: 14px; }
.race-nav { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* Intro: summary next to the key links (stacked on phones). */
.race-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.race-intro:empty { display: none; }
.race-intro > :only-child { grid-column: 1 / -1; }
/* The legacy .race-summary rule (app.css) caps it at 65ch with margins; in
   the intro grid it fills its column so the pair spans the content width. */
.race-intro .race-summary { max-width: none; margin: 0; }
/* The "Did you know" board lines up with the content column instead of
   sitting centred and narrower (its look is unchanged). */
.race-detail .trivia { max-width: none; margin-left: 0; margin-right: 0; }
.race-summary p { margin: 0; color: var(--fg-2); font-size: 14px; line-height: 1.6; text-wrap: pretty; }
.race-keylinks .s-stat dd b { font-family: var(--f-body); font-weight: 600; font-size: 14px; line-height: 1.3; letter-spacing: 0; }
/* Long names (e.g. "Bahrain International Circuit") wrap inside their tile
   instead of pushing past it; the right padding clears the link arrow. */
.race-keylinks .s-stat dd, .race-keylinks .s-stat-link, .race-keylinks .s-stat b { min-width: 0; }
.race-keylinks .s-stat b { overflow-wrap: anywhere; padding-right: 12px; }

/* Results / qualifying tables: DataTable above 720px, LeaderList below. */
.race-ll { display: none; }
.race-tbl[data-collapsed="true"] .s-tbl tbody tr:nth-child(n + 11),
.race-tbl[data-collapsed="true"] .s-ll > .s-lr:nth-child(n + 11) { display: none; }
.race-more { margin-top: 10px; }
.race-drv, .race-team { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.race-drv a, .race-team a { color: var(--fg-1); text-decoration: none; }
.race-drv a { font-weight: 600; }
.race-drv a:hover, .race-team a:hover { color: var(--accent-text); }
.race-drv small { font-family: var(--f-mono); font-size: 10px; color: var(--fg-3); }
.race-team { color: var(--fg-2); }
.race-status { color: var(--fg-3); font-size: 12.5px; }
.race-status[data-out] { color: var(--neg); }
.race-gap[data-none] { color: var(--fg-4); }

/* Upcoming: next-session card and last-held-here card. */
.race-next { display: grid; }
.race-next-label {
  margin: 0; padding: 12px 16px 10px; font-family: var(--f-display); font-weight: 800;
  font-size: var(--fs-num-s); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-1);
}
.race-pad { padding: 16px; display: grid; gap: 12px; }
.race-pad p { margin: 0; }

@media (max-width: 720px) {
  .race-intro { grid-template-columns: minmax(0, 1fr); }
  .race-ll { display: block; }
  /* Weekend tables on phones: no driver code, logo only for the team (name
     kept for screen readers), so the classification fits without scrolling. */
  .rw .race-drv small, .rw .race-drv-first { display: none; }
  .race-team--logo .race-team-name {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
}

/* Compact race hero on phones (owner review, 13 Nov). The toolbar already
   names the race, so below the session tabs the hero is one strip: flag,
   circuit, date and the name on one line. No art panel, no round line, no
   stats. Desktop keeps the full hero. */
@media (max-width: 720px) {
  .race-hero .s-hero-art,
  .race-hero .s-hero-first,
  .race-hero .s-hero-stats { display: none; }
  .race-hero .s-hero-tx { padding: 10px 12px; gap: 6px; }
  .race-hero .s-hero-last,
  .race-hero .s-hero-last--m,
  .race-hero .s-hero-last--s {
    font-size: var(--fs-num-s); line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .race-hero .s-hero-tags { order: 3; }
}

/* ============================================================
   RACE WEEKEND ANALYSIS (RaceWeekendIsland), Sharp stage 3c.
   Session Tabs (sticky), per-session Cards / Podium / StatGrid /
   DataTable, the chart gallery and the chart Sheet. Layout only; the
   charts' colours come from the site tokens (raceweekend/primitives.jsx).
   ============================================================ */
.rw { display: grid; gap: 14px; min-width: 0; }
.rw > * { min-width: 0; }
/* Hero + trivia (Astro slot) and the key links beside the summary. */
.rw-lead { display: grid; gap: 16px; min-width: 0; }
.rw-lead > *, .rw-lead astro-slot > * { min-width: 0; }
.rw-intro--one { grid-template-columns: minmax(0, 1fr); }
/* Session tab labels: full on desktop, short on phones (RaceWeekendIsland). */
.rw-tab-s { display: none; }

/* Session head: start time, headline badge, weather badges. */
.rw-head-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 16px 12px; }
.rw-head-when { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--fg-3); min-height: 14px; }
.rw-head-wx { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* Tables inside cards. */
.rw-table .s-tbl-wrap { border-top: 0; }
.rw-table-note { padding: 12px 16px 0; }
.rw-table-foot { padding: 10px 16px 14px; }
.rw-best { color: var(--purple); font-weight: 700; }
.rw-none { color: var(--fg-4); }
.rw-out { opacity: 0.72; }
.rw-pad { padding: 0 16px 16px; }

/* Upcoming session. */
.rw-upcoming-in { display: grid; justify-items: center; gap: 14px; padding: 28px 16px 30px; text-align: center; }
.rw-upcoming-in .s-cd { width: min(100%, 460px); }
.rw-upcoming-title {
  margin: 0; font-family: var(--f-display); font-weight: 800; font-size: var(--fs-num-l);
  line-height: 1; text-transform: uppercase; color: var(--fg-1);
}
.rw-upcoming-when { margin: 0; font-family: var(--f-mono); font-size: 12px; color: var(--fg-2); min-height: 15px; }
.rw-upcoming-note { margin: 0; font-size: 13px; color: var(--fg-3); max-width: 460px; line-height: 1.55; }

/* Chart gallery: one Card per chart. */
.rw-gal { display: grid; gap: 12px; margin-top: 6px; }
.s-card.rw-gal-card { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 10px; text-align: left; font: inherit; cursor: pointer; }
.s-card.rw-gal-card:hover { background: var(--bg-hover); }
.rw-gal-top { display: flex; justify-content: space-between; gap: 6px; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.1em; color: var(--fg-3); text-transform: uppercase; }
.rw-gal-thumb { display: flex; align-items: flex-start; justify-content: center; height: 124px; overflow: hidden; background: var(--surface-sunk); border: 1px solid var(--line-1); }
.rw-gal-thumb-in { width: 100%; height: 100%; padding: 6px; overflow: hidden; pointer-events: none; }
.rw-gal-thumb-in > * { width: 100%; min-width: 0 !important; }
.rw-gal-thumb-in svg { width: 100%; height: auto; max-height: 112px; display: block; }
.rw-gal-load { align-self: center; color: var(--fg-4); font-family: var(--f-mono); }
.rw-gal-title { font-family: var(--f-display); font-weight: 800; font-size: 15px; letter-spacing: 0.04em; line-height: 1.05; text-transform: uppercase; color: var(--fg-1); }
.rw-gal-desc { font-size: 11.5px; line-height: 1.45; color: var(--fg-3); }

/* Chart modal: a wide Sharp Sheet. */
.s-sheet-root .s-sheet.rw-mviz { width: min(1080px, 100%); max-width: 1080px; max-height: calc(100vh - 48px); }
.rw-mviz-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rw-mviz-count { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3); min-width: 0; }
.rw-mviz-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.rw-mviz-desc { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--fg-2); max-width: 760px; }
.rw-mviz-filter { display: grid; gap: 8px; }
.rw-mviz-filter .s-chips { flex-wrap: wrap; }
.rw-mviz-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.rw-mviz-chart { padding: 12px; min-height: 120px; }
.rw-mviz-src { margin: 0; padding: 8px 12px 10px; font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--fg-3); border-top: 1px solid var(--line-1); overflow-wrap: anywhere; }

/* Chart hover readout: the Sharp Tooltip on a fixed layer above the Sheet. */
.rw-tip-layer { position: fixed; inset: 0; z-index: var(--z-toast); pointer-events: none; }

/* Share preview inside the ShareSheet. */
.rw-share-preview { display: flex; align-items: center; justify-content: center; min-height: 280px; background: var(--surface-sunk); padding: 12px; }
.rw-share-preview img { max-width: 100%; max-height: 56vh; box-shadow: var(--shadow-float); }

@media (max-width: 720px) {
  /* App layout: the session tabs come first, straight under the toolbar,
     above the hero, key links and summary. */
  .rw-tabs { order: -1; margin-top: -16px; } /* meets the toolbar: cancels the page's 16px top padding */
  .rw-tab-l { display: none; }
  .rw-tab-s { display: inline; }
  .s-sheet-root .s-sheet.rw-mviz { max-height: 92vh; }
  .rw-head-wx { margin-left: 0; }
  .rw-stats { --cols: 3 !important; }
  /* Dense time-series SVGs are unreadable scaled to phone width: keep them
     at a legible size and let the chart pan sideways. Row-list charts render
     a compact mobile viewBox (.vx-fit) and fit the screen. */
  .rw-mviz-chart { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rw-mviz-chart svg:not(.vx-fit) { min-width: 720px; }
  .rw-mviz-chart:has(svg:not(.vx-fit))::after {
    content: 'Drag sideways to explore'; display: block; position: sticky; left: 0;
    text-align: center; padding-top: 10px; font-family: var(--f-mono);
    font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3);
  }
}
