/* ============================================================================
   GAA design system
   Dark-first, broadcast-inspired. Light mode is a real mode, not an
   afterthought -- both are authored, and `color-scheme` follows so native
   controls and scrollbars come along.
   ========================================================================= */

@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo.woff2") format("woff2-variations");
  font-weight: 400 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter.woff2") format("woff2-variations");
  font-weight: 400 700; font-style: normal; font-display: swap;
}

:root {
  /* surfaces, darkest to lightest */
  --bg:        #0b0c0e;
  --surface:   #131519;
  --raised:    #1a1d23;
  --border:    #24272e;
  --border-lo: #1b1e24;

  /* text */
  --fg:        #e9ebef;
  --muted:     #8b919c;
  --dim:       #5f656e;

  /* accents -- gold reads as stakes/trophy, which suits the league name */
  --accent:    #e8b339;
  --accent-lo: #3a2f16;
  --pos:       #34d399;
  --neg:       #f4795b;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -12px rgb(0 0 0 / .5);

  --display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  /* system stack -- no extra download, and it is what a scoreboard wants */
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono", "Roboto Mono", monospace;

  --page: 1180px;
  --prose: 720px;

  color-scheme: dark;
}

:root[data-theme="light"], /* explicit override wins */
html:not([data-theme="dark"]) {
  /* placeholder so the selector list below stays symmetric */
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:        #faf9f7;
    --surface:   #ffffff;
    --raised:    #f4f2ee;
    --border:    #e4e1db;
    --border-lo: #eeece7;
    --fg:        #14161a;
    --muted:     #61666f;
    --dim:       #8b909a;
    --accent:    #a97a06;
    --accent-lo: #fbf0d6;
    --pos:       #0f9d6b;
    --neg:       #d4502d;
    --shadow: 0 1px 2px rgb(20 22 26 / .06), 0 8px 24px -14px rgb(20 22 26 / .18);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg:#faf9f7; --surface:#fff; --raised:#f4f2ee; --border:#e4e1db; --border-lo:#eeece7;
  --fg:#14161a; --muted:#61666f; --dim:#8b909a;
  --accent:#a97a06; --accent-lo:#fbf0d6; --pos:#0f9d6b; --neg:#d4502d;
  --shadow: 0 1px 2px rgb(20 22 26 / .06), 0 8px 24px -14px rgb(20 22 26 / .18);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "tnum" 1, "cv05" 1, "ss03" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── header ─────────────────────────────────────────────────────────────── */

.masthead {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.masthead-inner {
  max-width: var(--page); margin: 0 auto;
  padding: 0 1.25rem;
  height: 58px;
  display: flex; align-items: center; gap: 1.5rem;
}
.wordmark {
  font-family: var(--display);
  font-weight: 800; font-size: 1.15rem;
  letter-spacing: -.02em;
  color: var(--fg); text-decoration: none;
  display: flex; align-items: baseline; gap: .5rem;
  flex-shrink: 0;
}
.wordmark .dot { color: var(--accent); }
.wordmark .sub {
  font-family: var(--body); font-weight: 500; font-size: .7rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--dim);
}
.nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a {
  font-size: .82rem; font-weight: 500; letter-spacing: .02em;
  color: var(--muted); text-decoration: none;
  padding: .35rem .6rem; border-radius: 6px;
  white-space: nowrap;
  transition: color .12s, background .12s;
}
.nav a:hover { color: var(--fg); background: var(--raised); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-lo); }

/* ── layout ─────────────────────────────────────────────────────────────── */

main { flex: 1; max-width: var(--page); width: 100%; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.prose { max-width: var(--prose); }

.page-head { margin-bottom: 2.5rem; }
.eyebrow {
  font-size: .7rem; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: .5rem;
}
h1 {
  font-family: var(--display);
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  font-weight: 800; letter-spacing: -.03em; line-height: 1.08;
}

section { margin-bottom: 3rem; }
h2 {
  font-family: var(--display);
  font-size: 1.25rem; font-weight: 700; letter-spacing: -.015em;
  margin-bottom: .9rem;
}

/* ── cards & charts ─────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.chart { width: 100%; overflow: visible; min-height: 60px; }
/* charts with an irreducible minimum width scroll instead of squashing */
.chart.scroll-x { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.chart.scroll-x svg { max-width: none; }
.chart svg { max-width: 100%; height: auto; display: block; }
figure svg[class^="plot-"], .chart svg { color: var(--fg); --plot-background: transparent; }
.chart svg g[aria-label$="tick label"],
.chart svg g[aria-label="text"] { font-family: var(--mono); }

/* Plot's tip uses --plot-background for its fill; keep it on the card colour */
.card { --plot-background: var(--surface); }

/* ── stat tiles ─────────────────────────────────────────────────────────── */

.tiles { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1rem;
}
.tile .k { font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.tile .v {
  font-family: var(--display); font-weight: 800;
  font-size: 1.75rem; letter-spacing: -.02em; line-height: 1.15; margin-top: .15rem;
}
.tile .n { font-size: .78rem; color: var(--muted); }

/* ── tables ─────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th {
  text-align: right; font-weight: 600; font-size: .68rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
  padding: .5rem .55rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
td { padding: .5rem .55rem; text-align: right; border-bottom: 1px solid var(--border-lo); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--raised); }
.num { font-variant-numeric: tabular-nums; }

/* owner chip: the colour identity carries across every page */
.owner {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--mono); font-weight: 600;
  font-size: .92em; letter-spacing: .02em;
}
.owner::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px;
  background: var(--owner, var(--dim)); flex-shrink: 0;
}
.trophy { color: var(--accent); }

/* ── misc ───────────────────────────────────────────────────────────────── */

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
p + p { margin-top: .85rem; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85em;
  background: var(--raised); padding: .12em .38em; border-radius: 4px;
}
.badge {
  display: inline-block; font-size: .68rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: .15rem .45rem; border-radius: 5px;
  background: var(--raised); color: var(--muted); border: 1px solid var(--border);
}
.badge.warn { background: var(--accent-lo); color: var(--accent); border-color: transparent; }

footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--dim); font-size: .8rem;
}
.footer-inner { max-width: var(--page); margin: 0 auto; display: flex; gap: 1rem; flex-wrap: wrap; }
.footer-inner a { color: var(--muted); }

.loading { color: var(--dim); font-size: .85rem; padding: 1.5rem 0; }
.error {
  color: var(--neg); font-size: .85rem; padding: .75rem 1rem;
  border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent);
  border-radius: 8px; background: color-mix(in srgb, var(--neg) 8%, transparent);
}

.rec-row { display: flex; gap: 1rem; align-items: baseline; padding: .6rem 0; border-bottom: 1px solid var(--border-lo); }
.rec-row .rec-k { flex: 0 0 8.5rem; font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
.rec-row .rec-v { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.rec-row .rec-d { color: var(--muted); font-size: .83rem; margin-left: auto; text-align: right; }

/* paired records: as scored | against its season */
.rec-pair { display: grid; grid-template-columns: 9.5rem 1fr 1fr; gap: 1.25rem; align-items: baseline; padding: .65rem 0; border-bottom: 1px solid var(--border-lo); }
.rec-pair:last-child { border-bottom: 0; }
.rec-pair.single .rec-cell { grid-column: span 2; }
.rec-pair .rec-k { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
.rec-pair .rec-v { display: flex; align-items: center; gap: .7rem; font-family: var(--display); font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.rec-pair .rec-v .owner { font-size: .78rem; font-weight: 600; }
.rec-pair .rec-d { color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.rec-pair .rec-d span { white-space: nowrap; }  /* wrap only at the · separators */
.rec-head { padding-top: 0; font-size: .68rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.rec-cell[data-tag]::before { display: none; }
.rec-note { color: var(--muted); font-size: .83rem; max-width: var(--prose); margin-top: -1rem; }

@media (max-width: 900px) {
  .nav a { padding: .3rem .45rem; font-size: .78rem; }
  .masthead-inner { gap: 1rem; }
}

@media (max-width: 640px) {
  main { padding: 1.75rem 1rem 3rem; }
  .rec-row { flex-wrap: wrap; gap: .1rem .75rem; }
  .rec-row .rec-k { flex: 1 0 100%; }
  .rec-row .rec-d { margin-left: 0; text-align: left; flex: 1 0 100%; }
  .rec-pair { grid-template-columns: 1fr; gap: .45rem; }
  .rec-pair.single .rec-cell { grid-column: auto; }
  .rec-head { display: none; }
  .rec-cell[data-tag]::before { content: attr(data-tag); display: block; font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin-bottom: .1rem; }
  .masthead-inner { height: auto; min-height: 58px; padding: .6rem 1rem; flex-wrap: wrap; gap: .5rem 1rem; }
  .wordmark .sub { display: none; }
  .nav { margin-left: 0; width: 100%; gap: 0; }
  .nav a { padding: .3rem .5rem; font-size: .78rem; }
  .card { padding: .9rem; border-radius: 8px; }
  body { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* sortable table headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--muted); }
th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 3px; }
th.sorted { color: var(--accent); }
.sort-arrow { display: inline-block; width: .75em; text-align: left; }

/* segmented control — switches which series a chart draws */
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--raised); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 1rem;
}
.seg button {
  font: inherit; font-size: .78rem; font-weight: 600; letter-spacing: .01em;
  color: var(--muted); background: none; border: 0; cursor: pointer;
  padding: .3rem .7rem; border-radius: 6px; white-space: nowrap;
  transition: color .12s, background .12s;
}
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--fg);
  box-shadow: 0 1px 2px rgb(0 0 0 / .25);
}
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Plot's continuous colour legend sits above the chart in its own figure */
.chart figure { margin: 0; }
.chart figure > div { color: var(--muted); font-size: .75rem; }
