/* site.css — shared chrome for the coach valuation site.
   Color roles follow the dataviz reference palette; light/dark swap in one
   place via custom properties. Theme resolution: the user toggle stamps
   data-theme on <html> (see js/theme.js) and wins over the system
   preference; with no stamp, prefers-color-scheme decides. The dark
   variable set therefore appears twice — keep both copies identical. */

:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* blue — primary series */
  --series-2: #1baf7a;   /* aqua — second series */
  --pos: #2a78d6;        /* diverging: above expectation */
  --neg: #e34948;        /* diverging: below expectation */
  --div-mid: #f0efec;    /* diverging neutral midpoint */
  --good-text: #006300;
  --accent-wash: rgba(42, 120, 214, 0.10);
  /* grade polarity (letters stay ink; these tint wash + border) */
  --grade-pos: #008300;
  --grade-mid: #898781;
  --grade-neg: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #199e70;
    --pos: #3987e5;
    --neg: #e66767;
    --div-mid: #383835;
    --good-text: #0ca30c;
    --accent-wash: rgba(57, 135, 229, 0.14);
    --grade-pos: #0ca30c;
    --grade-mid: #898781;
    --grade-neg: #e66767;
  }
}

:root[data-theme="dark"] {
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #199e70;
  --pos: #3987e5;
  --neg: #e66767;
  --div-mid: #383835;
  --good-text: #0ca30c;
  --accent-wash: rgba(57, 135, 229, 0.14);
  --grade-pos: #0ca30c;
  --grade-mid: #898781;
  --grade-neg: #e66767;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

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

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--series-1), var(--series-2));
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 52px;
  flex-wrap: wrap;
  padding-top: 6px;
  padding-bottom: 6px;
}
.site-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.site-title::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--series-1), var(--series-2));
  flex-shrink: 0;
}
.site-title:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-links a { color: var(--ink-2); }
.nav-links a:hover { color: var(--ink); text-decoration: none; }

.dropdown { position: relative; }
.dropdown > button {
  background: none;
  border: none;
  color: var(--ink-2);
  font: inherit;
  cursor: pointer;
  padding: 4px 0;
}
.dropdown > button:hover { color: var(--ink); }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: -8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  padding: 6px;
  min-width: 200px;
  max-height: 70vh;
  overflow-y: auto;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--ink);
  white-space: nowrap;
}
.dropdown-menu a:hover { background: var(--accent-wash); text-decoration: none; }

/* search */
.search-box { position: relative; margin-left: auto; flex: 0 1 260px; min-width: 150px; }
.search-box input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page);
  color: var(--ink);
  font: inherit;
}
.search-box input:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: min(320px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  z-index: 60;
}
.search-results.open { display: block; }
.search-results .group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 6px 10px 2px;
}
.search-results a {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--ink);
}
.search-results a mark {
  background: none;
  color: inherit;
  font-weight: 700;
}
.search-results a:hover,
.search-results a.active { background: var(--accent-wash); text-decoration: none; }
.search-results .empty { padding: 8px 10px; color: var(--muted); }

/* theme toggle */
.theme-toggle {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--ink); background: var(--accent-wash); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }

/* ---------- page scaffolding ---------- */

main.container { padding-top: 24px; padding-bottom: 48px; }

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 32px 0 10px; }
h3 { font-size: 16px; margin: 20px 0 8px; }

/* section-title accent bar (app pages only; the writeup keeps its rules) */
main.container h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 0.9em;
  margin-right: 9px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--series-1), var(--series-2));
  vertical-align: -0.12em;
}

.subtitle { color: var(--ink-2); margin: 0 0 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.error-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: var(--ink-2);
  margin-top: 32px;
}

.footnote { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* ---------- entity header block ---------- */

.entity-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.entity-photo {
  width: 110px;
  height: 110px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.entity-photo.crest { object-fit: contain; padding: 10px; }
.entity-main { flex: 1 1 280px; min-width: 240px; }

.grade-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  flex: 0 0 auto;
}
.grade-letter {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
}
.grade-detail { font-size: 13px; color: var(--ink-2); }
.grade-detail .cut-label {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  margin-bottom: 4px;
}
.grade-detail strong { color: var(--ink); }

/* stat row */
.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 6px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--series-1);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 108px;
}
.stat-tile .label { font-size: 12px; color: var(--muted); }
.stat-tile .value { font-size: 20px; font-weight: 600; }
.stat-tile .hint { font-size: 12px; color: var(--ink-2); }

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

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin: 12px 0;
}
.chart-title { font-weight: 600; margin-bottom: 2px; }
.chart-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.chart-card svg { display: block; width: 100%; height: auto; }

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 8px;
}
.chart-legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.key-line { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.key-line.dashed { border-top-style: dashed; }
.key-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

.viz-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  padding: 8px 10px;
  font-size: 12.5px;
  z-index: 100;
  max-width: 260px;
  display: none;
}
.viz-tooltip .tt-title { font-weight: 600; margin-bottom: 3px; }
.viz-tooltip .tt-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.viz-tooltip .tt-row strong { color: var(--ink); margin-left: auto; padding-left: 12px; }

/* segmented sort toggle */
.seg-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.seg-toggle button {
  background: var(--surface);
  border: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
}
.seg-toggle button + button { border-left: 1px solid var(--border); }
.seg-toggle button.active {
  background: var(--accent-wash);
  color: var(--ink);
  font-weight: 600;
}
.chart-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.chart-controls select {
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

/* stint / season detail panel */
.detail-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--page);
  padding: 12px 16px;
  margin-top: 10px;
}
.detail-panel .dp-title { font-weight: 600; margin-bottom: 6px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 18px;
  font-size: 13.5px;
}
.detail-grid .label { color: var(--muted); font-size: 12px; }
.detail-panel .dp-close {
  float: right;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
}
.detail-panel .dp-close:hover { color: var(--ink); }

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

.table-wrap { overflow-x: auto; }
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid var(--baseline);
  white-space: nowrap;
}
table.data td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.highlight td { background: var(--accent-wash); }
table.data .cell-entity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
table.data img.mini, table.data svg.mini {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
table.data img.mini.face { object-fit: cover; border-radius: 50%; }
.delta-pos { color: var(--good-text); }
.delta-neg { color: var(--neg); }
.grade-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 6px;
}

/* grade tiers — a green↔red diverging ramp with a neutral midpoint (same
   polarity language as residuals); letters stay ink, the hue carries
   wash + border, and A/B (F/D) differ by strength, not hue */
.grade-a { --tier: var(--grade-pos); --wash: 20%; --bord: 60%; }
.grade-b { --tier: var(--grade-pos); --wash: 9%;  --bord: 30%; }
.grade-c { --tier: var(--grade-mid); --wash: 12%; --bord: 45%; }
.grade-d { --tier: var(--grade-neg); --wash: 9%;  --bord: 30%; }
.grade-f { --tier: var(--grade-neg); --wash: 20%; --bord: 60%; }
.grade-chip.graded {
  background: color-mix(in srgb, var(--tier) var(--wash), transparent);
  border-color: color-mix(in srgb, var(--tier) var(--bord), transparent);
}
.grade-letter.graded {
  background: color-mix(in srgb, var(--tier) var(--wash), transparent);
  border: 1.5px solid color-mix(in srgb, var(--tier) var(--bord), transparent);
  border-radius: 12px;
  padding: 8px 13px;
}
.muted { color: var(--muted); }

/* ---------- home ---------- */

.hero { margin: 28px 0 20px; }
.hero h1 {
  font-size: 40px;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--series-1), var(--series-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--series-1); /* fallback if background-clip:text unsupported */
  width: fit-content;
}
.hero p { max-width: 640px; color: var(--ink-2); }
.hero .hero-link { margin: 2px 0 0; font-size: 13.5px; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.league-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--tile-accent, var(--series-1));
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--ink);
  font-weight: 600;
}
.league-tile:hover { background: var(--accent-wash); text-decoration: none; }

.show-more {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  cursor: pointer;
  margin-top: 10px;
}
.show-more:hover { color: var(--ink); }

/* ---------- archetype fit ---------- */

.fit-list { display: flex; flex-direction: column; gap: 8px; }
.fit-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14px;
}
.fit-item .dir { font-weight: 700; width: 14px; text-align: center; }
.fit-item .dir.pos { color: var(--good-text); }
.fit-item .dir.neg { color: var(--neg); }
.fit-item .r { color: var(--muted); font-size: 12.5px; }

/* ---------- writeup ---------- */

.writeup-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  padding-top: 24px;
  padding-bottom: 48px;
}
.toc {
  position: sticky;
  top: 68px;
  font-size: 13px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}
.toc h3 { margin-top: 0; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 4px 0; }
.toc a { color: var(--ink-2); }
.toc a.active, .toc a:hover { color: var(--series-1); }
.writeup { min-width: 0; }
.writeup h1 { font-size: 28px; }
.writeup h2 {
  font-size: 21px;
  margin-top: 36px;
  border-bottom: 1px solid var(--grid);
  padding-bottom: 6px;
}
.writeup table {
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 12px 0;
}
.writeup table th, .writeup table td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--grid);
  text-align: left;
}
.writeup table th { border-bottom-color: var(--baseline); }
.writeup blockquote {
  margin: 12px 0;
  padding: 4px 16px;
  border-left: 3px solid var(--baseline);
  color: var(--ink-2);
}
.writeup code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .writeup-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; }
}

@media (max-width: 480px) {
  .entity-header { gap: 12px; }
  .entity-photo { width: 84px; height: 84px; }
  h1 { font-size: 22px; }
  .hero h1 { font-size: 30px; }
  .grade-letter { font-size: 36px; }
}
