/* fetch — fetched.dog
   A field study in patience. Paper, serif, marginalia.
   Everything here is served from this origin: no remote fonts, no CDN. */

/* ── faces ──────────────────────────────────────────────────────────────── */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}

/* ── ink and paper ──────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  --paper: #f2ebdd;
  --paper-deep: #e8ddc7;
  --paper-card: #f7f2e7;

  --ink: #221e19;
  --ink-2: #564e44;
  --ink-3: #857b6c;

  --rule: #cdbfa6;
  --rule-soft: #ded2ba;

  --ember: #b4551f;
  --ember-deep: #85380e;
  --slate: #566a72;
  --moss: #5b6a4f;

  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
    Consolas, monospace;

  --measure: 37rem;
  --margin-col: 15rem;
  --gap: 2.75rem;
}

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

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background-color: var(--paper);
  /* Paper grain. A 160px tile of fractal noise, inlined — no request. */
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.32'/%3E%3C/svg%3E");
  background-repeat: repeat;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.62;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection {
  background: rgba(180, 85, 31, 0.2);
}

img,
svg,
canvas {
  max-width: 100%;
}

a {
  color: var(--ember-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover {
  color: var(--ember);
}

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  z-index: 90;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* ── the sheet: text column + margin column ─────────────────────────────── */

.sheet {
  display: grid;
  grid-template-columns:
    [full-start] minmax(1.25rem, 1fr)
    [text-start] minmax(0, var(--measure))
    [text-end] var(--gap)
    [margin-start] var(--margin-col)
    [margin-end] minmax(1.25rem, 1fr)
    [full-end];
}

.sheet > * {
  grid-column: text;
}
.sheet > .full {
  grid-column: full;
}
.sheet > .wide {
  grid-column: text-start / margin-end;
}

/* Marginalia. Hangs beside the paragraph it annotates on wide screens,
   folds into the flow underneath it on narrow ones. */
.note {
  grid-column: margin;
  align-self: start;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.66;
  color: var(--ink-2);
  letter-spacing: 0.005em;
  margin-top: 0.55rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--rule);
  font-variant-numeric: normal;
}
.note b {
  font-weight: 400;
  color: var(--ember-deep);
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.62rem;
  margin-bottom: 0.35rem;
}
.note--pull {
  margin-top: -3.2rem;
}

@media (max-width: 1080px) {
  .sheet {
    grid-template-columns:
      [full-start] minmax(1.15rem, 1fr)
      [text-start margin-start] minmax(0, var(--measure))
      [text-end margin-end] minmax(1.15rem, 1fr)
      [full-end];
  }
  .note,
  .note--pull {
    margin-top: 0.4rem;
    margin-bottom: 1.6rem;
    max-width: 34rem;
  }
}

/* ── progress: hairline at the top, chapter rail at the right ───────────── */

.progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 2px;
  width: 0;
  background: var(--ember);
  z-index: 60;
  will-change: width;
}

.rail {
  position: fixed;
  right: 1.6rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 55;
  display: none;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.5rem 0;
}
.rail::before {
  content: "";
  position: absolute;
  left: 0.32rem;
  top: 0.9rem;
  bottom: 0.9rem;
  width: 1px;
  background: var(--rule);
}
.rail a {
  position: relative;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper);
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.rail a::after {
  content: attr(data-label);
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.rail a:hover::after,
.rail a:focus-visible::after {
  opacity: 1;
}
.rail a[aria-current="true"] {
  background: var(--ember);
  border-color: var(--ember);
  transform: scale(1.15);
}
@media (min-width: 1180px) {
  .rail {
    display: flex;
  }
}

/* ── masthead ───────────────────────────────────────────────────────────── */

.masthead {
  padding: clamp(3.5rem, 11vh, 8rem) 0 clamp(3rem, 8vh, 5.5rem);
}

.masthead__rule {
  grid-column: text-start / margin-end;
  border: 0;
  border-top: 1px solid var(--ink);
  margin: 0 0 0.55rem;
}
.masthead__rule--thin {
  border-top: 1px solid var(--rule);
  margin: 0.55rem 0 2.4rem;
}

.overline {
  grid-column: text-start / margin-end;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  justify-content: space-between;
}

.wordmark {
  grid-column: text-start / margin-end;
  font-size: clamp(4.5rem, 17vw, 11.5rem);
  line-height: 0.84;
  font-weight: 600;
  letter-spacing: -0.035em;
  margin: 0.15em 0 0.12em;
  font-feature-settings: "liga" 1;
}
.wordmark .lead {
  display: inline-block;
  position: relative;
}

.deck {
  font-size: clamp(1.3rem, 2.6vw, 1.72rem);
  line-height: 1.34;
  font-style: italic;
  color: var(--ink);
  margin: 0 0 1.4rem;
  max-width: 26ch;
}

.standfirst {
  font-size: 1.06rem;
  color: var(--ink-2);
  margin: 0 0 2.2rem;
}

.masthead__mark {
  grid-column: margin;
  width: 100%;
  height: auto;
  grid-row: span 2;
  align-self: center;
  justify-self: start;
  margin: 0 0 0 -0.6rem;
}
@media (max-width: 1080px) {
  .masthead__mark {
    display: none;
  }
}

.dateline {
  grid-column: text-start / margin-end;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  border-top: 1px solid var(--rule);
  padding-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.4rem 1.6rem;
}
.dateline b {
  font-weight: 400;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
  display: block;
}

/* ── chapters ───────────────────────────────────────────────────────────── */

.chapter {
  padding: clamp(3rem, 8vh, 5.5rem) 0;
  position: relative;
}
.chapter--band {
  background: linear-gradient(
    to bottom,
    rgba(232, 221, 199, 0) 0,
    rgba(232, 221, 199, 0.72) 4rem,
    rgba(232, 221, 199, 0.72) calc(100% - 4rem),
    rgba(232, 221, 199, 0) 100%
  );
}

.chapno {
  grid-column: text-start / margin-end;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ember-deep);
  margin: 0 0 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.chapno::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

h2 {
  font-size: clamp(1.85rem, 4.4vw, 2.65rem);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.021em;
  margin: 0 0 1.15rem;
  max-width: 18ch;
}

h3 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2.4rem 0 0.6rem;
}

p {
  margin: 0 0 1.15rem;
}

.lede {
  font-size: 1.32rem;
  line-height: 1.48;
  margin-bottom: 1.5rem;
}
.lede--drop::first-letter {
  float: left;
  font-size: 3.55em;
  line-height: 0.78;
  padding: 0.06em 0.09em 0 0;
  font-weight: 600;
  color: var(--ember);
}

em.key {
  font-style: italic;
  color: var(--ink);
  background: linear-gradient(
    to top,
    rgba(180, 85, 31, 0.17) 0.42em,
    rgba(180, 85, 31, 0) 0.42em
  );
}

.mono {
  font-family: var(--mono);
  font-size: 0.88em;
  font-variant-numeric: normal;
}

/* footnote references */
sup.fn {
  font-family: var(--mono);
  font-size: 0.6rem;
  line-height: 0;
  vertical-align: super;
  margin-left: 0.12em;
}
sup.fn a {
  text-decoration: none;
  padding: 0 0.1em;
}
sup.fn a::before {
  content: "[";
}
sup.fn a::after {
  content: "]";
}

/* ── the three steps ────────────────────────────────────────────────────── */

.steps {
  list-style: none;
  counter-reset: step;
  margin: 2rem 0 1.5rem;
  padding: 0;
  border-top: 1px solid var(--rule);
}
.steps li {
  counter-increment: step;
  border-bottom: 1px solid var(--rule);
  padding: 1.15rem 0 1.25rem 3.1rem;
  position: relative;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1.22rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--paper);
  background: var(--ink);
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-variant-numeric: normal;
}
.steps h3 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
}
.steps p {
  margin: 0;
  color: var(--ink-2);
  font-size: 1.03rem;
}

/* ── figures ────────────────────────────────────────────────────────────── */

figure {
  margin: 2.4rem 0;
}
figcaption {
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.62;
  color: var(--ink-2);
  margin-top: 0.85rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--rule);
  max-width: 36rem;
}
figcaption b {
  font-weight: 400;
  color: var(--ember-deep);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.63rem;
}

.sketch {
  display: block;
  width: 100%;
  height: auto;
}

/* ── the streak figure (three.js) ───────────────────────────────────────── */

.streak {
  position: relative;
  margin: 0;
}
/* The tall scroll runway and the sticky stage only exist once the WebGL
   figure is actually running. Without it — no JS, no WebGL, reduced motion —
   the figure is an ordinary still illustration in the flow, not three and a
   half screens of nothing. */
.streak.is-live {
  height: 360svh;
}
.streak__stage {
  display: grid;
  grid-template-rows: auto minmax(0, 58svh) auto;
  align-content: center;
  padding: 1.5rem 0 2rem;
}
.streak.is-live .streak__stage {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 30rem;
}
.streak__canvas,
.streak__still {
  grid-row: 2;
  grid-column: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.streak__canvas {
  display: block;
  opacity: 0;
  transition: opacity 700ms ease;
}
.streak__canvas.is-live {
  opacity: 1;
}
.streak__still {
  display: block;
  align-self: center;
}
.streak__canvas.is-live + .streak__still {
  visibility: hidden;
}

.readout[hidden] {
  display: none;
}
.readout {
  grid-row: 3;
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 2.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--ink-2);
  border-top: 1px solid var(--rule);
  padding-top: 0.7rem;
  font-variant-numeric: normal;
}
.readout span b {
  font-weight: 400;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
  margin-right: 0.55rem;
}
.readout .val {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.readout .val--warn {
  color: var(--ember);
}
.readout .disc {
  margin-left: auto;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
}

.streak__scroll {
  grid-row: 1;
  grid-column: 1;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  margin: 0 0 0.5rem;
}

/* With reduced motion the runway collapses and the still figure stands alone —
   the drawing carries the same meaning without any of the movement. */
@media (prefers-reduced-motion: reduce) {
  .only-motion {
    display: none;
  }
  .streak,
  .streak.is-live {
    height: auto;
  }
  .streak.is-live .streak__stage {
    position: static;
    height: auto;
    min-height: 0;
  }
  .streak__canvas {
    display: none;
  }
}

/* ── ledger table ───────────────────────────────────────────────────────── */

.ledger {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0 1rem;
  font-size: 0.97rem;
}
.ledger caption {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  padding-bottom: 0.7rem;
}
.ledger th,
.ledger td {
  text-align: left;
  vertical-align: baseline;
  padding: 0.72rem 1rem 0.72rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.ledger th {
  font-weight: 400;
  color: var(--ink-2);
  width: 42%;
}
.ledger td {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
  font-variant-numeric: normal;
  padding-right: 0;
}
.ledger tr:first-child th,
.ledger tr:first-child td {
  border-top: 1px solid var(--ink);
}
@media (max-width: 620px) {
  .ledger th,
  .ledger td {
    display: block;
    width: auto;
    border: 0;
    padding: 0;
  }
  .ledger th {
    padding-top: 0.95rem;
  }
  .ledger td {
    padding-bottom: 0.95rem;
    border-bottom: 1px solid var(--rule-soft);
  }
  .ledger tr:first-child th {
    border-top: 1px solid var(--ink);
  }
}

/* ── status card ────────────────────────────────────────────────────────── */

.status {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  padding: 1.6rem 1.7rem 1.2rem;
  margin: 2rem 0 1.5rem;
  box-shadow: 0 1px 0 var(--rule-soft), 3px 4px 0 -1px rgba(34, 30, 25, 0.05);
}
.status h3 {
  margin: 0 0 0.9rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ember-deep);
}
.status dl {
  margin: 0;
  display: grid;
  gap: 0.15rem 1.4rem;
}
.status dt {
  font-weight: 600;
  font-size: 1rem;
}
.status dd {
  margin: 0 0 1rem;
  color: var(--ink-2);
  font-size: 0.99rem;
}
.status dd:last-child {
  margin-bottom: 0.4rem;
}

/* ── footnotes and colophon ─────────────────────────────────────────────── */

.footnotes {
  padding-top: 2.5rem;
  border-top: 1px solid var(--ink);
  margin-top: 1rem;
}
.footnotes h2 {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-2);
  margin-bottom: 1.3rem;
}
.footnotes ol {
  margin: 0;
  padding-left: 1.4rem;
  font-size: 0.93rem;
  line-height: 1.58;
  color: var(--ink-2);
}
.footnotes li {
  margin-bottom: 0.8rem;
}
.footnotes li:target {
  color: var(--ink);
}
.footnotes code {
  font-family: var(--mono);
  font-size: 0.83em;
}

.colophon {
  padding: 3rem 0 4.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.85;
  letter-spacing: 0.03em;
  color: var(--ink-3);
}
.colophon p {
  margin: 0 0 0.4rem;
  max-width: 40rem;
}

/* a hand-inked divider between chapters */
.divider {
  grid-column: text-start / margin-end;
  height: 12px;
  margin: 0;
  border: 0;
  color: var(--rule);
  background: no-repeat center /
    contain
    url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='12' viewBox='0 0 420 12'%3E%3Cpath d='M2 7.4C46 4.1 92 8.6 138 6.2c46-2.4 92-3.6 138 .4 46 4 92 1.2 142-2.2' fill='none' stroke='%23cdbfa6' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
}

@media (max-width: 560px) {
  body {
    font-size: 1.0625rem;
  }
  .streak.is-live .streak__stage {
    height: 92svh;
  }
  .streak__stage {
    grid-template-rows: auto minmax(0, 66svh) auto;
  }
}
