/* ==========================================================================
   BC PNP Draw Predictor — stylesheet
   Design tokens, the shared page shell, and page-specific blocks.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --panel: #f5f5f3;
  --fg: #14151a;
  --muted: #5b6070;
  --line: #dcdde2;
  --line-soft: #ececef;
  --accent: oklch(0.48 0.11 250);

  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1013;
  --panel: #16181c;
  --fg: #f1f2f5;
  --muted: #969cab;
  --line: #2a2d34;
  --line-soft: #1e2126;
  --accent: oklch(0.78 0.1 250);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1013;
    --panel: #16181c;
    --fg: #f1f2f5;
    --muted: #969cab;
    --line: #2a2d34;
    --line-soft: #1e2126;
    --accent: oklch(0.78 0.1 250);
  }
}

/* --- base --------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover { color: var(--fg); }

table { border-collapse: collapse; }

input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
  height: 44px;
}

input[type="date"] { color-scheme: light dark; }

/* Visible only to screen readers. */
.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;
}

/* --- page shell --------------------------------------------------------- */

/* Each page sets its own measures; these are the defaults used by the
   prose pages (About, Method, Data sources, Contact). */
.page {
  --shell-w: 760px;
  --main-w: 760px;
  --main-pad: 36px 20px 56px;

  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.page--home {
  --shell-w: 640px;
  --main-w: 1080px;
  --main-pad: 24px 20px 48px;
}

.page--predictor {
  --shell-w: 640px;
  --main-w: 640px;
  --main-pad: 18px 20px 48px;
}

.page--history {
  --shell-w: 720px;
  --main-w: 720px;
  --main-pad: 18px 20px 48px;
}

/* Same measure as the draw history page — the charts match it too. */
.page--pool {
  --shell-w: 720px;
  --main-w: 720px;
  --main-pad: 18px 20px 48px;
}

.site-header { border-bottom: 1px solid var(--line); }

.site-header__inner {
  max-width: var(--shell-w);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* The prose pages let the header wrap; the app pages keep it on one line. */
.site-header__inner--wrap {
  flex-wrap: wrap;
  gap: 10px 16px;
}

.site-main {
  max-width: var(--main-w);
  width: 100%;
  margin: 0 auto;
  padding: var(--main-pad);
  flex: 1;
}

.site-footer { border-top: 1px solid var(--line); }

.site-footer__inner {
  max-width: var(--shell-w);
  margin: 0 auto;
  padding: 24px 20px 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* --- navigation --------------------------------------------------------- */

.wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.nav-link {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
  border-bottom: 2px solid var(--fg);
  padding-bottom: 2px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 14px;
}

.back-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--muted);
}

/* --- shared bits -------------------------------------------------------- */

/* The eyebrow that introduces a page's main content. It is the page's <h1>
   on the landing page, so the weight is pinned back to normal — the design
   calls for a quiet label, not a bold heading. */
.page-eyebrow {
  margin: 0 0 20px;
  font-weight: 400;
}

/* Small mono uppercase label, used above sections and inside cards. */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 8px 10px;
  min-height: 36px;
  cursor: pointer;
}

.btn-mono--wide {
  padding: 8px 12px;
  min-height: 40px;
}

/* The toggle is labelled with the theme it switches *to*. Deriving that label
   in CSS — from the same cascade as the palette — means it is correct at first
   paint, with no JS and no flash of the wrong word. The button carries a
   static aria-label, so this text is decorative. */
.theme-toggle__label::after { content: "Dark"; }
[data-theme="dark"] .theme-toggle__label::after { content: "Light"; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__label::after { content: "Light"; }
}

/* The support card stands where the footer ad slot used to. Its button is the
   one saturated colour on the site — Buy Me a Coffee's yellow — which is what
   makes it read as a call to action next to a footer of grey type. */
.support-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
}

.support-card__cup {
  flex: none;
  color: var(--muted);
}

.support-card__text { flex: 1 1 260px; }

.support-card__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.support-card__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 52ch;
  text-wrap: pretty;
}

/* Yellow with near-black text is a fixed pair, not a palette token: it is the
   same in both themes, and it carries its own contrast either way. */
.support-card__btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #14151a;
  background: #ffdd00;
  text-decoration: none;
  border: 1px solid #ffdd00;
  border-radius: 2px;
  padding: 10px 16px;
  min-height: 42px;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.support-card__btn:hover {
  color: #14151a;
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.2);
}

@media (prefers-reduced-motion: reduce) {
  .support-card__btn { transition: none; }
  .support-card__btn:hover { transform: none; }
}

/* Every data page builds its figures in the browser, so with JavaScript off a
   reader would get a heading above an empty div. This says why, and points at
   the source that needs no script at all. */
.noscript {
  margin: 0 0 24px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 58ch;
  text-wrap: pretty;
}

.disclaimer {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  max-width: 58ch;
  text-wrap: pretty;
}

.updated {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* --- prose pages -------------------------------------------------------- */

.prose {
  max-width: 540px;
  font-size: 17px;
  line-height: 1.75;
}

.prose h1 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 28px;
}

.prose h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.prose p {
  margin: 0 0 20px;
  text-wrap: pretty;
}

.prose p:last-child { margin-bottom: 0; }

.prose ul {
  margin: 0 0 20px;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prose li { text-wrap: pretty; }

/* A hairline rule above a section heading. */
.is-ruled {
  padding-top: 4px;
  border-top: 1px solid var(--line-soft);
}

/* --- home: stream cards ------------------------------------------------- */

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  align-items: start;
}

.category { margin: 0; }

.category__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.category__streams {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stream-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 18px;
}

.stream-card__name {
  font-size: 16px;
  font-weight: 600;
}

.stream-card__value {
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  display: block;
  margin-top: 6px;
}

/* Streams without a predictor show a short phrase, not a score. */
.stream-card__value--pending {
  font-size: 17px;
  color: var(--muted);
}

.stream-card__assume {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.stream-card__caption {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stream-card__next {
  font-size: 15px;
  margin-top: 12px;
}

.stream-card__next strong { font-weight: 600; }

.stream-card__range {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.stream-card__link {
  font-size: 14px;
  margin-top: 12px;
}

/* A pending figure is a dash, not a number — quieten it so it does not read
   as a real value. */
.stream-card__value--pending-figure,
.predictor__value--pending { color: var(--muted); }

.predictor__pending {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--muted);
  max-width: 62ch;
  text-wrap: pretty;
}

.stream-card__last {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- predictor ---------------------------------------------------------- */

.stream-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 18px;
}

.page--history .stream-title { margin-bottom: 20px; }

.stream-eyebrow { margin: 0 0 2px; }

/* On the predictor the eyebrow follows the "all streams" link. */
.page--predictor .stream-eyebrow { margin-top: 16px; }

.predictor {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
}

.predictor__value {
  display: block;
  font-family: var(--mono);
  font-size: 64px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.predictor__range {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-wrap: pretty;
}

.predictor__range strong { font-weight: 500; }

.predictor__range span {
  color: var(--muted);
  font-family: var(--sans);
}

.predictor__controls {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.control-row label { font-size: 15px; }

.field {
  min-height: 44px;
  font-family: var(--mono);
  font-size: 16px;
  padding: 8px 10px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 2px;
}

.field--number {
  width: 92px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.field--date { font-size: 15px; }

.range-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.predictor__caveat {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 62ch;
  text-wrap: pretty;
}

.predictor__foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.predictor__hint {
  font-size: 13px;
  color: var(--muted);
}

.last-draw {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* The last published draw reads as a small stacked record: a quiet label,
   then one figure per line. Tighter leading than the page default keeps the
   block compact enough to sit inside a card. */
.last-draw__label { margin-bottom: 3px; }

.last-draw__line { line-height: 1.45; }

.history-link {
  margin-top: 10px;
  font-size: 14px;
}

/* --- history ------------------------------------------------------------ */

.stream-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.stream-tab {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-decoration: none;
  padding: 0 12px;
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
}

.stream-tab[aria-current="page"] {
  border-color: var(--fg);
  color: var(--fg);
}

.chart { margin-bottom: 28px; }

/* Chart.js draws into the canvas and needs a sized container to fill; its own
   layout handles the space for the tick labels and axis titles. Taller than
   the plot alone so those titles do not eat into the data area. */
.chart__plot {
  position: relative;
  height: 260px;
}

.chart__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart__summary {
  display: flex;
  justify-content: flex-end;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

.chart__note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  text-wrap: pretty;
}

/* --- pool history ------------------------------------------------------- */

/* One chart per row, styled to match the draw history chart. */
.pool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.pool-chart { margin: 0; }

.pool-chart__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 10px;
}

/* Same height as .chart__plot, so both pages read as one chart style. */
.pool-chart__plot {
  position: relative;
  height: 260px;
}

.pool-chart__plot canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- empty state -------------------------------------------------------- */

/* Shown where a stream has no published draws yet. */
.empty {
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 22px 20px;
  font-size: 15px;
  color: var(--muted);
  text-wrap: pretty;
}

/* One class on <body> swaps the chart and table for the explanation, so
   neither of them needs to know about the empty case. */
.has-no-draws .chart,
.has-no-draws .draws-section { display: none; }

.has-no-draws [data-empty] { display: block; }

[data-empty] { display: none; }

.draws-heading {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}

.draws {
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.draws th {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.draws th:first-child { text-align: left; }

.draws td {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  text-align: right;
  font-family: var(--mono);
}

.draws td:first-child {
  text-align: left;
  font-family: var(--sans);
}

/* Predictions sit back; the actual figure is the one that matters. */
.draws td.is-prediction { color: var(--muted); }
.draws td.is-actual { font-weight: 500; }

/* --- data sources ------------------------------------------------------- */

.source-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px 20px;
  margin: 0 0 24px;
  text-decoration: none;
  min-height: 64px;
}

.source-link__text {
  display: flex;
  flex-direction: column;
}

.source-link__name {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.source-link__url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.source-link__action {
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}

.stat {
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 14px 16px;
  margin: 0 0 24px;
}

.stat__value {
  font-family: var(--mono);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

