/* ============================================================================================
   COCKPIT — the Stupid Bastard Pool design system (§11).

   Dark-mode-first. This is the go-forward source of truth for design tokens and shared
   components; it loads AFTER app.css so it wins on any shared class name. New and rebuilt
   templates should reach for these tokens and the .tile / .chip / .gauge / .pill / .tab-bar
   primitives rather than hard-coded values.

   Rules the whole app follows:
   - GOLD (--gold) is money. Any bank, stake, payout, or dollar figure is gold + tabular-nums.
   - Team colors are IDENTITY only (an accent edge on a card), NEVER win/loss meaning.
   - Every win/loss encoding pairs color with a GLYPH (▲ ▼ + − ✓ ✗), never color alone.
   - Numbers are tabular: use .num (or the tnum utility) on every line, bank, stake, and score.
   ============================================================================================ */

:root, [data-theme="dark"] {
  /* Surfaces — from the page floor up to the most-raised card */
  --surface-0: #070a0f;   /* page background, behind everything */
  --surface-1: #121822;   /* the default card */
  --surface-2: #1a2330;   /* a card on a card / input wells */
  --surface-3: #202b3a;   /* the most-raised chip / hovered row */

  /* Text — labels by descending emphasis */
  --label-1: #e8eef6;     /* primary text */
  --label-2: #b6c2d2;     /* secondary */
  --label-3: #8a98ab;     /* muted / captions */
  --label-4: #5f6c7e;     /* dim / axis ink, disabled */

  /* Accent — the electric-blue family (interactive, focus, links, chart marks) */
  --accent:      #5aa9ff;
  --accent-strong:#2f7ff0;
  --accent-soft: rgba(90,169,255,.14);

  /* Money — gold, and gold only, for anything denominated in points or dollars */
  --gold:      #f2b94a;
  --gold-soft: rgba(242,185,74,.12);

  /* Semantic — win / loss / caution / locked. ALWAYS paired with a glyph on a surface. */
  --positive:      #1fd18a;
  --positive-soft: rgba(31,209,138,.14);
  --negative:      #ff5b6a;
  --negative-soft: rgba(255,91,106,.12);
  --warning:       #f2b94a;
  --warning-soft:  rgba(242,185,74,.12);
  --locked:        #6b7688;   /* a game/bet that has locked at kickoff */
  --locked-soft:   rgba(107,118,136,.14);

  --hairline: #26303f;        /* 1px separators and card borders */

  /* Radius + spacing (4pt grid) */
  --radius:    16px;          /* card radius */
  --radius-sm: 10px;          /* chips, pills, inputs */
  --radius-pill: 999px;
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --tap: 44px;                /* minimum touch target */
  --tab-h: 60px;              /* bottom tab-bar body height (safe-area added on top) */

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 6px 24px rgba(0,0,0,.45);
}

/* Light theme — an override, not the default. Toggled via <html data-theme="light">. */
[data-theme="light"] {
  --surface-0: #f2f5f9;
  --surface-1: #ffffff;
  --surface-2: #f4f7fb;
  --surface-3: #e8edf4;

  --label-1: #10151d;
  --label-2: #35404f;
  --label-3: #5f6c7e;
  --label-4: #94a2b4;

  --accent:      #1f74e0;
  --accent-strong:#155bc0;
  --accent-soft: rgba(31,116,224,.10);

  --gold:      #b8860b;
  --gold-soft: rgba(184,134,11,.12);

  --positive:      #0f9d63;
  --positive-soft: rgba(15,157,99,.12);
  --negative:      #d5323f;
  --negative-soft: rgba(213,50,63,.10);
  --warning:       #b8860b;
  --warning-soft:  rgba(184,134,11,.12);
  --locked:        #8895a6;
  --locked-soft:   rgba(136,149,166,.14);

  --hairline: #dbe2ec;
  --shadow-1: 0 1px 2px rgba(20,30,50,.08);
  --shadow-2: 0 6px 24px rgba(20,30,50,.12);
}

/* ---- Numeric utility: tabular figures everywhere a value lives ---- */
.num, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---- Money: gold + tabular. Use on banks, stakes, payouts, dollar figures. ---- */
.money { color: var(--gold); font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
  font-weight: 800; letter-spacing: -.01em; }

/* ---- Semantic text + the glyph pairing helpers ---- */
.is-pos { color: var(--positive); }
.is-neg { color: var(--negative); }
.is-warn { color: var(--warning); }
.is-locked { color: var(--locked); }
/* ::before glyphs so color is never the only signal (▲ up, ▼ down, ✓ cover, ✗ miss) */
.glyph-up::before   { content: "\25B2 "; }   /* ▲ */
.glyph-down::before { content: "\25BC "; }   /* ▼ */
/* The trailing space inside content: "\2713 " collapses like any other whitespace, which jammed the
   mark against the word. Margin instead, so it always sits off the text. */
.glyph-cover::before{ content: "\2713"; margin-right: .35em; }   /* ✓ */
.glyph-miss::before { content: "\2717"; margin-right: .35em; }   /* ✗ */
.glyph-push::before { content: "\2013"; margin-right: .35em; }   /* – */

/* ============================================================================================
   SHARED COMPONENTS
   ============================================================================================ */

/* Tile — the base card. .tiles is a 2-up grid of them. */
.tile {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.tile .l { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--label-3); }
.tile .v { font-weight: 800; font-size: 24px; margin-top: var(--sp-1); letter-spacing: -.02em;
  color: var(--label-1); }
.tile .s { font-size: 11px; color: var(--label-3); margin-top: 2px; }
.tile.accent { border-color: var(--accent-soft);
  background: linear-gradient(180deg, var(--accent-soft), transparent); }
.tile.money-tile { border-color: var(--gold-soft);
  background: linear-gradient(180deg, var(--gold-soft), transparent); }

/* Chip — a small inline stat/label with a leading accent edge. */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 28px; padding: var(--sp-1) var(--sp-3);
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: var(--radius-pill); font-weight: 700; font-size: 13px; color: var(--label-2);
}
.chip .k { font-size: 9px; text-transform: uppercase; letter-spacing: .12em; color: var(--label-3);
  font-weight: 700; }
.chip.edge-l { border-left: 3px solid var(--label-4); }
.chip.up   { border-left-color: var(--positive); }
.chip.down { border-left-color: var(--negative); }
.chip.money { border-left-color: var(--gold); }

/* Pill — a compact status tag. Bare .pill only; nested legacy `.section-h .pill` still wins there. */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--sp-2); border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--hairline); color: var(--label-2);
}
.pill.pos    { color: var(--positive); border-color: var(--positive); background: var(--positive-soft); }
.pill.neg    { color: var(--negative); border-color: var(--negative); background: var(--negative-soft); }
.pill.warn   { color: var(--warning);  border-color: var(--warning);  background: var(--warning-soft); }
.pill.locked { color: var(--locked);   border-color: var(--locked);   background: var(--locked-soft); }
.pill.money  { color: var(--gold);     border-color: var(--gold);     background: var(--gold-soft); }
.pill.accent { color: var(--accent);   border-color: var(--accent);   background: var(--accent-soft); }

/* Gauge — a thin horizontal fill bar (confidence, progress, share of bank). Recessive track,
   direct label over legend. Set --val (0..1) and optionally --gauge-color. */
.gauge { position: relative; height: 6px; border-radius: var(--radius-pill);
  background: var(--surface-3); overflow: hidden; }
.gauge > .fill { position: absolute; inset: 0 auto 0 0; width: calc(var(--val, 0) * 100%);
  background: var(--gauge-color, var(--accent)); border-radius: inherit; }
.gauge.pos { --gauge-color: var(--positive); }
.gauge.neg { --gauge-color: var(--negative); }
.gauge.money { --gauge-color: var(--gold); }

/* Tab bar — the bottom nav. Reinforces the legacy .tabs with real 44px targets + safe-area insets.
   The <nav> carries both `tab-bar` and `tabs` so it inherits legacy layout and this hardening. */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  min-height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--surface-0);
  border-top: 1px solid var(--hairline);
  height: auto;                     /* override the legacy fixed height so the inset can grow it */
}
.tab-bar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: var(--tap);
  color: var(--label-4); font-size: 10px; font-weight: 600; letter-spacing: .04em;
  text-decoration: none;
}
.tab-bar a.on { color: var(--accent); }
.tab-bar .ic { width: 23px; height: 23px; display: block; }

/* Keep the body clear of the fixed tab bar, including the home-indicator inset. */
body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px); }

/* Respect the OS reduced-motion setting for anything animated on top of this system. */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
      transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ================================================================================================
   SLIP STATUS CHIP — top bar, every screen
   "Did my bet go in" is not a question that only occurs on the board, so the answer travels with
   the player. Amber when a draft was never placed; quiet when everything is on record.
   ================================================================================================ */
.slip-chip { display: inline-flex; align-items: center; gap: 6px; margin-left: var(--sp-3);
  padding: 4px 10px; border-radius: var(--radius-pill); text-decoration: none;
  font-size: 11px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.slip-chip[hidden] { display: none; }
.slip-chip.ok    { color: var(--positive); border: 1px solid var(--positive); }
.slip-chip.none  { color: var(--label-3); border: 1px solid var(--label-4); }
.slip-chip.unplaced { color: var(--surface-0); background: var(--warning);
  animation: chipnudge 1.6s ease-in-out infinite; }
.slip-chip .sc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--surface-0); }
@keyframes chipnudge { 0%, 100% { opacity: 1 } 50% { opacity: .6 } }
@media (prefers-reduced-motion: reduce) { .slip-chip.unplaced { animation: none; } }

/* ---- MY PICKS ---- */
.mp-total { display: flex; gap: var(--sp-5); flex-wrap: wrap;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.mp-k { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--label-3); }
.mp-v { font-size: 22px; font-weight: 800; color: var(--label-1); }
.mp-of { color: var(--label-3); font-size: 12px; }
.mp-h { display: flex; align-items: center; gap: var(--sp-2);
  font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--label-3); margin: var(--sp-5) 0 var(--sp-2); }
.mp-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center;
  gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-left: 3px solid var(--positive);
  border-radius: var(--radius); margin-bottom: 6px; }
.mp-row.locked { border-left-color: var(--gold); }
.mp-team { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.mp-team b { color: var(--label-1); font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.mp-logo { width: 26px; height: 26px; object-fit: contain; flex: none; }
.mp-line { color: var(--gold); font-weight: 800; font-size: 14px; }
.mp-stake { color: var(--label-1); font-weight: 800; font-size: 15px; }
.mp-tag { font-size: 10px; font-weight: 800; letter-spacing: .06em;
  border-radius: var(--radius-pill); padding: 2px 8px; white-space: nowrap; }
.mp-tag.placed   { color: var(--positive); border: 1px solid var(--positive); }
.mp-tag.lockedin { color: var(--gold); border: 1px solid var(--gold); }
.mp-tag.result-won  { color: var(--positive); background: var(--positive-soft); }
.mp-tag.result-lost { color: var(--negative); background: var(--negative-soft); }
.mp-tag.result-push { color: var(--label-3); border: 1px solid var(--label-4); }
.mp-teaser-foot { border-left-color: var(--hairline); }
.mp-note { margin: var(--sp-4) 2px; line-height: 1.5; }
.mp-empty { text-align: center; padding: var(--sp-8) var(--sp-4); }
.mp-empty h3 { color: var(--label-1); margin: 0 0 var(--sp-2); }
.mp-empty p { color: var(--label-3); max-width: 40ch; margin: 0 auto var(--sp-5); line-height: 1.5; }
.mp-cta { display: inline-block; min-height: var(--tap); line-height: var(--tap);
  padding: 0 var(--sp-5); border-radius: var(--radius-sm); font-weight: 800;
  color: var(--surface-0); background: var(--accent); text-decoration: none; }

/* ---- Cockpit: this week's slip ---- */
.mycard { display: flex; align-items: center; gap: var(--sp-3); text-decoration: none;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-left: 3px solid var(--positive);
  border-radius: var(--radius); padding: var(--sp-4); margin: var(--sp-4) 0; }
.mycard .mc-l { flex: 1; min-width: 0; }
.mycard .mc-k { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--label-3); }
.mycard .mc-v { display: block; margin-top: 3px; color: var(--label-1); font-size: 14px;
  line-height: 1.4; }
.mycard .mc-go { color: var(--label-3); font-size: 22px; line-height: 1; }
.mycard.unplaced { border-left-color: var(--warning); background: var(--warning-soft); }
.mycard.unplaced .mc-v { color: var(--label-1); }

/* ================================================================================================
   TOP BAR — safe area
   The viewport is declared viewport-fit=cover, so on a notched iPhone it extends underneath the
   status bar. The bottom tab bar already accounts for that; the top bar did not, so its contents
   sat under the clock and the page scrolled visibly through the strip above it.

   Padding, not margin: the bar's own background then fills the inset, so content scrolling beneath
   is covered rather than peeking out above it.
   ================================================================================================ */
.topbar {
  /* max(), not calc() alone. If env(safe-area-inset-top) resolves (standalone PWA on a notched
     phone) we clear the inset and add breathing room on top of it. If it resolves to 0 — Safari
     with its own chrome, an older iOS, a desktop browser — the floor still keeps the bar off the
     top edge instead of collapsing back to the desktop padding. */
  padding-top: max(calc(34px + env(safe-area-inset-top, 0px)), 44px);
  padding-left: calc(14px + env(safe-area-inset-left, 0px));
  padding-right: calc(14px + env(safe-area-inset-right, 0px));
}

/* The season line wrapped to three lines on a phone, which is what made the bar tall enough to
   swallow the layout. It truncates instead — the week is on every screen below it anyway. */
.topbar > div:first-child { min-width: 0; }
.brand { white-space: nowrap; }
.brand-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.potchip { flex: none; }

/* On a narrow phone the slip chip gives up its words before anything else does; the colour still
   carries the warning, and it is still a tap target to My Picks. */
@media (max-width: 430px) {
  .topbar { gap: 8px; }
  .topicon { margin-left: 10px; }
  .topicon svg { width: 19px; height: 19px; }
  .slip-chip { margin-left: var(--sp-2); padding: 4px 8px; }
  .slip-chip.ok .sc-t, .slip-chip.none .sc-t { display: none; }
  .slip-chip.ok::after { content: "\2713"; font-weight: 900; }
  .slip-chip.none::after { content: "\2014"; }
}
