/* cupel docs — the fire-assay design system.
   Clean bone-ash paper throughout, with one calm warm-dark hearth for the hero.
   The accent is a restrained, muted gold (the refined bead), used as a hint:
   underlines, a drop cap, small markers, the fineness numbers. Display type is
   inscriptional (Hedvig Letters Serif); the reading body is Spectral; data and
   code are JetBrains Mono.

   Layout is an assay report: a persistent left sidebar of section links beside
   a reading column of numbered steps, each opened by a fineness-rule divider. */

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

html {
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

:root {
  color-scheme: light;
  --nav-h: 54px;

  --ico-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4.5' fill='black'/%3E%3Cpath d='M12 2v2.5M12 19.5V22M4.2 4.2l1.8 1.8M18 18l1.8 1.8M2 12h2.5M19.5 12H22M4.2 19.8l1.8-1.8M18 6l1.8-1.8' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  --ico-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8z' fill='black'/%3E%3C/svg%3E");

  /* Paper — bone-ash. Warm chalky off-white in light; ember-tinted charcoal in
     dark. Hue ~45 (warm red-orange tint), never navy. */
  --bg:        light-dark(oklch(0.955 0.010 72), oklch(0.165 0.016 45));
  --bg-alt:    light-dark(oklch(0.925 0.014 72), oklch(0.205 0.018 44));
  --surface:   light-dark(oklch(0.985 0.006 72), oklch(0.205 0.016 44));

  /* Ink */
  --ink:       light-dark(oklch(0.245 0.018 50), oklch(0.930 0.012 75));
  --ink-2:     light-dark(oklch(0.380 0.020 50), oklch(0.800 0.014 72));
  --ink-3:     light-dark(oklch(0.500 0.020 52), oklch(0.660 0.014 70));
  --ink-4:     light-dark(oklch(0.610 0.016 55), oklch(0.500 0.014 68));

  /* Gold — a restrained, refined accent. Used sparingly: a hint, not a flood.
     Muted (low chroma), warm hue ~85; never the bright incandescent orange. */
  --gold:      light-dark(oklch(0.660 0.080 84), oklch(0.800 0.075 87));
  --gold-deep: light-dark(oklch(0.535 0.072 80), oklch(0.760 0.082 86));
  --gold-soft: light-dark(oklch(0.760 0.045 86), oklch(0.560 0.060 84));  /* hairlines, faint fills */

  --rule:      light-dark(oklch(0.890 0.008 80), oklch(0.310 0.010 60));
  --border:    light-dark(oklch(0.910 0.007 80), oklch(0.275 0.010 60));

  /* Type scale — rem so it honours the reader's browser font size. Reading
     sizes climb ~1.18x; the two small mono-label steps stay tight because
     uppercase data labels must read compact. */
  --text-micro: 0.6875rem;  /* 11px  uppercase mono labels: eyebrow, kicker, tag, th */
  --text-mono:  0.8125rem;  /* 13px  mono UI + code: sidebar, step no., code, vault */
  --text-sm:    0.875rem;   /* 14px  compact prose / nav */
  --text-ui:    0.9375rem;  /* 15px  nav links, command name, footer links */
  --text-md:    1.0625rem;  /* 17px  secondary prose: command job, cited work */
  --text-body:  1.1875rem;  /* 19px  the reading body */
  --text-lede:  clamp(1.1875rem, 1.6vw, 1.4375rem);  /* 19->23  masthead lede */
  --text-h2:    1.625rem;   /* 26px  footer wordmark */
  --text-name:  clamp(1.4375rem, 2vw, 1.875rem);     /* 23->30  thinker names */
  --text-title: clamp(1.75rem, 3vw, 2.5rem);         /* 28->40  step titles */
  --text-mast:  clamp(2.5rem, 5vw, 4.25rem);         /* 40->68  page masthead */

  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-quick: 150ms;
  --dur-base:  260ms;

  --sans:    'Spectral', 'Iowan Old Style', Palatino, Georgia, serif;
  --display: 'Hedvig Letters Serif', 'Spectral', Georgia, serif;
  --mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme="light"] { color-scheme: light; }
[data-theme="dark"]  { color-scheme: dark; }

body {
  font-family: var(--sans);
  font-weight: 400;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1, "calt" 1;
  font-variant-numeric: oldstyle-nums;
}

::selection {
  background: light-dark(oklch(0.86 0.060 86), oklch(0.46 0.060 84));
  color: light-dark(oklch(0.24 0.02 60), oklch(0.97 0.01 80));
}

a { color: inherit; }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
img, svg { display: block; max-width: 100%; }

.skip {
  position: absolute; left: -10000px; top: 8px;
  background: var(--ink); color: var(--bg);
  padding: 8px 14px;
  font-family: var(--mono); font-weight: 500; font-size: var(--text-mono);
  z-index: 999;
}
.skip:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; border-radius: 1px; }

/* ── NAV ─────────────────────────────────────────────────── */

.site-nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: color-mix(in oklab, var(--bg) 90%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
  padding: 0 clamp(20px, 4vw, 40px);
  display: flex; align-items: center; gap: 32px;
}
.site-nav-home {
  font-family: var(--display);
  font-size: var(--text-body);
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 9px;
}
.site-nav-home .mark { width: 22px; height: 22px; }
.site-nav-links {
  margin-left: auto;
  display: flex; align-items: center; gap: 26px;
  font-size: var(--text-ui); font-weight: 500;
}
.site-nav-links a {
  color: var(--ink-3); text-decoration: none;
  transition: color var(--dur-quick);
}
.site-nav-links a:hover { color: var(--ink); }
.site-nav-links a[aria-current="page"] { color: var(--gold-deep); }

.theme-toggle {
  color: var(--ink-3);
  padding: 3px 10px; border-radius: 2px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color var(--dur-quick), background-color var(--dur-quick);
}
.theme-toggle:hover { color: var(--gold-deep); background-color: var(--bg-alt); }
.theme-toggle .glyph {
  width: 0.95em; height: 0.95em; align-self: center;
  background-color: currentColor;
  -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat;
}
.theme-toggle-dark .glyph { -webkit-mask-image: var(--ico-moon); mask-image: var(--ico-moon); }
.theme-toggle-light .glyph { -webkit-mask-image: var(--ico-sun); mask-image: var(--ico-sun); }
.theme-toggle-dark { display: inline-flex; align-items: center; gap: 6px; }
.theme-toggle-light { display: none; }
[data-theme="dark"] .theme-toggle-dark { display: none; }
[data-theme="dark"] .theme-toggle-light { display: inline-flex; align-items: center; gap: 6px; }

/* ── SHELL: persistent left sidebar + reading column ─────── */

.shell {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 40px) clamp(72px, 9vw, 112px);
  display: grid;
  grid-template-columns: 196px minmax(0, 720px);
  column-gap: clamp(36px, 5vw, 56px);
  justify-content: center;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: var(--nav-h);
  align-self: start;
  max-height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: clamp(40px, 5vw, 72px) 8px clamp(32px, 4vw, 56px) 0;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.sidebar-label {
  font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 0.14em; font-size: var(--text-micro); color: var(--ink-4);
  margin-bottom: 18px;
}
.sidebar ol { list-style: none; display: flex; flex-direction: column; gap: 11px; }
.sidebar a {
  display: flex; align-items: baseline; gap: 10px;
  text-decoration: none;
  font-family: var(--mono); font-size: var(--text-mono); line-height: 1.4;
  letter-spacing: 0.01em; color: var(--ink-3);
  transition: color var(--dur-quick);
}
.sidebar a .n {
  font-size: var(--text-micro); font-weight: 600; color: var(--ink-4);
  font-variant-numeric: lining-nums; transition: color var(--dur-quick);
}
.sidebar a:hover { color: var(--ink); }
.sidebar a:hover .n { color: var(--gold-deep); }
.sidebar a.is-current { color: var(--ink); font-weight: 600; }
.sidebar a.is-current .n { color: var(--gold-deep); }

/* ── READER: the reading column of assay steps ───────────── */

.reader {
  padding: clamp(40px, 5vw, 72px) 0 0;
  font-size: var(--text-body); line-height: 1.68; color: var(--ink);
  hanging-punctuation: first last;
}

/* ── MASTHEAD: the page header, top of the reading column ── */
.masthead {
  margin-bottom: clamp(36px, 5vw, 56px);
  padding-bottom: clamp(28px, 4vw, 44px);
  border-bottom: 1px solid var(--rule);
}
.masthead-eyebrow {
  font-family: var(--mono); font-size: var(--text-mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold-deep); margin-bottom: 16px;
}
.masthead-title {
  font-family: var(--display); font-weight: 400;
  font-size: var(--text-mast); line-height: 1.0;
  letter-spacing: -0.01em; color: var(--ink);
  margin-bottom: 20px; max-width: 18ch;
}
.masthead-lede {
  font-size: var(--text-lede); line-height: 1.5;
  color: var(--ink-2); max-width: 60ch;
}

.step {
  padding-bottom: clamp(38px, 5vw, 64px);
  margin-bottom: clamp(36px, 5vw, 60px);
  scroll-margin-top: 72px;
}
.step:last-child { margin-bottom: 0; padding-bottom: 0; }

/* The fineness rule: a struck number, its label, and a dotted line, all on
   one line, opening each step. */
.step-rule { display: flex; align-items: center; gap: 13px; margin-bottom: 16px; }
.step-num {
  font-family: var(--mono); font-size: var(--text-mono); font-weight: 600;
  letter-spacing: 0.12em; color: var(--gold-deep);
  font-variant-numeric: lining-nums;
}
.step-kicker {
  font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 0.13em; font-size: var(--text-micro); color: var(--ink-4);
  white-space: nowrap;
}
.step-line { flex: 1; height: 0; border-top: 1px dashed var(--rule); }
.step-title {
  font-family: var(--display); font-weight: 400;
  font-size: var(--text-title); line-height: 1.08;
  letter-spacing: -0.005em; color: var(--ink);
  margin-bottom: 24px; max-width: 22ch;
}

.step h3 {
  font-family: var(--display); font-weight: 400;
  font-size: 1.32em; color: var(--ink);
  margin: 1.7em 0 0.35em; line-height: 1.25; scroll-margin-top: 72px;
}
.step p { margin-bottom: 1.05em; }
.step p:last-child { margin-bottom: 0; }

/* Drop cap — struck in molten ember, only when the opening paragraph leads
   with .newthought (guaranteeing the first glyph is a letter). */
.step > p:first-of-type:has(> .newthought:first-child)::first-letter {
  font-family: var(--display); font-size: 3.5em; line-height: 0.82;
  float: left; margin: 0.06em 10px -0.04em 0;
  color: var(--gold-deep);
  font-variant: normal; font-variant-numeric: normal;
}

.step a {
  color: var(--ink); text-decoration: underline;
  text-decoration-color: var(--gold); text-decoration-thickness: 1px;
  text-underline-offset: 3px; transition: text-decoration-thickness var(--dur-quick);
}
.step a:hover { text-decoration-thickness: 2px; }
.step strong { font-weight: 600; color: var(--ink); }
.step em { font-style: italic; }
.newthought { font-variant: small-caps; font-weight: 600; letter-spacing: 0.03em; }

.step ul, .step ol { padding-left: 1.3em; margin-bottom: 1.1em; }
.step li { margin-bottom: 0.45em; }
.step ul li::marker { color: var(--gold); content: "\25c6  "; }
.step ol li::marker { color: var(--ink-4); font-family: var(--mono); font-size: 0.85em; }

.step code {
  font-family: var(--mono); font-size: 0.82em;
  background: var(--bg-alt); padding: 1.5px 5px; border-radius: 2px;
  font-variant-numeric: lining-nums;
}
.step pre {
  font-family: var(--mono); font-size: var(--text-mono); line-height: 1.65;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 4px;
  padding: 15px 18px; overflow-x: auto; margin: 1.4em 0;
  scrollbar-width: thin; scrollbar-color: var(--ink-4) transparent;
  font-variant-numeric: lining-nums;
}
.step pre code { background: none; padding: 0; font-size: inherit; }
.step pre .c { color: var(--ink-4); font-style: italic; }
.step pre .p { color: var(--gold-deep); }

.step blockquote {
  margin: 1.5em 0; padding: 2px 0 2px 22px;
  border-left: 2px solid var(--gold);
  font-style: italic; color: var(--ink-2);
}

/* Aside — a quiet supplementary line. No box: just smaller, lighter text. */
.sidenote {
  display: block;
  margin: 1.2em 0;
  font-size: 0.9em; line-height: 1.55; color: var(--ink-3);
}

/* ── COMMAND LEDGER ──────────────────────────────────────── */
.ledger { margin: 1.6em 0 0.4em; }
.ledger-row {
  display: grid; grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 6px 26px; align-items: baseline;
  padding: 15px 0; border-top: 1px solid var(--rule);
}
.ledger-row:last-child { border-bottom: 1px solid var(--rule); }
.ledger-cmd {
  font-family: var(--mono); font-size: var(--text-ui); font-weight: 600; color: var(--gold-deep);
}
.ledger-job { color: var(--ink-2); font-size: var(--text-md); line-height: 1.5; }
.ledger-job code { font-size: 0.86em; }

/* ── TABLES (incl. categories) ───────────────────────────── */
.step table, .data-table {
  width: 100%; border-collapse: collapse; margin: 1.6em 0; font-size: 0.95em;
}
.step th, .step td, .data-table th, .data-table td {
  border-bottom: 1px solid var(--rule);
  padding: 11px 16px 11px 0; text-align: left; vertical-align: top; line-height: 1.5;
}
.step th, .data-table th {
  font-family: var(--mono); text-transform: uppercase; font-size: var(--text-micro);
  font-weight: 500; letter-spacing: 0.08em; color: var(--ink-3);
}
.data-table td:first-child {
  font-family: var(--display); font-size: 1.06em; color: var(--ink); white-space: nowrap;
}
.data-table .tag {
  font-family: var(--mono); font-size: var(--text-micro); color: var(--gold-deep);
  display: block; margin-top: 3px; font-variant-numeric: lining-nums;
}

/* ── CALLOUT: the assay note ─────────────────────────────── */
.assay-note {
  margin: 1.8em 0; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
}
.assay-note .label {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.1em;
  font-size: var(--text-micro); font-weight: 600; color: var(--gold-deep);
  display: flex; align-items: center; gap: 8px; margin-bottom: 9px;
}
.assay-note .label::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
}
.assay-note p { margin-bottom: 0.6em; font-size: 0.98em; }
.assay-note p:last-child { margin-bottom: 0; }

/* ── CANON: the thinkers ─────────────────────────────────── */
.thinker {
  padding: clamp(22px, 3vw, 32px) 0; border-bottom: 1px solid var(--rule);
  scroll-margin-top: 72px;
}
.thinker:last-of-type { border-bottom: none; }
.thinker-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.thinker-name { font-family: var(--display); font-size: var(--text-name); line-height: 1.1; color: var(--ink); }
.thinker-work { font-style: italic; color: var(--ink-3); font-size: var(--text-md); }
.thinker-tag {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em;
  font-size: var(--text-micro); color: var(--gold-deep); margin-left: auto; white-space: nowrap;
}
.thinker p { color: var(--ink-2); margin-bottom: 0; }

/* ── OFFICE: the vault tree ──────────────────────────────── */
.vault {
  font-family: var(--mono); font-size: var(--text-mono); line-height: 1.9;
  white-space: pre;
  background: var(--bg-alt); color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 20px 22px; margin: 1.6em 0; overflow-x: auto;
}
.vault .dir { color: var(--gold-deep); font-weight: 500; }
.vault .note { color: var(--ink); }
.vault .cmt { color: var(--ink-4); }

/* ── FOOT (light and calm; a hairline, not a dark slab) ──── */
.site-foot {
  background: var(--bg);
  border-top: 1px solid var(--rule);
  padding: clamp(44px, 6vw, 72px) 0 30px;
}
.site-foot-wrap { max-width: 740px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px); }
.site-foot-brand {
  font-family: var(--display); font-size: var(--text-h2); color: var(--ink);
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px;
}
.site-foot-brand .mark { width: 24px; height: 24px; }
.site-foot-links {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0 14px; row-gap: 8px; margin-bottom: 26px; font-size: var(--text-ui);
}
.site-foot-sep { color: var(--ink-4); user-select: none; }
.site-foot a {
  color: var(--ink-2); text-decoration: underline;
  text-decoration-color: var(--gold-soft); text-underline-offset: 3px;
  transition: color var(--dur-quick);
}
.site-foot a:hover { color: var(--gold-deep); }
.site-foot-rule {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 22px; border-top: 1px solid var(--rule);
  flex-wrap: wrap; gap: 12px; font-size: var(--text-mono); color: var(--ink-4);
}
.site-foot-rule .mono { font-family: var(--mono); letter-spacing: 0.03em; }
.site-foot-note {
  margin-top: 16px; font-size: var(--text-mono); font-style: italic;
  color: var(--ink-4); max-width: 64ch;
}

/* ── NARROW ──────────────────────────────────────────────── */
/* Below the two-column threshold the sidebar folds to a compact wrapped
   section list above the content. */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; max-height: none; overflow: visible;
    padding: clamp(28px, 5vw, 44px) 0 0;
    margin-bottom: clamp(4px, 2vw, 14px);
  }
  .sidebar ol { flex-direction: row; flex-wrap: wrap; gap: 7px 18px; }
  .reader { padding-top: clamp(24px, 4vw, 36px); }
}

@media (max-width: 600px) {
  .site-nav { gap: 14px; padding: 0 18px; }
  .site-nav-links { gap: 14px; font-size: var(--text-sm); }
  .ledger-row { grid-template-columns: 1fr; gap: 4px; }
  .ledger-job { font-size: 1rem; }
  .site-foot-rule { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* Stack the four-column categories table into labelled cards before its
   columns get too cramped to read. */
@media (max-width: 720px) {
  .data-table thead { display: none; }
  .data-table tr { display: block; padding: 14px 0; border-bottom: 1px solid var(--rule); }
  .data-table td { display: block; border-bottom: none; padding: 2px 0; }
  .data-table td:first-child { font-size: 1.2em; white-space: normal; margin-bottom: 6px; }
  .data-table td::before {
    content: attr(data-label);
    font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.07em;
    font-size: var(--text-micro); color: var(--ink-4); display: block; margin-top: 6px;
  }
  .data-table td:first-child::before { content: none; }
}
