/* ─────────────────────────────────────────────────────────────
   Phrontic — an engraved treatise, plainly bound
   Aged paper · sepia ink · one rubric red · copperplate line art
   Chrome (wordmark, nav, controls): Instrument Sans, as before.
   Reading matter and plates: the Fell types (Oxford, c. 1700).
   ───────────────────────────────────────────────────────────── */

:root {
  --paper: #e9e1cd;
  --paper-light: #f2ebd9;
  --paper-deep: #d6c9a9;
  --ink: #241b12;
  --ink-soft: #4a3d2e;
  --ink-faint: #75664f;
  --rule: #a5957a;
  --rule-faint: #c9bc9d;
  --rubric: #8f2b1c;
  --accent: #c8371e;       /* the wordmark's dot, unchanged from the original */
  --sans: "Instrument Sans", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --fell: "IM Fell English", Georgia, "Times New Roman", serif;
  --fell-sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --pica: "IM Fell DW Pica", "IM Fell English", Georgia, serif;
  --wrap: 72rem;
  --measure: 62ch;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 70% 45% at 15% 8%, rgba(110, 78, 38, 0.09), transparent 70%),
    radial-gradient(ellipse 55% 45% at 88% 92%, rgba(110, 78, 38, 0.13), transparent 70%),
    radial-gradient(ellipse at 50% 40%, var(--paper-light) 0%, var(--paper) 60%, var(--paper-deep) 140%);
  background-attachment: fixed;
  font-family: var(--fell);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga", "kern";
}

/* Paper grain, laid lightly over everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 998;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.33  0 0 0 0 0.25  0 0 0 0 0.15  0 0 0 0.5 0'/></filter><rect width='300' height='300' filter='url(%23n)'/></svg>");
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.5rem, 5vw, 3rem);
}

::selection { background: var(--ink); color: var(--paper); }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--ink) 40%, transparent);
  text-underline-offset: 0.2em;
  transition: color 140ms ease, text-decoration-color 140ms ease;
}
a:hover { color: var(--rubric); text-decoration-color: var(--rubric); }

a:focus-visible,
button:focus-visible,
.slip:has(input:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ─── Skip link ─── */
.skip-link {
  position: absolute;
  top: -3.5rem;
  left: 1.5rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.9rem;
  z-index: 1000;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.skip-link:focus { top: 1.5rem; }

/* ─── Header: the original wordmark and nav, untouched in type ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule-faint);
  font-family: var(--sans);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 1.25rem;
}
.wordmark {
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
}
.wordmark:hover { color: var(--ink); }
.wordmark .dot { color: var(--accent); }

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.9rem;
}
.nav a {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
}
.nav a:hover { color: var(--rubric); }

/* ─── Hero ─── */
.hero {
  padding: clamp(4.5rem, 11vw, 8.5rem) 0 0;
  text-align: center;
}
.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.eyebrow {
  margin: 0 0 1.6rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rubric);
}
.tagline {
  margin: 0;
  font-family: var(--pica);
  font-weight: 400;
  font-size: clamp(2.6rem, 6.6vw, 5.2rem);
  line-height: 1.04;
  letter-spacing: -0.008em;
  max-width: 15ch;
}
.one-liner {
  margin: 2rem 0 0;
  max-width: 56ch;
  font-size: clamp(1.12rem, 1.5vw, 1.3rem);
  line-height: 1.55;
  color: var(--ink-soft);
}
.hero-cta {
  margin: 2.8rem 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem 1.1rem;
}

.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 0.8rem 1.6rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn[disabled]:hover { background: transparent; color: var(--ink); }
.btn-rubric { color: var(--rubric); border-color: var(--rubric); }
.btn-rubric:hover { background: var(--rubric); border-color: var(--rubric); }
.btn-quiet { border-color: var(--rule); color: var(--ink-soft); }
.btn-quiet:hover { border-color: var(--ink); }

/* ─── Plates (figures) ─── */
.plate {
  margin: clamp(3rem, 7vw, 5.5rem) auto 0;
  padding: 0;
  max-width: 100%;
}
.plate-mount {
  padding: clamp(14px, 2.4vw, 30px);
  background: var(--paper-light);
  border: 1px solid var(--rule);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 30px 60px -40px rgba(36, 27, 18, 0.55),
    0 2px 6px -3px rgba(36, 27, 18, 0.25);
}
.plate-mount > svg,
.plate-mount > canvas {
  display: block;
  width: 100%;
  height: auto;
  color: var(--ink);
  background: var(--paper-light);
  outline: 1px solid color-mix(in srgb, var(--ink) 55%, transparent);
  outline-offset: 5px;
}
.plate-mount > canvas { image-rendering: auto; }
.plate-glyph { font-family: var(--pica); }
.plate-label { font-family: var(--fell); }
.plate-caption { font-family: var(--fell); font-style: italic; }
.plate figcaption {
  margin-top: 1.1rem;
  text-align: center;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-faint);
  max-width: 70ch;
  margin-inline: auto;
}
.plate figcaption .pl {
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rubric);
  margin-right: 0.7em;
}

/* Colour, where light falls on a plate. */
.lantern-glow {
  mix-blend-mode: multiply;
  transform-box: fill-box;
  transform-origin: center;
  animation: flicker 4.2s ease-in-out infinite;
}
.door-glow {
  transform-box: fill-box;
  transform-origin: center;
  animation: breathe 7s ease-in-out infinite;
}
.flame {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flame 1.3s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  28% { opacity: 1; transform: scale(1.05); }
  52% { opacity: 0.72; transform: scale(0.965); }
  78% { opacity: 0.94; transform: scale(1.025); }
}
@keyframes breathe {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes flame {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  35% { transform: scaleY(1.12) scaleX(0.92); }
  70% { transform: scaleY(0.94) scaleX(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .lantern-glow, .door-glow, .flame { animation: none; }
}

/* ─── Sections ─── */
.section { padding: clamp(4rem, 9vw, 7rem) 0 0; }
.statement {
  margin: 0;
  font-family: var(--pica);
  font-size: clamp(1.75rem, 3vw, 2.6rem);
  line-height: 1.2;
  max-width: 28ch;
  letter-spacing: -0.005em;
}
.section-body {
  margin-top: 1.8rem;
  max-width: var(--measure);
}
.section-body p { margin: 0 0 1.25rem; }
.section-body p:last-child { margin-bottom: 0; }
.section-body > p:first-of-type::first-letter {
  float: left;
  font-family: var(--pica);
  font-size: 3.9em;
  line-height: 0.8;
  padding: 0.05em 0.14em 0 0;
  color: var(--rubric);
}

.section-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

/* Definition rows */
.rows {
  margin: 1.8rem 0 0;
  border-top: 1px solid var(--ink);
}
.section-cols .rows { margin-top: 0.6rem; }
.rows .row {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--rule-faint);
}
.rows .row:last-child { border-bottom: 1px solid var(--ink); }
.rows dt {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  padding-top: 0.3rem;
}
.rows dd { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }

/* Dividers */
.fleuron {
  display: block;
  width: min(30rem, 70%);
  height: auto;
  margin: clamp(4rem, 9vw, 7rem) auto 0;
  color: var(--rule);
}

/* ─── The Diffusion Press ─── */
.press {
  margin-top: 2.6rem;
  border: 1px solid var(--rule);
  padding: clamp(1.4rem, 3vw, 2.4rem);
  background: color-mix(in srgb, var(--paper-light) 75%, transparent);
  box-shadow: 0 30px 60px -44px rgba(36, 27, 18, 0.5);
}
.press-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: end;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 1.2rem;
}
.press-title {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rubric);
}
.press-instruction {
  margin: 0.5rem 0 0;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.02rem;
}
.press-gauge { width: 6.5rem; height: auto; color: var(--ink); }
.press-gauge .gauge-needle { transition: transform 260ms ease-out; }

.press-slips {
  margin: 0.4rem 0 0;
  border-bottom: 1px solid var(--rule-faint);
}
.slip {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.85rem 0.25rem;
  border-bottom: 1px solid var(--rule-faint);
  cursor: pointer;
  position: relative;
  transition: color 120ms ease;
}
.slip:last-child { border-bottom: 0; }
.slip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slip-num {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.slip-title { font-size: 1.05rem; line-height: 1.3; color: var(--ink-soft); }
.slip:hover .slip-title { color: var(--ink); }
.slip::after {
  content: "";
  width: 6px; height: 6px;
  border: 1px solid var(--rule);
  transform: rotate(45deg);
  align-self: center;
  justify-self: end;
  transition: background 120ms ease, border-color 120ms ease;
}
.slip:has(input:checked) .slip-title { color: var(--ink); }
.slip:has(input:checked) .slip-num { color: var(--rubric); }
.slip:has(input:checked)::after { background: var(--rubric); border-color: var(--rubric); }

.press-question {
  margin: 1.6rem 0 0;
  font-style: italic;
  font-size: 1.15rem;
  padding-left: 1rem;
  border-left: 1px solid var(--rubric);
}

.press-controls {
  margin: 1.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}
.press-controls .hint {
  font-size: 0.92rem;
  font-style: italic;
  color: var(--ink-faint);
  margin-left: auto;
}

.lanes {
  margin-top: 1.6rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem;
}
.lane {
  border: 1px solid var(--rule);
  background: var(--paper-light);
  display: flex;
  flex-direction: column;
  min-height: 19rem;
}
.lane-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule-faint);
  font-family: var(--sans);
}
.lane-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.lane-clock { font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--ink-soft); }
.lane-text {
  padding: 1.1rem 1.2rem;
  flex: 1;
  font-size: 1.05rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 12rem;
}
.lane-text.is-code {
  font-family: "Courier Prime", "Courier New", Courier, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}
.lane-note {
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--rule-faint);
  font-size: 0.86rem;
  font-style: italic;
  color: var(--ink-faint);
  margin: 0;
}
.lane[data-lane="dif"] .lane-title { color: var(--rubric); }
.is-done .lane[data-lane="dif"] .lane-clock { color: var(--rubric); }

.tok { transition: color 220ms ease, opacity 220ms ease; }
.tok.hidden { visibility: hidden; }
.tok.fresh { color: var(--rubric); }
.tok.noise { color: var(--rubric); opacity: 0.38; }
.tok.settled { animation: settle 480ms ease-out; }
@keyframes settle {
  from { color: var(--rubric); opacity: 0.55; }
  to { color: var(--ink); opacity: 1; }
}

.press-foot {
  margin: 1.3rem 0 0;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-faint);
  max-width: 70ch;
}

/* ─── Footer ─── */
.site-footer {
  margin-top: clamp(5rem, 11vw, 8rem);
  padding: 2.6rem 0 clamp(2.2rem, 5vw, 3.5rem);
  border-top: 1px solid var(--ink);
}
.footer-hire { margin: 0; font-size: 1.1rem; }
.footer-row {
  margin-top: 2.2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem 2rem;
  font-family: var(--sans);
}
.footer-brand { margin: 0; font-size: 0.875rem; color: var(--ink-faint); }
.footer-links {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  gap: 1.6rem;
  font-size: 0.9rem;
}
.footer-links a { text-decoration: none; color: var(--ink-soft); }
.footer-links a:hover { color: var(--rubric); }
.footer-imprint {
  margin: 2.4rem 0 0;
  text-align: center;
  font-family: var(--fell-sc);
  letter-spacing: 0.2em;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ─── Reveal ─── */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 800ms ease, transform 800ms ease;
}
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ─── Responsive ─── */
@media (max-width: 860px) {
  .section-cols { grid-template-columns: minmax(0, 1fr); }
  .section-cols .rows { margin-top: 1.4rem; }
  .lanes { grid-template-columns: minmax(0, 1fr); }
  .lane { min-height: 0; }
}
@media (max-width: 640px) {
  body { font-size: 1.06rem; }
  .header-row { flex-direction: column; align-items: flex-start; gap: 0.7rem; padding-block: 1rem; }
  .nav ul { gap: 0.25rem 1.2rem; }
  .nav a { font-size: 0.875rem; }
  .hero { text-align: left; }
  .hero-inner { align-items: flex-start; }
  .hero-cta { justify-content: flex-start; }
  .rows .row { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
  .press-head { grid-template-columns: minmax(0, 1fr); }
  .press-gauge { width: 5.5rem; }
  .slip { grid-template-columns: 2.6rem minmax(0, 1fr) auto; }
  .press-controls .hint { margin-left: 0; flex-basis: 100%; }
}
