/* The new front end (landing.html, app.html): tokens, type and shared components.
   One grotesk for every role (Hanken Grotesk, self-hosted under the OFL in three
   unicode-range subsets, so a page downloads only the subsets it uses; the CSP allows
   font-src 'self' and nothing else), a math face for the variables in annotations and a
   monospace face for symbol codes. A cool paper ground with a faint grid, one cobalt
   accent. Paper is the default theme; dark is the opt-in one. */
@font-face {
  font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('/static/hanken-grotesk-latin.woff2?v=1f21c6ea') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('/static/hanken-grotesk-latin-ext.woff2?v=a1376a56') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('/static/hanken-grotesk-vietnamese.woff2?v=2f467719') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
:root {
  --ground: #F7F7FA;
  --surface: #FFFFFF;
  --surface-2: #F9F9FC;
  --surface-hover: #EEF0FB;
  --ink: #080A13;
  --ink-2: #1B1D2C;
  --muted: #4A4C63;
  --rule: #DCDCE5;
  --rule-soft: #EAEAF0;
  --rule-strong: #C6C7D4;
  --grid-line: rgba(22, 18, 52, 0.045);
  --brand: #2547E0;
  --brand-ink: #FFFFFF;
  --brand-wash: #EAEEFC;
  --cta: #2547E0;
  --cta-hover: #1C39C4;
  --cta-glow: rgba(37, 71, 224, 0.42);
  --pos: #087A54;
  --neg: #C23542;
  --chart-line: #2547E0;
  --chart-fc: #080A13;
  --chart-band: rgba(37, 71, 224, 0.12);
  --chart-grid: #E4E4EC;
  /* Compare chart: four categorical slots in fixed order (validated with the dataviz
     checks against #FFFFFF; slots 3 and 4 sit under 3:1, so each line carries a label). */
  --series-0: #2547E0;
  --series-1: #EB6834;
  --series-2: #1BAF7A;
  --series-3: #EDA100;
  --shadow: 0 1px 2px rgba(22, 18, 52, 0.05), 0 12px 32px -18px rgba(22, 18, 52, 0.28);
  --sans: 'Hanken Grotesk', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --serif: var(--sans);
  --math: 'STIX Two Math', 'STIX Two Text', 'Cambria Math', 'Latin Modern Math', Georgia, serif;
  --mono: 'Berkeley Mono', 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --label: 0.12em;
  --r: 8px;
  --max: 1280px;
  --spring: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
[data-theme="dark"] {
  --ground: #08070F;
  --surface: #111022;
  --surface-2: #17152F;
  --surface-hover: #1D1B3A;
  --ink: #F4F4FA;
  --ink-2: #DEDEEB;
  --muted: #A6A8C6;
  --rule: #23223B;
  --rule-soft: #1A1930;
  --rule-strong: #34335A;
  --grid-line: rgba(186, 188, 255, 0.05);
  --brand: #5C7CFF;
  --brand-ink: #FFFFFF;
  --brand-wash: #1A1D45;
  --cta: #3D5BF0;
  --cta-hover: #3554D9;
  --cta-glow: rgba(61, 91, 240, 0.5);
  --pos: #34C98A;
  --neg: #EF5B6B;
  --chart-line: #5C7CFF;
  --chart-fc: #F4F4FA;
  --chart-band: rgba(92, 124, 255, 0.18);
  --chart-grid: #1F1E36;
  --series-0: #5C7CFF;
  --series-1: #D95926;
  --series-2: #199E70;
  --series-3: #C98500;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -18px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--ground);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1;
}
/* Graph paper: a faint 64px grid behind the whole page. */
.paper {
  background-color: var(--ground);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Type ── */
.serif { font-family: var(--serif); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums slashed-zero; }
.eyebrow {
  margin: 0 0 0.6rem;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink);
}
/* A kicker: a bordered label with a cobalt square, above a section headline. */
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.4rem;
  padding: 0.42rem 0.8rem;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--brand);
  background: var(--surface);
  border: 1px solid var(--brand);
  border-radius: 4px;
}
.kicker::before { content: ""; width: 6px; height: 6px; background: var(--brand); }
.accent { color: var(--brand); }
.display {
  margin: 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(2.4rem, 4.8vw, 3.7rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}
.headline {
  margin: 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2rem, 3.6vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.standfirst {
  margin: 0;
  max-width: 58ch;
  font-family: var(--sans);
  font-size: 1.2rem;
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink);
}
.standfirst b, .standfirst strong { font-weight: 600; }
.prose { font-family: var(--sans); font-size: 1.04rem; font-weight: 300; line-height: 1.65; color: var(--ink); max-width: 68ch; }
.prose b, .prose strong { font-weight: 600; }
.math { font-family: var(--math); font-style: normal; font-size: 1.05em; }
.math i { font-style: italic; }
.prose p { margin: 0 0 0.8rem; }
.small { font-size: 13px; color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ── Controls ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.66rem 1.15rem;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.25s var(--spring), transform 0.25s var(--spring);
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #FFFFFF;
  background: var(--cta);
  border-color: var(--cta);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset, 0 6px 18px -6px var(--cta-glow);
}
.btn-primary:hover { color: #FFFFFF; background: var(--cta-hover); border-color: var(--cta-hover); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18) inset, 0 10px 26px -6px var(--cta-glow); }
.btn .arrow { transition: transform 0.25s var(--spring); }
.btn:hover .arrow { transform: translateX(3px); }
.btn-quiet { border-color: var(--rule); }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* ── Header ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  height: 64px;
  padding: 0 max(16px, calc((100% - var(--max)) / 2));
  background: color-mix(in srgb, var(--ground) 80%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}
/* A cobalt hairline along the bottom of the header that tracks the scroll. */
.site-nav .progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 40%, transparent));
  transform-origin: 0 50%; transform: scaleX(var(--read, 0));
  pointer-events: none;
}
.site-nav.is-app { padding: 0 16px; }
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--sans);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark img { width: 30px; height: 30px; padding: 2px; border: 1.5px solid var(--brand); border-radius: 5px; }
.wordmark .wm-2 { margin-left: -0.3rem; font-weight: 400; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; margin-left: auto; }
.nav-links a {
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink-2);
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--brand); }
.nav-links .btn { color: #FFFFFF; }

/* ── Search ── */
.search { position: relative; flex: 1 1 420px; max-width: 560px; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 0.9rem 0 2.3rem;
  font-family: var(--sans);
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  transition: border-color 0.18s ease, box-shadow 0.25s var(--spring);
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-wash); }
.search .glass {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  stroke: var(--muted);
  fill: none;
  stroke-width: 1.8;
  pointer-events: none;
}
.search kbd {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 0.35rem;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.search-results[hidden] { display: none; }
.search-results li {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--brand-wash); }
.search-results .code { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.search-results .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .where { font-size: 12px; font-weight: 500; color: var(--brand); }
.search-results .empty { display: block; color: var(--muted); font-size: 13px; cursor: default; }

/* ── Tags and change ── */
.tag {
  display: inline-block;
  padding: 0.12rem 0.42rem;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  border: 1px solid currentColor;
  border-radius: 4px;
}
/* Grade and band tags (forecast_service.GRADE_LABELS and BAND_LABELS name each one). The is-
   prefix keeps a grade key off page classes of the same word (the landing page's .beats). */
.tag.is-beats { color: var(--pos); }
.tag.is-ties, .tag.is-narrow, .tag.is-wide { color: #8A5A00; }
[data-theme="dark"] .tag.is-ties, [data-theme="dark"] .tag.is-narrow, [data-theme="dark"] .tag.is-wide { color: #E0A84F; }
.tag.is-loses { color: var(--neg); }
.tag.is-few, .tag.is-unknown { color: var(--muted); }
.tag.brand { color: var(--brand); }
.chg { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Chart (SVG; every colour is a token, so the theme toggle needs no redraw) ── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-family: var(--mono); font-size: 11px; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .fc { fill: none; stroke: var(--chart-fc); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .band { fill: var(--chart-band); stroke: none; }
.chart .band-edge { fill: none; stroke: var(--brand); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.75; }
.chart .now { stroke: var(--rule); stroke-dasharray: 2 3; }
.chart .dot { fill: var(--surface); stroke: var(--chart-line); stroke-width: 2; }
.chart .dot.fc-dot { stroke: var(--chart-fc); }
.chart .cross { stroke: var(--ink); stroke-width: 1; }
.chart .label-fc { fill: var(--brand); font-family: var(--sans); font-size: 12px; font-weight: 600; }
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 9rem;
  padding: 0.45rem 0.6rem;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.chart-tip[hidden] { display: none; }
.chart-tip .d { font-size: 12px; font-weight: 600; color: var(--muted); }
.chart-tip .v { font-family: var(--mono); font-size: 14px; font-weight: 700; }
.chart-tip .b { font-family: var(--mono); color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: 12.5px; font-weight: 500; color: var(--ink); }
.legend i { display: inline-block; width: 18px; height: 0; margin-right: 0.4rem; vertical-align: middle; border-top: 2px solid var(--chart-line); }
.legend i.fc { border-top: 2px dashed var(--chart-fc); }
.legend i.band { height: 10px; border: 0; background: var(--chart-band); }
.chart .cmp { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cmp-fc { stroke-dasharray: 5 4; }
.chart .cmp-dot { fill: var(--surface); stroke-width: 2; }
.chart .cmp-label { font-family: var(--mono); font-size: 11px; font-weight: 700; fill: var(--ink); }
.chart .s0 { stroke: var(--series-0); }
.chart .s1 { stroke: var(--series-1); }
.chart .s2 { stroke: var(--series-2); }
.chart .s3 { stroke: var(--series-3); }
.sw { display: inline-block; width: 14px; height: 3px; margin-right: 0.4rem; vertical-align: middle; border-radius: 2px; background: var(--series-0); }
.sw.s1 { background: var(--series-1); }
.sw.s2 { background: var(--series-2); }
.sw.s3 { background: var(--series-3); }
.chart-tip .r { display: flex; align-items: center; gap: 0.2rem; font-family: var(--mono); font-size: 12.5px; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 0.5rem 0.6rem;
  text-align: left;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink);
  border-bottom: 1px solid var(--rule-strong);
}
.table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--rule-soft); }
.table .r { text-align: right; }
.table td.r, .table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums slashed-zero; }
.table tr.link { cursor: pointer; }
.table tr.link:hover td { background: var(--surface-hover); }

/* ── Footer ── */
.site-foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 16px 3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}
.site-foot a { color: inherit; }
.site-foot .spacer { flex: 1; }

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