/* ============================================================================
   MODULE 14 — DESIGN TOKENS. THE SINGLE SOURCE OF TRUTH FOR HOW RUSS LOOKS.
   ============================================================================

   These are the WC RUSS tokens, carried across verbatim — names and hex values
   both — because the identity is proven and Module 14's brief is explicit that
   it must not be reinvented. Module 12 shipped a provisional palette with
   different names (`--bg`, `--surface`, `--accent`, `--gold`, `--pink`); every
   component was migrated to the names below in one pass, so the site now speaks
   ONE vocabulary rather than a canonical set plus an alias layer.

   ONE DELIBERATE DEVIATION, MEASURED — `--text-muted`
   --------------------------------------------------
   The brief asks for the palette verbatim AND for WCAG AA contrast. On this
   palette those two requirements conflict in exactly one place. Measured
   (relative luminance, WCAG 2.1):

       #7a86a8 on --bg-primary     5.32  ✓
       #7a86a8 on --bg-card        4.74  ✓
       #7a86a8 on --bg-card-hover  4.27  ✗   AA normal text needs 4.5

   That pairing is reachable, not theoretical: `.log tr:hover td` and
   `.table .row.clickable:hover` both swap the row to `--bg-card-hover`, and
   both carry muted text. So the token is lightened to the SMALLEST value that
   clears 4.5 on all three surfaces: hue 224.3° and saturation 0.209 are
   unchanged, HSL lightness moves 0.569 → 0.585. Every other token in this
   block is byte-for-byte the brief's.

       #7f8aab on --bg-primary     5.62  ✓
       #7f8aab on --bg-card        5.00  ✓
       #7f8aab on --bg-card-hover  4.51  ✓

   An accessibility floor outranks two hex digits of fidelity, and the check is
   executable rather than asserted: `tests/test_design_tokens.py` recomputes
   every foreground/background pair and fails if any drops below AA.
   ========================================================================= */

:root {
  /* ---- Backgrounds (brief Part 1) ---- */
  --bg-primary:      #0a0e1a;   /* near-black page background */
  --bg-card:         #141b2d;   /* card/panel background */
  --bg-card-hover:   #1a2340;   /* hover state */

  /* EXTENSION, not in the brief: a third surface step for panels nested inside
     cards (score-matrix cells, modal sub-panels). Declared here rather than
     inlined so the rule "no colour literal outside :root" still holds. */
  --bg-card-raised:  #212c4a;

  /* ---- Accents (brief Part 1) ---- */
  --accent-green:    #00d4aa;   /* PRIMARY — RUSS's signature teal-green */
  --accent-red:      #ff4757;   /* away wins, losses, negative, relegation */
  --accent-gold:     #ffd700;   /* champion, 1st place, highlights */
  --accent-blue:     #4a9eff;   /* draws, secondary data series, info */
  --accent-highlight:#ff3b8a;   /* pink — active path / selection emphasis */

  /* The three medal colours are the brief's only sanctioned literals, and it
     asks for them as tokens if reused. They are. */
  --medal-gold:      var(--accent-gold);
  --medal-silver:    #c0c0c0;
  --medal-bronze:    #cd7f32;

  /* ---- Text: 3-tier hierarchy (brief Part 1) ---- */
  --text-primary:    #e8e8e8;   /* main text */
  --text-secondary:  #9aa5c4;   /* labels, secondary */
  --text-muted:      #7f8aab;   /* de-emphasised, captions — see AA note above */

  /* Channel triples for the three heat-map tones. Declared alongside the hex
     so the two can never drift, and consumed as rgba(var(--rgb-green), a) —
     see the shade() note in app.js (BACKLOG #107/#108). This is the ONE way a
     tone is allowed to be shaded; applying `opacity` to a cell fades its
     numeral too, which is the bug these replace. */
  --rgb-green: 0, 212, 170;     /* --accent-green */
  --rgb-gold:  255, 215, 0;     /* --accent-gold  */
  --rgb-red:   255, 71, 87;     /* --accent-red   */

  /* ---- Structure (brief Part 1) ---- */
  --border-color:     #1e2a45;
  --border-highlight: #2a3a5c;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0, 0, 0, 0.3);

  /* ---- Derived surfaces. Translucent, so they follow the palette instead of
     pinning the sticky nav and the modal scrim to one background colour. ---- */
  --accent-soft: rgba(0, 212, 170, 0.12);
  --accent-dim:  #008066;
  --bg-blur:     rgba(10, 14, 26, 0.92);
  --scrim:       rgba(0, 0, 0, 0.68);

  /* ---- Typography (brief Part 1) ----
     System stack only. No @import, no <link> to a font host: the site stays
     instant and works offline, which a downloaded face would break. */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* The brief's rem scale, one token per band:
     0.6 micro · 0.65-0.75 labels · 0.8-0.9 body/table · 1.0-1.3 heads
     · 1.5 modal titles · 1.8-2.5 hero numbers and logo */
  --fs-micro: 0.6rem;
  --fs-xs:    0.7rem;
  --fs-sm:    0.85rem;
  --fs-md:    0.9rem;
  --fs-lg:    1.15rem;
  --fs-xl:    1.5rem;
  --fs-2xl:   2rem;

  /* ---- Spacing and motion. Not specified by the brief beyond "keep it
     subtle"; Module 12's scale is kept because every component is built on it
     and the brief's motion figures (fadeIn 0.3s, fills 0.4-0.6s) fit it. ---- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --fade: 300ms ease;
  --fill: 500ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Height of the sticky nav, and the offset every sticky table header pins
     to. BACKLOG #104: those headers each carried a hard-coded `top: 52px`,
     a guess at this height that nothing kept honest. DERIVED from the rule
     below rather than eyeballed:

         .tabs padding      var(--sp-2) x 2            = 16px
         .tab-btn height    0.85rem x 1.6 line-height  = 21.76px
                          + var(--sp-2) x 2 padding    = 16px
                          + 1px border x 2             =  2px
         .tabs border-bottom                           =  1px
                                                   total ~= 56.8px

     Rounded UP, never down: an offset that is too small tucks the header
     under the nav, an offset a shade too large leaves a hairline gap. If the
     nav's padding or the pill's font size changes, change this with it. */
  --nav-height: 57px;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.6;                 /* brief Part 1 */
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
/* #109's sub-heading inside a modal panel that already owns the h3. Sized one
   step down so the hierarchy is visible, not just semantic. */
h4 { font-size: var(--fs-sm); color: var(--text-secondary); }
a { color: var(--accent-green); }

/* ---------------------------------------------------------------- header */
.masthead {
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--bg-card), var(--bg-primary));
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}
.masthead-inner { max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.brand .mark {
  /* Brief Part 1: weight 900, letter-spacing 0.15em, rendered as a green->blue
     gradient via background-clip. `color: transparent` is what lets the
     gradient show through the glyphs; the plain colour underneath it is the
     fallback for any engine that does not support background-clip: text. */
  color: var(--accent-green);
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
@supports not ((background-clip: text) or (-webkit-background-clip: text)) {
  .brand .mark { -webkit-text-fill-color: var(--accent-green); }
}
.brand .season { color: var(--text-muted); font-size: var(--fs-sm); }
.tagline { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: var(--sp-1); }

.disclosure {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-highlight);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}
.disclosure strong { color: var(--text-primary); }

/* ------------------------------------------------------------------- nav */
.tabs {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-5);
  background: var(--bg-blur);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}
.tabs-inner { display: flex; gap: var(--sp-1); max-width: 1180px; margin: 0 auto; width: 100%; }
.tab-btn {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--text-secondary); font: inherit; font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-4); border-radius: 999px;   /* pill, brief Part 1 */
  cursor: pointer; white-space: nowrap; transition: color var(--fade), background var(--fade);
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.tab-btn[aria-selected="true"] {
  color: var(--bg-primary); background: var(--accent-green); font-weight: 620;
}

/* ------------------------------------------------------------------ main */
main { max-width: 1180px; margin: 0 auto; padding: var(--sp-5); }
.panel { animation: fade var(--fade) both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.section { margin-bottom: var(--sp-6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.section-note { color: var(--text-muted); font-size: var(--fs-xs); }

.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius); padding: var(--sp-4);
  transition: border-color var(--fade), transform var(--fade),
              background var(--fade);
}
/* Brief Part 1: hover lifts 2px and the border turns green. Applied only to
   cards that DO something when clicked — a hover affordance on a static panel
   promises an interaction that is not there. */
.card.clickable:hover, .card.interactive:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-green);
  transform: translateY(-2px);
}
.grid { display: grid; gap: var(--sp-3); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); }
.stat .label { color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: var(--fs-xl); font-weight: 680; margin-top: var(--sp-1); }
.stat .sub { color: var(--text-secondary); font-size: var(--fs-xs); }
.value-good { color: var(--accent-green); }
.value-bad { color: var(--accent-red); }
.value-gold { color: var(--accent-gold); }

/* --------------------------------------------------------------- commentary */
.quip {
  border-left: 3px solid var(--accent-green); background: var(--accent-soft);
  padding: var(--sp-3) var(--sp-4); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-primary); font-size: var(--fs-sm);
}
.quip .who { color: var(--accent-green); font-weight: 650; margin-right: var(--sp-2); }
.quip .placeholder-flag { color: var(--text-muted); font-size: var(--fs-xs); display: block; margin-top: var(--sp-2); }

/* ------------------------------------------------------------- prob bars */
.probbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--bg-card-raised); }
.probbar > span { display: block; transition: width var(--fill); }
.probbar .h { background: var(--accent-green); }
.probbar .d { background: var(--accent-blue); }
.probbar .a { background: var(--accent-red); }
.probbar-legend { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-secondary); margin-top: var(--sp-1); }
.probbar-legend .h { color: var(--accent-green); }
.probbar-legend .d { color: var(--accent-blue); }
.probbar-legend .a { color: var(--accent-red); }

.meter { height: 8px; border-radius: 999px; background: var(--bg-card-raised); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent-green); transition: width var(--fill); }
.meter.gold > span { background: var(--accent-gold); }
.meter.red > span { background: var(--accent-red); }

/* ----------------------------------------------------------------- table */
/* BACKLOG #104, second pass. `.table` used to carry `overflow: hidden` purely
   to clip the first/last row's square corners to the container's own
   border-radius. That declaration also makes `.table` the nearest ancestor
   with a "scrolling mechanism" for CSS purposes (MDN, position:sticky), and
   because `.table` never itself scrolls (no max-height — it grows to fit all
   rows, so scrollHeight === clientHeight always), the sticky header below
   could never engage: it just sat in normal flow, one row above the first
   data row, contributing nothing and clashing with nothing on its own. The
   corner-clip is moved onto the first/last row directly (border-radius
   respects an element's own background) so `.table` no longer blocks the
   sticky rule from resolving against the real scrolling ancestor — the page,
   same as `.tabs`. NOT visually confirmed — no browser here (#52, #66). */
.table { display: grid; font-size: var(--fs-sm); border: 1px solid var(--border-color); border-radius: var(--radius); }
.table .row { display: grid; grid-template-columns: var(--table-cols); align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--border-color); }
.table .row:first-child { border-top: none; border-radius: var(--radius) var(--radius) 0 0; }
.table .row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
/* Offset comes from --nav-height instead of a magic 52px, z-index puts the
   header in front of the data rows explicitly rather than relying on paint
   order, and the background stays OPAQUE (--bg-card-hover has no alpha) so a
   row scrolling underneath cannot show through it. */
.table .row.head { background: var(--bg-card-hover); color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: var(--nav-height); z-index: 5; }
.table .row.clickable { cursor: pointer; transition: background var(--fade); }
.table .row.clickable:hover { background: var(--bg-card-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .team-cell { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.table .team-cell .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* BACKLOG #181. The twelve columns of the predicted table are fixed pixel
   tracks (app.js sets them inline as --table-cols) and sum to 460px; add
   11 x 8px gaps and 2 x 12px of row padding and the row cannot be narrower
   than 572px before the flexible team column has any width at all. The card's
   content box is only viewport - 58px here (main 2x12, card 2x16, borders
   2x1), so a 390px phone offers about 332px. #104 removed `.table`'s
   `overflow: hidden`, which had been silently clipping that excess off the
   right edge, so without the rule below the overflow now pushes the WHOLE
   PAGE sideways — worse than the clipping it replaced. The table scrolls
   inside its own box instead: the same idiom as `.fixture-table` and
   `.heat-wrap`. The floor on `.team-cell` overrides the `min-width: 0` above
   so the team column keeps room for the 22px crest, its 8px gap and a few
   ellipsised characters, rather than collapsing to nothing once the fixed
   tracks have taken everything.

   THE TRADEOFF, written down because #104 and check 40 exist precisely to
   stop it being introduced silently. A non-visible overflow on one axis makes
   the element a scroll container on BOTH — the CSS overflow rules forbid a
   visible/non-visible pair and promote the visible one — so below this
   breakpoint `.row.head`'s sticky positioning resolves against `.table`
   instead of the page, and `.table` has no max-height, so it never scrolls
   vertically and the header does not stick. That is exactly the #104 defect,
   deliberately re-accepted BELOW 720px ONLY. It is not a regression of #104:
   above the breakpoint the header still sticks, and below it the header row
   is ~668px wide against a ~330px viewport, so a header pinned to the top
   would show two of its twelve columns. Losing it there costs almost nothing;
   a page-wide horizontal scrollbar costs a lot. No pure-CSS arrangement keeps
   both — a horizontally scrolling ancestor IS a scroll container. The only
   alternative that keeps the header sticky is giving `.table` a max-height so
   it scrolls vertically too (the `.board-wrap`/`.log-wrap` idiom), which
   turns the table into a nested scroll pane on a phone; that was judged worse
   and is recorded in #181 rather than silently discarded.
   NOT visually confirmed — no browser here (#52, #66). */
@media (max-width: 720px) {
  .table { overflow-x: auto; }
  .table .team-cell { min-width: 96px; }
}
.zone-champion { box-shadow: inset 3px 0 0 var(--accent-gold); }
.zone-europe { box-shadow: inset 3px 0 0 var(--accent-green); }
.zone-relegation { box-shadow: inset 3px 0 0 var(--accent-red); }

.crest { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; background: var(--bg-card-raised); }
.crest.lg { width: 34px; height: 34px; }
.crest-fallback { display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 700; color: var(--text-primary); }

/* ----------------------------------------------------------- match cards */
.matchgrid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.match-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); cursor: pointer; transition: border-color var(--fade), transform var(--fade); }
.match-card:hover { border-color: var(--accent-green); transform: translateY(-2px); background: var(--bg-card-hover); }
.match-card .top { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-muted); }
.match-card .teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0 var(--sp-2); }
.match-card .side { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.match-card .side.away { justify-content: flex-end; }
.match-card .side .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.match-card .score { font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.match-card .foot { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-secondary); margin-top: var(--sp-2); }

.badge { font-size: var(--fs-xs); padding: 2px var(--sp-2); border-radius: 999px; border: 1px solid var(--border-highlight); color: var(--text-secondary); white-space: nowrap; }
.badge.actual { border-color: var(--accent-dim); color: var(--accent-green); }
.badge.predicted { border-color: var(--border-highlight); color: var(--text-muted); }
.badge.hit { border-color: var(--accent-dim); color: var(--accent-green); }
.badge.miss { border-color: var(--accent-red); color: var(--accent-red); }
.badge.gold { border-color: var(--accent-gold); color: var(--accent-gold); }
.badge.pink { border-color: var(--accent-highlight); color: var(--accent-highlight); }

.outcome-strip { height: 3px; border-radius: 999px; margin-top: var(--sp-2); background: var(--bg-card-raised); overflow: hidden; display: flex; }
.outcome-strip > span { display: block; height: 100%; }

.arrow-up::before { content: "▲"; color: var(--accent-green); }
.arrow-down::before { content: "▼"; color: var(--accent-red); }

/* --------------------------------------------------------------- controls */
.controls { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-3); }
select, input[type="search"] {
  background: var(--bg-card-hover); color: var(--text-primary); border: 1px solid var(--border-highlight);
  border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); font: inherit; font-size: var(--fs-sm);
}
select:focus, input:focus { outline: 2px solid var(--accent-highlight); outline-offset: 1px; }

/* --------------------------------------------------------------- team links
   BACKLOG 105. A club name is a way in to that club, everywhere it appears.
   Deliberately NOT styled as a coloured hyperlink: on a page where nearly every
   proper noun is a club, twenty accent-green words per screen is noise, and the
   accent already means something here (it is RUSS's home-win colour). So the
   affordance is an underline on hover plus a real focus ring, and the text
   keeps whatever colour its surroundings give it.

   The focus ring is the non-negotiable half. These are role="link" spans, not
   <a>, so nothing is inherited: without an explicit :focus-visible rule a
   keyboard user has no idea where they are. */
.team-link { cursor: pointer; border-radius: var(--radius-sm); }
.team-link:hover .name { text-decoration: underline; text-underline-offset: 2px; }
.team-link:hover { color: var(--accent-green); }
.team-link:focus-visible {
  outline: 2px solid var(--accent-highlight); outline-offset: 2px;
}
/* Fallback for engines without :focus-visible — a ring on plain :focus is
   worse than one only on keyboard focus, and far better than none. */
@supports not selector(:focus-visible) {
  .team-link:focus { outline: 2px solid var(--accent-highlight); outline-offset: 2px; }
}
.team-cell, .team-cell.team-link {
  display: flex; align-items: center; gap: var(--sp-2); min-width: 0;
}
.team-cell.reverse { flex-direction: row-reverse; }
.team-cell .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fixture-label .vs { color: var(--text-muted); }
.fixture-label .team-link { display: inline-flex; }

/* ----------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--scrim);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--sp-5); overflow-y: auto; z-index: 50; animation: fade var(--fade) both;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-highlight);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(860px, 100%); margin: auto 0;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--border-color); }
.modal-body { padding: var(--sp-4); }
.modal-close { appearance: none; background: var(--bg-card-hover); border: 1px solid var(--border-highlight); color: var(--text-secondary); border-radius: var(--radius-sm); width: 30px; height: 30px; cursor: pointer; font-size: var(--fs-md); line-height: 1; }
.modal-close:hover { color: var(--text-primary); border-color: var(--accent-highlight); }
.modal-tabs { display: flex; gap: var(--sp-1); padding: 0 var(--sp-4); border-bottom: 1px solid var(--border-color); }
.modal-tab { appearance: none; background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--text-secondary); font: inherit; font-size: var(--fs-sm); padding: var(--sp-3) var(--sp-3); cursor: pointer; }
.modal-tab[aria-selected="true"] { color: var(--accent-highlight); border-bottom-color: var(--accent-highlight); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--sp-2); align-items: center; font-size: var(--fs-sm); }
.compare .label { color: var(--text-muted); font-size: var(--fs-xs); text-align: center; }
.compare .left { text-align: left; font-variant-numeric: tabular-nums; }
.compare .right { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ svg */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-muted); font-size: 9px; font-family: var(--font); }
.chart .axis { stroke: var(--border-color); stroke-width: 1; }
.chart .grid-line { stroke: var(--border-color); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .bar { fill: var(--accent-green); }
.chart .bar.gold { fill: var(--accent-gold); }
.chart .bar.red { fill: var(--accent-red); }
.chart .bar.muted { fill: var(--bg-card-raised); }
.chart .line { fill: none; stroke: var(--accent-green); stroke-width: 2; }
.chart .line.market { stroke: var(--accent-blue); stroke-dasharray: 4 3; }
.chart .dot { fill: var(--accent-green); }
.chart .dot.market { fill: var(--accent-blue); }
.chart .ideal { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; fill: none; }
.legend { display: flex; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--text-secondary); flex-wrap: wrap; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.swatch-accent { background: var(--accent-green); }
.swatch-draw { background: var(--accent-blue); }
.swatch-gold { background: var(--accent-gold); }
.swatch-away { background: var(--accent-red); }

/* BACKLOG #107. Type up one band from --fs-xs (0.7rem, ~11px) — the numerals
   ARE the content of this grid. The cell's background is written inline by
   shade(); the base `background` here is only what shows if that is missing. */
.heatmap { display: grid; gap: 2px; font-size: var(--fs-sm); }
.heatmap .cell { aspect-ratio: 1 / 1; border-radius: 3px; display: flex; align-items: center; justify-content: center; color: var(--text-primary); font-variant-numeric: tabular-nums; background: var(--bg-card-hover); }
.heatmap .cell.best { outline: 2px solid var(--accent-highlight); }
.heatmap .axis-label { color: var(--text-secondary); font-size: var(--fs-sm); display: flex; align-items: center; justify-content: center; }

.form-run { display: flex; gap: var(--sp-1); }
.form-pip { width: 22px; height: 22px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 700; color: var(--bg-primary); }
.form-pip.W { background: var(--accent-green); }
.form-pip.D { background: var(--accent-blue); }
.form-pip.L { background: var(--accent-red); }

.dot-track { position: relative; height: 26px; }
.dot-track .rail { position: absolute; top: 12px; left: 0; right: 0; height: 2px; background: var(--bg-card-raised); border-radius: 999px; }
.dot-track .dot { position: absolute; top: 7px; width: 12px; height: 12px; border-radius: 50%; transform: translateX(-50%); }
.dot-track .dot.russ { background: var(--accent-green); }
.dot-track .dot.market { background: var(--accent-blue); }
/* The distance between the two dots, drawn. Used by the top-bets page, where
   the gap between the base rate and RUSS IS the ranking, so it is shown as a
   length rather than left as a subtraction for the reader. */
.dot-track .span { position: absolute; top: 11px; height: 4px; border-radius: 999px; background: var(--accent-dim); }

/* the bookmaker board on a match preview — one row per book, scrollable */
.board-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--border-color); border-radius: var(--radius); margin-top: var(--sp-2); }
.board { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.board th { position: sticky; top: 0; z-index: 5; background: var(--bg-primary); text-align: right; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; padding: var(--sp-1) var(--sp-2); border-bottom: 1px solid var(--border-color); }
.board th:first-child { text-align: left; }
.board td { padding: var(--sp-1) var(--sp-2); border-bottom: 1px solid var(--border-color); text-align: right; font-variant-numeric: tabular-nums; }
.board td:first-child { text-align: left; color: var(--text-secondary); }
.board td.top { color: var(--accent-green); font-weight: 700; }
.board tr.aggregate td { color: var(--text-muted); font-style: italic; }
.board tr:hover td { background: var(--bg-card-hover); }

/* ------------------------------------------------- module 13 features */

/* position heatmap (catalogue B8) — CSS grid, one cell per team-position */
.heat-wrap { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius); }
.heat-grid { display: grid; gap: 1px; min-width: 820px; padding: var(--sp-2); }
/* BACKLOG #108. Was --fs-xs / --text-muted: the smallest type on the page in
   the lightest colour it has. --text-secondary on --bg-card measures 6.99:1
   against --text-muted's 5.00:1, and one band larger makes the position
   numbers readable at a glance. min-width grew 720 -> 820px to keep a 21-column
   grid from crushing the larger type; .heat-wrap already scrolls horizontally. */
.heat-head { text-align: center; font-size: var(--fs-sm); color: var(--text-secondary); padding-bottom: var(--sp-1); }
.heat-head.champion { color: var(--accent-gold); }
.heat-head.relegation { color: var(--accent-red); }
.heat-team { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-primary); padding-right: var(--sp-2); min-width: 0; }
.heat-team .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heat-cell {
  aspect-ratio: 1 / 1; min-height: 22px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); color: var(--text-primary);
  font-variant-numeric: tabular-nums; cursor: default;
}
.heat-cell.champion { border: 1px solid var(--accent-gold); }
.heat-cell.relegation { border: 1px solid var(--accent-red); }

/* RUSS mood (feature 7) */
.mood { display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap; }
.mood-art { border-radius: var(--radius); background: var(--bg-card-hover); flex: 0 0 auto; }
.mood-name { text-transform: capitalize; color: var(--accent-green); }
.mood .label { color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }

/* info tooltips (catalogue E20) */
.infotip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; cursor: help;
  border: 1px solid var(--border-highlight); color: var(--text-muted);
  font-size: 10px; font-style: italic; font-weight: 700; vertical-align: 1px;
}
.infotip:hover, .infotip:focus { color: var(--accent-green); border-color: var(--accent-green); outline: none; }

/* goal-distribution bars (catalogue A3) */
.goalbars { display: flex; gap: var(--sp-1); align-items: flex-end; height: 84px; }
.goalbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.goalbar > span { width: 100%; border-radius: 2px 2px 0 0; min-height: 1px; transition: height var(--fill); }
.goalbar small { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; }

ul.plain { margin: var(--sp-2) 0 0; padding-left: var(--sp-4); color: var(--text-secondary); font-size: var(--fs-sm); }
ul.plain li { margin-bottom: var(--sp-1); }

/* ------------------------------------------------------------ empty state */
.empty {
  border: 1px dashed var(--border-highlight); border-radius: var(--radius);
  padding: var(--sp-5); text-align: center; color: var(--text-secondary);
  background: var(--bg-card);
}
.empty .why { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--sp-2); max-width: 60ch; margin-left: auto; margin-right: auto; }

.log { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.log th { text-align: left; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; padding: var(--sp-2); border-bottom: 1px solid var(--border-color); position: sticky; top: var(--nav-height); z-index: 5; background: var(--bg-primary); }
.log td { padding: var(--sp-2); border-bottom: 1px solid var(--border-color); font-variant-numeric: tabular-nums; }
.log tr:hover td { background: var(--bg-card-hover); }
.log-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--border-color); border-radius: var(--radius); }

footer { max-width: 1180px; margin: 0 auto; padding: var(--sp-5); color: var(--text-muted); font-size: var(--fs-xs); border-top: 1px solid var(--border-color); }

/* --------------------------------------------------------- responsive */
@media (max-width: 768px) {
  main, .masthead, .tabs { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matchgrid { grid-template-columns: 1fr; }
  .table { font-size: var(--fs-xs); }
  .heat-grid { min-width: 740px; }
  .mood { justify-content: center; text-align: center; }
  .modal-backdrop { padding: var(--sp-2); }
}
@media (max-width: 480px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .compare { grid-template-columns: 1fr; text-align: center; }
  .compare .left, .compare .right { text-align: center; }
  h1 { font-size: var(--fs-lg); }
}

/* ------------------------------------------------- scrollbar (brief Part 1)
   8px, track on the page background, thumb in the border colour so it reads as
   structure rather than content. Firefox takes the standard two-value form;
   WebKit needs its own pseudo-elements. Both are given. */
* { scrollbar-width: thin; scrollbar-color: var(--border-color) var(--bg-primary); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--border-color); border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-highlight); }

/* ============================================================ MODULE 14
   Catalogue components added by the design-system module. Tokens only —
   no literal below this line, same rule as the rest of the file. */

/* A5 — segmented distribution bar */
.segbar {
  display: flex; height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--bg-card-raised); border: 1px solid var(--border-color);
}
.segbar .seg { display: block; height: 100%; transition: width var(--fill); }
.segbar .seg.good     { background: var(--accent-green); }
.segbar .seg.neutral  { background: var(--accent-blue); }
.segbar .seg.bad      { background: var(--accent-red); }
.segbar .seg.gold     { background: var(--accent-gold); }
.segbar .seg.muted    { background: var(--border-highlight); }
.segbar-key {
  display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2);
  font-size: var(--fs-xs); color: var(--text-secondary);
}
.seg-key { display: inline-flex; align-items: center; gap: var(--sp-1); }
.seg-key .swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.seg-key .swatch.good    { background: var(--accent-green); }
.seg-key .swatch.neutral { background: var(--accent-blue); }
.seg-key .swatch.bad     { background: var(--accent-red); }
.seg-key .swatch.gold    { background: var(--accent-gold); }
.seg-key .swatch.muted   { background: var(--border-highlight); }

/* E18 — history / honours badges. The three medal tokens are the design
   system's only sanctioned literals and they are used only here and on the
   table's zone tints. */
.honours { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.honour {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-micro); font-weight: 700; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-highlight);
  background: var(--bg-card-raised); color: var(--text-secondary);
}
.honour.gold      { background: var(--medal-gold);   color: var(--bg-primary); border-color: var(--medal-gold); }
.honour.silver    { background: var(--medal-silver); color: var(--bg-primary); border-color: var(--medal-silver); }
.honour.bronze    { background: var(--medal-bronze); color: var(--bg-primary); border-color: var(--medal-bronze); }
.honour.top-four  { border-color: var(--accent-green); color: var(--accent-green); }
.honour.relegated { border-color: var(--accent-red);   color: var(--accent-red); }

/* A4 — goal-pattern bars with a league-average marker */
.pattern {
  position: relative; height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--bg-card-raised); border: 1px solid var(--border-color);
}
.pattern .fill { display: block; height: 100%; transition: width var(--fill); }
.pattern .fill.good { background: var(--accent-green); }
.pattern .fill.bad  { background: var(--accent-red); }
.pattern .marker {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--text-primary); transform: translateX(-1px);
}

/* D14 — home | label | away stat comparison */
.statgrid {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--sp-1) var(--sp-3);
  align-items: center;
}
.statgrid .sg-home, .statgrid .sg-away {
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-secondary);
}
.statgrid .sg-home { text-align: right; }
.statgrid .sg-away { text-align: left; }
.statgrid .sg-home.better, .statgrid .sg-away.better { color: var(--accent-green); }
.statgrid .sg-label {
  font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.06em; text-align: center; white-space: nowrap;
}

/* E16 — the flat state. A move too small to call is drawn as a dash rather
   than omitted, so "unchanged" and "not measured" stay distinguishable. */
.arrow-flat::before { content: "\2013"; color: var(--text-muted); }

/* ============================================================ TEAM PAGES
   Added 2026-08-21. Every value below is a token: the "no colour literal
   outside :root" rule is enforced by three separate checks and this section
   is no exception. Layout only — the components inside a team page (.card,
   .table, .board, .segbar, .honours) are the ones the rest of the site uses.
   ======================================================================== */

.teamgrid {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.teamcard { display: flex; flex-direction: column; gap: var(--sp-3); }
.teamcard-head { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.teamcard-head .name { font-weight: 600; }
.teamcard-nums {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-2); font-variant-numeric: tabular-nums; font-size: var(--fs-lg);
  font-weight: 600;
}

.teamhead { display: flex; flex-direction: column; gap: var(--sp-4); }
.teamhead-id { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
.teamhead-id h2 { font-size: var(--fs-xl); }

/* The link a fixture carries to the two clubs in it, and the one the team
   modal carries to the full page. */
.team-links { margin-bottom: var(--sp-3); }

/* Ten columns is a lot on a phone: the table scrolls inside its own box
   rather than pushing the page sideways. */
.fixture-table { overflow-x: auto; }

@media (max-width: 720px) {
  .teamgrid { grid-template-columns: 1fr; }
  .teamhead-id { flex-direction: column; align-items: flex-start; }
}
