/* ==========================================================================
   qDDC project website - single shared stylesheet
   MOBILE-FIRST: base rules target phones; wider layouts are added with
   min-width media queries (600px, 860px, 1100px).
   Academic but techy: dark-first, serif prose, monospace labels/numbers.
   No external fonts or scripts: the site is fully self-contained.
   ========================================================================== */

/* ---------- Design tokens ------------------------------------------------ */
:root {
  color-scheme: dark light;

  --bg: #0b0f14;
  --bg-elev: #111823;
  --bg-elev-2: #172131;
  --line: #243044;
  --line-soft: #1a2434;
  --text: #d8e0ec;
  --text-strong: #f1f5fb;
  --muted: #8a9ab0;

  --accent: #5ee0d2;          /* primary accent: teal */
  --accent-dim: rgba(94, 224, 210, 0.12);
  --on-accent: #04110f;
  --pid: #f5b455;             /* classical baseline: amber */
  --off: #5ee0d2;             /* off-policy family: teal */
  --on: #a98bff;              /* on-policy family: violet */
  --warn: #ff8a7a;
  --warn-dim: rgba(245, 180, 85, 0.1);

  --font-body: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --wrap: 1080px;
  --prose: 70ch;
  --gutter: 16px;
  --tap: 44px;                /* minimum touch-target size */
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fb;
    --bg-elev: #ffffff;
    --bg-elev-2: #eef2f8;
    --line: #d3dbe8;
    --line-soft: #e4e9f2;
    --text: #1c2633;
    --text-strong: #0a121d;
    --muted: #55657c;
    --accent: #07796f;
    --accent-dim: rgba(7, 121, 111, 0.09);
    --on-accent: #ffffff;
    --pid: #a8650a;
    --off: #07796f;
    --on: #6a45d6;
    --warn: #b3362a;
    --warn-dim: rgba(168, 101, 10, 0.1);
  }
}

/* ---------- Base (phone) ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  /* faint engineering-paper grid */
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 36px 36px;
}

img, svg, video { max-width: 100%; height: auto; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--text-strong); }
a:focus-visible, summary:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

h1, h2, h3, h4 {
  font-family: var(--font-ui);
  color: var(--text-strong);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.6rem, 7.2vw, 3rem); margin: 0 0 0.5em; }
h2 { font-size: 1.4rem; margin: 0 0 0.6em; }
h3 { font-size: 1.1rem; margin: 1.6em 0 0.5em; }
h4 { font-size: 1rem; margin: 1.2em 0 0.4em; }

p { margin: 0 0 1em; }
ul, ol { padding-left: 1.25em; margin: 0 0 1em; }
li { margin-bottom: 0.35em; }

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05em 0.4em;
}

.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 14px; border-radius: 6px; font-family: var(--font-ui); z-index: 100;
}
.skip-link:focus { left: 8px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.prose { max-width: var(--prose); }
.muted { color: var(--muted); }

/* ---------- Header / nav (compact, single row on phones) ----------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.brand {
  font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.04em;
  color: var(--text-strong); text-decoration: none; font-size: 1.05rem;
  min-height: var(--tap); display: inline-flex; align-items: center;
}
.brand .brand-full { display: none; color: var(--accent); font-weight: 400; letter-spacing: 0; }
@media (min-width: 900px) { .brand .brand-full { display: inline; } }
.site-header nav { min-width: 0; }
.nav {
  display: flex; flex-wrap: nowrap; gap: 0; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav li { margin: 0; flex: none; }
.nav a {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 9px;
  font-family: var(--font-ui); font-size: 0.85rem; color: var(--muted); text-decoration: none;
  border-radius: 6px;
}
.nav a:hover { color: var(--text-strong); background: var(--bg-elev-2); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-dim); }

/* ---------- Hero --------------------------------------------------------- */
.hero { padding: 36px 0 28px; border-bottom: 1px solid var(--line); }
.hero-text { max-width: 820px; }
.hero-video { margin: 28px 0 0; }
.hero-video-frame {
  position: relative; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.hero-video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; background: transparent; object-fit: contain; }

.eyebrow {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 12px;
}
.lede { font-size: 1.08rem; color: var(--text); max-width: 60ch; }

.authors { display: grid; gap: 10px; margin: 20px 0 6px; padding: 0; list-style: none; }
.authors li { margin: 0; font-family: var(--font-ui); }
.authors strong { display: block; color: var(--text-strong); }
.authors span { display: block; font-size: 0.82rem; color: var(--muted); font-family: var(--font-mono); line-height: 1.5; }

.supervisor { margin: 14px 0 0; font-family: var(--font-ui); font-size: 0.9rem; color: var(--muted); }
.supervisor strong { color: var(--text-strong); }

.btn-row { display: grid; gap: 10px; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: var(--tap); padding: 8px 18px; border-radius: 8px;
  font-family: var(--font-ui); font-weight: 600; font-size: 0.95rem; text-decoration: none;
  border: 1px solid var(--line); color: var(--text-strong); background: var(--bg-elev);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { background: transparent; color: var(--accent); }

/* ---------- Sections ----------------------------------------------------- */
section { padding: 40px 0; border-bottom: 1px solid var(--line-soft); }
section:last-of-type { border-bottom: 0; }
.section-label {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 6px;
}
.section-label::before { content: "// "; color: var(--accent); }
.section-intro { color: var(--muted); max-width: var(--prose); }

/* ---------- Cards & grids (1 column on phones) --------------------------- */
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }  /* stat tiles: 2-up on phones */

.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.stat { padding: 14px; }
.stat .num {
  font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700;
  color: var(--accent); line-height: 1.15; display: block; overflow-wrap: anywhere;
}
.stat .lbl { font-family: var(--font-ui); font-size: 0.8rem; color: var(--muted); line-height: 1.4; display: block; margin-top: 4px; }

/* long stat values (e.g. "p = 0.0039"): size to the card width so they never wrap mid-number */
.stat { container-type: inline-size; }
.stat .num.num-sm { font-size: 1.15rem; white-space: nowrap; }
@supports (width: 1cqw) {
  .stat .num.num-sm { font-size: clamp(1rem, 14.5cqw, 2.1rem); }
}

.card-link { text-decoration: none; color: inherit; display: block; transition: border-color 0.15s, transform 0.15s; }
.card-link:hover { border-color: var(--accent); transform: translateY(-2px); color: inherit; }
.card-link .more { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); }

.pill {
  display: inline-block; font-family: var(--font-mono); font-size: 0.74rem;
  padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor;
  margin: 0 6px 6px 0; letter-spacing: 0.03em;
}
.pill-off { color: var(--off); }
.pill-on { color: var(--on); }
.pill-pid { color: var(--pid); }
.pill-neutral { color: var(--muted); }

/* ---------- Process pipeline -------------------------------------------- */
.pipeline { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.pipeline li {
  margin: 0; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; counter-increment: step;
}
.pipeline li::before {
  content: "0" counter(step); font-family: var(--font-mono); color: var(--accent);
  font-size: 0.8rem; display: block; margin-bottom: 4px;
}
.pipeline h3 { margin: 0 0 4px; font-size: 1rem; }
.pipeline p { margin: 0; font-size: 0.92rem; color: var(--muted); }

/* ---------- Tables (scroll sideways inside a wrapper, sticky 1st column) - */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 1.2em 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-elev);
  /* edge shadows hint that the table scrolls */
  background-image:
    linear-gradient(to right, var(--bg-elev) 30%, transparent),
    linear-gradient(to left, var(--bg-elev) 30%, transparent),
    linear-gradient(to right, rgba(0,0,0,0.35), transparent),
    linear-gradient(to left, rgba(0,0,0,0.35), transparent);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 28px 100%, 28px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}
table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 0.85rem; }
caption {
  caption-side: top; text-align: left; padding: 12px 14px; color: var(--muted);
  font-size: 0.82rem; border-bottom: 1px solid var(--line); line-height: 1.45;
}
caption strong { color: var(--text-strong); }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; background: var(--bg-elev-2); }
tbody th[scope="row"] {
  font-weight: 600; color: var(--text-strong);
  position: sticky; left: 0; background: var(--bg-elev); z-index: 1;
}
thead th:first-child { position: sticky; left: 0; z-index: 2; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tr.group th { background: var(--bg-elev-2); color: var(--accent); font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; position: static; }
td.wrap-cell, th.wrap-cell { white-space: normal; min-width: 220px; }
.best { color: var(--accent); font-weight: 700; }
.bad { color: var(--warn); }
.table-note { font-size: 0.82rem; color: var(--muted); font-family: var(--font-ui); }

/* ---------- Horizontal bar chart (CSS only) ------------------------------ */
.bars { margin: 0 0 1em; padding: 0; list-style: none; font-family: var(--font-ui); }
.bars li { display: grid; grid-template-columns: 76px minmax(0, 1fr) 52px; gap: 8px; align-items: center; margin: 0 0 10px; }
.bars .name { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-strong); }
.bars .track { height: 14px; background: var(--bg-elev-2); border-radius: 4px; overflow: hidden; }
.bars .fill { display: block; height: 100%; width: var(--v); border-radius: 4px; background: var(--c, var(--accent)); }
.bars .val { font-family: var(--font-mono); font-size: 0.8rem; text-align: right; color: var(--muted); }
.bars .fill-pid { --c: var(--pid); }
.bars .fill-off { --c: var(--off); }
.bars .fill-on { --c: var(--on); }

/* ---------- Figures, media, placeholders -------------------------------- */
figure { margin: 1.4em 0; }
figcaption { font-family: var(--font-ui); font-size: 0.85rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }
figcaption strong { color: var(--text-strong); }
figure img, figure video { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #000; }

.placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 180px; padding: 16px; border: 1px dashed var(--line); border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, transparent 0 12px, var(--bg-elev) 12px 24px);
  color: var(--muted); font-family: var(--font-mono); font-size: 0.78rem;
}
.placeholder strong { display: block; color: var(--text); margin-bottom: 4px; overflow-wrap: anywhere; }

/* figures: white-background plots sit in a clean frame; capped so they stay readable */
.fig { max-width: 900px; }
.fig-sq { max-width: 640px; }
figure.fig img { background: #fff; }
.fig-link { display: block; }
.fig-link:focus-visible { outline-offset: 4px; }

/* ---------- Callouts, equations, definition lists ------------------------ */
.callout {
  border-left: 3px solid var(--accent); background: var(--accent-dim);
  padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.4em 0;
  font-family: var(--font-ui); font-size: 0.92rem;
}
.callout.warn { border-left-color: var(--pid); background: var(--warn-dim); }
.callout > :last-child { margin-bottom: 0; }

.eq {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 12px; margin: 1.2em 0; overflow-x: auto; text-align: center; font-size: 1rem;
}

.rq { margin: 0 0 12px; padding: 14px 16px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); }
.rq b { font-family: var(--font-mono); color: var(--accent); margin-right: 6px; }

dl.facts { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; font-family: var(--font-ui); font-size: 0.93rem; }
dl.facts dt { color: var(--muted); font-family: var(--font-mono); font-size: 0.78rem; padding-top: 2px; }
dl.facts dd { margin: 0 0 10px; }

details { margin: 1.2em 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); }
details > summary { cursor: pointer; padding: 12px 16px; min-height: var(--tap); font-family: var(--font-ui); font-weight: 600; color: var(--text-strong); }
details[open] > summary { border-bottom: 1px solid var(--line); }
details > .details-body { padding: 4px 12px 12px; }
details .table-wrap { margin: 0.6em 0; }

/* ---------- Documents page ---------------------------------------------- */
.doc-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.doc {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: center; margin: 0;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.doc .btn { grid-column: 1 / -1; }
.doc .ext {
  font-family: var(--font-mono); font-weight: 700; font-size: 0.74rem; text-align: center;
  padding: 10px 0; border-radius: 8px; border: 1px solid var(--line); color: var(--accent); background: var(--accent-dim);
}
.doc h3 { margin: 0 0 2px; font-size: 1rem; }
.doc p { margin: 0; font-size: 0.88rem; color: var(--muted); font-family: var(--font-ui); }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.toc li { margin: 0; }
.toc a {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-family: var(--font-ui); font-size: 0.9rem;
}
.toc a:hover { border-color: var(--accent); }

/* ---------- Page footer / pager ----------------------------------------- */
.pager { display: grid; gap: 10px; }
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-family: var(--font-ui); font-size: 0.85rem; background: var(--bg); }
.site-footer .wrap { display: grid; gap: 8px; }
.site-footer p { margin: 0; }

/* ==========================================================================
   >= 600px  (large phones landscape / small tablets)
   ========================================================================== */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  body { font-size: 1.0625rem; }
  h2 { font-size: 1.6rem; }
  section { padding: 52px 0; }
  .hero { padding: 52px 0 36px; }

  .btn-row { display: flex; flex-wrap: wrap; }
  .authors { display: flex; flex-wrap: wrap; gap: 8px 28px; }
  .pager { display: flex; justify-content: space-between; flex-wrap: wrap; }
  .site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 32px; }

  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { gap: 16px; }
  .card { padding: 20px 22px; }
  .stat { padding: 18px 20px; }
  .stat .num { font-size: 1.8rem; }
  .stat .lbl { font-size: 0.88rem; }

  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  table { font-size: 0.9rem; }
  th, td { padding: 9px 14px; }
  .bars li { grid-template-columns: 100px minmax(0, 1fr) 60px; gap: 12px; }

  dl.facts { grid-template-columns: max-content 1fr; gap: 6px 22px; }
  dl.facts dd { margin: 0; }

  .doc { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; padding: 14px 18px; }
  .doc .btn { grid-column: auto; }
  .nav a { padding: 0 12px; font-size: 0.92rem; }
}

/* ==========================================================================
   >= 860px  (tablets landscape / laptops)
   ========================================================================== */
@media (min-width: 860px) {
  html { scroll-padding-top: 72px; }
  body { background-attachment: fixed; background-size: 48px 48px; }
  h1 { font-size: 3rem; }
  section { padding: 60px 0; }
  .hero { padding: 64px 0 40px; }
  .lede { font-size: 1.18rem; }

  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat .num { font-size: 2.1rem; }
  .eq { font-size: 1.1rem; padding: 16px 20px; }
  .placeholder { min-height: 220px; font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card-link { transition: none; }
  .card-link:hover { transform: none; }
}

@media print {
  .site-header, .btn-row, .skip-link { display: none; }
  body { background: #fff; color: #000; }
}

/* wx:begin (generated by tools/gen_wind.py: edit EPISODES there, not here) */
/* ==========================================================================
   Wind visualiser (.wx): pure CSS animation, one 20 s loop per episode.
   Keyframe percentages are time / 20 s. Episodes are chosen with hidden radio
   buttons (#wx-ep1..3) and the general-sibling combinator, so no scripts.
   All text is HTML (.wx-lab) so it stays small and in the site's mono face.
   ========================================================================== */
.wx { margin: 1.4em 0; max-width: 640px; }

.wx-body {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.wx-body svg { display: block; width: 100%; height: auto; }
.wx-scene-wrap, .wx-chart { position: relative; }
.wx-chart { border-top: 1px solid var(--line-soft); }

/* text: same small mono as the section labels */
.wx-lab {
  position: absolute; font-family: var(--font-mono); font-size: 0.68rem; line-height: 1;
  letter-spacing: 0.02em; color: var(--muted); white-space: nowrap; pointer-events: none;
}
.wx-hud, .wx-hud .wx-ep, .wx-glabels { position: absolute; inset: 0; pointer-events: none; }
.wx-lab-l { left: 3%; top: 8px; }
.wx-lab-r { right: 3%; top: 8px; color: var(--pid); }
.wx-axis-title { left: 9%; top: 4px; }
.wx-ytick { right: 91.5%; transform: translateY(-50%); }
.wx-xtick { bottom: 3px; transform: translateX(-50%); }
.wx-xtick:last-of-type { transform: translateX(-100%); }
.wx-glab { color: var(--pid); transform: translate(-50%, -135%); }

.wx-ring { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.8; }
.wx-cross { stroke: var(--muted); stroke-width: 1; fill: none; opacity: 0.8; }

/* wind streaks */
.wx-flow-base line, .wx-flow-gust line { stroke: var(--pid); stroke-linecap: round; }
.wx-flow-base line { stroke-width: 1.2; stroke-dasharray: 6 12; opacity: 0.35; animation: wx-flow 1.1s linear infinite; }
.wx-flow-gust line { stroke-width: 2; stroke-dasharray: 10 10; animation: wx-flow-fast 0.6s linear infinite; }
.wx-flow-gust { opacity: 0; }
@keyframes wx-flow      { to { stroke-dashoffset: -18; } }
@keyframes wx-flow-fast { to { stroke-dashoffset: -20; } }

/* drone: thin schematic line drawing */
.wx-arm { stroke: var(--text-strong); stroke-width: 1.6; stroke-linecap: round; fill: none; }
.wx-rotor { stroke: var(--accent); stroke-width: 1.2; fill: var(--accent-dim); }
.wx-body-rect { stroke: var(--text-strong); stroke-width: 1.6; fill: var(--bg-elev); }
.wx-drone { transform-box: fill-box; transform-origin: 50% 70%; }

/* force read-out: exactly one is visible at a time */
.wx-readout { opacity: 0; }

/* force-vs-time chart */
.wx-grid line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.wx-axis { stroke: var(--muted); stroke-width: 1; }
.wx-area { fill: color-mix(in srgb, var(--pid) 16%, transparent); }
.wx-line { fill: none; stroke: var(--pid); stroke-width: 1.8; stroke-linejoin: round; }

/* HTML overlays: the plot spans 9 % to 97 % of the chart width */
.wx-cover {
  position: absolute; top: 14%; bottom: 16%; left: 9%; right: 0;
  background: color-mix(in srgb, var(--bg-elev) 72%, transparent);
  pointer-events: none;
}
.wx-ph {
  position: absolute; top: 14%; bottom: 16%; left: 9%; width: 1px;
  background: var(--accent); pointer-events: none;
}

/* episode switching: only the selected episode's groups are shown */
.wx-ep { display: none; }
.wx-radio, .wx-pause-input { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* controls */
.wx-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.wx-tab, .wx-pause-label {
  display: inline-flex; flex-direction: column; justify-content: center; min-height: var(--tap);
  padding: 4px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-elev);
  cursor: pointer; font-family: var(--font-ui); color: var(--text-strong);
}
.wx-tab strong { font-size: 0.9rem; line-height: 1.2; }
.wx-tab span { font-size: 0.7rem; color: var(--muted); line-height: 1.2; }
.wx-pause-label { margin-left: auto; font-size: 0.88rem; font-weight: 600; flex-direction: row; align-items: center; }
.wx-tab:hover, .wx-pause-label:hover { border-color: var(--accent); }
.when-paused { display: none; }
.wx-pause-input:checked ~ .wx-controls .when-playing { display: none; }
.wx-pause-input:checked ~ .wx-controls .when-paused { display: inline; }
.wx-pause-input:checked ~ .wx-body,
.wx-pause-input:checked ~ .wx-body * { animation-play-state: paused !important; }
.wx-pause-input:focus-visible ~ .wx-controls .wx-pause-label { outline: 2px solid var(--accent); outline-offset: 3px; }

.wx-tables { margin-top: 12px; }
.wx-tables .wx-ep { margin-top: 0; }


/* ---- Episode A ---- */
@keyframes wx-drone-1 { 0% { transform: translateX(4px) rotate(3deg) } 24.5% { transform: translateX(4px) rotate(3deg) } 27% { transform: translateX(20px) rotate(12deg) } 33% { transform: translateX(4px) rotate(3deg) } 50.5% { transform: translateX(4px) rotate(3deg) } 53% { transform: translateX(25px) rotate(14deg) } 55.5% { transform: translateX(4px) rotate(3deg) } 73.5% { transform: translateX(4px) rotate(3deg) } 76% { transform: translateX(14px) rotate(8deg) } 84% { transform: translateX(4px) rotate(3deg) } 100% { transform: translateX(4px) rotate(3deg) } }
@keyframes wx-gust-1 { 0% { opacity: 0 } 24.5% { opacity: 0 } 25.5% { opacity: 0.94 } 31.5% { opacity: 0.94 } 32.5% { opacity: 0 } 50.5% { opacity: 0 } 51.5% { opacity: 1 } 54% { opacity: 1 } 55% { opacity: 0 } 73.5% { opacity: 0 } 74.5% { opacity: 0.72 } 82.5% { opacity: 0.72 } 83.5% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-1-0 { 0% { opacity: 1 } 24.5% { opacity: 1 } 25.5% { opacity: 0 } 31.5% { opacity: 0 } 32.5% { opacity: 1 } 50.5% { opacity: 1 } 51.5% { opacity: 0 } 54% { opacity: 0 } 55% { opacity: 1 } 73.5% { opacity: 1 } 74.5% { opacity: 0 } 82.5% { opacity: 0 } 83.5% { opacity: 1 } 100% { opacity: 1 } }
@keyframes wx-rd-1-1 { 0% { opacity: 0 } 24.5% { opacity: 0 } 25.5% { opacity: 1 } 31.5% { opacity: 1 } 32.5% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-1-2 { 0% { opacity: 0 } 50.5% { opacity: 0 } 51.5% { opacity: 1 } 54% { opacity: 1 } 55% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-1-3 { 0% { opacity: 0 } 73.5% { opacity: 0 } 74.5% { opacity: 1 } 82.5% { opacity: 1 } 83.5% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-sweep-1 { 0% { left: 9% } 100% { left: 97% } }
@keyframes wx-ph-1 { 0% { left: 9% } 100% { left: 97% } }
#wx-ep1:checked ~ .wx-body .wx-ep1, #wx-ep1:checked ~ .wx-tables .wx-ep1 { display: block; }
#wx-ep1:checked ~ .wx-body svg .wx-ep1 { display: inline; }
#wx-ep1:checked ~ .wx-body .wx-drone { animation: wx-drone-1 20s ease-in-out infinite; }
#wx-ep1:checked ~ .wx-body .wx-flow-gust { animation: wx-gust-1 20s linear infinite; }
#wx-ep1:checked ~ .wx-body .wx-cover { animation: wx-sweep-1 20s linear infinite; }
#wx-ep1:checked ~ .wx-body .wx-ph { animation: wx-ph-1 20s linear infinite; }
#wx-ep1:checked ~ .wx-body .wx-rd-1-0 { animation: wx-rd-1-0 20s linear infinite; }
#wx-ep1:checked ~ .wx-body .wx-rd-1-1 { animation: wx-rd-1-1 20s linear infinite; }
#wx-ep1:checked ~ .wx-body .wx-rd-1-2 { animation: wx-rd-1-2 20s linear infinite; }
#wx-ep1:checked ~ .wx-body .wx-rd-1-3 { animation: wx-rd-1-3 20s linear infinite; }
#wx-ep1:checked ~ .wx-controls label[for="wx-ep1"] { border-color: var(--accent); background: var(--accent-dim); }
#wx-ep1:focus-visible ~ .wx-controls label[for="wx-ep1"] { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---- Episode B ---- */
@keyframes wx-drone-2 { 0% { transform: translateX(-4px) rotate(-3deg) } 24.5% { transform: translateX(-4px) rotate(-3deg) } 27% { transform: translateX(-24px) rotate(-14deg) } 30.5% { transform: translateX(-4px) rotate(-3deg) } 51% { transform: translateX(-4px) rotate(-3deg) } 53.5% { transform: translateX(-16px) rotate(-9deg) } 62% { transform: translateX(-4px) rotate(-3deg) } 77% { transform: translateX(-4px) rotate(-3deg) } 79.5% { transform: translateX(-19px) rotate(-11deg) } 84.5% { transform: translateX(-4px) rotate(-3deg) } 100% { transform: translateX(-4px) rotate(-3deg) } }
@keyframes wx-gust-2 { 0% { opacity: 0 } 24.5% { opacity: 0 } 25.5% { opacity: 1 } 29% { opacity: 1 } 30% { opacity: 0 } 51% { opacity: 0 } 52% { opacity: 0.78 } 60.5% { opacity: 0.78 } 61.5% { opacity: 0 } 77% { opacity: 0 } 78% { opacity: 0.89 } 83% { opacity: 0.89 } 84% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-2-0 { 0% { opacity: 1 } 24.5% { opacity: 1 } 25.5% { opacity: 0 } 29% { opacity: 0 } 30% { opacity: 1 } 51% { opacity: 1 } 52% { opacity: 0 } 60.5% { opacity: 0 } 61.5% { opacity: 1 } 77% { opacity: 1 } 78% { opacity: 0 } 83% { opacity: 0 } 84% { opacity: 1 } 100% { opacity: 1 } }
@keyframes wx-rd-2-1 { 0% { opacity: 0 } 24.5% { opacity: 0 } 25.5% { opacity: 1 } 29% { opacity: 1 } 30% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-2-2 { 0% { opacity: 0 } 51% { opacity: 0 } 52% { opacity: 1 } 60.5% { opacity: 1 } 61.5% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-2-3 { 0% { opacity: 0 } 77% { opacity: 0 } 78% { opacity: 1 } 83% { opacity: 1 } 84% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-sweep-2 { 0% { left: 9% } 100% { left: 97% } }
@keyframes wx-ph-2 { 0% { left: 9% } 100% { left: 97% } }
#wx-ep2:checked ~ .wx-body .wx-ep2, #wx-ep2:checked ~ .wx-tables .wx-ep2 { display: block; }
#wx-ep2:checked ~ .wx-body svg .wx-ep2 { display: inline; }
#wx-ep2:checked ~ .wx-body .wx-drone { animation: wx-drone-2 20s ease-in-out infinite; }
#wx-ep2:checked ~ .wx-body .wx-flow-gust { animation: wx-gust-2 20s linear infinite; }
#wx-ep2:checked ~ .wx-body .wx-cover { animation: wx-sweep-2 20s linear infinite; }
#wx-ep2:checked ~ .wx-body .wx-ph { animation: wx-ph-2 20s linear infinite; }
#wx-ep2:checked ~ .wx-body .wx-rd-2-0 { animation: wx-rd-2-0 20s linear infinite; }
#wx-ep2:checked ~ .wx-body .wx-rd-2-1 { animation: wx-rd-2-1 20s linear infinite; }
#wx-ep2:checked ~ .wx-body .wx-rd-2-2 { animation: wx-rd-2-2 20s linear infinite; }
#wx-ep2:checked ~ .wx-body .wx-rd-2-3 { animation: wx-rd-2-3 20s linear infinite; }
#wx-ep2:checked ~ .wx-body .wx-flow-base line, #wx-ep2:checked ~ .wx-body .wx-flow-gust line { animation-direction: reverse; }
#wx-ep2:checked ~ .wx-controls label[for="wx-ep2"] { border-color: var(--accent); background: var(--accent-dim); }
#wx-ep2:focus-visible ~ .wx-controls label[for="wx-ep2"] { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---- Episode C ---- */
@keyframes wx-drone-3 { 0% { transform: translateX(4px) rotate(3deg) } 24.5% { transform: translateX(4px) rotate(3deg) } 27% { transform: translateX(16px) rotate(10deg) } 29% { transform: translateX(4px) rotate(3deg) } 43.5% { transform: translateX(4px) rotate(3deg) } 46% { transform: translateX(22px) rotate(13deg) } 52.5% { transform: translateX(4px) rotate(3deg) } 69% { transform: translateX(4px) rotate(3deg) } 71.5% { transform: translateX(13px) rotate(8deg) } 74.5% { transform: translateX(4px) rotate(3deg) } 93.5% { transform: translateX(4px) rotate(3deg) } 96% { transform: translateX(25px) rotate(15deg) } 100% { transform: translateX(4px) rotate(3deg) } 100% { transform: translateX(4px) rotate(3deg) } }
@keyframes wx-gust-3 { 0% { opacity: 0 } 24.5% { opacity: 0 } 25.5% { opacity: 0.8 } 27.5% { opacity: 0.8 } 28.5% { opacity: 0 } 43.5% { opacity: 0 } 44.5% { opacity: 0.99 } 51% { opacity: 0.99 } 52% { opacity: 0 } 69% { opacity: 0 } 70% { opacity: 0.69 } 73% { opacity: 0.69 } 74% { opacity: 0 } 93.5% { opacity: 0 } 94.5% { opacity: 1 } 99% { opacity: 1 } 100% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-3-0 { 0% { opacity: 1 } 24.5% { opacity: 1 } 25.5% { opacity: 0 } 27.5% { opacity: 0 } 28.5% { opacity: 1 } 43.5% { opacity: 1 } 44.5% { opacity: 0 } 51% { opacity: 0 } 52% { opacity: 1 } 69% { opacity: 1 } 70% { opacity: 0 } 73% { opacity: 0 } 74% { opacity: 1 } 93.5% { opacity: 1 } 94.5% { opacity: 0 } 99% { opacity: 0 } 100% { opacity: 1 } 100% { opacity: 1 } }
@keyframes wx-rd-3-1 { 0% { opacity: 0 } 24.5% { opacity: 0 } 25.5% { opacity: 1 } 27.5% { opacity: 1 } 28.5% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-3-2 { 0% { opacity: 0 } 43.5% { opacity: 0 } 44.5% { opacity: 1 } 51% { opacity: 1 } 52% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-3-3 { 0% { opacity: 0 } 69% { opacity: 0 } 70% { opacity: 1 } 73% { opacity: 1 } 74% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-rd-3-4 { 0% { opacity: 0 } 93.5% { opacity: 0 } 94.5% { opacity: 1 } 99% { opacity: 1 } 100% { opacity: 0 } 100% { opacity: 0 } }
@keyframes wx-sweep-3 { 0% { left: 9% } 100% { left: 97% } }
@keyframes wx-ph-3 { 0% { left: 9% } 100% { left: 97% } }
#wx-ep3:checked ~ .wx-body .wx-ep3, #wx-ep3:checked ~ .wx-tables .wx-ep3 { display: block; }
#wx-ep3:checked ~ .wx-body svg .wx-ep3 { display: inline; }
#wx-ep3:checked ~ .wx-body .wx-drone { animation: wx-drone-3 20s ease-in-out infinite; }
#wx-ep3:checked ~ .wx-body .wx-flow-gust { animation: wx-gust-3 20s linear infinite; }
#wx-ep3:checked ~ .wx-body .wx-cover { animation: wx-sweep-3 20s linear infinite; }
#wx-ep3:checked ~ .wx-body .wx-ph { animation: wx-ph-3 20s linear infinite; }
#wx-ep3:checked ~ .wx-body .wx-rd-3-0 { animation: wx-rd-3-0 20s linear infinite; }
#wx-ep3:checked ~ .wx-body .wx-rd-3-1 { animation: wx-rd-3-1 20s linear infinite; }
#wx-ep3:checked ~ .wx-body .wx-rd-3-2 { animation: wx-rd-3-2 20s linear infinite; }
#wx-ep3:checked ~ .wx-body .wx-rd-3-3 { animation: wx-rd-3-3 20s linear infinite; }
#wx-ep3:checked ~ .wx-body .wx-rd-3-4 { animation: wx-rd-3-4 20s linear infinite; }
#wx-ep3:checked ~ .wx-controls label[for="wx-ep3"] { border-color: var(--accent); background: var(--accent-dim); }
#wx-ep3:focus-visible ~ .wx-controls label[for="wx-ep3"] { outline: 2px solid var(--accent); outline-offset: 3px; }

/* reduced motion: calm static chart, no pause control; episodes stay selectable */
@media (prefers-reduced-motion: reduce) {
  .wx-body, .wx-body * { animation: none !important; }
  .wx-cover, .wx-ph, .wx-pause-label { display: none; }
  .wx-flow-gust { opacity: 0; }
  .wx .wx-rd-1-0, .wx .wx-rd-2-0, .wx .wx-rd-3-0 { opacity: 1; }
}
/* wx:end */
