/* Flow Window — the front page's paper (Day edition) and ink (Night edition). Fonts are self-hosted Go fonts. */

@font-face { font-family: Go; src: url(../fonts/Go-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Go; src: url(../fonts/Go-Italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Go Smallcaps"; src: url(../fonts/Go-Smallcaps.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Go Mono"; src: url(../fonts/Go-Mono.woff2) format("woff2"); font-display: swap; }

:root {
  --paper: #efe9dc; --paper-2: #e6dfcd; --ink: #1b1a17; --ink-2: #47433b; --muted: #675f52;
  --rule: rgba(27, 26, 23, .82); --hair: rgba(27, 26, 23, .16); --accent: #b5361d; --sun: #e0d2ad;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L", Georgia, serif;
  --sans: Go, "Segoe UI", system-ui, sans-serif;
  --caps: "Go Smallcaps", Go, system-ui, sans-serif;
  --mono: "Go Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --gutter: clamp(16px, 3.4vw, 44px);
  color-scheme: light;
}
:root[data-edition="night"] {
  --paper: #111214; --paper-2: #18191c; --ink: #e9e2d2; --ink-2: #c3bba9; --muted: #8d8778;
  --rule: rgba(233, 226, 210, .7); --hair: rgba(233, 226, 210, .13); --accent: #ff7a57; --sun: #2c2820; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--paper); }
.wrap { max-width: 1360px; margin-inline: auto; padding: 0 max(var(--gutter), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--gutter), env(safe-area-inset-left)); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.smallcaps, .label { font-family: var(--caps); font-weight: 400; letter-spacing: .08em; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--ink); color: var(--paper); padding: 8px 14px; }
.skip:focus { left: 8px; }
.small { font-size: 13px; color: var(--muted); }

/* ---------- Masthead, as on the front page ---------- */
.masthead { padding-top: clamp(14px, 2vw, 22px); }
.folio {
  display: flex; align-items: center; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap;
  font-family: var(--caps); font-size: 13px; letter-spacing: .08em; color: var(--ink-2);
  border-bottom: 1px solid var(--rule); padding: 0 0 9px 64px; min-height: 44px;
}
.folio__now { font-size: 12.5px; letter-spacing: 0; color: var(--ink); }
.edition { display: flex; align-items: center; gap: 6px; }
.edition span { opacity: .5; }
.edition button { background: none; border: 0; padding: 8px 2px; min-height: 44px; font: inherit; letter-spacing: inherit; color: var(--muted); }
.edition button[aria-pressed="true"] { color: var(--ink); }
.edition button:hover { color: var(--accent); }
.wordmark { margin: clamp(10px, 1.6vw, 18px) 0 0; text-align: center; font: 400 clamp(44px, 7.6vw, 108px)/.95 var(--serif); letter-spacing: -.025em; padding-bottom: .06em; }
.wordmark__in { font-style: italic; font-size: .5em; margin-left: .04em; letter-spacing: 0; color: var(--accent); }
.dek {
  display: flex; justify-content: space-between; gap: 4px 24px; flex-wrap: wrap; margin-top: clamp(10px, 1.4vw, 16px); padding: 8px 0 7px;
  border-top: 3px double var(--rule); border-bottom: 1px solid var(--rule);
  font-family: var(--caps); font-size: 13px; letter-spacing: .07em; color: var(--ink-2);
}
.dek p { margin: 0; }

/* ---------- Stage: the tunnel, its controls and the readout ---------- */
.stage { display: flex; flex-wrap: wrap; gap: 28px 48px; padding: clamp(22px, 3vw, 40px) 0 clamp(40px, 5vw, 64px); align-items: flex-start; }
.stage__main { flex: 7 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.tunnel { margin: 0; min-width: 0; }
.tunnel__frame { position: relative; border: 3px double var(--rule); padding: 4px; }
#flow { display: block; width: 100%; height: auto; aspect-ratio: 5 / 2; background: var(--paper); touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#flow[data-tool="erase"] { cursor: cell; }
.tunnel__wind { position: absolute; left: 12px; top: 9px; font: 12px var(--caps); letter-spacing: .1em; color: var(--ink-2); pointer-events: none; }
.runbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 10px; }
.live { display: flex; gap: 4px 16px; flex-wrap: wrap; margin: 0; font-size: 14px; color: var(--muted); }
.live b { font-weight: 400; color: var(--ink); }
#flow.is-tall { aspect-ratio: 2 / 1; }
.readout__what { margin: 8px 0 0; }
.tunnel figcaption { margin: 8px auto 0; text-align: center; font-size: 13px; color: var(--ink-2); font-style: italic; max-width: 72ch; }

.controls { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field__row { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.label { font-size: 13px; color: var(--accent); margin: 0; }
.jumps { display: flex; gap: 0 16px; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0 2px; min-height: 44px; min-width: 44px; font-family: var(--caps); font-size: 14px; letter-spacing: .06em; color: var(--muted); text-decoration: none; }
.link[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1px; }
.link:hover { color: var(--accent); }
.hint { margin: 0; font-size: 13.5px; color: var(--ink-2); max-width: 64ch; }
.steps { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { min-height: 44px; min-width: 44px; padding: 0 12px; background: transparent; border: 1px solid var(--rule); font-family: var(--caps); letter-spacing: .06em; font-size: 14px; }
.btn:hover { color: var(--accent); border-color: var(--accent); }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn--play { min-width: 7em; }
.btn--play[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* sliders, engraved: a hairline track and an ink thumb */
.slider { display: grid; grid-template-columns: 8.4em minmax(0, 1fr) 7.2em; align-items: center; gap: 0 14px; min-height: 44px; }
.slider label { font-size: 14px; color: var(--ink-2); }
.slider output { font-size: 14px; text-align: right; white-space: nowrap; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--rule); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--rule); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
input[type="range"]:hover::-webkit-slider-thumb { border-color: var(--accent); }
input[type="range"]:hover::-moz-range-thumb { border-color: var(--accent); }
input[type="range"]:focus-visible { outline-offset: 0; }

.readout { flex: 4 1 340px; position: sticky; top: 16px; min-width: 0; border: 1px solid var(--hair); outline: 1px solid var(--hair); outline-offset: -5px; padding: 20px 22px 18px; }
.readout__head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 20px; flex-wrap: wrap; border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
.readout__head .label { color: var(--ink-2); }
.readout__big { font: 400 clamp(38px, 4.2vw, 54px)/1 var(--serif); letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 14px 0 0; }
.facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts dt { font-family: var(--caps); font-size: 12px; letter-spacing: .07em; color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.trace { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--hair); }
.trace__lbl { font: 12px var(--caps); letter-spacing: .07em; color: var(--muted); }
#trace { display: block; width: 100%; height: 56px; }
.readout__note { margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.status { margin: 8px 0 0; font-size: 13.5px; color: var(--accent); }
.status:empty { display: none; }

/* ---------- Plates ---------- */
.plate { padding-bottom: clamp(40px, 5vw, 60px); }
.chapter__h {
  display: flex; align-items: baseline; gap: 12px; margin: 0 0 18px; padding-bottom: 8px; border-bottom: 1px solid var(--rule);
  font: italic 400 clamp(24px, 2.4vw, 32px)/1.1 var(--serif); letter-spacing: -.01em;
}
.chapter__n { font: 400 .62em/1 var(--caps); font-style: normal; letter-spacing: .1em; color: var(--accent); }
.plate__body { display: flex; flex-wrap: wrap; gap: 24px 48px; align-items: flex-start; }
.plate__text { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 10px; font-size: 15px; color: var(--ink-2); max-width: 72ch; }
.plate__text p { margin: 0; }
.fig { margin: 0; flex: 1 1 420px; min-width: 0; max-width: 620px; }
.fig--small { flex: 0 1 300px; max-width: 320px; }
.fig svg { display: block; width: 100%; height: auto; }
.fig figcaption { margin-top: 8px; font-size: 13px; color: var(--ink-2); font-style: italic; }

/* the drawings in the plates */
.d-flow { fill: none; stroke: var(--ink); stroke-width: 1; opacity: .55; }
.d-body { fill: var(--paper-2); stroke: var(--ink); stroke-width: 1.4; }
.d-hatch { stroke: var(--ink); stroke-width: .8; opacity: .55; }
.d-vort circle { fill: none; stroke-width: 1; }
.d-vort--a circle { stroke: var(--accent); }
.d-vort--b circle { stroke: var(--ink); }
.d-arrow { fill: none; stroke: var(--ink-2); stroke-width: 1.2; }
.d-dim { fill: none; stroke: var(--muted); stroke-width: .8; }
.d-lab { font: italic 400 14px var(--serif); fill: var(--ink-2); }
.d-grid { stroke: var(--hair); stroke-width: 1; }
.d-dir line { stroke: var(--ink); stroke-width: 1.6; }
.d-dir--diag line { stroke: var(--accent); }
.d-head { fill: var(--ink); }
.d-node circle { fill: var(--paper); stroke: var(--ink); stroke-width: 1.2; }
.d-rest { fill: var(--ink); }

@media (max-width: 600px) {
  .folio { padding-left: 60px; font-size: 12px; }
  .folio__now { display: none; }
  .dek { justify-content: center; text-align: center; }
  .dek p + p { display: none; }
  .readout { padding: 16px 16px 14px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage__main, .readout { flex-basis: 100%; }
  .readout { position: static; }
  .slider { grid-template-columns: 6.4em minmax(0, 1fr) 5.6em; gap: 0 10px; }
  .slider label, .slider output { font-size: 13px; }
  .jumps { gap: 0 12px; }
  .tunnel__wind { display: none; }
  .tunnel__frame { margin-inline: -12px; padding: 2px; }   /* the tunnel runs nearly edge to edge on a phone */
  .runbar .steps { flex: 1 1 100%; }
  .runbar .btn { flex: 1 1 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 12px 0 40px; border-top: 3px double var(--rule); font-size: 13px; color: var(--ink-2); }
.foot p { margin: 0; max-width: 72ch; }
.noscript { text-align: center; padding: 24px; }
.readout .small { margin: 8px 0 0; }
