/* Deliberately small and hand-written: no build step, no framework.
   Phase 4 is where the time goes. */

:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1b1b1a;
  --muted: #7a7a74;
  --line: #e2e2dd;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --bad: #b42318;
  --warn: #9a6700;
  --heat: 31, 111, 235;
  /* Tier colours: distinct, low-saturation, readable behind black text. */
  --t1: #d8ecff; --t2: #dcf3e4; --t3: #fdf2cc; --t4: #fde4d3;
  --t5: #f3e0f7; --t6: #e5e6ea; --t7: #eef0f2; --t8: #f5f6f7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --panel: #1c1f24; --ink: #e9eaec; --muted: #9096a0;
    --line: #2b3038; --accent: #67a2ff; --ok: #4ac26b; --bad: #ff7b72;
    --warn: #d5a017; --heat: 103, 162, 255;
    --t1: #1b3b5c; --t2: #1c4232; --t3: #4a3c10; --t4: #4d2f1c;
    --t5: #40254a; --t6: #2c313a; --t7: #24282f; --t8: #1e2127;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 0.92em; }
.muted { color: var(--muted); font-weight: 400; }
.strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- chrome ---------------------------------------------------------- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline;
  justify-content: space-between;
  padding: 10px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand strong { margin-right: 8px; }
.topbar nav { display: flex; gap: 16px; align-items: baseline; }
.topbar nav a.on { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--accent); }
.tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 99px;
  padding: 1px 8px;
}

main { padding: 18px 20px 60px; max-width: 1200px; }
.page-head h1 { font-size: 20px; margin: 4px 0; }
.page-head p { margin: 0 0 14px; max-width: 76ch; }

/* --- filters --------------------------------------------------------- */

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 12px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  border-radius: 99px; padding: 4px 12px; user-select: none;
}
/* Kept in the layout but invisible, so the radio still takes focus and the
   keyboard can move between chips. */
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) {
  border-color: var(--accent); color: var(--accent); font-weight: 600;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
}
.chip:has(input:checked) .muted { color: var(--accent); opacity: .7; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="search"], input[type="password"], select {
  font: inherit; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
input[type="search"] { min-width: 220px; }
.rows { color: var(--muted); }

button.primary {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0;
  border-radius: 6px; padding: 7px 14px; margin-right: 10px;
}
button.primary:hover { filter: brightness(1.08); }

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

table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: left; }
thead th {
  position: sticky; top: 47px; background: var(--panel); z-index: 1;
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
thead th a { color: inherit; }
thead th.sorted { color: var(--ink); }
.arrow { margin-left: 3px; }

/* No `overflow` here: an overflow container would become the scrollport for
   the sticky header and shove it down over the first rows. */
/* Column help. The ? sits in the header next to the sort link; the panel is a
   native popover, so it escapes the table's stacking and scroll contexts. */
.help {
  font: inherit; font-size: 10px; line-height: 14px; cursor: help;
  width: 15px; height: 15px; padding: 0; margin-left: 5px; vertical-align: 1px;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--bg); color: var(--muted);
}
.help:hover, .help:focus-visible { border-color: var(--accent); color: var(--accent); }

.tip {
  max-width: 44ch; margin: auto; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  /* The panel lives inside a <th>, so it inherits the header's alignment,
     nowrap, uppercase and small type however it is positioned. Reset them. */
  text-align: left; white-space: normal; text-transform: none;
  letter-spacing: normal; font-weight: 400; font-size: 14px; line-height: 1.5;
}
.tip::backdrop { background: rgba(0, 0, 0, .35); }
.tip h3 { margin: 0 0 6px; font-size: 14px; text-transform: none; }
.tip p { margin: 0 0 12px; font-weight: 400; text-transform: none;
  letter-spacing: 0; color: var(--ink); }
.tip-close {
  font: inherit; cursor: pointer; padding: 4px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
/* Hidden by default with a plain attribute selector, so a browser without
   popover support drops the panel rather than printing it inside the table
   header — the ? still explains itself through its title attribute. The
   :popover-open rule is more specific, so supporting browsers still open it. */
[popover] { display: none; }
[popover]:popover-open { display: block; }

.board { border: 1px solid var(--line); border-radius: 8px; }
.board td { border-left: 0; }
.board tbody tr:hover { outline: 1px solid var(--accent); outline-offset: -1px; }
.board .player { font-weight: 600; }
.board tr.hurt .player { text-decoration: underline dotted var(--bad); }
.empty { color: var(--muted); padding: 20px; text-align: center; }

/* Pool players with no ESPN projection: findable, visibly not ranked. */
.unranked-head td {
  padding-top: 14px; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em;
}
.board tr.unranked { background: repeating-linear-gradient(
    135deg, transparent, transparent 6px,
    rgba(128, 128, 128, .06) 6px, rgba(128, 128, 128, .06) 12px); }
.board tr.unranked .player { font-weight: 500; }

/* Tier colour lives on the dot, so the row stays readable and the tier is
   still scannable down the column. */
.tier-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 6px; vertical-align: baseline; background: var(--t8);
  border: 1px solid rgba(128, 128, 128, .35);
}
.tier-1 .tier-dot { background: var(--t1); }
.tier-2 .tier-dot { background: var(--t2); }
.tier-3 .tier-dot { background: var(--t3); }
.tier-4 .tier-dot { background: var(--t4); }
.tier-5 .tier-dot { background: var(--t5); }
.tier-6 .tier-dot { background: var(--t6); }
.tier-7 .tier-dot { background: var(--t7); }
.tier-1 td:first-child { box-shadow: inset 3px 0 var(--t1); }
.tier-2 td:first-child { box-shadow: inset 3px 0 var(--t2); }
.tier-3 td:first-child { box-shadow: inset 3px 0 var(--t3); }
.tier-4 td:first-child { box-shadow: inset 3px 0 var(--t4); }
.tier-5 td:first-child { box-shadow: inset 3px 0 var(--t5); }
.tier-6 td:first-child { box-shadow: inset 3px 0 var(--t6); }

.pos {
  display: inline-block; min-width: 40px; text-align: center;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
  border-radius: 4px; padding: 1px 6px;
  background: var(--t8); border: 1px solid var(--line);
}
.pos-QB { background: var(--t1); }
.pos-RB { background: var(--t2); }
.pos-WR { background: var(--t3); }
.pos-TE { background: var(--t4); }
.pos-K  { background: var(--t5); }
.pos-DST, .pos-RBWRTE { background: var(--t6); }

.status {
  font-size: 12px; font-weight: 600; border-radius: 4px; padding: 1px 6px;
  background: var(--t3); color: var(--warn);
}
.status.bad { background: transparent; color: var(--bad); }
.status.ok { background: transparent; color: var(--ok); }
.status.running { background: transparent; color: var(--accent); }

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

.cards {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  align-items: start;
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px;
}
.card.wide { grid-column: 1 / -1; }
.card h2 { font-size: 15px; margin: 0 0 2px; }
.card p { margin: 2px 0 10px; }
.card table { margin-top: 8px; }
.card table th, .card table td { padding: 4px 8px; }
.card table tr:last-child td, .card table tr:last-child th { border-bottom: 0; }
.card thead th { position: static; }
/* A narrow card scrolls its table sideways rather than spilling past its
   own border. */
.tablewrap { overflow-x: auto; }
.tablewrap table { min-width: 100%; width: auto; }
.when { white-space: nowrap; }

.mix th.phase { font-weight: 600; white-space: nowrap; }
.mix th.phase .muted { display: block; font-size: 11px; text-transform: none;
  letter-spacing: 0; font-weight: 400; }
/* Heat cell: opacity carries the share, so it reads without a legend. */
.heat { background: rgba(var(--heat), calc(var(--w) * 0.55)); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

.log {
  margin: 0; max-height: 380px; overflow: auto; font-size: 12px;
  line-height: 1.5; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 10px; white-space: pre-wrap;
}
.log .lvl-WARNING { color: var(--warn); }
.log .lvl-ERROR { color: var(--bad); }

/* --- login ----------------------------------------------------------- */

body.centered { display: flex; min-height: 100vh; align-items: center;
  justify-content: center; }
.login { width: 320px; display: grid; gap: 10px; }
.login h1 { font-size: 17px; margin: 0; }
.login p { margin: 0; }
