/* Tokens — the ONLY place raw colour values may appear. Plan §9a. */
:root {
  --surface-0: #f7f6f3;
  --surface-1: #efede8;
  --surface-2: #ffffff;
  --text-primary:   #1c1b19;
  --text-secondary: #5f5e5a;
  --text-muted:     #888780;
  --border:        rgba(0,0,0,0.12);
  --border-strong: rgba(0,0,0,0.24);
  --accent:      #185fa5;
  --danger:      #a32d2d;
  /* The YouTube embed renders dark in both themes — one fixed frame colour,
     not a token that flips (§9a). */
  --player-frame-bg: #131211;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-voice: ui-serif, Georgia, "Times New Roman", serif;
  --radius: 8px;
  --measure: 680px;
}

[data-theme="dark"] {
  --surface-0: #131312;
  --surface-1: #1e1e1c;
  --surface-2: #2a2a27;
  --text-primary:   #f1efe8;
  --text-secondary: #b4b2a9;
  --text-muted:     #888780;
  --border:        rgba(255,255,255,0.14);
  --border-strong: rgba(255,255,255,0.28);
  --accent:      #85b7eb;
  --danger:      #f09595;
}

/* The :not() guard is load-bearing: without it an explicit light choice is
   overridden by a dark OS preference. Plan §9a. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-0: #131312;
    --surface-1: #1e1e1c;
    --surface-2: #2a2a27;
    --text-primary:   #f1efe8;
    --text-secondary: #b4b2a9;
    --text-muted:     #888780;
    --border:        rgba(255,255,255,0.14);
    --border-strong: rgba(255,255,255,0.28);
    --accent:      #85b7eb;
    --danger:      #f09595;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--measure); margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* Header */
.site-head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 14px; border-bottom: 0.5px solid var(--border);
}
.wordmark {
  font-family: var(--font-mono); font-size: 15px; letter-spacing: 0.14em;
  font-weight: 500; color: var(--text-primary); text-decoration: none;
}
.site-nav { display: flex; gap: 16px; align-items: center; font-size: 13px; }
.site-nav a { color: var(--text-secondary); text-decoration: none; }
.site-nav a:hover { color: var(--text-primary); }
.site-nav a.nav-strong { color: var(--text-primary); }
.theme-form { display: flex; margin: 0; }
.icon-btn {
  background: none; border: 0; padding: 2px; cursor: pointer; display: flex;
  color: var(--text-secondary);
}
.icon-btn:hover { color: var(--text-primary); }

/* Hero */
.hero { padding: 2.5rem 0 2rem; max-width: 520px; }
.hero h1 { font-size: 26px; font-weight: 500; line-height: 1.35; margin: 0; }
.lede { font-size: 16px; color: var(--text-secondary); margin: 12px 0 0; }
.signup { display: flex; gap: 8px; margin-top: 20px; }
.signup input {
  flex: 1; height: 40px; padding: 0 12px; font: inherit; font-size: 15px;
  border: 0.5px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-primary);
}
.signup input::placeholder { color: var(--text-muted); }
.signup button, .card-foot button {
  height: 40px; padding: 0 16px; font: inherit; font-size: 15px; cursor: pointer;
  border: 0.5px solid var(--border-strong); border-radius: var(--radius);
  background: transparent; color: var(--text-primary); white-space: nowrap;
}
.signup button:hover { background: var(--surface-1); }
.signup button:active { transform: scale(0.98); }
.hint, .muted-sm { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; }
.field-err { font-size: 12px; color: var(--danger); margin: 8px 0 0; }
.muted { color: var(--text-secondary); }

/* Live round */
.panel { background: var(--surface-1); border-radius: 12px; padding: 1.25rem 1.5rem; }
.live-round {
  display: flex; justify-content: space-between; align-items: center;
  gap: 20px; flex-wrap: wrap;
}
.live-round-meta { text-align: right; }
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em;
  color: var(--text-secondary); margin: 0;
}
.theme-line { font-family: var(--font-voice); font-size: 19px; margin: 6px 0 0; }
.countdown { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* Last round */
.last-round { margin-top: 2.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head .muted-sm { margin: 0; }
.last-round .theme-line { font-size: 17px; margin-bottom: 14px; }

.card {
  background: var(--surface-2); border: 0.5px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.play-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border-bottom: 0.5px solid var(--border); background: var(--surface-1);
  text-decoration: none; color: var(--text-primary);
}
.play-row:hover { background: var(--surface-2); }
.play-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.play-title { font-size: 15px; font-weight: 500; }
.play-copy .muted-sm { margin: 0; }
.tag {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em;
  color: var(--text-muted);
}

.track-list { list-style: none; margin: 0; padding: 0; }
.track-list li {
  display: flex; align-items: baseline; gap: 12px; padding: 11px 16px;
  border-bottom: 0.5px solid var(--border);
}
.track-pos {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); width: 16px;
}
.track-name { flex: 1; font-size: 14px; min-width: 0; }
.track-score {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.card-foot { padding: 11px 16px; background: var(--surface-1); }
.card-foot a { font-size: 13px; text-decoration: none; }

/* Steps */
.steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-top: 2.5rem;
}
.step { background: var(--surface-1); border-radius: var(--radius); padding: 1rem; }
.step-num { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin: 0; }
.step-title { font-size: 14px; font-weight: 500; margin: 6px 0 4px; }
.step .muted-sm { margin: 0; }

/* Footer */
.site-foot {
  margin-top: 2.5rem; padding-top: 14px; border-top: 0.5px solid var(--border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  font-size: 12px; color: var(--text-muted);
}
.foot-links { display: flex; gap: 14px; }
.foot-links a { color: var(--text-muted); text-decoration: none; }

/* Thumbnails need a hairline or dark art bleeds into a dark surface. §9a. */
img.thumb { border: 0.5px solid var(--border); border-radius: 4px; display: block; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Legal pages (privacy, terms) */
.legal { padding-bottom: 2rem; }
.legal h2 { font-size: 17px; font-weight: 500; margin: 2rem 0 0.5rem; }
.legal p, .legal ul { color: var(--text-secondary); margin: 0.75rem 0; }
.legal ul { padding-left: 1.25rem; }
.legal li { margin: 0.35rem 0; }
.legal a { color: var(--accent); }

/* Section rhythm + list-of-cards — reused across rounds, archive, standings,
   and anywhere else that stacks panels or cards vertically. */
.stack-section { margin-top: 2rem; }
.card-list { display: flex; flex-direction: column; gap: 12px; }

/* .track-list li that also carries a thumbnail and, once resolved, a score
   block — the base row styling (padding, border, gap) is shared with the
   home-page track list; this only adjusts alignment for the extra content. */
.track-list li.entry-row { align-items: center; flex-wrap: wrap; }
.score-block { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tag-accent { color: var(--accent); }

/* Share bar. A native <meter> keeps this accessible and CSP-safe — no
   inline style is needed for a computed width (plan §11). Reusable
   wherever a share-of-pool ratio needs to render, not just here. */
.meter-share { width: 72px; height: 8px; vertical-align: middle; }
.meter-share::-webkit-meter-bar { background: var(--surface-0); border: none; border-radius: 4px; }
.meter-share::-webkit-meter-optimum-value { background: var(--accent); border-radius: 4px; }
.meter-share::-moz-meter-bar { background: var(--accent); border-radius: 4px; }

/* Frame for the YouTube embed, which is always dark and otherwise sits as a
   bare black rectangle on a light page (§9a). */
.player-frame { background: var(--player-frame-bg); border-radius: 12px; min-height: 200px; }

/* Generic table — standings today, the P9 admin surface later. */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 9px 10px; border-bottom: 0.5px solid var(--border); }
.data-table th {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; font-weight: 500; color: var(--text-secondary);
}
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Link-finding tutorial on the submit form — collapsed by default via
   <details>, so it costs nothing for anyone who already knows how. */
.link-help { margin-top: 14px; }
.link-help summary {
  cursor: pointer; font-size: 13px; color: var(--accent);
  list-style: none;
}
.link-help summary::-webkit-details-marker { display: none; }
.link-help summary::before { content: "+ "; }
.link-help[open] summary::before { content: "\2212 "; }
.link-help-body {
  margin-top: 12px; padding: 14px 16px; background: var(--surface-1);
  border-radius: var(--radius); display: flex; flex-direction: column; gap: 14px;
}
.link-help-step { display: flex; gap: 12px; align-items: flex-start; }
.link-help-icon {
  flex: none; width: 28px; height: 28px; border-radius: 6px;
  background: var(--surface-2); border: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.link-help-step .step-title { font-size: 13px; font-weight: 500; margin: 0 0 2px; }
.link-help-step .muted-sm { margin: 0; }
