/* Trap Lines
   One stylesheet for every page. The rules it holds itself to:
   - four type sizes, no more (--fs-1 .. --fs-4)
   - one accent colour, plus the three tier colours
   - every number in tabular figures, right-aligned in columns
   - dark by default; light is a full second theme, not an inversion */

:root {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: rgba(255, 255, 255, 0.10);
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #3987e5;
  --accent-ink: #8dbcf5;
  --neutral-mark: #57564f;
  --contrast-mark: #d95926;

  --tier-glaring: #e0504f;
  --tier-strong: #ec835a;
  --tier-worth: #fab219;
  --tier-none: #6f6e68;
  --ok: #2fb62f;
  --fail: #e0504f;

  --fs-1: 12px;
  --fs-2: 14px;
  --fs-3: 17px;
  --fs-4: 28px;

  --radius: 10px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --border: rgba(11, 11, 11, 0.12);
  --ink: #0b0b0b;
  --ink-2: #45443f;
  --muted: #6b6a64;
  --grid: #e6e5df;
  --axis: #c3c2b7;
  --accent: #2468bd;
  --accent-ink: #1c5cab;
  --neutral-mark: #b9b8b0;
  --contrast-mark: #c9521f;

  --tier-glaring: #d03b3b;
  --tier-strong: #d9662f;
  --tier-worth: #c98500;
  --tier-none: #8c8b84;
  --ok: #0a8a0a;
  --fail: #c93434;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-2);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-4); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-3); font-weight: 650; line-height: 1.3; }
h3 { font-size: var(--fs-2); font-weight: 650; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 var(--gap); }
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Small uppercase label used above every number */
.label {
  font-size: var(--fs-1);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
[data-tip] { cursor: help; text-decoration: underline dotted var(--axis); text-underline-offset: 3px; }

/* ------------------------------------------------------------------ top navigation */

.nav { background: var(--surface); border-bottom: 1px solid var(--border); }
.nav .wrap { display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; letter-spacing: 0.08em; font-size: var(--fs-2); }
.brand:hover { text-decoration: none; }
.brand svg { display: block; }
.tabs { display: flex; gap: 2px; align-items: center; }
.tab {
  padding: 6px 12px; border-radius: 7px; color: var(--ink-2);
  font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.tab:hover { background: var(--surface-2); text-decoration: none; }
.tab[aria-current="page"] { background: var(--accent); color: #fff; }
.tab[aria-disabled="true"] { color: var(--muted); opacity: 0.6; cursor: default; pointer-events: none; }
.nav-links { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav-links a { padding: 6px 10px; border-radius: 7px; color: var(--ink-2); font-weight: 600; }
.nav-links a:hover { background: var(--surface-2); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.theme-toggle {
  margin-left: 6px; border: 1px solid var(--border); background: transparent; color: var(--ink-2);
  font: inherit; font-size: var(--fs-1); font-weight: 600; padding: 6px 10px; border-radius: 7px; cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--ink); }

/* ------------------------------------------------------------------ page header and stat strip */

.page-head { padding: 28px 0 8px; }
.page-head p { color: var(--ink-2); max-width: 64ch; margin-top: 8px; }
.page-head .meta { margin-top: 10px; font-size: var(--fs-1); color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.stat .value { font-size: var(--fs-4); font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat .note { font-size: var(--fs-1); color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ filter bar (sticks to the top) */

.filters {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  margin-top: 12px;
}
.filters .wrap { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding-top: 10px; padding-bottom: 10px; }
.filter { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button {
  font: inherit; font-size: var(--fs-1); font-weight: 600; color: var(--ink-2); background: transparent;
  border: 0; border-right: 1px solid var(--border); padding: 6px 10px; cursor: pointer; white-space: nowrap;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
select, .check {
  font: inherit; font-size: var(--fs-1); font-weight: 600; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px;
}
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }
.filters .count { margin-left: auto; font-size: var(--fs-1); color: var(--muted); }

/* ------------------------------------------------------------------ day groups and cards */

.day { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.day .count { font-size: var(--fs-1); color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px;
  border-left: 3px solid var(--tier-color, var(--tier-none));
}
.card[data-tier="glaring"] { --tier-color: var(--tier-glaring); }
.card[data-tier="strong"] { --tier-color: var(--tier-strong); }
.card[data-tier="worth_a_look"] { --tier-color: var(--tier-worth); }

.card-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "meta score"
    "teams line"
    "cols cols"
    "why why"
    "vegas vegas";
  gap: 12px 24px;
  align-items: center;
}
.card-meta { grid-area: meta; font-size: var(--fs-1); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.card-score { grid-area: score; display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.card-teams { grid-area: teams; display: grid; gap: 6px; min-width: 0; }
.card-line { grid-area: line; text-align: right; }
.card-cols { grid-area: cols; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.card-why { grid-area: why; font-size: var(--fs-3); font-weight: 650; line-height: 1.35; }
.card:not([data-state="flagged"]) .card-why { font-size: var(--fs-2); font-weight: 500; color: var(--ink-2); }
.card:not([data-state="flagged"]) .big-line, .card:not([data-state="flagged"]) .score .value { color: var(--ink-2); }
.card-vegas { grid-area: vegas; color: var(--muted); }
.card-vegas b { font-weight: 600; color: var(--ink-2); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--tier-color, var(--tier-none)) 55%, transparent);
  background: color-mix(in srgb, var(--tier-color, var(--tier-none)) 14%, transparent);
  color: var(--ink); font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tier-color, var(--tier-none)); }
.badge.plain { --tier-color: var(--tier-none); }

.score { display: flex; align-items: center; gap: 10px; }
.score .value { font-size: var(--fs-4); font-weight: 750; line-height: 1; }
.score .label { text-align: right; }
.meter { width: 64px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--tier-color, var(--tier-none)) 22%, transparent); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--tier-color, var(--tier-none)); }

.team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team .logo { width: 28px; height: 28px; flex: none; display: grid; place-items: center; }
.team .logo img { width: 28px; height: 28px; object-fit: contain; }
.team .logo span { font-size: var(--fs-1); font-weight: 800; color: var(--ink-2); }
.team .name { font-size: var(--fs-3); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team .rec { color: var(--muted); font-size: var(--fs-1); }
.team .side { color: var(--muted); font-size: var(--fs-1); margin-left: auto; padding-left: 8px; }

.big-line { font-size: var(--fs-4); font-weight: 750; line-height: 1.1; white-space: nowrap; }
.card-line .sub { font-size: var(--fs-1); color: var(--muted); margin-top: 2px; }

.col .value { font-size: var(--fs-3); font-weight: 650; margin-top: 2px; white-space: nowrap; }
.col .sub { font-size: var(--fs-1); color: var(--muted); }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
details.breakdown { margin-top: 12px; }
details.breakdown > summary {
  cursor: pointer; font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
  list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0;
}
details.breakdown > summary::-webkit-details-marker { display: none; }
details.breakdown > summary::before { content: "+"; display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1px solid var(--border); border-radius: 4px; font-weight: 700; }
details.breakdown[open] > summary::before { content: "\2212"; }
.breakdown-body { margin-top: 12px; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
/* Grid children must be allowed to shrink, or a wide table pushes the page sideways on a phone. */
.breakdown-body > *, .two > *, .card-grid > * { min-width: 0; }

.note-row { font-size: var(--fs-1); color: var(--muted); margin-top: 8px; }
.locked-note { font-size: var(--fs-1); color: var(--muted); }
.result { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-1); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); }
.result::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--muted); }
.result.won::before { background: var(--accent); }
.result.held::before { background: var(--contrast-mark); }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-2); }
th, td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-size: var(--fs-1); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 700; border-top: 1px solid var(--axis); }
td.reason { color: var(--ink-2); min-width: 22ch; }
tr.dim td { color: var(--muted); }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; }
.checks .mark { font-weight: 800; }
.checks .ok .mark { color: var(--ok); }
.checks .fail .mark { color: var(--fail); }
.checks .src { font-size: var(--fs-1); color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.panel > h2 { margin-bottom: 10px; }
.panel > h3 { margin-bottom: 8px; }
.section-title { margin: 28px 0 12px; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 28px 20px; text-align: center; color: var(--ink-2); }
.callout { border-left: 3px solid var(--accent); background: var(--surface); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; color: var(--ink-2); }

/* ------------------------------------------------------------------ charts */

.chart { position: relative; }
.chart svg { display: block; max-width: 100%; overflow: visible; }
.chart text { font-family: var(--font); font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--neutral-mark); }
.chart .bar.on { fill: var(--accent); }
.chart .bar:hover, .chart .bar.hover { filter: brightness(1.2); }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .value-label { fill: var(--ink); font-weight: 650; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-1); color: var(--ink-2); margin: 6px 0 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.table-toggle { margin-top: 6px; }
.table-toggle > summary { cursor: pointer; font-size: var(--fs-1); color: var(--muted); }

.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 300px;
  background: var(--ink); color: var(--bg); border-radius: 6px; padding: 6px 9px; font-size: var(--fs-1); line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); opacity: 0; transition: opacity 80ms;
}
.tip.show { opacity: 1; }
.tip b { font-size: var(--fs-2); }

/* ------------------------------------------------------------------ prose (methodology) and footer */

.prose { max-width: 70ch; }
.prose h2 { margin: 30px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; color: var(--ink-2); }
.prose li { margin-bottom: 4px; }
.prose strong { color: var(--ink); }

.footer { margin-top: 48px; border-top: 1px solid var(--border); padding: 20px 0 40px; color: var(--muted); font-size: var(--fs-1); }
.footer p { max-width: 80ch; margin-bottom: 6px; }

/* ------------------------------------------------------------------ small screens: the line and the score lead */

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav .wrap { gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; }
  .nav-links { margin-left: 0; width: 100%; justify-content: space-between; }
  .card { padding: 14px; }
  .card-grid {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "line score"
      "meta meta"
      "teams teams"
      "cols cols"
      "why why"
      "vegas vegas";
    gap: 10px 12px;
  }
  .card-line { text-align: left; }
  .two { grid-template-columns: minmax(0, 1fr); }
  /* One row that scrolls sideways, so the sticky bar never covers the cards. */
  .filters .wrap { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters .wrap::-webkit-scrollbar { display: none; }
  .filters .filter, .filters .check { flex: none; }
  .filters .count { display: none; }
  .card-foot { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }
