/* Fieldnotes — Concept A: editorial typography, warm colours, spacious layouts. */
:root {
  --paper: #fbf7f0;
  --paper-2: #f3ece1;
  --ink: #1f1a17;
  --ink-2: #4a3f38;
  --muted: #6b5e55;
  --rule: #e4d9ca;
  --accent: #b8471f;        /* terracotta */
  --accent-soft: #f6dfd3;
  --published: #2f6f5e;     /* evergreen */
  --published-soft: #dcebe5;
  --experimental: #7a5200;  /* amber, AA on its soft background */
  --experimental-soft: #f6e7c8;
  --unavailable: #565656;
  --unavailable-soft: #e9e6e2;
  --over: #2f6f5e;
  --under: #8a4b8f;
  --push: #9a6700;
  --focus: #1f5fbf;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --space: clamp(16px, 2.5vw, 28px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1613;
    --paper-2: #231e1a;
    --ink: #f2eae0;
    --ink-2: #d9cdbf;
    --muted: #b2a393;
    --rule: #3a322b;
    --accent: #e3794f;
    --accent-soft: #3d2519;
    --published: #7cc3ac;
    --published-soft: #1d3530;
    --experimental: #e2b04f;
    --experimental-soft: #3a2e14;
    --unavailable: #a39e98;
    --unavailable-soft: #2d2926;
    --over: #7cc3ac;
    --under: #d19ad6;
    --push: #e2b04f;
    --focus: #8ab4ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--sans);
  font-variant-numeric: tabular-nums;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 var(--space); } }

a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
[tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper);
  padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 5vw, 46px); margin: 0.6em 0 0.2em; }
h2 { font-size: clamp(22px, 3vw, 28px); margin: 1.6em 0 0.5em; }
h3 { font-size: 20px; margin: 1.4em 0 0.4em; }
.card h3 { margin: 0 0 0.3em; }
p { margin: 0 0 1em; }
.lede { font-family: var(--serif); font-size: clamp(19px, 2.2vw, 22px); color: var(--ink-2); max-width: 46em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.kicker { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; font-weight: 700;
  color: var(--accent); margin: 0; }

/* Masthead */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.masthead__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 24px; padding-top: 14px; padding-bottom: 10px; }
.brand { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; margin: 0; padding: 0; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: 15px; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main { min-height: 60vh; padding-top: 20px; padding-bottom: 48px; outline: none; }
/* Focus moves to <main> on each route change for screen readers; it is not a
   control, so it never gets a ring (beats the [tabindex]:focus-visible rule). */
main[tabindex]:focus, main[tabindex]:focus-visible { outline: none; }
main > .kicker:first-child { margin-top: 8px; }
.loading { margin-top: 48px; color: var(--muted); }

/* Banners */
.banner { margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius); font-size: 15px;
  border: 1px solid var(--rule); background: var(--paper-2); }
.banner--sample { background: var(--experimental-soft); border-color: transparent; }
.banner--stale { background: var(--accent-soft); border-color: transparent; }
.banner--error { background: var(--accent-soft); border-color: var(--accent); }

/* State badges: descriptive / experimental / published / unavailable */
.badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px; vertical-align: middle; white-space: nowrap;
  font-family: var(--sans); line-height: 1.5; }
.badge--published { background: var(--published-soft); color: var(--published); }
.badge--experimental { background: var(--experimental-soft); color: var(--experimental); }
.badge--unavailable, .badge--unsupported { background: var(--unavailable-soft); color: var(--unavailable); }
.badge--descriptive { background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--rule); }

/* Layout pieces */
.grid { display: grid; gap: var(--space); }
@media (min-width: 860px) { .grid--2 { grid-template-columns: 1fr 1fr; } .grid--3 { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px 22px; }
.card--feature { background: var(--paper-2); border-color: transparent; }
.card h3 { font-size: 24px; }
.card .kicker + h3 { margin-top: 6px; }
.card--hero { border-top: 4px solid var(--accent); border-radius: 4px 4px var(--radius) var(--radius); }
.card--hero h3 { font-size: clamp(26px, 3.2vw, 32px); }
.card--hero .stat-big { font-size: clamp(44px, 6vw, 60px); margin: 10px 0 14px; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.stat-big { font-family: var(--serif); font-size: 40px; line-height: 1; margin: 6px 0; }
.rule { border: 0; border-top: 1px solid var(--rule); margin: 32px 0; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--paper-2); }

/* Forms */
.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin: 16px 0 8px; }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select { font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid var(--rule);
  border-radius: 8px; background: var(--paper); color: var(--ink); min-width: 0; }
input[type="search"] { width: min(320px, 100%); }
button { font: inherit; font-size: 15px; font-weight: 600; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; }

/* Probability bar */
.pbar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--unavailable-soft); margin: 6px 0; }
.pbar span { display: block; height: 100%; }
.pbar .over { background: var(--over); }
.pbar .push { background: var(--push); }
.pbar .under { background: var(--under); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; margin-bottom: 14px; }

/* Win-probability bar (home hero card) */
.winbar { display: flex; justify-content: space-between; height: 14px; border-radius: 999px; overflow: hidden;
  background: var(--unavailable-soft); margin: 4px 0 4px; }
.winbar span { display: block; height: 100%; }
.winbar__away { background: var(--under); }
.winbar__home { background: var(--over); }
.winbar__labels { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700;
  color: var(--muted); margin-bottom: 10px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.dot.over { background: var(--over); } .dot.under { background: var(--under); } .dot.push { background: var(--push); }

/* Distribution chart */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--ink-2); opacity: 0.35; }
.chart .bar.in-range { opacity: 0.75; }
.chart .bar.over, .chart .bar.under, .chart .bar.push { opacity: 0.85; }
.chart .bar.over { fill: var(--over); }
.chart .bar.under { fill: var(--under); }
.chart .bar.push { fill: var(--push); }
.chart .axis { stroke: var(--rule); }
.chart text { fill: var(--muted); font: 12px var(--sans); }
.chart .line { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }

.footer { border-top: 1px solid var(--rule); padding: 24px 0 40px; font-size: 14px; color: var(--muted); }
.row-meta { display: none; font-weight: 400; color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Tabs and sortable headers */
.tabs { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; gap: 2px; }
.tabs [role="tab"] { background: transparent; color: var(--ink-2); border: 0; border-radius: 999px; padding: 6px 14px; }
.tabs [role="tab"][aria-selected="true"] { background: var(--ink); color: var(--paper); }
button.sort { background: none; border: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; padding: 0; cursor: pointer; text-align: right; }
button.sort[aria-pressed="true"] { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
td.sorted { font-weight: 700; }
.lens-state { margin: 4px 0 12px; }
.defs dt { font-weight: 600; margin-top: 10px; }
.defs dd { margin: 2px 0 0; color: var(--ink-2); }
select:disabled { opacity: 0.5; }

/* Phones */
@media (max-width: 639px) {
  /* Nav: one row that scrolls sideways instead of wrapping. */
  .masthead__row nav { width: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .masthead__row nav::-webkit-scrollbar { display: none; }
  /* Fade the right edge while more links sit off-screen (app.js sets data-end). */
  .masthead__row nav:not([data-end]) { -webkit-mask-image: linear-gradient(to right, #000 80%, transparent);
    mask-image: linear-gradient(to right, #000 80%, transparent); }
  .nav { flex-wrap: nowrap; white-space: nowrap; }

  /* Filters: two per row, search across the top. */
  .controls--filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .controls--filters label:first-child { grid-column: 1 / -1; }
  .controls--filters input[type="search"], .controls--filters select { width: 100%; }

  /* Stacked table: each row becomes a small card so the numbers stay on screen. */
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody { display: block; }
  .table--stack tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline;
    padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .table--stack td { border: 0; padding: 0; text-align: left; }
  .table--stack .cell-name { grid-column: 1; font-weight: 600; }
  .table--stack .cell-state { grid-column: 2; grid-row: 1; justify-self: end; }
  .table--stack .cell-stat { grid-column: 1; color: var(--ink-2); }
  .table--stack .cell-team, .table--stack .cell-pos { display: none; }
  .table--stack .row-meta { display: inline; }
  .table--stack .cell-mid, .table--stack .cell-range { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
  .table--stack .cell-mid { grid-column: 1; }
  .table--stack .cell-range { grid-column: 2; text-align: right; }
  .table--stack .cell-reason { grid-column: 1 / -1; }
  .table--stack td[data-label]::before { content: attr(data-label); display: block; font-family: var(--sans);
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
  .table--stack tbody tr:hover { background: none; }
}
