/* ------------------------------------------------------------------
   Shared styles for index.html and dashboard.html
   Theme: red, white and navy
------------------------------------------------------------------- */
:root {
  --wall: #0b2545;        /* navy wall */
  --wall-2: #13315c;
  --wall-3: #2a5aa0;
  --chalk: #f4f7fb;       /* page background */
  --paper: #ffffff;
  --ink: #101a2b;
  --muted: #52617a;
  --line: #d3dbe8;
  --stitch: #c8102e;      /* baseball stitch red */
  --lights: #ffffff;      /* scoreboard lights */
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  --radius-lg: 10px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

body {
  margin: 0;
  background: var(--chalk);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--wall-3); }
:focus-visible { outline: 3px solid var(--lights); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); line-height: 1.05; margin: 0; letter-spacing: 0.01em; }

/* ---------------- navigation (shared) ---------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--wall);
  color: #fff;
  border-bottom: 4px solid var(--stitch);
}
.nav-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; min-height: 60px;
  flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; white-space: nowrap;
  font-family: var(--display); font-weight: 800; font-size: 26px; }
.brand-ball { width: 24px; height: 24px; }
.nav-links { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: block; padding: 8px 11px; border-radius: var(--radius-sm);
  color: #dbe5f5; text-decoration: none; font-weight: 600; font-size: 14.5px; white-space: nowrap;
}
.nav-links a:hover { background: var(--wall-2); color: #fff; }
.nav-links a[aria-current="page"] { background: var(--lights); color: var(--wall); }

.sound-controls { display: flex; gap: 8px; flex: none; }
.sound-toggle {
  border: 2px solid var(--lights); background: transparent; color: var(--lights); border-radius: 999px;
  padding: 6px 14px; font: 700 13px/1 var(--body); cursor: pointer; white-space: nowrap;
}
.sound-toggle:hover { background: var(--wall-2); }
.sound-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.sound-toggle[aria-pressed="true"] { background: var(--lights); border-color: var(--lights); color: var(--wall); }
@media (max-width: 1280px) { .brand span { display: none; } }
@media (max-width: 900px) { .sound-toggle { padding: 6px 10px; font-size: 12px; } }
@media (max-width: 760px) {
  .nav { position: static; }
  .nav-inner { padding: 8px 12px; row-gap: 4px; }
  .brand { order: 1; }
  .sound-controls { order: 2; margin-left: auto; gap: 6px; }
  .sound-toggle { flex: none; padding: 6px 9px; font-size: 12px; }
  .nav-links { order: 3; width: 100%; gap: 0; }
  .nav-links a { padding: 6px 8px; font-size: 14px; }
}

.progress { position: absolute; left: 0; bottom: -4px; height: 4px; width: 0; background: var(--lights); }

/* ---------------- scoreboard (the signature element) ---------------- */
.scoreboard {
  background: var(--wall);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: #fff;
  box-shadow: inset 0 0 0 6px var(--wall-2);
}
.scoreboard-title { font-family: var(--display); font-size: 20px; color: var(--lights); margin: 0 0 14px 4px; font-weight: 700; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.board-row-label { font-family: var(--display); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: #c3d0e6; margin: 14px 0 8px 4px; }
.board-row-label:first-of-type { margin-top: 0; }
.board-grid + .board-row-label { margin-top: 20px; }
.tile {
  background: #071a33;
  border: 2px solid var(--wall-3);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
}
.tile-value {
  font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1;
  color: #fff; font-variant-numeric: tabular-nums;
}
.tile-value.small { font-size: 34px; }
.tile-label { font-size: 13.5px; color: #c3d0e6; margin-top: 8px; line-height: 1.35; }

/* ---------------- report page ---------------- */
.report-layout {
  max-width: 1320px; margin: 0 auto; padding: 0 20px 80px;
  display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 48px;
}
.hero { grid-column: 1 / -1; padding: 56px 0 28px; }
.hero h1 { font-size: clamp(56px, 9vw, 124px); font-weight: 900; color: var(--wall); max-width: 14ch; }
.byline { font-weight: 600; color: var(--muted); margin: 18px 0 0; }
.summary { max-width: 68ch; font-size: 19px; margin: 16px 0 0; }
.hero-board { grid-column: 1 / -1; }

.toc { position: sticky; top: 84px; align-self: start; padding-top: 8px; }
.toc h2 { font-size: 20px; color: var(--wall); margin-bottom: 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 3px solid var(--line); }
.toc a {
  display: block; padding: 6px 12px; margin-left: -3px; border-left: 3px solid transparent;
  color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.35;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--wall); border-left-color: var(--stitch); font-weight: 600; }

.finding { padding: 56px 0 8px; border-bottom: 1px solid var(--line); scroll-margin-top: 70px; }
.finding h2 { font-size: clamp(32px, 4vw, 46px); color: var(--wall); max-width: 22ch; font-weight: 800; }
.finding p { max-width: 68ch; }
.stat-inline { font-weight: 700; color: var(--stitch); font-variant-numeric: tabular-nums; }

.chart-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 18px 12px; margin: 20px 0 28px;
}
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-title { font-family: var(--body); font-size: 15px; font-weight: 700; color: var(--ink); }
.chart-box { position: relative; height: 360px; }
.chart-box.tall { height: 480px; }
.chart-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

.methods { padding: 56px 0 0; }
.methods h2 { font-size: 42px; color: var(--wall); }
.methods h3 { font-family: var(--body); font-size: 17px; margin: 26px 0 4px; }
.methods table { border-collapse: collapse; font-size: 15px; margin: 8px 0; }
.methods td, .methods th { border-bottom: 1px solid var(--line); padding: 7px 14px 7px 0; text-align: left; vertical-align: top; }
.cta { display: inline-block; margin-top: 18px; background: var(--stitch); color: #fff; text-decoration: none;
  padding: 12px 20px; border-radius: var(--radius-sm); font-weight: 700; }
.cta-inline {
  display: inline-block; margin-top: 10px; color: var(--wall-3); text-decoration: none;
  font-weight: 700; font-size: 14.5px; border-bottom: 2px solid transparent;
}
.cta-inline:hover { border-bottom-color: var(--wall-3); }
.cta-inline::after { content: " \2192"; }

/* ---------------- toggles (both pages) ---------------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--chalk); }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; font: 600 13px var(--body); color: var(--muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--wall); color: #fff; }

/* ---------------- dashboard ---------------- */
.dash { max-width: 1440px; margin: 0 auto; padding: 24px 20px 80px;
  display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 24px; }
.dash-title { grid-column: 1 / -1; display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dash-title h1 { font-size: clamp(40px, 5vw, 64px); color: var(--wall); font-weight: 900; }
.dash-title p { margin: 4px 0 0; color: var(--muted); }

.filters {
  position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px;
}
.filters h2 { font-size: 26px; color: var(--wall); }
.filter { border-top: 1px solid var(--line); padding: 14px 0; }
.filter:first-of-type { border-top: 0; }
.filter-label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.filter-label .count { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.filter select, .filter input[type="search"] {
  width: 100%; font: 14px var(--body); padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
.range-row { display: flex; gap: 8px; align-items: center; }
.range-row input[type="number"] { width: 100%; font: 14px var(--body); padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
input[type="range"] { width: 100%; accent-color: var(--wall); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--chalk); color: var(--ink); border-radius: 999px;
  padding: 4px 11px; font: 600 13px var(--body); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--wall); border-color: var(--wall); color: #fff; }
.checklist { max-height: 200px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 8px; }
.checklist label { display: flex; gap: 8px; align-items: center; font-size: 13.5px; padding: 3px 0; cursor: pointer; }
.linkish { background: none; border: 0; color: var(--wall-3); font: 600 12.5px var(--body); cursor: pointer; padding: 0; text-decoration: underline; }

.btn-reset {
  width: 100%; margin-top: 8px; padding: 11px; border: 0; border-radius: var(--radius-sm);
  background: var(--stitch); color: #fff; font: 700 15px var(--body); cursor: pointer;
}
.btn { border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); padding: 7px 12px; font: 600 13px var(--body); cursor: pointer; color: var(--ink); }
.btn:hover { border-color: var(--wall-3); }

.controls {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: end;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 18px;
}
.control label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.control select { font: 15px var(--body); padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 220px; max-width: 100%; }
.status { margin-left: auto; font-size: 13.5px; color: var(--muted); }

.kpi-board { margin-bottom: 18px; padding: 16px; }
.kpi-board .board-grid { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.kpi-board .tile { padding: 12px; }
.kpi-board .tile-value { font-size: 32px; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-grid .chart-card { margin: 0; }
.chart-grid .wide { grid-column: 1 / -1; }
.chart-grid .chart-box { height: 320px; }
.chart-box.clickable canvas { cursor: pointer; }

/* ---------------- player lookup ---------------- */
.player-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 18px;
}
.player-card h2 { font-size: 18px; color: var(--wall); margin-bottom: 4px; }
.player-search-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.player-search-row input[type="search"] {
  flex: 1; min-width: 220px; font: 15px var(--body); padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.player-search-row p { margin: 0; color: var(--muted); font-size: 13.5px; }
.player-result { margin-top: 16px; }
.player-result-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.player-result-head h3 { font-family: var(--display); font-size: 26px; color: var(--wall); }
.player-result-head span { color: var(--muted); font-size: 14px; }
.player-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-bottom: 14px; }
.player-tiles .tile { background: var(--chalk); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.player-tiles .tile-value { font-size: 22px; color: var(--ink); }
.player-tiles .tile-label { font-size: 11.5px; color: var(--muted); }
.player-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.player-chart-head label { font-size: 13px; font-weight: 700; }
.player-chart-head select { font: 13.5px var(--body); padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); }

.heatmap-wrap { overflow-x: auto; }
.heatmap { border-collapse: separate; border-spacing: 3px; font-size: 12.5px; width: 100%; }
.heatmap th { font-weight: 600; color: var(--muted); padding: 4px 6px; text-align: left; white-space: nowrap; }
.heatmap td { text-align: center; padding: 8px 4px; border-radius: 3px; font-variant-numeric: tabular-nums; min-width: 58px; }

.table-card { margin-top: 18px; }
.table-wrap { overflow-x: auto; max-height: 520px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.data-table th {
  position: sticky; top: 0; background: var(--wall); color: #fff; text-align: right; padding: 9px 10px; cursor: pointer; white-space: nowrap; font-weight: 600;
}
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
.data-table th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.data-table tbody tr:hover { background: #e9eff8; }
.data-table tfoot td { font-weight: 700; background: var(--chalk); border-top: 2px solid var(--wall); }

.loading { position: fixed; inset: 0; background: rgba(244,247,251,.92); display: grid; place-items: center; z-index: 100; font-family: var(--display); font-size: 30px; color: var(--wall); }
.loading[hidden] { display: none; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: 14px; padding: 30px 20px; border-top: 1px solid var(--line); }

/* ---------------- responsive ---------------- */
@media (max-width: 1000px) {
  .report-layout, .dash { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .filters { position: static; max-height: none; }
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .brand span { display: none; }
  .tile-value { font-size: 34px; }
  .chart-box { height: 300px; }
  .control, .control select { width: 100%; min-width: 0; }
}

/* ---------------- matchups page ---------------- */
.top-pairs { margin: 0; padding-left: 20px; font-size: 14px; }
.top-pairs li { margin: 5px 0; }
.opp-table { max-height: 520px; overflow: auto; }
.data-table tbody tr[data-o] { cursor: pointer; }
.data-table tbody tr[data-o]:hover { background: #e9eff8; }
.data-table tbody tr.selected { background: #fde3e6; }
.part-head { margin: 56px 0 8px; padding-top: 10px; border-top: 4px solid var(--stitch); }
.part-head h2 { font-size: clamp(34px, 4vw, 48px); color: var(--wall); }
.part-head p { color: var(--muted); max-width: 70ch; }

.suggest-wrap { position: relative; }
.suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px; list-style: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(11,37,69,.18); max-height: 320px; overflow: auto; }
.suggest li { padding: 7px 9px; border-radius: 3px; cursor: pointer; font-size: 14px; }
.suggest li:hover, .suggest li.active { background: #e9eff8; }

/* ---------------- the three big takeaways (report) ---------------- */
.takeaways { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 26px; max-width: 1100px; }
.takeaway { display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; row-gap: 4px; align-items: start; padding: 14px 16px; background: var(--paper);
  border: 1px solid var(--line); border-left: 5px solid var(--stitch); border-radius: var(--radius-sm); text-decoration: none; color: var(--ink); }
.takeaway:hover { background: #eef3fb; }
.takeaway-num { grid-row: 1 / span 2; font-family: var(--display); font-weight: 900; font-size: 34px; line-height: 1; color: var(--stitch); }
.takeaway strong { font-family: var(--display); font-size: 21px; color: var(--wall); }
.takeaway span:last-child { font-size: 14.5px; color: var(--muted); grid-column: 2; }

/* ---------------- Daily Grid game (grid.html) ---------------- */
.grid-page { display: block; }
.grid-wrap { max-width: 760px; margin: 18px auto 0; }
.grid-bar { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.grid-date { font-size: 14px; color: var(--muted); }
.grid-date input { font: inherit; margin-left: 6px; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.grid-stats { display: flex; gap: 18px; font-size: 14px; color: var(--muted); }
.grid-stats b { font-family: var(--display); font-size: 26px; color: var(--wall); margin-left: 4px; }
.grid { display: grid; grid-template-columns: minmax(70px, 0.8fr) repeat(3, 1fr); gap: 6px; }
.g-head { display: grid; place-items: center; text-align: center; padding: 8px 6px; background: var(--wall); color: #fff; border-radius: var(--radius-sm);
  font-family: var(--display); font-weight: 700; font-size: clamp(14px, 2.6vw, 20px); line-height: 1.1; }
.g-row { min-height: 96px; }
.g-cell { aspect-ratio: 1; min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px; text-align: center;
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius-sm); font: 600 14px var(--body); color: var(--ink); }
button.g-cell { cursor: pointer; font-size: 30px; color: var(--wall-3); }
button.g-cell:hover:not(:disabled), button.g-cell.active { border-color: var(--stitch); background: #fde3e6; }
button.g-cell:disabled { cursor: default; background: #eef1f6; }
.g-cell.hit { background: #e3f4e6; border-color: #3a8f4d; }
.g-name { font-weight: 700; line-height: 1.15; }
.g-pts { font-size: 12px; color: var(--muted); }
.grid-pick { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin: 16px 0 4px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--stitch); border-radius: var(--radius-sm); }
.grid-pick[hidden] { display: none; }
.grid-pick .filter-label { flex-basis: 100%; }
.grid-pick .suggest-wrap { flex: 1 1 260px; }
.grid-pick input { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.suggest .muted { color: var(--muted); }
.grid-msg { min-height: 1.6em; margin: 10px 0; color: var(--wall); font-weight: 600; }
.grid-msg.bad { color: var(--stitch); }
.grid-done { padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 16px; }
.grid-done h2 { font-size: 30px; color: var(--wall); margin-bottom: 8px; }
.grid-done ul { padding-left: 18px; font-size: 14.5px; }
.share-text { background: var(--chalk); padding: 10px 12px; border-radius: var(--radius-sm); font: 15px/1.4 var(--body); white-space: pre-wrap; }
@media (max-width: 520px) { .g-cell { min-height: 78px; font-size: 12.5px; } .g-name { font-size: 12.5px; } .g-row { min-height: 78px; } }
.g-photo { width: clamp(40px, 9vw, 72px); height: clamp(40px, 9vw, 72px); border-radius: 50%; object-fit: cover; object-position: top; background: #dfe6f1; border: 2px solid #3a8f4d; }
.g-none { display: grid; place-items: center; font-size: 24px; }
.g-logo { object-fit: contain; background: #fff; padding: 6px; border-color: var(--line); }

/* ---------------- "Watch it" stat animations (report page) ---------------- */
.stat-anim { max-width: 700px; margin: 22px 0; background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--stitch); border-radius: var(--radius-sm); overflow: hidden; }
.anim-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.anim-title { font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--wall); }
.anim-stage { position: relative; width: 100%; aspect-ratio: 16 / 8; background: var(--wall); overflow: hidden; }
.anim-stage[hidden] { display: none; }
.anim-canvas { display: block; width: 100%; height: 100%; }
.anim-hud { position: absolute; left: 14px; top: 10px; font-family: var(--display); font-weight: 800; font-size: clamp(20px, 3.4vw, 30px); color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.55); letter-spacing: .04em; }
.anim-big { position: absolute; left: 50%; top: 27%; transform: translate(-50%, -50%); opacity: 0; font-family: var(--display); font-weight: 900; font-size: clamp(40px, 9vw, 84px); color: var(--lights); -webkit-text-stroke: 2px var(--stitch); text-shadow: 0 4px 14px rgba(0,0,0,.5); white-space: nowrap; pointer-events: none; }
.anim-formula { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px; text-align: center; background: rgba(11,37,69,.78); color: var(--gold, #ffd23f); font-family: var(--display); font-weight: 800; font-size: clamp(20px, 3.6vw, 32px); opacity: 0; }
.anim-caption { margin: 0; padding: 10px 14px 12px; font-size: 15px; color: var(--muted); }
.anim-hint { margin: 0; padding: 6px 14px 0; font-size: 13.5px; color: var(--muted); }
.anim-voice { font: inherit; font-size: 13px; max-width: 220px; padding: 2px 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
