/* Layout and components. Every color, font and duration is a token from tokens.css.

   The identity is a drafting sheet: a 16 px grid on cream paper, plates and
   cards ruled in ink with a caption bar, labels in mono, and one signal
   color (the accent) for the thing to follow. Everything off-chain is drawn
   outlined; the on-chain strip's tab is the one solid-filled shape. */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--color-bg);
  background-image:
    linear-gradient(var(--color-grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid-major) 1px, transparent 1px),
    linear-gradient(var(--color-grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid-minor) 1px, transparent 1px);
  background-size:
    calc(var(--grid) * 4) calc(var(--grid) * 4),
    calc(var(--grid) * 4) calc(var(--grid) * 4),
    var(--grid) var(--grid),
    var(--grid) var(--grid);
  background-position: -1px -1px;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  overflow-wrap: break-word;
}

a { color: var(--color-link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code, kbd, .mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
}
code {
  background: var(--color-surface-2);
  padding: 0.05em 0.3em;
  border-radius: var(--radius-sm);
}
a code { color: inherit; }

strong, b { font-weight: 600; }

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  padding: var(--space-2) var(--space-3);
  z-index: 10;
}
.skip-link:focus { top: var(--space-2); }

/* Header: a title block. */

.site-header {
  border-bottom: var(--border-width) solid var(--color-rule);
  background: var(--color-surface);
}
.site-header__inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: var(--space-3) var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
}
.site-name {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-md);
  letter-spacing: -0.02em;
  color: var(--color-text);
  text-decoration: none;
}
.site-name b { font-weight: 700; }
.site-name img { width: 28px; height: 28px; display: block; flex: none; }
.site-name .logo-dark { display: none; }
:root[data-theme="dark"] .site-name .logo-light { display: none; }
:root[data-theme="dark"] .site-name .logo-dark { display: block; }

.site-nav { flex: 1 1 24rem; }

/* Theme toggle: light by default, dark on request (js/theme.js). */
.theme-toggle {
  flex: none;
  font: inherit;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: transparent;
  border: var(--border-width) solid var(--color-border-strong);
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--color-text); border-color: var(--color-text); }
.theme-toggle:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.site-nav li { margin: 0; }
.site-nav a { color: var(--color-text-muted); text-decoration: none; }
.site-nav a:hover { color: var(--color-text); text-decoration: underline; }
.site-nav a[aria-current="page"] {
  color: var(--color-text);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* Main column. Prose is held to a measure; figures may run wider. */

main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: var(--space-7) var(--gutter) var(--space-8);
  counter-reset: fig;
}
main > * { max-width: var(--measure); }
main > .wide, main > .tree-anim, main > .card-grid, main > .table-wrap { max-width: var(--wide); }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  font-weight: 700;
  letter-spacing: -0.03em;
}
h1 { font-size: var(--text-2xl); margin: 0 0 var(--space-5); }
h2 { font-size: var(--text-lg); margin: var(--space-7) 0 var(--space-3); letter-spacing: -0.02em; }
h3 { font-size: var(--text-md); margin: var(--space-5) 0 var(--space-2); letter-spacing: -0.02em; }
p, ul, ol { margin: 0 0 var(--space-4); }
li { margin-bottom: var(--space-2); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-link);
  margin: 0 0 var(--space-3);
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 2px;
  background: var(--color-accent);
  vertical-align: middle;
  margin-right: var(--space-2);
}

.takeaway {
  font-size: var(--text-md);
  line-height: 1.55;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-6);
}

.lede { font-size: var(--text-md); line-height: 1.55; }

dl.terms { margin: 0 0 var(--space-5); }
dl.terms dt {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95em;
  margin-top: var(--space-4);
}
dl.terms dd { margin: var(--space-1) 0 0 var(--space-4); }

/* Tables: a datasheet block. The wrapper scrolls on a narrow screen so the page does not. */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 var(--space-5);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-radius: var(--radius);
}
table {
  border-collapse: collapse;
  font-size: var(--text-sm);
  min-width: 100%;
}
caption {
  text-align: left;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) solid var(--color-rule);
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}
tr:last-child td { border-bottom: 0; }
th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--color-surface-2);
  border-bottom: var(--border-width) solid var(--color-rule);
}
tbody th[scope="row"] {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  background: transparent;
  border-bottom: var(--border-width) solid var(--color-border);
}
tr:last-child th[scope="row"] { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { font-size: var(--text-xs); }

/* Cards linking to the component pages: datasheet entries. */

.card-grid {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-4);
}
.card-grid li { margin: 0; }
.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--color-text);
  text-decoration: none;
  transition: border-color var(--motion-fast) var(--motion-ease), box-shadow var(--motion-fast) var(--motion-ease);
}
.card:hover, .card:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 3px 3px 0 var(--color-accent);
}
.card__ref {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-bottom: var(--border-width) solid var(--color-rule);
  padding: var(--space-1) var(--space-3);
}
.card:hover .card__ref { border-bottom-color: var(--color-accent); }
.card__title {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  margin: var(--space-4) var(--space-4) var(--space-2);
}
.card__title::after { content: " \2192"; color: var(--color-accent); font-weight: 400; }
.card__body {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 var(--space-4) var(--space-4);
}
.card--primary { border-width: 2px; border-color: var(--color-accent); }
.card--primary .card__ref { color: var(--color-accent-ink); background: var(--color-accent); border-bottom-color: var(--color-accent); }

/* Figures: a numbered plate. Figures and step-throughs share one counter. */

.tree-anim, main figure { counter-increment: fig; }

figure {
  margin: var(--space-6) 0;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-radius: var(--radius);
  overflow: hidden;
}
figure svg { display: block; max-width: 100%; height: auto; padding: var(--space-4); }
figcaption {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-top: var(--border-width) solid var(--color-rule);
  padding: var(--space-3) var(--space-4);
}
figcaption::before {
  content: "FIG. " counter(fig);
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

/* Static diagrams drawn inline in the pages. */
.diagram text { fill: var(--color-text); font-family: var(--font-mono); font-size: 12px; }
.diagram .d-sm { font-size: 11px; fill: var(--color-text-muted); letter-spacing: 0.02em; }
.diagram .d-b { font-weight: 700; }
.diagram .d-box { fill: var(--color-surface); stroke: var(--color-border-strong); stroke-width: 1.5px; }
.diagram .d-chain { fill: var(--color-surface-2); stroke: var(--color-chain); stroke-width: 2px; }
.diagram .d-tree { fill: var(--color-surface); stroke: var(--color-chain); stroke-width: 2px; }
.diagram .d-tx { fill: var(--color-surface); stroke: var(--color-text); stroke-width: 1.5px; }
.diagram .d-off { fill: var(--color-surface); stroke: var(--color-node); stroke-width: 1.5px; stroke-dasharray: 4 3; }
.diagram .d-line { stroke: var(--color-text-muted); stroke-width: 1.5px; fill: none; }
.diagram .d-dash { stroke: var(--color-chain); stroke-width: 1.5px; fill: none; stroke-dasharray: 2 4; }
.diagram .d-head { fill: var(--color-text-muted); }
.diagram .d-tab { fill: var(--color-chain); }
.diagram text.d-tab-t { fill: var(--color-surface); font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; }

.callout {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-5);
}
.callout > :last-child { margin-bottom: 0; }

/* The "deeper" footer of each page and the site footer. */

.deeper {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 2px solid var(--color-rule);
}
.deeper h2 {
  margin-top: 0;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.site-footer {
  border-top: var(--border-width) solid var(--color-rule);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.site-footer__inner { max-width: var(--wide); margin: 0 auto; padding: var(--space-5) var(--gutter); }
.site-footer p { margin: 0 0 var(--space-2); }

/* ------------------------------------------------------------------ */
/* The step-through animation drawn by js/tree-anim.js.                 */
/* ------------------------------------------------------------------ */

.tree-anim { margin: var(--space-6) 0 var(--space-7); }

.ta {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.ta:focus-visible { outline-offset: 3px; }

.ta-cap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--space-4);
  margin: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-2);
  border-bottom: var(--border-width) solid var(--color-rule);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.ta-cap__fig::before {
  content: "FIG. " counter(fig) "\00a0\00a0";
  font-weight: 700;
  color: var(--color-text);
}

.ta-stage { padding: var(--space-3) 0 0; }
.ta-stage svg { display: block; width: 100%; height: auto; }

.ta-panel {
  border-top: var(--border-width) solid var(--color-rule);
  padding: var(--space-3) var(--space-4) var(--space-2);
  min-height: 9.5rem;
}
.ta-count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-link);
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ta-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  margin: var(--space-1) 0 var(--space-2);
}
.ta-caption { margin: 0 0 var(--space-2); }

.ta-checks { list-style: none; padding: 0; margin: 0 0 var(--space-2); font-size: var(--text-sm); }
.ta-checks li { margin: 0 0 var(--space-1); padding-left: 1.6em; position: relative; }
.ta-checks li::before {
  position: absolute; left: 0; top: 0;
  font-family: var(--font-mono); font-weight: 700;
}
.ta-checks li[data-state="pending"] { color: var(--color-text-muted); }
.ta-checks li[data-state="pending"]::before { content: "\2026"; }
.ta-checks li[data-state="ok"]::before { content: "\2713"; color: var(--color-good); }
.ta-checks li[data-state="fail"]::before { content: "\2717"; color: var(--color-bad); }
.ta-checks .ta-check-state { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.ta-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-top: var(--border-width) solid var(--color-rule);
  background: var(--color-surface-2);
}
.ta-btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-3);
  min-height: 2.4rem;
  min-width: 4.8rem;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--motion-ease), box-shadow var(--motion-fast) var(--motion-ease);
}
.ta-btn:hover:not(:disabled) { border-color: var(--color-accent); box-shadow: 2px 2px 0 var(--color-accent); }
.ta-btn:disabled { color: var(--color-text-muted); border-color: var(--color-border-strong); cursor: default; opacity: 0.55; }
.ta-dots {
  list-style: none; padding: 0; margin: 0 auto;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px;
}
.ta-dots li { margin: 0; }
.ta-dot {
  width: 1.6rem; height: 1.6rem;
  border: 0; background: none; padding: 0; cursor: pointer;
  display: grid; place-items: center;
}
.ta-dot::before {
  content: "";
  width: 0.6rem; height: 0.6rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface);
}
.ta-dot:hover::before { border-color: var(--color-accent); }
.ta-dot[aria-current="step"]::before { background: var(--color-accent); border-color: var(--color-accent); }
.ta-dot.is-done::before { background: var(--color-border-strong); }

.ta-legend {
  display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4);
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-4) var(--space-3);
  border-top: var(--border-width) solid var(--color-rule);
}
.ta-legend span { white-space: nowrap; }
.ta-legend span::before {
  content: ""; display: inline-block; width: 1.2em; height: 0.75em;
  margin-right: 0.45em; vertical-align: -0.05em; border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.ta-legend .lg-node::before { border: 1.5px solid var(--color-node); }
.ta-legend .lg-leaf::before { border: 1.5px solid var(--color-leaf); }
.ta-legend .lg-path::before { border: var(--stroke-strong) solid var(--color-accent); }
.ta-legend .lg-sib::before { border: var(--stroke) dashed var(--color-sibling); }
.ta-legend .lg-exit::before { border: var(--stroke-strong) solid var(--color-leaf-exit); }
.ta-legend .lg-pending::before { border: var(--stroke) dashed var(--color-pending); }
.ta-legend .lg-chain::before { background: var(--color-chain); border: var(--stroke) solid var(--color-chain); }

.ta-noscript { padding: var(--space-4); }

/* SVG parts. Labels are mono; text wears ink, never a series color. */

.ta svg text { fill: var(--color-text); font-family: var(--font-mono); font-size: var(--svg-text); }
.ta svg .t-sm { font-size: var(--svg-text-sm); fill: var(--color-text-muted); }
.ta svg .t-lg { font-size: var(--svg-text-lg); font-weight: 700; }
.ta svg .t-b { font-weight: 700; }
.ta svg .t-muted { fill: var(--color-text-muted); }
.ta svg .t-cap { font-size: var(--svg-text-sm); fill: var(--color-text-muted); letter-spacing: 0.08em; }

/* Edges are orthogonal buses: ink-3 hairlines, the path thick in the signal. */
.ta svg .edge { stroke: var(--color-border-strong); stroke-width: 1.25px; fill: none; stroke-linejoin: round; }
.ta svg .edge.is-path { stroke: var(--color-accent); stroke-width: 2.75px; }

/* Nodes: lightly rounded boxes outlined in their role color on paper. */
.ta svg .node rect { fill: var(--color-surface); stroke: var(--color-node); stroke-width: var(--stroke); }
.ta svg .node .hash { font-size: var(--svg-text-sm); fill: var(--color-text-muted); }
.ta svg .node .sum { font-weight: 700; fill: var(--color-node-sum); }
.ta svg .node.is-leaf rect { stroke: var(--color-leaf); }
.ta svg .node.is-empty rect { fill: var(--color-bg); stroke: var(--color-empty); stroke-dasharray: 4 3; }
.ta svg .node.is-empty text { fill: var(--color-text-muted); }
.ta svg .node.is-root rect { stroke-width: 2px; }
.ta svg .node.is-pending rect { stroke: var(--color-pending); stroke-dasharray: 6 3; stroke-width: var(--stroke-strong); }
.ta svg .node.is-pending .root-tag { fill: var(--color-text); }
.ta svg .node.is-path rect, .ta svg .node.is-fold rect { stroke: var(--color-accent); stroke-width: var(--stroke-strong); stroke-dasharray: none; fill: var(--color-accent-soft); }
.ta svg .node.is-sib rect { stroke: var(--color-sibling); stroke-width: var(--stroke); stroke-dasharray: 4 3; fill: var(--color-sibling-soft); }
.ta svg .node.is-pending.is-fold rect, .ta svg .node.is-pending.is-path rect { stroke-dasharray: 6 3; }
.ta svg .node.is-exit rect { stroke: var(--color-leaf-exit); stroke-width: var(--stroke-strong); stroke-dasharray: 4 3; fill: var(--color-bg); }
.ta svg .node.is-bad rect { stroke: var(--color-bad); stroke-width: var(--stroke-strong); fill: var(--color-bad-soft); stroke-dasharray: none; }

/* A cohort or swept subtree: hatched, like a section on a drawing. */
.ta svg .region rect { stroke: var(--color-border-strong); stroke-width: var(--border-width); stroke-dasharray: 3 3; }
.ta svg .hatch-line { stroke: var(--color-border-strong); stroke-width: 1px; opacity: 0.35; }
.ta svg .region text { fill: var(--color-text-muted); font-size: var(--svg-text-sm); font-weight: 700; }
.ta svg .region .region-bg { fill: var(--color-surface); stroke: none; }

.ta svg .badge rect { fill: var(--color-surface); stroke: var(--color-text); stroke-width: var(--border-width); }
.ta svg .badge.k-sig rect { stroke: var(--color-text); }
.ta svg .badge.k-voucher rect { stroke: var(--color-node); stroke-width: var(--stroke); }
.ta svg .badge.k-hash rect { stroke: var(--color-leaf-exit); stroke-width: var(--stroke); stroke-dasharray: 3 2; }
.ta svg .badge.k-bad rect { stroke: var(--color-bad); fill: var(--color-bad-soft); stroke-width: var(--stroke); }
.ta svg .badge text { font-size: var(--svg-text-sm); }

.ta svg .link path { stroke: var(--color-text-muted); stroke-width: var(--stroke); fill: none; stroke-dasharray: 5 4; stroke-linejoin: round; }
.ta svg .link text { font-size: var(--svg-text-sm); fill: var(--color-text-muted); }
.ta svg .arrowhead { fill: var(--color-text-muted); }

/* A leaving leaf: an arrow straight down from its slot to the strip. */
.ta svg .exit-arrow path { stroke: var(--color-leaf-exit); stroke-width: var(--stroke-strong); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ta svg .exit-head { stroke: var(--color-leaf-exit); stroke-width: 2px; stroke-linecap: round; stroke-linejoin: round; }

/* The root commits to the strip: a dotted rail in the chain color. */
.ta svg .rail { stroke: var(--color-chain); stroke-width: var(--stroke); fill: none; stroke-dasharray: 2 4; }

/* The on-chain strip. Its tab is the one solid-filled shape in the figure. */
.ta svg .chain-bg { fill: var(--color-surface-2); stroke: var(--color-chain); stroke-width: 2px; }
.ta svg .chain-tab { fill: var(--color-chain); }
.ta svg .chain-title { font-size: var(--svg-text-sm); font-weight: 700; fill: var(--color-surface); letter-spacing: 0.1em; }
.ta svg .chip rect { fill: var(--color-surface); stroke: var(--color-border-strong); stroke-width: var(--stroke); }
.ta svg .chip.k-tree rect { stroke: var(--color-chain); stroke-width: var(--stroke-strong); }
.ta svg .chip.k-tree2 rect { stroke: var(--color-chain); stroke-width: var(--stroke-strong); stroke-dasharray: 6 3; }
.ta svg .chip.k-payout rect { stroke: var(--color-leaf-exit); stroke-width: var(--stroke-strong); }
.ta svg .chip.k-input rect { stroke: var(--color-text-muted); stroke-dasharray: 5 3; }
.ta svg .chip.k-htlc rect { stroke: var(--color-text); }
.ta svg .chip.k-none rect { stroke: var(--color-border-strong); stroke-dasharray: 3 3; fill: var(--color-surface-2); }

/* Animation. Each step re-renders the figure, so these run once per step.
   The fold draws the path from the changed node to the root one level at a
   time; nodes on it settle into the signal color. Nothing moves or scales. */

@keyframes ta-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ta-settle { from { opacity: 0.3; } to { opacity: 1; } }
@keyframes ta-fade-in { from { opacity: 0; } to { opacity: 1; } }

.ta svg .edge.is-draw {
  stroke-dasharray: 1;
  animation: ta-draw var(--motion-step) linear both;
  animation-delay: calc(var(--i, 0) * var(--motion-step));
}
.ta svg .node.is-fold rect {
  animation: ta-settle var(--motion-pulse) var(--motion-ease) both;
  animation-delay: calc(var(--i, 0) * var(--motion-step));
}
.ta svg .node.is-fold .val {
  animation: ta-fade-in var(--motion-pulse) var(--motion-ease) both;
  animation-delay: calc(var(--i, 0) * var(--motion-step));
}
.ta svg .chip.is-commit, .ta svg .chip.is-new, .ta svg .badge, .ta svg .link,
.ta svg .region, .ta svg .exit-arrow, .ta svg .rail {
  animation: ta-fade-in var(--motion-pulse) var(--motion-ease) both;
  animation-delay: calc(var(--i, 0) * var(--motion-step));
}
.ta.no-anim svg * { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .ta svg *, .card, .ta-btn { animation: none !important; transition: none !important; }
}

@media (max-width: 520px) {
  h1 { font-size: var(--text-xl); }
  main { padding-top: var(--space-6); }
  .takeaway { padding: var(--space-3) var(--space-4); font-size: var(--text-base); }
  .ta-cap { padding: var(--space-2) var(--space-3); }
  .ta-panel { padding: var(--space-3); min-height: 11rem; }
  .ta-controls { padding: var(--space-2) var(--space-3); gap: var(--space-2); }
  .ta-btn { min-width: 3.6rem; padding: var(--space-1) var(--space-2); }
  .ta-dots { gap: 0; }
  .ta-dot { width: 1.3rem; }
  .ta-legend { padding: var(--space-2) var(--space-3); gap: var(--space-1) var(--space-3); }
  figure svg { padding: var(--space-2); }
}

/* Scaling page: line charts and the size calculator (js/scaling.js). */

.chart svg { width: 100%; }
.chart .ch-grid line { stroke: var(--color-border); stroke-width: 1; }
.chart .ch-grid line.ch-mark { stroke: var(--color-border-strong); stroke-dasharray: 3 3; }
.chart text { font-family: var(--font-mono); fill: var(--color-text-muted); }
.chart .ch-tick { font-size: var(--svg-text-sm); }
.chart .ch-label { font-size: var(--svg-text-sm); letter-spacing: 0.04em; }
.chart .ch-end { font-size: var(--svg-text-sm); font-weight: 700; }
.chart .ch-line { fill: none; stroke-width: var(--stroke-strong); stroke-linejoin: round; }
.chart .ch-line.is-dash { stroke-dasharray: 6 4; stroke-width: var(--stroke); }
.chart .s-lt { stroke: var(--color-accent); fill: var(--color-accent); }
.chart .s-full { stroke: var(--color-node); fill: var(--color-node); }
.chart .s-ark { stroke: var(--color-chain); fill: var(--color-chain); }
.chart .s-ln { stroke: var(--color-leaf); fill: var(--color-leaf); }
.chart .s-bare { stroke: var(--color-text-muted); fill: var(--color-text-muted); }
.chart .ch-line.s-lt, .chart .ch-line.s-full, .chart .ch-line.s-ark,
.chart .ch-line.s-ln, .chart .ch-line.s-bare { fill: none; }

.calc { max-width: var(--wide); }
main > .calc { max-width: var(--wide); }
.calc__controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  margin: 0 0 var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.calc__controls input[type="range"] { width: 100%; accent-color: var(--color-accent); }
.calc__controls output { grid-column: 2; font-weight: 700; color: var(--color-text); }
.calc__controls select {
  justify-self: start;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-strong);
  padding: 0.2rem 0.4rem;
}
.calc__note { color: var(--color-text-muted); font-size: var(--text-sm); }
tr.is-ours th, tr.is-ours td { background: var(--color-accent-soft); font-weight: 700; }
.loses li { margin-bottom: var(--space-3); }

/* Lean signatures and shell snippets on the verification page. */
pre.leansig {
  max-width: var(--wide);
  overflow-x: auto;
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-rule);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.5;
}
pre.leansig code { background: none; padding: 0; border: 0; white-space: pre; }

@media print {
  body { background-image: none; }
  .ta-controls, .site-nav, .theme-toggle { display: none; }
}
