/*
 * The SolveOffs dashboard. It follows the game's design language (docs/DESIGN.md): the same ink background and
 * surfaces, the same three typefaces, amber only on what can be pressed, champagne for progress. The chart
 * colours are the one addition: a categorical set validated on these surfaces (docs/ANALYTICS.md).
 */

@font-face { font-family: 'Bricolage Grotesque'; font-weight: 800; font-display: swap; src: url('/fonts/BricolageGrotesque_800ExtraBold.ttf') format('truetype'); }
@font-face { font-family: 'Geist'; font-weight: 400; font-display: swap; src: url('/fonts/Geist_400Regular.ttf') format('truetype'); }
@font-face { font-family: 'Geist'; font-weight: 500; font-display: swap; src: url('/fonts/Geist_500Medium.ttf') format('truetype'); }
@font-face { font-family: 'Geist'; font-weight: 600; font-display: swap; src: url('/fonts/Geist_600SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Geist Mono'; font-weight: 500; font-display: swap; src: url('/fonts/GeistMono_500Medium.ttf') format('truetype'); }
@font-face { font-family: 'Geist Mono'; font-weight: 600; font-display: swap; src: url('/fonts/GeistMono_600SemiBold.ttf') format('truetype'); }

:root {
  color-scheme: dark;
  /* src/theme/tokens.ts */
  --bg: #0c0f17;
  --surface-1: #151a24;
  --surface-2: #171c28;
  --surface-3: #1f2533;
  --inset: #1d232f;
  --border: #1e2430;
  --border-raised: #222936;
  --track: #191e29;
  --text: #f2f1ee;
  --text-muted: #8b93a5;
  --icon-faint: #646c7d;
  --action: #f0a73a;
  --action-edge: #b06e18;
  --on-action: #1a1206;
  --meaning: #e2bb72;
  --danger: #d9573f;
  /* Chart series: fixed order, each kept by the thing it stands for. Checked as neighbours on --surface-1. */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  /* One hue for "how much": darker is less, lighter is more. */
  --heat-1: #0d366b;
  --heat-2: #184f95;
  --heat-3: #256abf;
  --heat-4: #3987e5;
  --heat-5: #6da7ec;
  --heat-6: #9ec5f4;
  --display: 'Bricolage Grotesque', 'Geist', sans-serif;
  --sans: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/20px var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--text); }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 6px; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; line-height: 16px; }
.overline { font: 600 11px/14px var(--sans); letter-spacing: 1.3px; text-transform: uppercase; color: var(--text-muted); }
.boot { padding: 32px 20px; color: var(--text-muted); }

/* The top bar. */
.top { display: flex; align-items: center; gap: 24px; padding: 14px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; background: var(--bg); }
.brand { font: 800 20px/24px var(--display); letter-spacing: -0.5px; text-decoration: none; display: inline-flex; align-items: baseline; gap: 8px; }
.brand span { font: 600 11px/14px var(--sans); letter-spacing: 1.3px; text-transform: uppercase; color: var(--text-muted); }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 6px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; color: var(--text-muted); }
.top nav a:hover { color: var(--text); }
.top nav a[aria-current='true'] { color: var(--text); background: var(--surface-3); }
.who { display: flex; align-items: center; gap: 12px; }

.page { max-width: 1280px; margin: 0 auto; padding: 24px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font: 800 30px/32px var(--display); letter-spacing: -1px; }
.page-tools { display: flex; align-items: center; gap: 12px; }
.page h2 { font: 800 22px/26px var(--display); letter-spacing: -0.5px; margin: 32px 0 12px; }
.back { margin-top: 16px; }
.back a { color: var(--text-muted); text-decoration: none; font-weight: 500; }
.back a:hover { color: var(--text); }
.content.stale { opacity: 0.55; transition: opacity 120ms; }

/* Buttons: one amber button (signing in); everything else is quiet. */
.quiet { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; font-weight: 500; cursor: pointer; }
.quiet:hover:not(:disabled) { background: var(--surface-3); }
.quiet:disabled { color: var(--icon-faint); cursor: default; }
.quiet[aria-pressed='true'] { background: var(--surface-3); border-color: var(--border-raised); }
.primary { background: var(--action); color: var(--on-action); border: 0; border-bottom: 3px solid var(--action-edge); border-radius: 14px; padding: 12px 16px; font: 800 18px/22px var(--display); letter-spacing: -0.3px; cursor: pointer; }
.primary:disabled { opacity: 0.6; cursor: default; }

/* The filter row: it scopes everything under it. */
.filters-row { margin-top: 16px; }
.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-body > .presets { justify-self: start; }
.presets { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; flex-wrap: wrap; }
.preset { background: none; border: 1.5px solid transparent; border-radius: 10px; padding: 5px 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.preset:hover { color: var(--text); }
.preset[aria-pressed='true'] { color: var(--text); background: var(--surface-3); border-color: var(--action); }
.custom { display: inline-flex; align-items: center; gap: 8px; }
input[type='date'], .search, .login-form input { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; }
.search { width: min(320px, 100%); }
.filters-note { color: var(--text-muted); font-size: 13px; line-height: 18px; }
.sources { margin-top: 16px; color: var(--text-muted); font-size: 13px; line-height: 18px; }

/* Where a number comes from. */
.source { display: inline-block; font: 500 11px/14px var(--sans); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-raised); color: var(--text-muted); white-space: nowrap; }
.source-tracked, .source-both { border-style: dashed; }

/* The hero: today against the target, then the figures everyone asks for first. */
.hero { display: grid; grid-template-columns: minmax(300px, 1fr) 2fr; gap: 16px; margin-top: 20px; align-items: stretch; }
.hero-goal { display: flex; align-items: center; gap: 20px; padding: 20px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 20px; }
.hero-ring { position: relative; width: 132px; height: 132px; flex: none; }
.hero-share { position: absolute; inset: 0; display: grid; place-items: center; font: 600 20px/24px var(--mono); letter-spacing: -0.2px; }
.ring-track { fill: none; stroke: var(--track); }
.ring-fill { fill: none; stroke: var(--meaning); stroke-linecap: round; }
.hero-figure { font: 600 44px/48px var(--mono); letter-spacing: -1.5px; margin-top: 6px; }
.hero-of { font-size: 20px; letter-spacing: -0.2px; color: var(--text-muted); }
.hero-note { margin: 6px 0 4px; font-weight: 600; }

/* Figures side by side, divided by hairlines rather than boxed one by one. */
.tray { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; gap: 1px; }
.tray .tile { background: var(--surface-1); box-shadow: 0 0 0 1px var(--border); }
.tray-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-3 .tray, .tray-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-body > .tray { border-radius: 14px; background: var(--inset); }
.panel-body > .tray .tile { background: var(--inset); box-shadow: 0 0 0 1px var(--border-raised); }
.tile { padding: 14px 16px; min-width: 0; }
.tile-label { font: 500 13px/18px var(--sans); color: var(--text-muted); }
.tile-value { font: 600 24px/30px var(--mono); letter-spacing: -0.6px; margin-top: 2px; overflow-wrap: anywhere; }
.tile-note { font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: 2px; }
.tile .source { margin-top: 8px; white-space: normal; }

/* Panels. */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px 20px; min-width: 0; }
.panel-wide { grid-column: 1 / -1; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel-head h3 { font: 600 15px/20px var(--sans); }
.panel-note { color: var(--text-muted); font-size: 13px; line-height: 18px; margin-top: 2px; max-width: 78ch; }
.panel-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.grid-3 .panel-head { flex-direction: column-reverse; gap: 10px; }
.panel-body { margin-top: 14px; display: grid; gap: 16px; min-width: 0; }
.footnote { color: var(--text-muted); font-size: 13px; line-height: 18px; max-width: 90ch; }

/* Legends and keys: a coloured mark beside text in a text colour. */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; color: var(--text-muted); font-size: 13px; line-height: 18px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend strong { color: var(--text); font: 600 13px/18px var(--mono); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.keyed { display: inline-flex; align-items: center; gap: 8px; }
.bg-1 { background-color: var(--series-1); } .bg-2 { background-color: var(--series-2); } .bg-3 { background-color: var(--series-3); }
.bg-4 { background-color: var(--series-4); } .bg-5 { background-color: var(--series-5); }
.fill-1 { fill: var(--series-1); } .fill-2 { fill: var(--series-2); } .fill-3 { fill: var(--series-3); }
.fill-4 { fill: var(--series-4); } .fill-5 { fill: var(--series-5); }
.stroke-1 { stroke: var(--series-1); } .stroke-2 { stroke: var(--series-2); } .stroke-3 { stroke: var(--series-3); }
.stroke-4 { stroke: var(--series-4); } .stroke-5 { stroke: var(--series-5); }
.swatch-hatch, .key-hatch { background-image: repeating-linear-gradient(45deg, transparent 0 2px, var(--surface-1) 2px 4px); }
.hatch-wash { opacity: 0.3; }

/* Charts: thin marks, hairline grid, text in text colours. */
.plot { position: relative; min-width: 0; }
.chart { width: 100%; }
.chart svg { display: block; }
.axis { font: 500 11px/14px var(--mono); fill: var(--text-muted); }
.gridline { stroke: var(--border-raised); stroke-width: 1; }
.baseline { stroke: var(--icon-faint); stroke-width: 1; }
.reference { stroke: var(--meaning); stroke-width: 1; }
.reference-label { fill: var(--meaning); }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { stroke: var(--surface-1); stroke-width: 2; }
.crosshair { stroke: var(--icon-faint); stroke-width: 1; }
.hit { fill: transparent; }
.hit:hover { fill: rgba(242, 241, 238, 0.04); }
.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border-raised); border-radius: 10px; padding: 8px 10px; min-width: 120px; max-width: 280px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.tip-title { font: 600 12px/16px var(--sans); color: var(--text-muted); margin-bottom: 4px; }
.tip-row { font-size: 13px; line-height: 18px; color: var(--text-muted); white-space: nowrap; }
.tip-row strong { font: 600 13px/18px var(--mono); color: var(--text); }
.key { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.key-1 { background-color: var(--series-1); } .key-2 { background-color: var(--series-2); } .key-3 { background-color: var(--series-3); }
.key-4 { background-color: var(--series-4); } .key-5 { background-color: var(--series-5); }

.heat { stroke: none; }
.heat:hover { stroke: var(--text); stroke-width: 1; }
.heat-0 { fill: var(--track); } .heat-1 { fill: var(--heat-1); } .heat-2 { fill: var(--heat-2); } .heat-3 { fill: var(--heat-3); }
.heat-4 { fill: var(--heat-4); } .heat-5 { fill: var(--heat-5); } .heat-6 { fill: var(--heat-6); }
.heat-key { display: flex; align-items: center; gap: 4px; margin-top: 10px; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.heat-swatch { width: 14px; height: 10px; border-radius: 2px; }
.heat-bg-1 { background: var(--heat-1); } .heat-bg-2 { background: var(--heat-2); } .heat-bg-3 { background: var(--heat-3); }
.heat-bg-4 { background: var(--heat-4); } .heat-bg-5 { background: var(--heat-5); } .heat-bg-6 { background: var(--heat-6); }

/* One whole split into parts; a meter. */
.split { display: flex; gap: 2px; height: 8px; }
.split span { border-radius: 999px; min-width: 4px; }
.split-empty { background: var(--track); border-radius: 999px; }
.meter { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--heat-4); border-radius: 999px; }
.meter-step-1 span { background: var(--heat-5); } .meter-step-2 span { background: var(--heat-4); } .meter-step-3 span { background: var(--heat-3); }
.funnel { display: grid; gap: 14px; }
.funnel-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.funnel-head span:first-child { flex: 1; font-weight: 500; }
.funnel-head strong { font: 600 15px/20px var(--mono); }

.feature-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px 32px; }
.features { display: grid; gap: 12px; margin-top: 10px; }
.feature-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 500; margin-bottom: 6px; }
.feature-figures { margin-top: 4px; font-size: 13px; line-height: 18px; color: var(--text-muted); }
.feature-figures strong { font: 600 13px/18px var(--mono); color: var(--text); }

/* Tables. */
.table-scroll { overflow-x: auto; }
.table-panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; margin-top: 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data thead th { font: 600 11px/14px var(--sans); letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); }
table.data tbody th { font-weight: 500; }
table.data tbody tr:last-child th, table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
table.data thead .num { font-family: var(--sans); }
table.players tbody tr:hover { background: var(--surface-3); }
table.players a { text-decoration: none; font-weight: 600; }
table.players a:hover { text-decoration: underline; }
.sort { background: none; border: 0; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer; }
.sort:hover, th[aria-sort='ascending'] .sort, th[aria-sort='descending'] .sort { color: var(--text); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.pager-buttons { display: flex; align-items: center; gap: 10px; }

.player-head { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 16px; align-items: center; margin-top: 12px; }
.player-name { font: 800 30px/32px var(--display) !important; letter-spacing: -1px; margin: 4px 0 6px !important; overflow-wrap: anywhere; }

.notice { padding: 28px 20px; text-align: center; color: var(--text-muted); display: grid; gap: 8px; justify-items: center; }
.notice h3 { color: var(--text); font: 600 15px/20px var(--sans); }

/* Signing in. */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--surface-1); border: 1px solid var(--border); border-radius: 20px; padding: 28px; display: grid; gap: 12px; }
.login-card h1 { font: 800 30px/32px var(--display); letter-spacing: -1px; margin-top: 8px; }
.login-form { display: grid; gap: 8px; margin-top: 8px; }
.login-form label { font: 500 13px/18px var(--sans); color: var(--text-muted); margin-top: 6px; }
.login-form input { padding: 11px 12px; border-radius: 14px; }
.login-form .primary { margin-top: 14px; }
.form-error { color: var(--danger); font-weight: 500; }

@media (max-width: 900px) {
  .hero, .player-head, .grid, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .top { gap: 12px; padding: 12px 16px; flex-wrap: wrap; position: static; }
  .top nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .page { padding: 16px 16px 48px; }
  .panel { padding: 16px; }
  .panel-head { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .hero-goal { flex-direction: column; align-items: flex-start; }
  .hero-figure { font-size: 34px; line-height: 40px; }
  .tray, .tray-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 20px; line-height: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .content.stale { transition: none; }
}
