@font-face {
  font-family: Geist;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-latin.woff2") format("woff2");
}
@font-face {
  font-family: Geist Mono;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-mono.woff2") format("woff2");
}

/* The page is text and figures. Everything here serves one or the other. */

:root {
  color-scheme: light dark;
  --bg: #fafaf9;
  --surface: #f2f2f0;
  --ink: #0b0b0b;
  --ink-2: #51514d;
  --ink-3: #8c8c88;
  --line: #dcdcd8;
  --line-2: #b4b4b0;
  --accent: #127245;
  --accent-soft: rgb(18 114 69 / 0.12);
  --sans: Geist, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, Menlo, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 56px);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  font: 400 100%/1.55 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --surface: #0b0b0b;
    --ink: #f1efe8;
    --ink-2: rgb(241 239 232 / 0.64);
    --ink-3: rgb(241 239 232 / 0.38);
    --line: #222;
    --line-2: #3d3d3b;
    --accent: #5ee39a;
    --accent-soft: rgb(94 227 154 / 0.12);
  }
}

* {
  box-sizing: border-box;
}
body,
figure,
h1,
h2,
h3,
p {
  margin: 0;
}
body {
  background: var(--bg);
}
::selection {
  background: var(--accent-soft);
}
a {
  color: inherit;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
}
button,
input {
  font: inherit;
}
button,
a,
input,
summary {
  touch-action: manipulation;
}
:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}
strong {
  font-weight: 600;
}
code {
  font: 0.86em var(--mono);
  padding: 0 3px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.skip {
  position: absolute;
  inset: 8px auto auto 8px;
  z-index: 5;
  padding: 10px 14px;
  color: var(--bg);
  background: var(--ink);
  transform: translateY(-180%);
}
.skip:focus {
  transform: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Publication and section navigation. */
main,
.header-inner {
  width: min(1296px, calc(100% - 2 * var(--gutter)));
  margin-inline: auto;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
}
.brand,
.publisher {
  font: 500 0.75rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.publisher {
  color: var(--ink-2);
  transition: color 160ms ease;
}
.publisher[aria-current="page"] {
  color: var(--ink);
}
.sections {
  display: flex;
  gap: 18px;
  margin-left: auto;
}

/* Opening ---------------------------------------------------------------- */

.hero {
  display: grid;
  justify-items: center;
  gap: clamp(32px, 4.5vw, 64px);
  padding-block: clamp(40px, 6vw, 88px) clamp(40px, 5vw, 72px);
}
.hero-copy,
.library > h1,
.library > .subtitle {
  text-align: center;
}
.hero-copy {
  max-width: min(100%, 960px);
}
h1,
h2,
h3 {
  font-weight: 500;
}
h1 {
  margin-bottom: 18px;
  font-size: clamp(3.25rem, 9vw, 8.5rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.subtitle {
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  line-height: 1.25;
  letter-spacing: -0.03em;
}
.intro {
  margin: 14px auto 0;
  max-width: 56ch;
  color: var(--ink-2);
  font-size: 1.04rem;
  line-height: 1.6;
  text-wrap: pretty;
}
.hero > figure {
  width: min(100%, 640px);
}

/* Reading layout: text left, the current figure pinned right ------------- */

.doc {
  padding-block: clamp(32px, 5vw, 72px) clamp(64px, 8vw, 120px);
}
.doc.is-staged {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  column-gap: clamp(40px, 5vw, 80px);
  align-items: start;
}
.doc-text {
  min-width: 0;
  max-width: 680px;
}
.doc-stage {
  display: none;
}
/* The stage is a full-height sticky column; doc.mjs places the figure in
   it, level with the section it explains. */
.doc.is-staged .doc-stage {
  position: sticky;
  top: 0;
  display: grid;
  align-items: start;
  height: 100vh;
}
/* Figures hand over through a slight blur: the outgoing one softens and
   fades, and the incoming one sharpens into place just after it, so two
   drawings never read on top of each other. The first time, the incoming
   figure also plays its entrance (assets/entrance.mjs). easeOutCubic
   (easings.net) is gentler than --ease-out, so the softness stays visible
   through the hand-over instead of clearing in a blink. */
.doc-stage > figure {
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  filter: blur(10px);
  transition: opacity 260ms var(--ease-soft), filter 260ms var(--ease-soft),
    visibility 0s linear 260ms;
}
.doc-stage > figure.is-active {
  opacity: 1;
  visibility: visible;
  filter: none;
  transition: opacity 480ms var(--ease-soft) 140ms,
    filter 480ms var(--ease-soft) 140ms, visibility 0s;
}
.figure-anchor {
  height: 0;
}

article section {
  scroll-margin-top: 28px;
  margin-bottom: clamp(56px, 7vw, 104px);
}
article section:last-child {
  margin-bottom: 0;
}
/* While a figure is pinned, the passage it belongs to stays bright. */
.doc.is-staged article section {
  transition: opacity 420ms ease;
}
.doc.is-staged article section:not(.is-current) {
  opacity: 0.4;
}
article h2,
.entry h2 {
  font-size: clamp(1.9rem, 3.2vw, 2.75rem);
  letter-spacing: -0.04em;
  line-height: 1.08;
  margin-bottom: 20px;
  text-wrap: balance;
}
article p {
  max-width: 66ch;
  font-size: clamp(1.025rem, 1.3vw, 1.09rem);
  line-height: 1.7;
  margin-bottom: 15px;
  text-wrap: pretty;
}
article :is(.lab, .aes-drawing, .instrument) {
  margin-block: 36px;
}

.calculation {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.calculation:last-child {
  border-bottom: 1px solid var(--line);
}
.calculation summary {
  cursor: pointer;
  font-weight: 500;
  letter-spacing: -0.015em;
}
.calculation p {
  margin: 13px 0;
}
.sources {
  margin-top: 40px;
}
.sources h3 {
  margin-bottom: 8px;
  color: var(--ink-3);
  font: 500 0.75rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sources a {
  display: block;
  width: fit-content;
  margin-block: 6px;
  color: var(--ink-2);
}

/* Figures: the drawing, its controls, its caption. No frame. ------------ */

.instrument,
.lab,
.aes-drawing {
  min-width: 0;
}
.drawing {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.drawing svg,
.instrument > svg,
.lab svg,
.thumb svg {
  display: block;
  width: 100%;
  height: auto;
}
.lab > svg,
.lab [data-scene] {
  max-width: 580px;
  margin-inline: auto;
}
.aes-drawing svg,
.seal-figure svg,
.note-tray svg {
  max-width: 620px;
  margin-inline: auto;
}
.timeline svg {
  max-width: 440px;
}
:is(.lab, .instrument, .aes-drawing, .thumb) svg [data-bg] {
  fill: transparent !important;
}
:is(.lab, .instrument, .aes-drawing, .thumb) svg text:not([data-space]) {
  font-family: var(--mono);
  letter-spacing: -0.02em;
}
:is(.lab, .instrument, .aes-drawing, .thumb) svg text.caps {
  letter-spacing: 0.1em;
}
:is(.lab, .instrument, .aes-drawing, .thumb) svg .accent {
  fill: var(--accent) !important;
}
:is(.lab, .instrument, .aes-drawing, .thumb) svg .accent-line {
  stroke: var(--accent) !important;
}

.instrument-controls,
.aes-drawing .interface,
.aes-drawing .round-controls,
.seal-action {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
}
.instrument-controls label,
.aes-drawing .round-controls label {
  color: var(--ink-2);
  font: 500 0.75rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.instrument figcaption,
.lab figcaption,
.aes-drawing figcaption {
  max-width: 62ch;
  margin: 14px auto 0;
  color: var(--ink-2);
  font: 400 0.8125rem/1.65 var(--mono);
  letter-spacing: -0.01em;
  text-align: center;
  text-wrap: pretty;
}

button {
  cursor: pointer;
  min-height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--bg);
  font: 500 0.71875rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 120ms ease, background-color 120ms ease,
    border-color 120ms ease, transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.instrument button:not(#reset):not([data-secondary]),
.primary,
.seal-action button,
button[aria-pressed="true"] {
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}
button:active:enabled {
  transform: scale(0.97);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
#reset {
  min-width: 34px;
  padding: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: min(50%, 240px);
  min-width: 90px;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--line-2);
}
input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--line-2);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6.5px;
  border: 0;
  border-radius: 1px;
  background: var(--ink);
  transition: transform 160ms var(--ease-out);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 1px;
  background: var(--ink);
}
input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.2);
}

/* AES: round timeline and the GCM check, each part flipping in turn. */
[data-dial],
[data-progress] {
  transition: transform 300ms var(--ease-out);
}
#seal-demo [data-when] {
  transition: opacity 200ms ease;
}
#seal-demo[data-changed="true"] [data-when="intact"],
#seal-demo[data-changed="false"] [data-when="changed"] {
  opacity: 0;
}
#seal-demo[data-changed="true"] [data-when="changed"] {
  transition-delay: var(--after, 0ms);
}

/* Hide the hero drawing until its decode starts, so it never flashes in
   complete first. If the script never runs, show it after a moment. */
.will-decode .hero > figure svg {
  animation: decode-fallback 0s linear 1.5s forwards;
  opacity: 0;
}
@keyframes decode-fallback {
  to {
    opacity: 1;
  }
}

/* Lists: home, sections, topics ---------------------------------------- */

.library {
  min-height: 72vh;
  padding-block: clamp(40px, 6vw, 88px) 96px;
}
.library > .subtitle {
  max-width: 34ch;
  margin-inline: auto;
  color: var(--ink-2);
  margin-bottom: clamp(32px, 4vw, 48px);
  text-wrap: balance;
}
.topic-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: clamp(48px, 6vw, 88px);
}
.topic-nav a,
.filed a {
  padding: 6px 10px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font: 500 0.72rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 160ms ease, border-color 160ms ease;
}
.topic-nav a[aria-current="page"] {
  color: var(--ink);
  border-color: var(--ink);
}
.entries {
  max-width: 980px;
  margin-inline: auto;
}
/* One row per piece: a drawing (fieldnotes) or a date (journal) on the
   left, what it is on the right. */
.entry {
  display: grid;
  grid-template-columns: minmax(160px, 300px) minmax(0, 560px);
  gap: clamp(22px, 4vw, 56px);
  align-items: center;
  padding-block: clamp(24px, 3vw, 36px);
  border-top: 1px solid var(--line);
  text-decoration: none;
}
.entry:last-child {
  border-bottom: 1px solid var(--line);
}
.entry-journal {
  align-items: start;
}
.entry-date,
.entry-kind {
  color: var(--ink-3);
  font: 500 0.75rem/1.4 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.entry-date {
  padding-top: 6px;
}
.entry-kind {
  margin-bottom: 10px;
}
.entry h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
}
.entry p:last-child {
  color: var(--ink-2);
}
.thumb {
  background: var(--surface);
}
.thumb img {
  display: block;
  width: 100%;
}
.empty {
  color: var(--ink-3);
  text-align: center;
}
/* Beats `article p` and `.prose p`: this is a label, not a paragraph. */
article p.filed {
  max-width: none;
  margin-bottom: 0;
  font-size: 0.75rem;
  line-height: 1;
}
.filed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: clamp(56px, 7vw, 104px);
  color: var(--ink-3);
  font: 500 0.75rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Journal post: one readable column of plain writing --------------------- */

.post {
  width: min(680px, calc(100% - 2 * var(--gutter)));
  padding-block: clamp(40px, 6vw, 88px) clamp(64px, 8vw, 120px);
}
.post-head {
  margin-bottom: clamp(40px, 5vw, 64px);
}
.post-head h1 {
  font-size: clamp(2.6rem, 6vw, 4.5rem);
  letter-spacing: -0.045em;
}
.post-head .subtitle {
  color: var(--ink-2);
}
.prose h2 {
  margin: 48px 0 16px;
  font-size: clamp(1.5rem, 2.4vw, 1.9rem);
}
.prose h3 {
  margin: 32px 0 12px;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}
.prose :is(p, li) {
  font-size: clamp(1.025rem, 1.3vw, 1.09rem);
  line-height: 1.7;
  text-wrap: pretty;
}
.prose p,
.prose :is(ul, ol) {
  margin: 0 0 16px;
}
.prose :is(ul, ol) {
  padding-left: 1.3em;
}
.prose li {
  margin-bottom: 6px;
}
.prose blockquote {
  margin: 28px 0;
  padding-left: 18px;
  border-left: 1px solid var(--ink);
}
.prose pre {
  margin: 24px 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--surface);
  font-size: 0.9rem;
  line-height: 1.6;
}
.prose pre code {
  padding: 0;
  background: none;
  overflow-wrap: normal;
}
.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 32px 0;
}
.prose hr {
  margin: 48px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

@media (hover: hover) and (pointer: fine) {
  .brand-letter:hover {
    color: transparent;
    -webkit-text-stroke: 0.7px var(--ink);
  }
  .publisher:hover,
  .sources a:hover,
  .topic-nav a:hover,
  .filed a:hover {
    color: var(--ink);
  }
  .topic-nav a:hover,
  .filed a:hover {
    border-color: var(--ink);
  }
  .entry:hover h2 {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.12em;
  }
  button:enabled:hover {
    border-color: var(--ink);
  }
  .instrument button:not(#reset):not([data-secondary]):enabled:hover,
  .primary:enabled:hover,
  .seal-action button:enabled:hover,
  button[aria-pressed="true"]:enabled:hover {
    background: var(--ink-2);
    border-color: transparent;
  }
}

@media (max-width: 1099px) {
  .doc-text {
    margin-inline: auto;
  }
}
@media (max-width: 720px) {
  .hero {
    gap: 24px;
  }
  .entry {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .entry-date {
    padding-top: 0;
  }
  .sections {
    gap: 12px;
  }
  /* Spec drawings keep a readable scale; on a phone they scroll sideways. */
  .drawing svg {
    min-width: 600px;
  }
  .timeline .drawing svg {
    min-width: 0;
  }
}
@media (max-width: 500px) {
  .header-inner {
    flex-wrap: wrap;
    row-gap: 12px;
    padding-block: 14px;
  }
  .sections {
    flex: 1 0 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
  .will-decode .hero > figure svg {
    animation: none;
    opacity: 1;
  }
}
