/* Gridiron Graphs — styles. Colors are tokens so light and dark both work. */

:root {
  color-scheme: light;
  --page: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6e69;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --brand: #14532d;
  --brand-ink: #ffffff;
  --focus: #2a78d6;
  --good: #006300;
  --warn-bg: #fff4dc;
  --warn-ink: #6b4500;
  --info-bg: #e8f1fc;
  --info-ink: #1c4f8f;
  --error-bg: #fde8e8;
  --error-ink: #8f1d1d;
  --tooltip-bg: #1a1a19;
  --tooltip-ink: #ffffff;
  /* Chart series (validated categorical palette, light steps) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --series-other: #c9c8c1;
  --series-other-strong: #898781;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #45453f;
    --border: rgba(255, 255, 255, 0.10);
    --brand: #4ade80;
    --brand-ink: #0d0d0d;
    --focus: #6da7ec;
    --good: #0ca30c;
    --warn-bg: #3a2c0c;
    --warn-ink: #f6d48a;
    --info-bg: #14263d;
    --info-ink: #b7d3f6;
    --error-bg: #3d1616;
    --error-ink: #f6b7b7;
    --tooltip-bg: #f0efea;
    --tooltip-ink: #0b0b0b;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --series-other: #4a4a45;
    --series-other-strong: #898781;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9a9890;
  --grid: #2c2c2a;
  --axis: #45453f;
  --border: rgba(255, 255, 255, 0.10);
  --brand: #4ade80;
  --brand-ink: #0d0d0d;
  --focus: #6da7ec;
  --good: #0ca30c;
  --warn-bg: #3a2c0c;
  --warn-ink: #f6d48a;
  --info-bg: #14263d;
  --info-ink: #b7d3f6;
  --error-bg: #3d1616;
  --error-ink: #f6b7b7;
  --tooltip-bg: #f0efea;
  --tooltip-ink: #0b0b0b;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --series-other: #4a4a45;
  --series-other-strong: #898781;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; letter-spacing: -0.01em; }
h3.sub { font-size: 0.95rem; margin: 18px 0 8px; color: var(--ink-2); }
p { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 750; font-size: 1.05rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; color: var(--brand); flex: none; }
.tabs { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  text-decoration: none; padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 600; font-size: 0.93rem; white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a.active { background: var(--ink); color: var(--page); }
.icon-btn {
  flex: none; width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; }
  .brand span { font-size: 1rem; }
  .tabs { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .tabs { gap: 0; }
  .tabs a { padding: 6px 9px; font-size: 0.86rem; }
  .icon-btn { margin-left: auto; }
}

/* ---------------------------------------------------------------- layout */

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; transition: opacity 0.15s; }
main.is-loading .page { opacity: 0.55; pointer-events: none; }
.page { display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.lede { color: var(--ink-2); max-width: 70ch; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; min-width: 0;
}
.card-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.card-head.row { flex-direction: row; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.card-head p { font-size: 0.9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.footnote { font-size: 0.82rem; color: var(--muted); margin-top: 12px; }
.callout { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 0.92rem; }

.site-footer {
  max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 16px 28px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ink-2);
}

/* ---------------------------------------------------------------- controls */

.controls { display: flex; flex-direction: column; gap: 12px; }
.control-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.grow { flex: 1 1 220px; }
.field-label { font-size: 0.78rem; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.select, .input, .picker-input {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis);
  border-radius: 10px; padding: 8px 10px; min-height: 40px; width: 100%; min-width: 0;
}
.select { padding-right: 28px; }
.input[type="search"] { max-width: 240px; }
.select:hover, .input:hover, .picker-input:hover { border-color: var(--muted); }
.picker-input:disabled { opacity: 0.6; cursor: not-allowed; }

.picker { position: relative; display: flex; flex-direction: column; gap: 5px; }
.picker-box { position: relative; }
.picker-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; max-height: 320px; overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.picker-opt { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.picker-opt[aria-selected="true"] { background: var(--surface-2); }
.picker-name { font-weight: 600; }
.picker-conf { margin-left: auto; font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.picker-empty { padding: 10px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 4px 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 0.9rem;
}
.chip-x {
  border: 0; background: transparent; color: var(--ink-2); width: 26px; height: 26px; border-radius: 999px; cursor: pointer; font-size: 17px; line-height: 1;
}
.chip-x:hover { background: var(--border); color: var(--ink); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }

.picked { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 4px 4px 10px; border: 1px solid var(--axis); border-radius: 10px; }
.picked strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--border); max-width: 100%; overflow-x: auto; }
.seg.wrap { flex-wrap: wrap; overflow: visible; margin-bottom: 12px; }
.seg-btn {
  font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--ink-2); background: transparent; border: 0;
  padding: 6px 11px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--border); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 650; font-size: 0.92rem;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--page); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.9; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 0.82rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------------------------------------------------------------- status */

.notice { padding: 10px 14px; border-radius: 10px; font-size: 0.92rem; }
.notice-info { background: var(--info-bg); color: var(--info-ink); }
.notice-warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice-error { background: var(--error-bg); color: var(--error-ink); }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: 24px 4px; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--grid); border-top-color: var(--ink-2); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-float {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40;
  background: var(--tooltip-bg); color: var(--tooltip-ink); padding: 8px 14px; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
}
.empty { text-align: left; }
.empty h2 { margin-bottom: 6px; }

/* ---------------------------------------------------------------- team cards */

.team-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.team-card { position: relative; overflow: hidden; padding-top: 22px; }
.team-card-bar { position: absolute; inset: 0 0 auto 0; height: 5px; }
.team-card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.team-name { font-size: 1.15rem; }
.kv { margin: 0; display: grid; gap: 6px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; border-top: 1px solid var(--grid); padding-top: 6px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.logo { object-fit: contain; flex: none; }
.logo-fallback {
  display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 750; flex: none;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35); letter-spacing: -0.02em;
}

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

.chart-box { position: relative; width: 100%; min-height: 200px; }
.radar-box { height: min(520px, 92vw); max-width: 640px; margin: 0 auto; }
.scatter-box { height: clamp(340px, 62vw, 560px); }

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

.table-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--grid); border-radius: 10px; }
.table-wrap.tall { max-height: 560px; overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data th, .data td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: middle; }
.data thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-2); white-space: nowrap;
}
.data tbody tr:last-child > * { border-bottom: 0; }
.data tbody th { font-weight: 600; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data td.best { font-weight: 750; }
.data .rank { color: var(--muted); font-size: 0.8em; font-weight: 500; }
.data td.sorted { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.data tr.is-chosen > * { background: color-mix(in srgb, var(--focus) 9%, transparent); }
.th-team { display: inline-flex; align-items: center; gap: 6px; }
.data th.center, .data td.center { text-align: center; }
.tape td.num:first-child { text-align: right; }
.tape td.num:last-child { text-align: left; }
.sort-btn { font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.sort-btn:hover { color: var(--ink); text-decoration: underline; }
.team-btn {
  font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; text-align: left;
}
.team-btn:hover span:last-child { text-decoration: underline; }
.board th[scope="row"] { min-width: 180px; }

.table-details { margin-top: 12px; }
.table-details summary { cursor: pointer; font-weight: 650; color: var(--ink-2); font-size: 0.9rem; width: fit-content; }
.table-details summary:hover { color: var(--ink); }

/* ---------------------------------------------------------------- matchup */

.mu-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.mu-team { position: relative; display: flex; align-items: center; gap: 14px; min-width: 0; }
.mu-team:last-child { flex-direction: row-reverse; text-align: right; }
.mu-bar { width: 5px; align-self: stretch; border-radius: 3px; flex: none; }
.mu-vs { font-weight: 800; font-size: 1.2rem; color: var(--muted); }
.tag { display: inline-block; margin-top: 4px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }
@media (max-width: 640px) {
  .mu-head { grid-template-columns: 1fr; }
  .mu-team:last-child { flex-direction: row; text-align: left; }
  .mu-vs { display: none; }
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.tile-label { font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); margin-bottom: 4px; }
.tile-value { font-size: 1.35rem; font-weight: 750; letter-spacing: -0.01em; }
.prob { margin-top: 14px; }
.prob-bar { display: flex; gap: 2px; height: 14px; border-radius: 999px; overflow: hidden; margin: 6px 0; }
.prob-bar span { display: block; height: 100%; }
.prob-legend { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; color: var(--ink-2); }
.prob-legend strong { color: var(--ink); }

/* ---------------------------------------------------------------- predictions */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.verdict { display: flex; align-items: center; gap: 14px; margin: 14px 0 4px; }
.verdict-bar { width: 5px; align-self: stretch; border-radius: 3px; flex: none; }
.verdict-pick { font-size: clamp(1.4rem, 1.1rem + 1.4vw, 1.9rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.verdict-pick .tag { margin-top: 0; letter-spacing: 0.05em; }
.verdict-line { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; color: var(--ink-2); }
.verdict-line strong { color: var(--ink); }
.tiles.spaced { margin-top: 16px; }
.tile-value.small { font-size: 1.05rem; }
.edges { margin-top: 16px; border-top: 1px solid var(--grid); padding-top: 14px; }
.edges-lead { font-weight: 650; }
.grid-2.tight { gap: 8px 24px; }
.edges h3.sub { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.edge-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 0.92rem; }
h3.sub.flat { margin: 0; color: var(--ink); font-size: 1rem; }

.h2h td.num { min-width: 92px; }
.show-sm { display: none; }
.h2h .row-logo { display: inline-flex; }
@media (max-width: 560px) {
  .hide-sm, .h2h .rank { display: none !important; }
  .show-sm { display: inline; }
  .h2h td.num { min-width: 0; }
  .h2h th, .h2h td { padding: 8px 6px; }
  .h2h thead th { font-size: 0.7rem; }
}
.bracket-wrap { margin-top: 20px; border-top: 1px solid var(--grid); padding-top: 16px; }
.bracket { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; align-items: center; }
@media (max-width: 860px) { .bracket { grid-template-columns: 1fr; align-items: stretch; } }
.br-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.br-title { margin: 0; font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); }
.br-game { border: 1px solid var(--grid); border-radius: 12px; padding: 8px 10px; background: var(--surface-2); }
.br-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; color: var(--ink-2); min-width: 0; }
.br-row + .br-row { border-top: 1px solid var(--grid); }
.br-row.fav { color: var(--ink); font-weight: 750; }
.br-seed { width: 1.1em; text-align: center; font-size: 0.8rem; color: var(--muted); font-weight: 600; flex: none; }
.br-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.br-pct { font-variant-numeric: tabular-nums; }
.br-note { font-size: 0.82rem; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--grid); }
.odds { display: grid; gap: 8px; }
.odds-row { display: grid; grid-template-columns: minmax(90px, 0.9fr) minmax(60px, 1.4fr) 44px; align-items: center; gap: 8px; font-size: 0.92rem; }
.odds-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odds-track { display: block; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.odds-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.odds-pct { text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; }

/* Butterfly rows: offense percentile grows left, defense percentile grows right. */
.bf { display: flex; flex-direction: column; gap: 4px; }
.bf-head { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.bf-head span { display: inline-flex; align-items: center; gap: 6px; }
.bf-row {
  display: grid; grid-template-columns: 104px 1fr 1fr 104px; grid-template-areas: "label label label label" "lv lb rb rv";
  column-gap: 2px; row-gap: 2px; padding: 6px 0; border-top: 1px solid var(--grid);
}
.bf-label { grid-area: label; text-align: center; font-size: 0.82rem; font-weight: 650; color: var(--ink-2); }
.bf-row > .bf-val:not(.right) { grid-area: lv; }
.bf-row > .bf-track.left { grid-area: lb; }
.bf-row > .bf-track.right { grid-area: rb; }
.bf-row > .bf-val.right { grid-area: rv; text-align: right; }
.bf-val { font-size: 0.86rem; font-variant-numeric: tabular-nums; white-space: nowrap; align-self: center; }
.bf-val.edge { font-weight: 800; }
.bf-val .rank { color: var(--muted); font-size: 0.8em; }
.bf-track { position: relative; height: 12px; background: var(--surface-2); align-self: center; }
.bf-track.left { border-radius: 6px 0 0 6px; }
.bf-track.right { border-radius: 0 6px 6px 0; }
.bf-fill { position: absolute; top: 0; bottom: 0; }
.bf-track.left .bf-fill { right: 0; border-radius: 4px 0 0 4px; }
.bf-track.right .bf-fill { left: 0; border-radius: 0 4px 4px 0; }

.res { display: inline-block; margin-right: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.res-W { font-weight: 700; }

@media (max-width: 520px) {
  main { padding-top: 16px; }
  .card { padding: 14px; }
  .bf-row { grid-template-columns: 62px 1fr 1fr 62px; }
  .bf-val { font-size: 0.8rem; white-space: normal; line-height: 1.2; }
  .bf-val .rank { display: block; }
  .seg { flex-wrap: wrap; overflow: visible; }
  .input[type="search"] { max-width: none; }
}

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