/* Historic-series explainer. Colours live as custom properties so a later React
   port can swap them for the app's tokens without touching the geometry. The
   three source grids keep one colour each throughout the page. */

:root {
  color-scheme: light dark;

  --bg: #fbfaf8;
  --bg-sunk: #f2efe9;
  --ink: #1c1a17;
  --ink-soft: #5d574e;
  --ink-faint: #948b7d;
  --rule: #ddd6ca;

  --c-sn: #1f6f8b;      /* seNorge / KSS, 1 km */
  --c-n3: #9a7b3f;      /* NORA3, 3 km */
  --c-e5: #b0472e;      /* ERA5, 0.25 degrees */
  --c-out: #4d3a8c;     /* the prepared reference */
  --c-site: #1c1a17;
  --c-reject: #a8a096;

  --stage-max: 760px;
  --ease: cubic-bezier(0.4, 0.05, 0.2, 1);
  --dur: 760ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --bg-sunk: #1e1d24;
    --ink: #eeeae4;
    --ink-soft: #b3ada4;
    --ink-faint: #7c7669;
    --rule: #34323c;

    --c-sn: #5fb6d4;
    --c-n3: #d8b160;
    --c-e5: #f08a6c;
    --c-out: #a48ce8;
    --c-site: #eeeae4;
    --c-reject: #6b6459;
  }
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 Lato, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code, pre { font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace; }

/* ------------------------------------------------------------------ masthead */

.masthead {
  max-width: 720px;
  margin: 0 auto;
  padding: 22vh 24px 16vh;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.masthead h1 {
  margin: 0 0 18px;
  font-size: clamp(38px, 7vw, 66px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.standfirst {
  margin: 0 0 14px;
  font-size: 19px;
  color: var(--ink-soft);
  max-width: 56ch;
}

.worked-example {
  margin: 26px 0 0;
  font-size: 15px;
  color: var(--ink-faint);
}

.scroll-hint {
  margin-top: 56px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.scroll-hint::after {
  content: "";
  display: block;
  width: 1px;
  height: 42px;
  margin-top: 10px;
  background: linear-gradient(var(--ink-faint), transparent);
}

/* ------------------------------------------------------------------- scrolly */

.scrolly {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 40px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
  align-items: start;
}

.prose, .stage-wrap, .stage { min-width: 0; }

.part {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.step {
  min-height: 82vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4vh 0;
  opacity: 0.24;
  transition: opacity 420ms var(--ease);
}

.step.is-active { opacity: 1; }

.step h2 {
  margin: 0 0 14px;
  font-size: 27px;
  line-height: 1.18;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.step p { margin: 0 0 14px; color: var(--ink-soft); }
.step p b, .step p b span { color: var(--ink); font-weight: 700; }

.aside {
  border-left: 2px solid var(--rule);
  padding-left: 14px;
  font-size: 14.5px;
}

/* --------------------------------------------------------------------- stage */

.stage-wrap {
  position: sticky;
  top: var(--story-header-height, 72px);
  height: calc(100vh - var(--story-header-height, 72px));
  height: calc(100svh - var(--story-header-height, 72px));
  display: flex;
  align-items: center;
}

.stage { width: 100%; max-width: var(--stage-max); }

/* Clipped, not visible: an ERA5 cell is wider than the frame, and a rotated
   NORA3 neighbourhood runs past its corners. Every label is inside GEOM. */
#stage {
  width: 100%;
  height: auto;
  overflow: hidden;
}

.stage-caption {
  margin: 6px 4px 0;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  min-height: 1.4em;
}

/* ------------------------------------------------------------- stage: chips */

.basemap {
  opacity: 0.52;
}

.basemap-attribution-bg {
  fill: var(--bg);
  opacity: 0.84;
}

.basemap-attribution {
  fill: var(--ink-soft);
  font-size: 10px;
}

/* One chip per seNorge 1 km cell: they persist across the map steps so the
   lattice keeps its identity while the frame zooms. */
.chip {
  transition: transform var(--dur) var(--ease), opacity 380ms var(--ease);
  transition-delay: calc(var(--i, 0) * 4ms);
}

.chip rect {
  fill: var(--c-sn);
  stroke: var(--c-sn);
  stroke-opacity: 0.45;
  stroke-width: 0.6;
  transition: width var(--dur) var(--ease), height var(--dur) var(--ease),
    x var(--dur) var(--ease), y var(--dur) var(--ease), fill-opacity 380ms var(--ease);
}

.chip.is-sea rect { fill: var(--c-reject); stroke: var(--c-reject); }
.chip.is-selected rect { stroke: var(--ink); stroke-opacity: 1; stroke-width: 1.6; }

@media (prefers-reduced-motion: reduce) {
  .chip, .chip rect { transition: opacity 1ms linear; transition-delay: 0ms; }
  #marks { transition: none !important; }
}

/* ------------------------------------------------------------- stage: marks */

#marks { transition: opacity 240ms linear; }

.axis { stroke: var(--rule); stroke-width: 1; fill: none; }
.grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; fill: none; }
/* Two daily windows close at different hours, so the temperature frame draws
   both sets of boundaries and distinguishes them by dash. */
.boundary { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 1 5; opacity: 0.6; }
.boundary.is-range { stroke-dasharray: 6 5; opacity: 0.36; }
.scalebar { stroke: var(--ink-faint); stroke-width: 1.2; }
.link { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 3 3; }

text { font-family: Lato, Arial, sans-serif; }
.tick { font-size: 10.5px; fill: var(--ink-faint); font-variant-numeric: tabular-nums; }
.axis-label { font-size: 11px; fill: var(--ink-faint); letter-spacing: 0.05em; }
.panel-title { font-size: 12px; fill: var(--ink-soft); letter-spacing: 0.03em; }
.column-head {
  font-size: 10px;
  fill: var(--ink-faint);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.callout { font-size: 12.5px; fill: var(--ink-soft); }
.rho { font-size: 15px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.weight-label { font-size: 12px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.legend-text { font-size: 11.5px; fill: var(--ink-soft); }

/* map cells that are not axis-aligned on this frame */
.cell-n3 { fill: none; stroke: var(--c-n3); stroke-width: 1; opacity: 0.75; }
.cell-n3.is-chosen { fill: var(--c-n3); fill-opacity: 0.18; stroke-width: 2; opacity: 1; }
.cell-n3-centre { fill: var(--c-n3); }
.cell-e5 { fill: var(--c-e5); stroke: var(--c-e5); stroke-width: 1.4; }
.cell-e5-centre { fill: var(--c-e5); }
.cell-selected { fill: none; stroke: var(--ink); stroke-width: 1.8; }
.site { fill: var(--c-site); }
.site-halo { fill: none; stroke: var(--c-site); stroke-width: 1; opacity: 0.4; }

.row-band { fill: var(--bg-sunk); }
.row-label { font-size: 13px; fill: var(--ink); }
.row-label.mono, .row-value.mono {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}
.row-value { font-size: 12.5px; fill: var(--ink-soft); }
.row-value.dim, .dim { fill: var(--ink-faint); }
.row-value.ok, .ok { fill: var(--c-sn); font-weight: 700; }
.row-value.bad, .bad { fill: var(--c-e5); font-weight: 700; }

.trace { fill: none; stroke-width: 1.6; }
.trace.faded { opacity: 0.5; }
.trace.ghosted { opacity: 0.32; stroke-width: 1.2; }
/* The template and the corrected series coincide on most hours; drawing the
   template as a wide halo keeps it visible underneath rather than hidden. */
.trace.halo { opacity: 0.32; stroke-width: 4.5; stroke-linecap: round; }
.trace.s-sn { stroke: var(--c-sn); }
.trace.s-n3 { stroke: var(--c-n3); }
.trace.s-e5 { stroke: var(--c-e5); }
.trace.s-out { stroke: var(--c-out); stroke-width: 1.9; }
.validation-question { fill: var(--ink); font-size: 17px; font-weight: 700; }
.trace.envelope-cs { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 4 3; }
.trace.envelope-toa { stroke: var(--rule); stroke-width: 1; }

.level { stroke-width: 2; }
.level.s-sn { stroke: var(--c-sn); }
.level.s-n3 { stroke: var(--c-n3); }
.level.s-e5 { stroke: var(--c-e5); }

.target { stroke-width: 1.4; stroke-dasharray: 5 3; }
.target.raw { stroke: var(--ink-faint); opacity: 0.55; }
.target.s-sn { stroke: var(--c-sn); }
.target.s-sn.strong { stroke-width: 2.4; stroke-dasharray: none; }

.swatch { rx: 2; }
.swatch.sw-sn { fill: var(--c-sn); }
/* Matches the dashed TN/TX step lines rather than the solid TG one. */
.swatch.sw-sn-dash {
  fill: none;
  stroke: var(--c-sn);
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
}
.swatch.sw-n3 { fill: var(--c-n3); }
.swatch.sw-e5 { fill: var(--c-e5); }
.swatch.sw-out { fill: var(--c-out); }
.swatch.sw-cs { fill: var(--ink-faint); }
.swatch.sw-toa { fill: var(--rule); }

/* prose accents, one per source grid */
.s-sn, .s-sn-ink { color: var(--c-sn); }
.s-n3, .s-n3-ink { color: var(--c-n3); }
.s-e5, .s-e5-ink { color: var(--c-e5); }
.s-out { color: var(--c-out); }

text.s-sn, text.s-sn-ink { fill: var(--c-sn); }
text.s-n3, text.s-n3-ink { fill: var(--c-n3); }
text.s-e5, text.s-e5-ink { fill: var(--c-e5); }
text.s-out { fill: var(--c-out); }

/* ----------------------------------------------------------------- colophon */

.colophon {
  max-width: 720px;
  margin: 12vh auto 0;
  padding: 32px 24px 18vh;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 14px;
}

.colophon h2 {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}

.colophon dl {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 6px 16px;
  margin: 0 0 22px;
}

.colophon dt { color: var(--ink-faint); font-size: 12.5px; }
.colophon dd {
  margin: 0;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  word-break: break-all;
}

/* ------------------------------------------------------------------ narrow */

@media (max-width: 900px) {
  .scrolly { grid-template-columns: 1fr; gap: 0; }
  .stage-wrap {
    grid-row: 1;
    height: calc(56vh - var(--story-header-height, 72px));
    top: var(--story-header-height, 72px);
    background: var(--bg);
    z-index: 2;
    border-bottom: 1px solid var(--rule);
  }
  .prose { grid-row: 2; }
  .step { min-height: 78vh; }
  .masthead { padding: 14vh 24px 8vh; }
  .masthead h1 { font-size: clamp(36px, 11vw, 54px); }
}
