/* =============================================================
   Chaperonin landing — Swiss System
   Light off-white field, near-black ink, single blue signal.
   ============================================================= */

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

:root {
  /* ── Color tokens ── */
  --bg:          #fafaf8;
  --surface:     #ffffff;
  --surface-2:   #f3f3ee;
  --ink:         #0f0f10;
  --ink-2:       #1f1f22;
  --muted:       #5c5c5e;
  --dim:         #9b9b9d;
  --rule:        #0f0f10;
  --rule-soft:   #e0e0da;
  --rule-hair:   #d6d6cf;
  --accent:      #1a4a8a;
  --accent-soft: #e8eef7;
  --accent-tint: rgba(26, 74, 138, 0.08);

  /* ── Typography scale ──
     One value per importance tier. Everything else inherits.   */
  --t-display:    clamp(56px, 7vw, 104px);    /* H1 hero */
  --t-title:      clamp(40px, 5vw, 76px);     /* H2 section */
  --t-quote:      clamp(24px, 2.3vw, 34px);   /* pull-quote */
  --t-lede:       clamp(17px, 1.3vw, 21px);   /* intro paragraphs */
  --t-body:       16px;                        /* table cells, notes */
  --t-small:      14px;                        /* secondary descriptions */
  --t-mono-data:  13px;                        /* mono data: tables, code */
  --t-mono-label: 12px;                        /* eyebrow, mono labels */

  /* ── Spacing & layout ── */
  --container-max: 1280px;
  --container-pad: 56px;
  --section-py:    7rem;
  --topbar-h:      72px;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  line-height: 1.5;
  font-size: var(--t-body);
}

a { color: inherit; text-decoration: none; }

/* ── Reusable: container, eyebrow, codes ── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: var(--container-pad);
  padding-right: var(--container-pad);
}

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: baseline;
  gap: 0.75em;
}
.eyebrow .num { color: var(--accent); font-weight: 700; }

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.86em;
  color: var(--accent);
  background: transparent;
  padding: 0;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── Reveal (intersection observer) ── */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* =============================================================
   TOP RAIL
   ============================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--container-pad);
}
.topbar-logo {
  display: inline-flex;
  align-items: center;
}
.topbar-logo img {
  height: 32px;
  width: auto;
  display: block;
}
.topbar-index {
  display: flex;
  align-items: center;
  gap: 32px;
}
.topbar-index a {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  font-weight: 500;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  color: var(--ink);
  position: relative;
  padding-bottom: 2px;
}
.topbar-index a .ix-n { color: var(--accent); font-weight: 700; }
.topbar-index a .ix-l { text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); transition: color 0.2s; }
.topbar-index a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease;
}
.topbar-index a:hover .ix-l { color: var(--ink); }
.topbar-index a:hover::after { transform: scaleX(1); }

/* =============================================================
   §01 HERO
   ============================================================= */
.hero {
  border-bottom: 1px solid var(--rule);
  padding: 64px 0 0 0;
  min-height: calc(100dvh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 56px;
  padding-top: 24px;
  padding-bottom: 56px;
  align-items: start;
}

.hero-text {
  padding-top: 12px;
}
.hero-text .eyebrow { margin-bottom: 28px; }

.display {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: var(--t-display);
  line-height: 0.96;
  letter-spacing: -0.035em;
  color: var(--ink);
  margin-bottom: 28px;
  text-wrap: balance;
}
.display .accent { color: var(--accent); }

.lede {
  font-size: var(--t-lede);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 56ch;
  margin-bottom: 36px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  padding: 13px 24px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
  white-space: nowrap;
}
.btn .arrow { font-family: 'Inter', sans-serif; transition: transform 0.18s ease; }
.btn:hover .arrow { transform: translateX(2px); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* ── Hero diagram ── */
.hero-diagram {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 18px 18px 0 18px;
  display: flex;
  flex-direction: column;
}
#canvas {
  width: 100%;
  height: auto;
  display: block;
}
.diagram-caption {
  display: flex;
  align-items: center;
  gap: 16px;
  border-top: 1px solid var(--rule);
  margin-top: 16px;
  padding: 14px 0 14px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.diagram-caption .cap-num {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
}
.diagram-caption em { color: var(--ink); font-style: normal; font-weight: 600; }
.btn-run {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.btn-run:hover {
  background: var(--ink);
  color: var(--bg);
}
.btn-run.running {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  cursor: not-allowed;
}

/* ── Hero SVG details ── */
.ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  transform-origin: 300px 230px;
  animation: ring-pulse 3.4s ease-out infinite;
  opacity: 0.6;
}
@keyframes ring-pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(2.1); opacity: 0;    }
}

.edge {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 180;
  stroke-dashoffset: 180;
  opacity: 0;
  transition: stroke-dashoffset 0.8s ease, opacity 0.4s ease;
}
.edge.drawn {
  stroke-dashoffset: 0;
  opacity: 0.85;
}

.node-body {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 1;
}
.tool-node.connected .node-body {
  stroke: var(--accent);
  stroke-width: 1.4;
}
.tool-node.activated .node-body {
  fill: var(--accent-tint);
}
.node-label {
  fill: var(--ink);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.node-tag {
  fill: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tool-node.connected .node-tag { fill: var(--accent); }

.pulse-dot {
  fill: var(--accent);
  opacity: 0;
  pointer-events: none;
}

/* ── Hero ledger ── */
.hero-ledger {
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-top: 22px;
  padding-bottom: 22px;
}
.hero-ledger > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 24px;
  border-right: 1px solid var(--rule-hair);
}
.hero-ledger > div:last-child { border-right: none; }
.hero-ledger .lk {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
}
.hero-ledger .lv {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* =============================================================
   Reusable: section head
   ============================================================= */
.section-head {
  margin-bottom: 64px;
  max-width: 820px;
}
.section-head .eyebrow { margin-bottom: 26px; }
.section-title {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: var(--t-title);
  line-height: 1.04;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 26px;
  text-wrap: balance;
}
.section-lede {
  font-size: var(--t-lede);
  line-height: 1.6;
  color: var(--muted);
  max-width: 60ch;
}

/* =============================================================
   §02 MECHANISM
   ============================================================= */
.mechanism {
  border-bottom: 1px solid var(--rule);
  padding: var(--section-py) 0;
  background: var(--bg);
}

.triptych {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}
.trip {
  background: var(--surface);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
}
.trip-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule-hair);
  background: var(--surface);
}
.trip-letter {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-data);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.12em;
}
.trip-head h3 {
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.trip-body {
  padding: 24px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  background: var(--surface);
}
.trip-body svg {
  width: 100%;
  height: auto;
  max-width: 280px;
}
.trip-code { align-items: flex-start; justify-content: flex-start; padding: 20px 24px; }
.code-mini {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-data);
  line-height: 1.55;
  color: var(--ink);
  white-space: pre;
}
.code-mini .kw  { color: #7a1f8a; }
.code-mini .mod { color: var(--accent); font-weight: 600; }
.code-mini .str { color: #2a6a2a; }
.code-mini .com { color: var(--dim); font-style: italic; }
.code-mini .num { color: #b07c00; }

.trip-foot {
  padding: 16px 24px 20px 24px;
  border-top: 1px solid var(--rule-hair);
  background: var(--surface-2);
}
.trip-foot p {
  font-family: 'Inter', sans-serif;
  font-size: var(--t-small);
  line-height: 1.55;
  color: var(--muted);
}

/* =============================================================
   FIELD NOTE (testimonial band)
   ============================================================= */
.fieldnote {
  border-bottom: 1px solid var(--rule);
  padding: 96px 0 104px 0;
  background: var(--bg);
}

.fieldnote-grid {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 960px;
  gap: 28px;
}
.fieldnote-grid .eyebrow { margin: 0; }

.fieldnote-quote {
  position: relative;
  margin: 0;
  padding-left: 0;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: var(--t-quote);
  line-height: 1.36;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-wrap: balance;
}
.fieldnote-quote .fq-mark {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.6em;
  line-height: 0.6;
  color: var(--accent);
  margin-right: 0.12em;
  vertical-align: -0.18em;
}

.fieldnote-attr {
  display: flex;
  align-items: center;
  gap: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}
.fieldnote-attr .fa-rule {
  display: inline-block;
  width: 40px;
  height: 1px;
  background: var(--ink);
}
.fieldnote-attr .fa-name {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.fieldnote-attr .fa-affil { color: var(--muted); }

@media (max-width: 560px) {
  .fieldnote { padding: 56px 0 64px 0; }
  .fieldnote-attr {
    flex-wrap: wrap;
    gap: 10px;
  }
  .fieldnote-attr .fa-rule { width: 28px; }
}

/* =============================================================
   §03 TYPES
   ============================================================= */
.types {
  border-bottom: 1px solid var(--rule);
  padding: var(--section-py) 0;
  background: var(--surface-2);
}

.types-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}

/* ── Reusable spec table ── */
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.spec-table thead th {
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  white-space: nowrap;
}
.spec-table tbody td {
  padding: 20px 20px;
  border-bottom: 1px solid var(--rule-hair);
  font-size: var(--t-body);
  color: var(--ink);
  vertical-align: baseline;
}
.spec-table tbody tr:last-child td { border-bottom: none; }
.spec-table .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-data);
  color: var(--ink-2);
}

.ns-name {
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.types-note {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 24px 26px;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 26px;
  align-items: baseline;
}
.note-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.types-note p {
  font-size: var(--t-body);
  line-height: 1.65;
  color: var(--ink-2);
}

/* =============================================================
   §04 MODULES
   ============================================================= */
.modules {
  border-bottom: 1px solid var(--rule);
  padding: var(--section-py) 0;
  background: var(--bg);
}

.module-table .mod-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.modules-foot {
  margin-top: 30px;
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--muted);
  max-width: 72ch;
}

/* =============================================================
   §05 PROTOCOL
   ============================================================= */
.protocol {
  border-bottom: 1px solid var(--rule);
  padding: var(--section-py) 0;
  background: var(--surface-2);
}

.protocol-grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 56px;
  align-items: start;
}

.protocol-events .ph {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}
.event-list {
  display: flex;
  flex-direction: column;
}
.event-row {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-hair);
  align-items: baseline;
}
.event-row:last-child { border-bottom: none; }
.ev {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-data);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 11px;
  width: max-content;
  border: 1px solid var(--rule-hair);
  background: var(--surface);
}
.event-row dd {
  font-size: var(--t-small);
  line-height: 1.55;
  color: var(--ink-2);
}
.event-row dd code { color: var(--accent); font-size: 0.9em; }

.ev-start { color: #0a6d3e; border-color: #0a6d3e; }
.ev-queue { color: #a16207; border-color: #a16207; }
.ev-run   { color: var(--accent); border-color: var(--accent); }
.ev-prog  { color: #a16207; border-color: #a16207; }
.ev-log   { color: #5b2491; border-color: #5b2491; }
.ev-done  { color: #0a6d3e; border-color: #0a6d3e; }
.ev-end   { color: var(--ink); border-color: var(--ink); background: var(--ink); color: var(--bg); }

/* Protocol stream (terminal) */
.protocol-stream {
  border: 1px solid var(--rule);
  background: #0f0f10;
  display: flex;
  flex-direction: column;
}
.stream-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a2c;
  background: #14141a;
}
.stream-head .d {
  width: 9px; height: 9px;
  border: 1px solid #2a2a2c;
}
.stream-head .addr {
  margin-left: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  color: #6a6a6c;
  letter-spacing: 0.06em;
}
.stream {
  margin: 0;
  padding: 20px 24px 24px 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-data);
  line-height: 1.7;
  color: #b8b8bc;
  overflow-x: auto;
  white-space: nowrap;
}
.stream .line { display: block; }
.stream .line.dim { opacity: 0.42; }
.stream .t { color: #4a4a4c; }
.stream .k { color: #6a6a6c; }
.stream .s { color: #9aa3b4; }
.stream .n { color: #d1a64a; }
.stream .v-start { color: #3fbf7a; }
.stream .v-queue { color: #d1a64a; }
.stream .v-run   { color: #5da8ef; }
.stream .v-prog  { color: #d1a64a; }
.stream .v-log   { color: #b791d6; }
.stream .v-done  { color: #3fbf7a; }
.stream .v-end   { color: #3fbf7a; font-weight: 700; }

/* =============================================================
   §06 START
   ============================================================= */
.start {
  border-bottom: 1px solid var(--rule);
  padding: var(--section-py) 0;
  background: var(--bg);
}

.start-grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 56px;
  align-items: start;
}

.start-cmd {
  margin: 0 0 24px 0;
  padding: 24px 26px;
  background: #0f0f10;
  color: #d8d8d4;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.7;
  border: 1px solid var(--rule);
  white-space: pre;
  overflow-x: auto;
}
.start-cmd .c { color: var(--accent); margin-right: 8px; }

.start-note {
  font-size: var(--t-body);
  line-height: 1.65;
  color: var(--muted);
  margin-bottom: 30px;
  max-width: 60ch;
}

.start-right .actions { gap: 14px; }

/* =============================================================
   FOOTER
   ============================================================= */
.foot {
  background: var(--bg);
  padding: 26px 0;
}
.foot-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 28px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--t-mono-label);
  color: var(--muted);
  letter-spacing: 0.06em;
}
.foot-left { text-align: left; }
.foot-center { text-align: center; }
.foot-right { text-align: right; }
.foot-right a { color: var(--muted); transition: color 0.18s; border-bottom: 1px solid transparent; padding-bottom: 1px; }
.foot-right a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 960px) {
  :root {
    --container-pad: 32px;
    --section-py: 5rem;
  }

  .topbar { padding: 0 32px; }
  .topbar-index { gap: 18px; }
  .topbar-index a .ix-l { display: none; }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 36px;
  }
  .hero-ledger {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .hero-ledger > div:nth-child(2) { border-right: none; }
  .hero-ledger > div:nth-child(1),
  .hero-ledger > div:nth-child(2) { padding-bottom: 16px; border-bottom: 1px solid var(--rule-hair); }

  .triptych {
    grid-template-columns: 1fr;
  }

  .protocol-grid,
  .start-grid {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .event-row {
    grid-template-columns: 148px 1fr;
    gap: 16px;
  }

  .foot-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }
  .foot-left, .foot-right { text-align: center; }
}

@media (max-width: 560px) {
  .topbar-index { gap: 14px; }
  .actions { gap: 10px; }
  .btn { padding: 11px 18px; font-size: 14px; }
  .hero-text { padding-top: 0; }
}
