/* ==========================================================================
   Pack: "Graphite + Signal".
   HB pencil on vellum: achromatic graphite, one signal yellow under 5% of the
   page, never yellow text on light. Light = vellum, dark = ink inverted.
   ========================================================================== */

:root {
  --bg: oklch(0.985 0 0); --bg-deep: oklch(0.96 0 0); --surface: oklch(1 0 0);
  --sl: oklch(0.96 0 0); --sd: oklch(0.94 0 0);
  --text: oklch(0.20 0 0); --muted: oklch(0.38 0 0); --light: oklch(0.51 0 0);
  --border: oklch(0.80 0 0); --bl: oklch(0.90 0 0); --control-edge: oklch(0.62 0 0);
  --accent: oklch(0.85 0.17 95); --accent-ink: oklch(0.20 0 0);
  --action: oklch(0.20 0 0); --action-ink: oklch(0.99 0 0); --action-hover: oklch(0.30 0 0);
  --focus: var(--text);
  --grid: oklch(0.20 0 0 / 0.06);
  --shc: 0 1px 2px oklch(0 0 0 / 0.04), 0 4px 16px oklch(0 0 0 / 0.04);

  --r4: 3px; --r8: 6px; --r12: 8px;
  --f-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --w: 720px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: oklch(0.16 0 0); --bg-deep: oklch(0.115 0 0); --surface: oklch(0.21 0 0);
  --sl: oklch(0.25 0 0); --sd: oklch(0.28 0 0);
  --text: oklch(0.93 0 0); --muted: oklch(0.75 0 0); --light: oklch(0.65 0 0);
  --border: oklch(0.38 0 0); --bl: oklch(0.30 0 0); --control-edge: oklch(0.50 0 0);
  --action: oklch(0.93 0 0); --action-ink: oklch(0.20 0 0); --action-hover: oklch(1 0 0);
  --focus: var(--accent); --grid: oklch(0.30 0 0 / 0.5); --shc: none;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: oklch(0.16 0 0); --bg-deep: oklch(0.115 0 0); --surface: oklch(0.21 0 0);
  --sl: oklch(0.25 0 0); --sd: oklch(0.28 0 0);
  --text: oklch(0.93 0 0); --muted: oklch(0.75 0 0); --light: oklch(0.65 0 0);
  --border: oklch(0.38 0 0); --bl: oklch(0.30 0 0); --control-edge: oklch(0.50 0 0);
  --action: oklch(0.93 0 0); --action-ink: oklch(0.20 0 0); --action-hover: oklch(1 0 0);
  --focus: var(--accent); --grid: oklch(0.30 0 0 / 0.5); --shc: none;
  color-scheme: dark }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg-deep); color: var(--text);
  font-family: var(--f-sans); font-size: 1rem; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r4); }

a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 0.2em; }
@media (hover: hover) and (pointer: fine) { a:hover { text-decoration-color: var(--accent); } }

/* --- the drawing board --------------------------------------------------- */
.page {
  position: relative; isolation: isolate;
  padding-block: clamp(20px, 4vw, 40px) 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
/* Drafting grid behind the top of every page. Decorative, inert. */
.page::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 420px; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid) 0 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 0 1px, transparent 1px);
  background-size: 3.5rem 3.5rem;
  mask-image: radial-gradient(90% 100% at 70% 0%, #000 0%, transparent 75%);
}
.sheet {
  max-width: var(--w); margin: 0 auto; background: var(--surface);
  border: 1px solid var(--bl); border-radius: var(--r12); box-shadow: var(--shc);
  padding: clamp(20px, 5vw, 44px); display: grid; gap: clamp(28px, 5vw, 40px);
}

/* --- type ---------------------------------------------------------------- */
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 5.5vw, 2.6rem); line-height: 1.08; letter-spacing: -0.03em; font-weight: 600; }
h1:has(em) { font-weight: 500; }
/* Highlighter pass: yellow underline, weight carries it too (never the sole signal). */
h1 em { font-style: normal; font-weight: 600; box-shadow: inset 0 -0.12em 0 var(--accent); box-decoration-break: clone; -webkit-box-decoration-break: clone; }
h2 { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--light); display: flex; align-items: center; gap: 0.6rem; }
/* Drawing-sheet section rule: short ink tick before every section label. */
h2::before { content: ""; width: 1rem; height: 1px; background: var(--text); flex: none; }
h3 { font-size: 1.06rem; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; max-width: 62ch; text-wrap: pretty; }
.meta { color: var(--muted); }
.muted { color: var(--light); font-size: 0.9rem; }
.mono, .n, time { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
section { display: grid; gap: 14px; }
header.top { display: grid; gap: 10px; }
.eyebrow { font-family: var(--f-mono); font-size: 0.75rem; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; color: var(--light); text-transform: uppercase; }
section > .btn { justify-self: start; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
q { quotes: "“" "”" "‘" "’"; }

/* --- controls ------------------------------------------------------------ */
.btn {
  --lift: 0; display: inline-flex; align-items: center; gap: 0.6rem; min-height: 44px; padding: 0.7rem 1.25rem;
  background: var(--action); color: var(--action-ink); font: inherit; font-weight: 600; text-decoration: none;
  border: 0; border-radius: var(--r8); cursor: pointer; transform: translateY(var(--lift));
  transition: transform 150ms var(--ease-out-quart);
}
.btn .arrow { transition: transform 160ms var(--ease-out-quart); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--action-hover); --lift: -1px; }
  .btn:hover .arrow { transform: translateX(3px); }
}
.btn:active { transform: translateY(0) scale(0.96); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--control-edge); }
@media (hover: hover) and (pointer: fine) { .btn.ghost:hover { background: var(--sl); } }

.back { max-width: var(--w); margin: 0 auto 10px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.back a { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 44px; color: var(--muted); text-decoration: none; font-size: 0.875rem; }
.back a:hover { color: var(--text); }
.back .arrow { transition: transform 160ms var(--ease-out-quart); }
.back a:hover .arrow { transform: translateX(-3px); }
/* Datum mark: the register crosshair, signal-yellow centre as the one accent. */
.datum { width: 22px; height: 22px; flex: none; color: var(--text); }

/* --- page ending: the same on every page, next page in reading order --- */
.pager {
  border-top: 1px solid var(--bl); padding-top: 12px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 16px;
}
.pager a { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; text-decoration: none; font-weight: 600; }
.pager a .lbl { color: var(--muted); font-weight: 400; }
.pager .arrow { transition: transform 160ms var(--ease-out-quart); }
@media (hover: hover) and (pointer: fine) { .pager a:hover .arrow { transform: translateX(3px); } }

/* Signal marker: a small yellow square, always next to ink text that says the same thing. */
.sig { display: inline-block; width: 8px; height: 8px; background: var(--accent); box-shadow: 0 0 0 1px currentColor; flex: none; }

/* --- motion: one orchestrated entrance, then still --------------------------
   Content is visible by default. motion.js adds .js-motion only when it runs. */
.js-motion [data-reveal] { opacity: 0; transform: translateY(0.7rem); }
.js-motion [data-reveal].is-in {
  opacity: 1; transform: none;
  transition: opacity 520ms var(--ease-out-quart), transform 720ms var(--ease-out-expo);
}
.js-motion [data-reveal]:focus-within { opacity: 1; transform: none; transition: none; }
@media (prefers-reduced-motion: reduce) {
  .js-motion [data-reveal] { transform: none; }
  .js-motion [data-reveal].is-in { transition: opacity 200ms ease; }
  .btn, .btn .arrow, .back .arrow, .pager .arrow { transition: none; }
  .btn:hover, .btn:active, .btn:hover .arrow, .back a:hover .arrow, .pager a:hover .arrow { transform: none; }
}

@media print {
  :root:root {
    --bg: #fff; --bg-deep: #fff; --surface: #fff; --sl: #fff; --sd: #fff;
    --text: #000; --muted: #333; --light: #444;
    --border: #777; --bl: #bbb; --control-edge: #777;
    color-scheme: light;
  }
  .js-motion [data-reveal], .js-motion [data-reveal].is-in { opacity: 1; transform: none; transition: none; }
  .page { padding: 0; } .page::before { display: none; }
  .sheet { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .back, .pager, .page .no-print { display: none; }
}
