/* Signals-Before-Storms.
   The visual world is inherited, not invented. Every colour below is lifted from
   src/regime_shift/style.py, which validated them with a contrast and colour-vision
   script. The page embeds figures drawn with those exact values, so the container
   agrees with its contents instead of fighting them. */

:root {
  /* from style.py */
  --surface: #fcfcfb;
  --ink: #1c1c1c;
  --ink-soft: #5c5c5c;
  --ink-faint: #8a8a8a;
  --rule: #e4e4e1;
  --series-a: #1a6ca8;
  --series-b: #c8501e;
  --neutral: #37474f;
  /* The lightness-ordered risk ramp, as validated. The values that used to sit here (#e8b84b,
     #d2691e, #8f1d14) are the palette the validator failed: the light end measured 1.80:1
     against the surface, under the 3:1 floor. Regimes are ordinal, so order is lightness. */
  --regime-0: #b8860b;
  --regime-1: #9e4310;
  --regime-2: #6b1210;

  /* derived */
  --ground: var(--surface);
  --plate: var(--surface);
  --plate-edge: var(--rule);
  --link: var(--series-a);

  /* Sign, encoded as the validated pair rather than green against red. Simulate a dichromat and
     #2e7d32 and #c62828 land 1.1 degrees apart in hue: one colour at two lightnesses. These two
     land 166.6 apart. The names are kept because story.html marks up sign in several places. */
  --good: var(--series-a);
  --bad: var(--series-b);

  --measure: 68ch;
  --margin-col: 5.5rem;
  --gap: clamp(1.25rem, 3vw, 2.25rem);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #16171a;
    --ink: #ececea;
    --ink-soft: #b3b2ae;
    --ink-faint: #85847f;
    --rule: #2e3036;
    --link: #7ab8e5;
    /* The line colours are chart ink drawn straight onto the dark page, not onto a plate, so
       they get lighter variants of the same two hues. Hue is what carries the encoding and hue
       is preserved; only lightness moves, which is what the dark ground requires. */
    --series-a: #6aa9d8;
    --series-b: #e8845a;
    --neutral: #9aa7ae;
    /* figures keep their own light surface, so they get a plate rather than the page ground */
    --plate: #fcfcfb;
    --plate-edge: #2e3036;
    /* The swatches are UI chrome on the dark ground, not chart ink: #8f1d14 on #16171a is
       almost invisible. Lightness order is preserved, so the encoding stays ordinal. The
       figures themselves sit on a light plate and keep the true ramp. */
    --regime-0: #f0cd72;
    --regime-1: #e08343;
    --regime-2: #cf5344;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-underline-offset: 0.18em;
  text-decoration-thickness: from-font;
}

a:focus-visible,
:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 2px;
}

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

h1, h2, h3 {
  text-wrap: balance;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
}

p { margin: 0 0 1.1em; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

strong { font-weight: 650; color: var(--ink); }

code, .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.94em;
}

/* ---- page frame: a ruled log ---------------------------------------------- */

.log {
  max-width: 78rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1.15rem, 4vw, 3rem) 0;
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: baseline;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

.masthead__id { color: var(--ink-soft); font-weight: 600; }
.masthead__meta { font-family: var(--mono); }

/* ---- cover ---------------------------------------------------------------- */

.cover {
  display: grid;
  gap: var(--gap) clamp(2rem, 5vw, 4rem);
  grid-template-columns: 1fr;
  padding: clamp(1.75rem, 4vw, 3rem) 0 clamp(2rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}

@media (min-width: 62rem) {
  .cover { grid-template-columns: minmax(28ch, 42ch) 1fr; align-items: start; }
}

.cover h1 {
  font-size: clamp(2.05rem, 1.25rem + 3.1vw, 3rem);
  font-weight: 680;
  letter-spacing: -0.03em;
  margin-bottom: 1.1rem;
}

.cover h1 .quiet {
  display: block;
  font-size: 0.42em;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--ink-soft);
  margin-top: 0.7rem;
  line-height: 1.45;
}

.verdict {
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 1.15rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--bad);
  max-width: 52ch;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem 0.75rem; align-items: center; }

.action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.62rem 1.05rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 550;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}

.action:hover { border-color: var(--ink-faint); }

.action--primary {
  background: var(--link);
  border-color: var(--link);
  color: #fcfcfb;
}

.action--primary:hover { background: #15578a; border-color: #15578a; }

@media (prefers-color-scheme: dark) {
  .action--primary { color: #16171a; }
  .action--primary:hover { background: #a3d0f2; border-color: #a3d0f2; }
}

.cover__figure { margin: 0; }

/* ---- index of entries ----------------------------------------------------- */
/* The form's own device. A log has a contents page, and it is also the honest answer to
   a reader who has forty seconds rather than five minutes. */







/* ---- entries -------------------------------------------------------------- */

.entry {
  position: relative;
  padding: clamp(2.5rem, 6vw, 4rem) 0;
  border-bottom: 1px solid var(--rule);
}

@media (min-width: 62rem) {
  .entry { padding-left: var(--margin-col); }
  /* the margin rule: a notebook's ruled edge, and the page's only authored motion */
  .entry::before {
    content: "";
    position: absolute;
    left: calc(var(--margin-col) - 2.25rem);
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--rule);
    transform-origin: top;
  }
}

.entry__no {
  display: block;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  margin-bottom: 0.55rem;
}

@media (min-width: 62rem) {
  .entry__no {
    position: absolute;
    left: 0;
    margin-bottom: 0;
    padding-top: 0.35rem;
  }
  .entry__no::after {
    content: "";
    position: absolute;
    top: 0.95rem;
    right: -2.32rem;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ground);
    box-shadow: inset 0 0 0 1px var(--ink-faint);
  }
}

.entry h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2.05rem);
  font-weight: 640;
  margin-bottom: 0.85rem;
  max-width: 24ch;
}

.entry__lede {
  font-size: 1.075rem;
  color: var(--ink-soft);
  max-width: 60ch;
  margin-bottom: 1.75rem;
}

.entry h3 {
  font-size: 1.02rem;
  font-weight: 640;
  margin: 2rem 0 0.6rem;
}

/* ---- marginal notes ------------------------------------------------------- */

.note {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
  padding-top: 0.7rem;
  margin: 1.75rem 0;
  max-width: 52ch;
}

.note b { color: var(--ink); font-weight: 620; }

/* ---- figures -------------------------------------------------------------- */

.plate { margin: 2rem 0; }


.plate img {
  display: block;
  width: 100%;
  background: var(--plate);
  border: 1px solid var(--plate-edge);
  border-radius: 2px;
}

.plate figcaption {
  margin-top: 0.7rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 66ch;
}

.plate figcaption b { color: var(--ink); font-weight: 620; }

/* ---- tables --------------------------------------------------------------- */

.scroll {
  overflow-x: auto;
  margin: 0 0 1.75rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 34rem;
  font-size: 0.9rem;
}

/* Captions sit OUTSIDE the scroller. A table caption inherits the table's min-width, so on a
   phone it wraps at 544px and half the sentence ends up off screen behind a horizontal scroll.
   The scroll region references these by aria-describedby, so the association survives. */
.table-caption {
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: 66ch;
  margin: 1.75rem 0 0.5rem;
}

th, td {
  text-align: right;
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 13rem; }

thead th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.8125rem;
  position: sticky;
  top: 0;
  background: var(--ground);
}

tbody tr:last-child td { border-bottom: 0; }

/* No best-in-column marking. Several rows tie on max drawdown and Calmar, so a colour
   marker read as "best" would be wrong by inspection, and entry 05 is the reason ranking
   these point estimates means nothing anyway. Benchmarks are distinguished, not scored. */
tr.is-benchmark td { color: var(--ink-soft); }
tr.is-benchmark td:first-child { font-style: italic; }

/* ---- regime keys ---------------------------------------------------------- */

.key { display: inline-flex; align-items: baseline; gap: 0.4rem; white-space: nowrap; }

.key::before {
  content: "";
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 2px;
  background: var(--swatch, var(--ink-faint));
  flex: none;
  transform: translateY(0.02rem);
}

.key--0 { --swatch: var(--regime-0); }
.key--1 { --swatch: var(--regime-1); }
.key--2 { --swatch: var(--regime-2); }

/* ---- the rescue ledger ---------------------------------------------------- */

.ledger { margin: 1.75rem 0 0; display: grid; gap: 1.6rem; }

.ledger > dl {
  display: grid;
  gap: 0.35rem 1.5rem;
  margin: 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

@media (min-width: 48rem) {
  .ledger > dl { grid-template-columns: minmax(11rem, 15rem) 1fr; }
}

.ledger dt { font-weight: 640; }
.ledger dd { margin: 0; color: var(--ink-soft); max-width: 62ch; }
.ledger dd + dd { margin-top: 0.3rem; }
.ledger .criterion { font-size: 0.9rem; }
.ledger .criterion b { color: var(--ink); font-weight: 620; }

.stamp {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 0.12rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  margin-right: 0.5rem;
  vertical-align: 0.08em;
}

/* A pre-registered criterion that was not met is a result, not a casualty. It reads in
   the same ink as the rest of the page; the outcome is carried by the words after it. */
.stamp--pre { color: var(--ink-soft); }
.stamp--held { color: var(--good); }

/* ---- retraction ----------------------------------------------------------- */

.entry--retraction .entry__lede { color: var(--ink); }

.struck {
  text-decoration: line-through;
  text-decoration-color: var(--bad);
  text-decoration-thickness: 1px;
  color: var(--ink-soft);
}

/* ---- pipeline diagram ----------------------------------------------------- */

/* Capped at its authored scale. Left at width:100% the 420-unit viewBox scales its 13px
   labels up to h2 size, which makes a subordinate schematic the largest thing on the page. */
.diagram { margin: 2rem 0; max-width: 26rem; }
.diagram svg { display: block; width: 100%; height: auto; }
.diagram .d-box { fill: none; stroke: var(--rule); }
.diagram .d-label { fill: var(--ink); font-size: 13px; font-family: var(--sans); }
.diagram .d-sub { fill: var(--ink-soft); font-size: 11px; font-family: var(--mono); }
.diagram .d-line { stroke: var(--ink-faint); stroke-width: 1; fill: none; }
.diagram .d-guard { stroke: var(--bad); }
.diagram .d-guard-label { fill: var(--bad); }

/* ---- close ---------------------------------------------------------------- */

.close { padding: clamp(2.5rem, 6vw, 4rem) 0 clamp(3rem, 7vw, 5rem); }

.close h2 { font-size: 1.5rem; margin-bottom: 1rem; }

pre {
  overflow-x: auto;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.95rem 1.05rem;
  margin: 1.25rem 0;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--ink);
}




/* ---- the one authored moment ---------------------------------------------- */
/* The ruled margin draws downward with the scroll, the way a log fills as the work
   proceeds. It starts fully drawn, so nothing depends on it, and it is the page's
   only motion. */

@media (min-width: 62rem) and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .entry::before {
      animation: draw-rule linear both;
      animation-timeline: view();
      animation-range: entry 5% entry 55%;
    }
    @keyframes draw-rule {
      from { transform: scaleY(0); }
      to { transform: scaleY(1); }
    }
  }
}


/* ---- cover: composite on wide, its own panels stacked on narrow ------------ */

.plate__stack { display: grid; gap: 1rem; }
.plate__wide { display: none; }

@media (min-width: 60rem) {
  .plate__stack { display: none; }
  .plate__wide { display: block; }
}

/* ---- close ---------------------------------------------------------------- */

.close__note { max-width: 68ch; color: var(--ink-soft); margin-bottom: 1.25rem; }
.close blockquote {
  margin: 1.5rem 0 0;
  padding-left: 0.85rem;
  border-left: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ==========================================================================
   INSTRUMENT PANEL (index.html)

   The log styles above dress story.html, which is prose. This layer dresses the
   landing page, which is a control surface: a verdict, four numbers, and charts
   the reader drives. Charts are inline SVG drawn by site.js, so they inherit
   every custom property declared at the top of this file and theme themselves.
   ========================================================================== */

.panel {
  --panel-max: 74rem;
  padding: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  max-width: var(--panel-max);
  margin: 0 auto;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
}
.topbar__id { font-weight: 650; letter-spacing: -0.01em; }
.topbar__nav { display: flex; gap: 1.25rem; font-size: 0.9rem; }

.panel main {
  max-width: var(--panel-max);
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 3rem;
}

.panel section { padding-block: clamp(1.75rem, 4vw, 2.75rem); }
.panel section + section { border-top: 1px solid var(--rule); }

/* ---- verdict -------------------------------------------------------------- */

/* Display and Lede steps, straight off the DESIGN.md ramp. The panel is a different form from the
   log, but it is the same publication and has no reason to invent a second type scale. */
.verdict h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.05rem, 1.25rem + 3.1vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.lede {
  max-width: 62ch;
  margin: 0 0 1.75rem;
  font-size: 1.075rem;
  color: var(--ink-soft);
}
.micro { font-size: 0.83rem; color: var(--ink-faint); margin: 1rem 0 0; }

.stats {
  display: grid;
  /* 9.5rem lets two tiles pair up inside a 375px viewport, which keeps the first chart within
     reach of the fold on a phone. Wider viewports fill out to four across. */
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  background: var(--ground);
}
.stat__k {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
}
.stat__v {
  font-family: var(--mono);
  font-size: clamp(1.4rem, 1.1rem + 1.1vw, 1.9rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat__sub { font-size: 0.78rem; color: var(--ink-soft); }

/* ---- controls ------------------------------------------------------------- */

.controls { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }

.switch { display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.switch--inline { margin-left: 0.5rem; vertical-align: middle; }
.switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.switch button + button { border-left: 1px solid var(--rule); }
.switch button[aria-pressed="true"] { background: var(--series-a); color: #fff; }
.switch button:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-size: 0.8125rem;
  color: var(--ink-faint);
  cursor: pointer;
}
.chip.on { color: var(--ink); border-color: var(--ink-faint); }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:focus-within { outline: 2px solid var(--link); outline-offset: 1px; }
.chip i,
.legend i,
.readout i {
  width: 0.85rem;
  height: 0.2rem;
  border-radius: 2px;
  flex: none;
  opacity: 0.35;
}
.chip.on i { opacity: 1; }

/* ---- plots ---------------------------------------------------------------- */

.plot { margin: 0 0 1.75rem; }
.plot figcaption {
  max-width: 60ch;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.plot figcaption b { color: var(--ink); font-weight: 620; }

.plot svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.plot .grid { stroke: var(--rule); stroke-width: 1; }
.plot .zero { stroke: var(--ink-faint); stroke-width: 1; }
.plot .ci { stroke: var(--ink-faint); stroke-width: 2; stroke-linecap: round; }
.plot .crosshair { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 2 3; }
.plot .tick {
  fill: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.plot .barlab {
  fill: var(--ink-soft);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.plot .regime-name { text-anchor: middle; font-weight: 600; }

.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  min-height: 1.4rem;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.readout span,
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.readout b { color: var(--ink); }

.legend {
  display: flex;
  gap: 1rem;
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.pair { display: grid; gap: 1.5rem; }
@media (min-width: 56rem) {
  .pair { grid-template-columns: 1fr 1fr; gap: 2rem; }
}

/* ---- scorecard ------------------------------------------------------------ */

.scorecard { overflow-x: auto; }
.scorecard table { border-collapse: collapse; width: 100%; font-size: 0.83rem; }
.scorecard caption {
  text-align: left;
  color: var(--ink-soft);
  font-size: 0.85rem;
  padding-bottom: 0.6rem;
}
.scorecard th,
.scorecard td {
  padding: 0.4rem 0.7rem 0.4rem 0;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--rule);
}
.scorecard thead th {
  color: var(--ink-faint);
  font-weight: 500;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.scorecard tbody th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-soft);
  padding-right: 1.25rem;
}
.scorecard td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.scorecard .ci-cell { color: var(--ink-faint); }
.scorecard tr.on th,
.scorecard tr.on td { color: var(--ink); }

/* ---- prose blocks on the panel -------------------------------------------- */

.panel h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2.05rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.facts { max-width: 68ch; margin: 0 0 1.25rem; padding-left: 1.1rem; }
.facts li { margin-bottom: 0.7rem; color: var(--ink-soft); }
.facts b { color: var(--ink); font-weight: 620; }
.why p { max-width: 68ch; color: var(--ink-soft); }

.specs { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); margin: 0; }
.specs > div { display: grid; gap: 0.15rem; padding: 0.7rem 1rem; background: var(--ground); }
@media (min-width: 44rem) {
  .specs > div { grid-template-columns: 12rem 1fr; gap: 1rem; align-items: baseline; }
}
.specs dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
.specs dd { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

.note {
  padding: 1rem;
  border: 1px solid var(--ink-faint);
  color: var(--ink-soft);
}

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  max-width: var(--panel-max);
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 2.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
  color: var(--ink-faint);
}
