/* Baseball Greeks — dark-first design system.
   Palette per validated dark-mode steps; text always wears ink tokens. */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --ring: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;      /* diverging + pole */
  --neg: #e66767;         /* diverging − pole */
  --good: #0ca30c;
  --pt-FF: #3987e5;
  --pt-SI: #d95926;
  --pt-FC: #199e70;
  --pt-SL: #c98500;
  --pt-ST: #d55181;
  --pt-CU: #008300;
  --pt-KC: #9085e9;
  --pt-CH: #e66767;
  --pt-FS: #898781;
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--grid);
  position: sticky;
  top: 0;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
}
.brand .delta { color: var(--accent); }

.nav { display: flex; gap: 18px; margin-left: auto; }
.nav a { color: var(--ink-2); font-size: 14px; padding: 4px 2px; }
.nav a.active { color: var(--ink); border-bottom: 2px solid var(--accent); }
.nav a:hover { color: var(--ink); }

.wrap { max-width: 1060px; margin: 0 auto; padding: 28px 28px 64px; }

h1 { font-size: 26px; font-weight: 650; margin: 6px 0 2px; }
.sub { color: var(--ink-2); font-size: 14px; margin: 0 0 22px; }
.sub .hint { color: var(--muted); }

/* ── controls ─────────────────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.seg button:hover { color: var(--ink); border-color: var(--baseline); }
.seg button.on {
  color: var(--ink);
  border-color: var(--pt, var(--accent));
  box-shadow: inset 0 0 0 1px var(--pt, var(--accent));
}
.seg button .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--pt, var(--accent));
  vertical-align: 1px;
}

select, input[type="search"], input[type="text"] {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13.5px;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.spacer { flex: 1; }

/* ── leaderboard table ────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 14px;
  overflow: hidden;
}

.tablewrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

thead th {
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--grid);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface);
}
thead th.l { text-align: left; }
thead th:hover { color: var(--ink-2); }
thead th .arrow { color: var(--accent); margin-left: 3px; }

tbody td {
  padding: 9px 14px;
  text-align: right;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
  color: var(--ink-2);
}
tbody td.l { text-align: left; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
td.rank { color: var(--muted); width: 44px; }
td.name { color: var(--ink); font-weight: 550; }
td.z { color: var(--ink); font-weight: 600; }

/* centered diverging inline bar for zStuff */
.zbar {
  display: inline-block;
  width: 96px;
  height: 8px;
  margin-left: 10px;
  border-radius: 4px;
  background: var(--surface-2);
  position: relative;
  vertical-align: 1px;
  overflow: hidden;
}
.zbar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--baseline);
}
.zbar i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 4px;
}
.zbar i.pos { left: 50%; background: var(--accent); border-top-left-radius: 0; border-bottom-left-radius: 0; }
.zbar i.neg { right: 50%; background: var(--neg); border-top-right-radius: 0; border-bottom-right-radius: 0; }

.empty { padding: 42px; text-align: center; color: var(--muted); }

/* ── pitcher page ─────────────────────────────────────── */
.search-box { position: relative; max-width: 420px; }
.search-box input { width: 100%; padding: 10px 14px; font-size: 15px; }
.suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 10px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}
.suggest.open { display: block; }
.suggest div { padding: 9px 14px; cursor: pointer; color: var(--ink-2); }
.suggest div:hover, .suggest div.sel { background: var(--surface-2); color: var(--ink); }

.player-head { margin: 26px 0 6px; }
.player-head h2 { font-size: 32px; font-weight: 700; margin: 0; }
.player-head .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }

.ptcard {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 18px 20px 14px;
  margin-top: 16px;
}

.ptcard .head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.ptchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 650;
  font-size: 15px;
}
.ptchip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pt, var(--accent)); }
.ptcard .head .season { color: var(--muted); font-size: 13px; margin-left: auto; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.tile {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.tile .lbl { font-size: 12px; color: var(--muted); }
.tile .val { font-size: 22px; font-weight: 650; margin-top: 2px; }
.tile .delta { font-size: 12.5px; margin-top: 1px; color: var(--muted); }
.tile .delta.up { color: var(--good); }
.tile .delta.down { color: var(--neg); }

.spark { margin-top: 14px; }
.spark svg { display: block; width: 100%; height: 84px; overflow: visible; }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--baseline);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--ink);
  z-index: 50;
  display: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

footer {
  max-width: 1060px;
  margin: 0 auto;
  padding: 20px 28px 40px;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--grid);
}
footer p { margin: 4px 0; }
