/* ==========================================================================
   0. FONT (Inter variable, Latin subset, self-hosted: no external requests)
   ========================================================================== */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("inter-latin-wght-normal.woff2") format("woff2");
}

/* ==========================================================================
   1. TOKENS
   ========================================================================== */
:root {
  --colour-page: #f6f4ef;
  --colour-surface: #ffffff;
  --colour-text: #1d2330;
  --colour-text-soft: #5a6275;
  --colour-border: #dcd8cd;
  --colour-brand: #12284c;
  --colour-brand-text: #ffffff;
  --colour-accent: #d8481f;
  --colour-accent-soft: #fbe6de;
  --colour-link: #0b4fa8;
  --colour-bar: #d8481f;
  --colour-chart-alt: #3b5a94;
  --colour-gridline: #e6e2d8;
  --radius: 10px;
  --space-xs: .4rem;
  --space-sm: .75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3.5rem;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 62rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --colour-page: #11141b;
    --colour-surface: #1a1f2a;
    --colour-text: #eceff5;
    --colour-text-soft: #a3abbd;
    --colour-border: #2d3445;
    --colour-brand: #0a1730;
    --colour-accent: #ff7a50;
    --colour-accent-soft: #33211b;
    --colour-link: #8db8ff;
    --colour-bar: #ff7a50;
    --colour-chart-alt: #6f93d6;
    --colour-gridline: #2a3142;
  }
}

/* ==========================================================================
   2. BASE / TYPOGRAPHY
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--colour-page);
  color: var(--colour-text);
  font: 1rem/1.55 var(--font-body);
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--colour-link); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--colour-accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }

/* ==========================================================================
   3. LAYOUT CONTAINERS
   ========================================================================== */
.container { max-width: 120rem; margin-inline: auto; padding-inline: clamp(1rem, 3vw, 3rem); }
.section { padding-block: var(--space-lg); }

/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */
/* page header */
.page-header { background: var(--colour-brand); color: var(--colour-brand-text); padding-block: var(--space-xl) var(--space-lg); }
.page-kicker { margin: 0 0 var(--space-sm); font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }
.page-logo { font: 800 clamp(2rem, 6vw, 3.2rem)/1 var(--font-display); letter-spacing: -.035em; margin: 0; }
.page-logo span { color: var(--colour-accent); }
.page-tagline { margin-top: var(--space-sm); max-width: 38rem; opacity: .88; font-size: 1.05rem; }
.page-nav { display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-md); margin-top: var(--space-md); padding: 0; list-style: none; }
.page-nav a { color: var(--colour-brand-text); font-weight: 600; }

/* section headings */
.section-title { font: 700 1.55rem/1.2 var(--font-display); letter-spacing: -.02em; }
.section-intro { color: var(--colour-text-soft); margin-top: var(--space-xs); max-width: 40rem; }

/* card + stat card */
.card { background: var(--colour-surface); border: 1px solid var(--colour-border); border-radius: var(--radius); padding: var(--space-md); }
.stat-grid { display: grid; gap: var(--space-sm); grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr)); margin-top: var(--space-md); }
.stat-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--colour-text-soft); font-weight: 600; }
.stat-value { font: 700 1.9rem/1.1 var(--font-display); letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin-top: var(--space-xs); overflow-wrap: anywhere; }
.stat-value--small { font-size: 1.15rem; line-height: 1.3; }
.stat-note { margin-top: var(--space-xs); font-size: .9rem; color: var(--colour-text-soft); }
.stat-grid--lead { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid--lead .card { grid-column: span 2; }
.card--hero { padding: var(--space-lg) var(--space-md); }
.card--hero .stat-label { font-size: .85rem; }
.card--hero .stat-value { font-size: clamp(3rem, 8vw, 4.5rem); line-height: 1; letter-spacing: -.045em; }
.card--hero .stat-note { max-width: 32ch; }
@media (max-width: 52rem) { .stat-grid--lead { grid-template-columns: minmax(0, 1fr); } .stat-grid--lead .card { grid-column: auto; } }
.card--accent { border-color: var(--colour-accent); background: var(--colour-accent-soft); }

/* tinted statistics section */
.section--tinted { background: var(--colour-surface); border-block: 1px solid var(--colour-border); }
.notes { margin-top: var(--space-lg); padding-top: var(--space-md); border-top: 1px solid var(--colour-border); font-size: .85rem; color: var(--colour-text-soft); max-width: 48rem; }
.notes-title { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 var(--space-xs); color: var(--colour-text); }
.notes ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .25rem; }

/* league table (bar chart) */
.league { list-style: none; padding: 0; margin: var(--space-sm) 0 0; display: grid; gap: .5rem; }
.league-row { display: grid; grid-template-columns: 8.5rem 1fr 3.6rem; align-items: center; gap: var(--space-sm); font-size: .95rem; }
.league-bar { height: .9rem; background: var(--colour-border); border-radius: 999px; overflow: hidden; }
.league-fill { display: block; height: 100%; width: 0; background: var(--colour-bar); border-radius: 999px; transition: width 1.1s cubic-bezier(.2,.8,.2,1); transition-delay: calc(var(--i, 0) * 70ms); }
.is-visible .league-fill { width: var(--w); }
.league-count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* charts */
.chart-grid { display: grid; gap: var(--space-sm); grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); margin-top: var(--space-md); }
.chart-card { margin: 0; }
.chart-card--wide { grid-column: 1 / -1; }
.chart-title { font: 650 1rem/1.3 var(--font-display); letter-spacing: -.01em; margin: 0; }
.chart { margin-top: var(--space-sm); }
.chart-caption { margin-top: var(--space-sm); font-size: .9rem; color: var(--colour-text-soft); }
.section-subtitle { font: 700 1.3rem/1.2 var(--font-display); letter-spacing: -.015em; margin-top: var(--space-lg); }

/* vertical bars */
.vbars { display: flex; gap: .3rem; align-items: stretch; padding-top: 1.3rem; }
.chart-card .league-row { grid-template-columns: 8rem 1fr 3.6rem; }
.vbar { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.vbar-track { width: 100%; height: 11rem; display: flex; align-items: flex-end; border-bottom: 1px solid var(--colour-border); }
.vbar-fill { position: relative; width: 100%; height: 0; background: var(--colour-chart-alt); border-radius: 4px 4px 0 0; transition: height 1s cubic-bezier(.2,.8,.2,1); transition-delay: calc(var(--i, 0) * 45ms); }
.vbar-fill--peak { background: var(--colour-accent); }
.is-visible .vbar-fill { height: var(--h); }
.vbar-value { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .7rem; font-weight: 700; padding-bottom: 2px; opacity: 0; transition: opacity .5s ease; transition-delay: calc(var(--i, 0) * 45ms + .6s); }
.is-visible .vbar-value { opacity: 1; }
.vbar-label { margin-top: .3rem; font-size: .7rem; color: var(--colour-text-soft); white-space: nowrap; }

/* Dense column charts on narrow screens: values read vertically above each bar, labels on alternate columns, counting back from the latest */
@media (max-width: 40rem) {
  .vbars--dense { gap: .2rem; padding-top: 3.4rem; }
  .vbars--dense .vbar-value { writing-mode: vertical-rl; transform: translateX(-50%) rotate(180deg); font-size: .65rem; padding-bottom: 4px; white-space: nowrap; }
  .vbars--dense .vbar-label { font-size: .6rem; visibility: hidden; }
  .vbars--dense .vbar:nth-last-child(odd) .vbar-label { visibility: visible; }
}

/* svg charts */
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg text { fill: var(--colour-text-soft); font: 11px var(--font-body); }
.line-grid { stroke: var(--colour-gridline); stroke-width: 1; }
.line-path { fill: none; stroke: var(--colour-accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 2.4s cubic-bezier(.4,.1,.2,1); }
.is-visible .line-path { stroke-dashoffset: 0; }
.line-area { fill: var(--colour-accent); opacity: 0; transition: opacity 1.2s ease 1.4s; }
.is-visible .line-area { opacity: .14; }
.line-end { opacity: 0; transition: opacity .6s ease 2.3s; }
.is-visible .line-end { opacity: 1; }
.line-end circle { fill: var(--colour-accent); }
.line-end text { fill: var(--colour-text); font-weight: 700; }

/* heatmap */
.heatmap { display: grid; grid-template-columns: 2.6rem repeat(12, 1fr); gap: 3px; align-items: center; }
.heat-head, .heat-year { font-size: .7rem; color: var(--colour-text-soft); text-align: center; }
.heat-year { text-align: right; padding-right: .3rem; }
.heat-cell { aspect-ratio: 1.6 / 1; border-radius: 3px; background: var(--colour-gridline); position: relative; overflow: hidden; }
.heat-cell::after { content: ""; position: absolute; inset: 0; background: var(--colour-accent); opacity: 0; transform: scale(.4); transition: opacity .5s ease, transform .5s cubic-bezier(.2,1.4,.4,1); transition-delay: calc(var(--i, 0) * 7ms); }
.is-visible .heat-cell::after { opacity: var(--o, 0); transform: none; }
.heat-cell--future { background: transparent; border: 1px dashed var(--colour-gridline); }
.heat-legend { display: flex; align-items: center; gap: .4rem; margin-top: var(--space-sm); font-size: .75rem; color: var(--colour-text-soft); }
.heat-legend-bar { width: 7rem; height: .5rem; border-radius: 999px; background: linear-gradient(90deg, var(--colour-gridline), var(--colour-accent)); }

/* clock */
.clock-wedge { fill: var(--colour-chart-alt); transform: scale(0); transition: transform .9s cubic-bezier(.2,1.2,.3,1); transition-delay: calc(var(--i, 0) * 40ms); }
.clock-wedge--peak { fill: var(--colour-accent); }
.is-visible .clock-wedge { transform: scale(1); }
.clock-ring { fill: none; stroke: var(--colour-gridline); stroke-width: 1; }

/* gauge */
.gauge-needle { transform: rotate(-90deg); transform-origin: 120px 120px; transition: transform 2s cubic-bezier(.3,1.5,.5,1) .3s; }
.gauge-needle line { stroke: var(--colour-text); stroke-width: 3; stroke-linecap: round; }
.gauge-needle circle { fill: var(--colour-text); }
svg[aria-label^="Gauge reading"] { display: block; max-width: 34rem; margin-inline: auto; }
.gauge-mood { text-align: center; font: 700 1.2rem/1.25 var(--font-display); letter-spacing: -.015em; margin-top: var(--space-xs); }

/* controls */
.controls { display: grid; gap: var(--space-sm); margin-top: var(--space-md); }
.controls-row { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: end; }
.field { display: grid; gap: .25rem; }
.field label { font-size: .8rem; font-weight: 600; color: var(--colour-text-soft); }
.field input, .field select { font: inherit; padding: .55rem .75rem; border: 1px solid var(--colour-border); border-radius: 8px; background: var(--colour-surface); color: var(--colour-text); min-width: 12rem; }
.field--grow { flex: 1 1 16rem; }
.pill-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { font: inherit; font-size: .9rem; padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--colour-border); background: var(--colour-surface); color: var(--colour-text); cursor: pointer; }
.pill[aria-pressed="true"], .pill[aria-current] { background: var(--colour-brand); border-color: var(--colour-brand); color: var(--colour-brand-text); }
.result-count { color: var(--colour-text-soft); font-size: .95rem; }

/* article list */
.day { display: grid; grid-template-columns: 8.5rem 1fr; gap: var(--space-sm) var(--space-md); padding-block: var(--space-sm); border-top: 1px solid var(--colour-border); }
.day-label { font-size: .95rem; font-weight: 700; color: var(--colour-text-soft); font-variant-numeric: tabular-nums; padding-top: .2rem; }
.entry-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-sm); }
.entry-title { font-weight: 700; font-size: 1.08rem; line-height: 1.3; }
.entry-summary { color: var(--colour-text-soft); margin-top: .2rem; font-size: .95rem; }
.entry-meta { margin-top: .2rem; font-size: .8rem; color: var(--colour-text-soft); }
.empty-state { padding: var(--space-lg) 0; color: var(--colour-text-soft); }

/* footer */
/* COOKIE CONSENT + FOOTER CREDIT */
.page-credit { margin-top: var(--space-xs); }
.link-button { font: inherit; color: var(--colour-link); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }
.consent { position: fixed; z-index: 50; inset: auto var(--space-sm) var(--space-sm) var(--space-sm); max-width: 44rem; margin-inline: auto; padding: var(--space-md); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-md); background: var(--colour-surface); color: var(--colour-text); border: 1px solid var(--colour-border); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); font-size: .9rem; }
.consent[hidden] { display: none; }
.consent-text { flex: 1 1 22rem; margin: 0; }
.consent-actions { display: flex; gap: var(--space-xs); }
.consent-btn { font: inherit; font-weight: 600; padding: .5rem 1.1rem; border-radius: 999px; border: 1px solid var(--colour-border); background: var(--colour-surface); color: var(--colour-text); cursor: pointer; }
.consent-btn--primary { background: var(--colour-text); border-color: var(--colour-text); color: var(--colour-page); }

/* privacy notice modal */
.policy { width: calc(100% - 2rem); max-width: 38rem; max-height: 85vh; padding: 0; overflow: auto; background: var(--colour-surface); color: var(--colour-text); border: 1px solid var(--colour-border); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .35); }
.policy::backdrop { background: rgba(10, 15, 25, .6); }
.policy-inner { padding: var(--space-md) var(--space-lg) var(--space-lg); font-size: .95rem; }
.policy-title { margin: 0 0 var(--space-sm); font-size: 1.4rem; }
.policy-inner p { margin: 0 0 var(--space-sm); }
.policy-inner a { color: var(--colour-link); }
.policy-inner code { font-size: .85em; }
.policy-date { color: var(--colour-text-soft); font-size: .85rem; }

.page-footer { padding-block: var(--space-lg); color: var(--colour-text-soft); font-size: .9rem; border-top: 1px solid var(--colour-border); }

/* ==========================================================================
   5. UTILITIES
   ========================================================================== */
.u-visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.u-mt-md { margin-top: var(--space-md); }
.u-mt-lg { margin-top: var(--space-lg); }
.u-nowrap { white-space: nowrap; }

/* ==========================================================================
   6. MEDIA QUERIES
   ========================================================================== */
@media (max-width: 40rem) {
  .day { grid-template-columns: 1fr; gap: .25rem; }
  .league-row { grid-template-columns: 6.5rem 1fr 3.4rem; }
  .field input, .field select { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .league-fill, .vbar-fill, .vbar-value, .line-path, .line-area, .line-end, .heat-cell::after, .clock-wedge, .gauge-needle { transition: none !important; }
}
@media print {
  .page-header { background: none; color: #000; padding-block: 0; }
  .page-nav, .controls, .section--tinted .chart-grid { display: none; }
  .league-fill, .vbar-fill, .vbar-value, .line-path, .line-area, .line-end, .clock-wedge, .gauge-needle { transition: none !important; }
  .day { break-inside: avoid; }
}

/* ==========================================================================
   DASHBOARD LAYOUT (wide screens). Everything above stays the mobile/tablet layout.
   ========================================================================== */
@media (min-width: 75rem) {
  .section-intro { max-width: 60rem; }

  /* header: title block left, navigation right */
  .page-header .container { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-lg); align-items: end; }
  .page-header .container > * { grid-column: 1; }
  .page-header .page-nav { grid-column: 2; grid-row: 1 / span 3; align-self: end; margin: 0; }

  /* key indicators: four across */
  .stat-grid--lead { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid--lead .card { grid-column: span 1; }

  /* summary: three across, then six on very wide screens */
  #summary-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* charts: two big charts, heat map beside two stacked charts, then four small ones */
  .chart-grid--live { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .chart-grid--live > .chart-card { grid-column: span 3; }
  .chart-grid--live > :nth-child(-n+5) { grid-column: span 6; }
  .chart-grid--live > :nth-child(3) { grid-row: span 2; }

  .notes { max-width: none; }
  .notes ul { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-lg); }
}
@media (min-width: 100rem) {
  #summary-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ==========================================================================
   SERVER-RENDERED ADDITIONS (data tables, year links, breadcrumbs)
   ========================================================================== */
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.data-table caption { text-align: left; font-weight: 600; padding-bottom: var(--space-xs); }
.data-table th, .data-table td { text-align: left; padding: .25rem .5rem; border-bottom: 1px solid var(--colour-border); }
.data-table td:last-child, .data-table th:last-child { text-align: right; }
.data-table--matrix td, .data-table--matrix th { text-align: right; padding-inline: .3rem; }
.data-table--matrix th:first-child, .data-table--matrix td:first-child { text-align: left; }
.table-scroll { overflow-x: auto; }
.pill--link { text-decoration: none; display: inline-block; color: inherit; }
.breadcrumb { font-size: .85rem; margin: 0 0 var(--space-sm); opacity: .85; }
.breadcrumb a { color: inherit; }
.page-meta { font-size: .85rem; opacity: .8; margin-top: var(--space-sm); }
.downloads { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin: var(--space-sm) 0 0; padding: 0; list-style: none; }
