/* Hallmark · macrostructure: Map / Diagram · genre: editorial · theme: Almanac (warm)
 * tone: technical, austere · audience: engineers evaluating the framework
 * nav: N3 Side-rail · footer: Ft4 Dense colophon · section: F3 Tabular spec sheet
 * enrichment: Tier A pure-CSS pipeline diagram + Tier B hand-built SVG cutoff axis
 * axes vs previous run (Cobalt): display style + accent hue
 * pre-emit critique: P5 H5 E4 S5 R5 V4
 */
@import url("./tokens.css");

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.62;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-style: normal; margin: 0; overflow-wrap: anywhere; min-width: 0; }
p { margin: 0; }
a { color: inherit; }

/* ── N3 · side rail ─────────────────────────────────────────── */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail); z-index: 20;
  display: flex; flex-direction: column; align-items: center;
  justify-content: space-between; padding: var(--space-lg) 0;
  border-right: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper-2);
}
.rail__mark {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--font-mono); font-size: var(--text-xs);
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--color-muted); margin: 0;
}
.rail__dots { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-sm); }
.rail__dots a {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; text-decoration: none;
}
.rail__dots a::after {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--color-rule-2);
  transition: background var(--dur-fast) var(--ease-out);
}
.rail__dots a:hover::after, .rail__dots a.is-current::after { background: var(--color-accent); }
.rail__dots a:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; border-radius: 50%; }
.rail__year { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-neutral); writing-mode: vertical-rl; margin: 0; }

/* ── shell ──────────────────────────────────────────────────── */
.shell { padding-left: var(--rail); }
.wrap { max-width: 74rem; margin: 0 auto; padding: 0 var(--space-xl); }
.section { padding-block: var(--space-3xl); border-top: var(--rule-hair) solid var(--color-rule); }
.section:first-of-type { border-top: 0; }

.lede { max-width: var(--measure); color: var(--color-muted); font-size: var(--text-md); }
.lede + .lede { margin-top: var(--space-md); }
.tight { max-width: 58ch; }

h2 {
  font-family: var(--font-display); font-weight: 500;
  font-size: var(--text-2xl); line-height: 1.1;
  letter-spacing: -0.015em; margin-bottom: var(--space-xs);
}
h3 {
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--color-muted);
  margin-bottom: var(--space-sm);
}
.sub { color: var(--color-neutral); font-size: var(--text-sm); margin-bottom: var(--space-xl); max-width: var(--measure); }

/* ── masthead ───────────────────────────────────────────────── */
.masthead { padding-block: var(--space-3xl) var(--space-2xl); }
.masthead__orient {
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--color-accent); margin-bottom: var(--space-lg);
}
.masthead h1 {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(2.4rem, 6vw, var(--text-display-s));
  line-height: 0.98; letter-spacing: -0.03em; margin-bottom: var(--space-lg);
  max-width: 18ch;
}
.masthead h1 em { font-style: normal; color: var(--color-accent); }
.masthead__meta {
  display: flex; flex-wrap: wrap; min-width: 0; gap: var(--space-xs) var(--space-lg);
  margin-top: var(--space-xl); padding-top: var(--space-md);
  border-top: var(--rule-hair) solid var(--color-rule);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-neutral);
}
.masthead__meta b { font-weight: 500; color: var(--color-ink); }

/* ── the map (Tier A pure-CSS pipeline) ─────────────────────── */
.map { margin-top: var(--space-xl); }
.map__flow {
  display: grid; gap: var(--space-xs);
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: stretch;
}
.node {
  position: relative; padding: var(--space-md) var(--space-sm) var(--space-md);
  background: var(--color-paper-2);
  border: var(--rule-hair) solid var(--color-rule);
  border-top: var(--rule-bold) solid var(--color-rule-2);
  min-width: 0;
  opacity: 0; transform: translateY(6px);
  animation: ink-on var(--dur-slow) var(--ease-out) forwards;
}
.node:nth-child(1) { animation-delay: 0ms; }
.node:nth-child(2) { animation-delay: 60ms; }
.node:nth-child(3) { animation-delay: 120ms; }
.node:nth-child(4) { animation-delay: 180ms; }
.node:nth-child(5) { animation-delay: 240ms; }
.node:nth-child(6) { animation-delay: 240ms; }
.node:nth-child(7) { animation-delay: 240ms; }
@keyframes ink-on { to { opacity: 1; transform: none; } }

.node--gate { border-top-color: var(--color-accent); background: var(--color-accent-wash); }
.node__k { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--color-neutral); letter-spacing: 0.1em; }
.node__n { font-family: var(--font-display); font-size: var(--text-md); line-height: 1.15; margin-top: var(--space-2xs); display: block; }
.node__d { font-size: var(--text-xs); color: var(--color-muted); margin-top: var(--space-xs); line-height: 1.45; }

.axis { margin-top: var(--space-lg); }
.axis__line { position: relative; height: var(--rule-hair); background: var(--color-rule-2); }
.axis__cut {
  position: absolute; top: -13px; bottom: -13px; left: 62%; width: 0;
  border-left: var(--rule-bold) dashed var(--color-accent);
}
.axis__labels {
  display: grid; grid-template-columns: minmax(0, 62%) minmax(0, 1fr); gap: var(--space-sm);
  margin-top: var(--space-md);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-muted);
}
.axis__labels b { color: var(--color-accent); font-weight: 500; display: block; }
.map__legend {
  display: flex; flex-wrap: wrap; gap: var(--space-md) var(--space-xl);
  margin-top: var(--space-md); padding-top: var(--space-sm);
  border-top: var(--rule-hair) solid var(--color-rule);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-muted);
}
.map__legend span { display: inline-flex; align-items: center; gap: var(--space-xs); }
.swatch { display: inline-block; width: 10px; height: 10px; flex: none; border: var(--rule-hair) solid var(--color-rule-2); }
.swatch--gate { background: var(--color-accent-wash); border-color: var(--color-accent); }
.swatch--stage { background: var(--color-paper-2); }

/* ── F3 · tabular spec sheet ────────────────────────────────── */
.sheet { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sheet caption { text-align: left; font-size: var(--text-sm); color: var(--color-neutral); padding-bottom: var(--space-sm); }
.sheet th, .sheet td { text-align: left; padding: var(--space-sm) var(--space-md) var(--space-sm) 0; border-bottom: var(--rule-hair) solid var(--color-rule); vertical-align: baseline; }
.sheet thead th {
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-muted);
  border-bottom: var(--rule-bold) solid var(--color-rule-2);
}
.sheet tbody th { font-weight: 500; font-family: var(--font-mono); font-size: var(--text-sm); }
.sheet td.num { font-family: var(--font-mono); white-space: nowrap; }
.sheet td.muted, .sheet .muted { color: var(--color-muted); font-size: var(--text-sm); }
.sheet tr.is-lead th, .sheet tr.is-lead td { color: var(--color-accent-ink); }
.sheet tr.is-control th, .sheet tr.is-control td { color: var(--color-muted); font-style: normal; }
.scroll-x { overflow-x: auto; }

/* ── prose blocks ───────────────────────────────────────────── */
.cols { display: grid; gap: var(--space-2xl); grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
.stack { min-width: 0; }
.stack > * + * { margin-top: var(--space-lg); }

.note {
  border-left: var(--rule-bold) solid var(--color-accent);
  padding: var(--space-xs) 0 var(--space-xs) var(--space-md);
  color: var(--color-muted); font-size: var(--text-sm); max-width: var(--measure);
}
.note b { color: var(--color-ink); font-weight: 500; }

.layers { list-style: none; margin: 0; padding: 0; counter-reset: layer; }
.layers li { min-width: 0; padding: var(--space-md) 0; border-bottom: var(--rule-hair) solid var(--color-rule); display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: var(--space-md); }
.layers li::before { counter-increment: layer; content: counter(layer, decimal-leading-zero); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-accent); padding-top: 0.25em; }
.layers b { font-weight: 500; display: block; }
.layers span { color: var(--color-muted); font-size: var(--text-sm); }

.verdict {
  font-family: var(--font-display); font-size: var(--text-xl); line-height: 1.28;
  font-weight: 400; max-width: 34ch; letter-spacing: -0.01em;
}
.verdict mark { background: var(--color-accent-wash); color: inherit; padding: 0 0.12em; box-decoration-break: clone; }

code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
code { background: var(--color-paper-3); padding: 0.1em 0.34em; border-radius: var(--radius-sm); }
pre { margin: 0; overflow-x: auto; background: var(--color-paper-2); border: var(--rule-hair) solid var(--color-rule); padding: var(--space-md); font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.7; }
pre code { background: none; padding: 0; }

/* ── command blocks ─────────────────────────────────────────── */
pre + p.caption-note { margin-top: var(--space-sm); }

/* ── Ft4 · dense colophon ───────────────────────────────────── */
.colophon {
  overflow-wrap: anywhere;
  border-top: var(--rule-bold) solid var(--color-rule-2);
  padding-block: var(--space-xl) var(--space-2xl);
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--color-muted); line-height: 1.85; max-width: 76ch;
}
.colophon b { color: var(--color-ink); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .node { opacity: 1; transform: none; }
}

/* ── responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .map__flow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); }
}
@media (max-width: 720px) {
  :root { --rail: 0rem; }
  .rail {
    position: static; width: auto; inset: auto; flex-direction: row;
    padding: var(--space-sm) var(--space-md);
    border-right: 0; border-bottom: var(--rule-hair) solid var(--color-rule);
  }
  .rail__mark, .rail__year { writing-mode: horizontal-tb; transform: none; }
  .rail__dots { grid-auto-flow: column; }
  .shell { padding-left: 0; }
  .wrap { padding: 0 var(--space-md); }
  .section { padding-block: var(--space-2xl); }
  .map__flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .masthead { padding-block: var(--space-2xl) var(--space-xl); }
}
@media (max-width: 480px) {
  .axis__labels { grid-template-columns: minmax(0, 1fr); }
  .axis__cut { left: 100%; }
}
@media (max-width: 420px) {
  .map__flow { grid-template-columns: minmax(0, 1fr); }
  .layers li { grid-template-columns: minmax(0, 1fr); gap: var(--space-2xs); }
}

/* ============================================================================
 * docs-platform reconciliation
 * The shared shell owns page width, gutters, the bar, code blocks, tables and
 * motion. The fixed dot rail it replaces is gone, so the left inset goes too.
 * ========================================================================== */
.dp-main.wrap { max-width: none; margin-inline: 0; padding-inline: 0; }
body { padding-left: 0; }
.dp-shell { margin-left: 0; }

/* Prose holds the measure; sheets and diagrams keep the full column. */
.dp-sec > p, .dp-sec > .lede { max-width: var(--measure); }

@media (prefers-reduced-motion: reduce) {
  [class*="reveal"] { opacity: 1 !important; transform: none !important; }
}
