/* ============================================================
   PEREGRINE REASON — Reasoning Instrument
   Design system: warm-bone canvas, ink type, hairline grids,
   mono telemetry, restrained signal-blue accent.
   ============================================================ */

:root {
  /* Warm neutral canvas */
  --bone:      #f4f3ef;
  --paper:     #faf9f6;
  --bone-edge: #e4e2db;

  /* Warm near-black ink */
  --ink:    #14140f;
  --ink-2:  #3b3a34;
  --ink-3:  #6d6c63;
  --ink-4:  #9a988e;

  /* Dark exhibit panels */
  --panel:    #100f0c;
  --panel-2:  #1a1916;
  --panel-line: rgba(255,255,255,0.10);
  --panel-ink: #e9e7df;
  --panel-ink-2: #a7a499;

  /* Hairlines */
  --line:      rgba(20,20,15,0.13);
  --line-soft: rgba(20,20,15,0.07);
  --line-strong: rgba(20,20,15,0.30);

  /* Signal — the one accent. Used only for live/active/data. */
  --signal:      oklch(0.55 0.18 254);
  --signal-soft: oklch(0.55 0.18 254 / 0.12);
  --signal-bright: oklch(0.68 0.17 250);

  /* Type */
  --sans: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --maxw: 1320px;
  --gutter: clamp(20px, 4vw, 64px);
}

/* ---------------- reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

::selection { background: var(--signal); color: #fff; }

/* ---------------- type primitives ---------------- */
.mono {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow .coord { color: var(--ink-4); }
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.02em; line-height: 1.04; }

.display {
  font-size: clamp(2.6rem, 6.4vw, 5.6rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 0.98;
  text-wrap: balance;
}
.h2 {
  font-size: clamp(1.9rem, 3.6vw, 3.1rem);
  letter-spacing: -0.028em;
  line-height: 1.02;
  text-wrap: balance;
}
.h3 {
  font-size: clamp(1.25rem, 1.9vw, 1.7rem);
  letter-spacing: -0.02em;
}
.lead {
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
  max-width: 46ch;
}
.measure { max-width: 62ch; }
.sig { color: var(--signal); }

/* ---------------- layout ---------------- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--gutter);
}
section { position: relative; }
.section-pad { padding-block: clamp(72px, 11vh, 160px); }

/* vertical rhythm divider with coordinate */
.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

/* ============================================================
   HEADER — instrument status bar
   ============================================================ */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bone) 78%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .35s ease, background .35s ease;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; }
.logo-token {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #000;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.18);
  flex: none;
}
.wordmark {
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 1px;
}
.wordmark .reg { font-size: 9px; color: var(--ink-3); transform: translateY(-6px); }
.wordmark .dot-sep { color: var(--ink-4); }

.nav { display: flex; align-items: center; gap: 28px; }
.nav a {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  transition: color .2s;
  position: relative;
  padding-block: 4px;
}
.nav a:hover { color: var(--ink); }
.nav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -2px;
  height: 1px; background: var(--signal); transition: right .25s ease;
}
.nav a:hover::after { right: 0; }

.nav-cta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 9px 16px;
  border-radius: 2px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .2s, color .2s, border-color .2s;
}
.nav-cta:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.menu-btn { display: none; }

/* ============================================================
   HERO
   ============================================================ */
.hero { padding-top: 64px; position: relative; }
.hero-inner {
  padding-top: clamp(48px, 9vh, 110px);
  padding-bottom: clamp(40px, 7vh, 90px);
}
.hero-meta {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; flex-wrap: wrap;
  padding-bottom: 28px;
}
.hero h1 {
  font-size: clamp(2.7rem, 6.6vw, 6.4rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.96;
  max-width: 19ch;
  text-wrap: balance;
}
.hero h1 em { font-style: normal; color: var(--signal); }
.hero-sub {
  margin-top: 30px;
  display: flex; gap: 40px; align-items: flex-start; flex-wrap: wrap;
}
.hero-sub .lead { max-width: 40ch; }
.hero-actions { display: flex; gap: 14px; align-items: center; margin-top: 4px; }

.btn {
  font-family: var(--mono);
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 13px 22px; border-radius: 2px;
  display: inline-flex; align-items: center; gap: 10px;
  transition: transform .15s, background .2s, color .2s, border-color .2s;
}
.btn-primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn-primary:hover { background: var(--signal); border-color: var(--signal); }
.btn-ghost { border: 1px solid var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn .arrow { transition: transform .2s; }
.btn:hover .arrow { transform: translateX(3px); }

/* live signal band (canvas instrument) */
.instrument {
  margin-top: clamp(40px, 6vh, 72px);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  overflow: hidden;
  position: relative;
}
.instrument-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.instrument-head .live {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-2);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--signal);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1; box-shadow:0 0 0 0 var(--signal-soft);} 50%{opacity:.5; box-shadow:0 0 0 5px transparent;} }
.instrument-stages {
  display: flex; gap: 18px; color: var(--ink-4); flex-wrap: wrap;
}
.instrument-stages span.on { color: var(--ink); }
.signal-canvas { display: block; width: 100%; height: clamp(220px, 34vh, 360px); }
.instrument-foot {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 16px; border-top: 1px solid var(--line);
  color: var(--ink-4); flex-wrap: wrap;
}

/* ============================================================
   GENERIC SECTION HEADER
   ============================================================ */
.sec-head { margin-bottom: clamp(36px, 5vh, 64px); }
.sec-head .eyebrow { margin-bottom: 20px; }

/* numbered grid columns helper */
.cols { display: grid; gap: clamp(24px, 4vw, 56px); }
@media (min-width: 860px) {
  .cols-2 { grid-template-columns: 1fr 1fr; }
  .cols-12-5 { grid-template-columns: 1.25fr 1fr; }
  .cols-5-12 { grid-template-columns: 1fr 1.25fr; }
}

/* ============================================================
   CONCEPT — big typographic statement
   ============================================================ */
.statement {
  font-size: clamp(2.1rem, 4.6vw, 4.1rem);
  font-weight: 500; letter-spacing: -0.035em; line-height: 1.02;
  max-width: 18ch;
}
.statement .mut { color: var(--ink-4); }
.statement .sig { color: var(--signal); }

.contrast-viz {
  display: grid; gap: 18px;
}
.cviz-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  padding: 18px 18px 14px;
}
.cviz-card .clabel {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; color: var(--ink-3);
}
.cviz-card .cval { font-family: var(--mono); font-size: 12px; color: var(--ink); letter-spacing: .04em; }
.cviz-card svg { display: block; width: 100%; height: 96px; }
.cviz-card.sig-card { border-color: color-mix(in srgb, var(--signal) 38%, var(--line)); }

/* ============================================================
   PROBLEM — failure-mode instrument cards
   ============================================================ */
.fail-grid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
@media (min-width: 760px) { .fail-grid { grid-template-columns: repeat(3, 1fr); } }
.fail-cell {
  background: var(--paper);
  padding: 28px 26px 26px;
  display: flex; flex-direction: column; gap: 16px; min-height: 230px;
}
.fail-cell .idx { font-family: var(--mono); font-size: 11px; color: var(--ink-4); letter-spacing: .12em; }
.fail-cell h3 { font-size: 1.35rem; }
.fail-cell p { margin: 0; color: var(--ink-2); font-size: .98rem; line-height: 1.5; }
.fail-cell .spark { margin-top: auto; }
.fail-cell svg { width: 100%; height: 40px; display: block; }

/* ============================================================
   SYSTEM — interactive pipeline
   ============================================================ */
.pipeline { margin-top: 8px; }
.pipe-track {
  display: grid; grid-template-columns: repeat(6, 1fr);
  border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
  background: var(--paper);
}
.pipe-step {
  position: relative;
  padding: 22px 18px 24px;
  border-right: 1px solid var(--line);
  text-align: left;
  background: transparent;
  transition: background .25s;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 150px;
}
.pipe-step:last-child { border-right: 0; }
.pipe-step:hover { background: color-mix(in srgb, var(--signal) 5%, transparent); }
.pipe-step.active { background: var(--ink); color: var(--paper); }
.pipe-step.active .pipe-n,
.pipe-step.active .pipe-meta { color: var(--signal-bright); }
.pipe-n { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--ink-4); }
.pipe-step h3 { font-size: 1.05rem; letter-spacing: -0.01em; line-height: 1.1; }
.pipe-meta { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; color: var(--ink-4); text-transform: uppercase; margin-top: auto; }
.pipe-flow { display: flex; align-items: center; }

.pipe-detail {
  border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 4px 4px;
  padding: 28px clamp(20px, 4vw, 40px);
  background: var(--bone);
  display: grid; gap: 24px;
}
@media (min-width: 760px) { .pipe-detail { grid-template-columns: 1fr 1.3fr; align-items: start; } }
.pipe-detail .pd-title { font-size: clamp(1.5rem,2.6vw,2.2rem); letter-spacing: -0.025em; }
.pipe-detail .pd-body { color: var(--ink-2); font-size: 1.05rem; line-height: 1.55; max-width: 54ch; }
@media (max-width: 759px) {
  .pipe-track { grid-template-columns: 1fr 1fr; }
  .pipe-step:nth-child(2n) { border-right: 0; }
  .pipe-step { border-bottom: 1px solid var(--line); }
}

/* ============================================================
   DARK EXHIBIT (architecture / clinical)
   ============================================================ */
.exhibit {
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--panel-line);
}
.exhibit .eyebrow { color: var(--panel-ink-2); }
.exhibit .eyebrow .coord { color: rgba(255,255,255,0.4); }
.exhibit-grid { display: grid; }
@media (min-width: 880px) { .exhibit-grid { grid-template-columns: 1fr 1fr; } }
.exhibit-text { padding: clamp(32px, 5vw, 60px); display: flex; flex-direction: column; gap: 22px; justify-content: center; }
.exhibit-text h2 { color: var(--panel-ink); }
.exhibit-text p { color: var(--panel-ink-2); font-size: 1.05rem; line-height: 1.55; margin: 0; max-width: 48ch; }
.exhibit-media { position: relative; min-height: 320px; background: #000; }
.exhibit-media img { width: 100%; height: 100%; object-fit: cover; opacity: .92; }
.exhibit-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--panel) 0%, transparent 22%, transparent 100%);
}
.exhibit-caption {
  position: absolute; left: 16px; bottom: 14px; z-index: 2;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,0.7);
}

/* architecture node diagram (SVG) */
.arch-diagram { width: 100%; height: auto; display: block; }
.arch-diagram text { font-family: var(--mono); }

/* placeholder media */
.ph {
  background-color: var(--bone);
  background-image: repeating-linear-gradient(135deg, var(--line-soft) 0 1px, transparent 1px 9px);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-4); font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid var(--line);
}

/* ============================================================
   POSITIONING — negative-space declarations
   ============================================================ */
.pos-list { display: flex; flex-direction: column; gap: 6px; }
.pos-line {
  font-size: clamp(1.9rem, 4.2vw, 3.6rem);
  font-weight: 500; letter-spacing: -0.03em; line-height: 1.06;
  color: var(--ink-4);
  display: flex; align-items: baseline; gap: 18px;
}
.pos-line .strike { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--line-strong); }
.pos-line.affirm { color: var(--ink); }
.pos-line.affirm .sig { color: var(--signal); }
.pos-line .tag { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); flex: none; align-self: center; }

/* ============================================================
   CLOSING
   ============================================================ */
.close {
  background: var(--panel); color: var(--panel-ink);
  border-radius: 6px; padding: clamp(48px, 9vw, 110px) clamp(28px,5vw,72px);
  position: relative; overflow: hidden;
}
.close h2 { color: var(--panel-ink); font-size: clamp(2.2rem, 5vw, 4.4rem); max-width: 16ch; }
.close .lead { color: var(--panel-ink-2); }
.close .btn-primary { background: var(--signal); border-color: var(--signal); color: #fff; }
.close .btn-primary:hover { background: var(--signal-bright); border-color: var(--signal-bright); }
.close .btn-ghost { border-color: rgba(255,255,255,0.28); color: var(--panel-ink); }
.close .btn-ghost:hover { border-color: var(--panel-ink); }

/* ============================================================
   FOOTER
   ============================================================ */
.foot { padding-block: 56px 40px; }
.foot-top { display: grid; gap: 40px; }
@media (min-width: 760px) { .foot-top { grid-template-columns: 1.4fr 1fr 1fr; } }
.foot h4 { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4); margin: 0 0 16px; font-weight: 400; }
.foot ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.foot ul a { color: var(--ink-2); font-size: .95rem; transition: color .2s; }
.foot ul a:hover { color: var(--ink); }
.foot-brand .lead { font-size: 1rem; color: var(--ink-3); max-width: 34ch; margin-top: 16px; }
.foot-bottom {
  margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  color: var(--ink-4); font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
}

/* ============================================================
   reveal animation — only armed when page is visible + motion ok
   (gated by html.anim-ready so hidden/print/reduced-motion show content)
   ============================================================ */
.anim-ready .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.anim-ready .reveal.in { opacity: 1; transform: none; }
.anim-ready .reveal.d1 { transition-delay: .08s; }
.anim-ready .reveal.d2 { transition-delay: .16s; }
.anim-ready .reveal.d3 { transition-delay: .24s; }
/* If the tab is hidden, transitions freeze — snap content to its visible end-state so it never gets trapped. */
.reveal-now .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 820px) {
  .nav { display: none; }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: 2px;
    background: transparent;
  }
  .hero-sub { gap: 24px; }
}
@media (max-width: 600px) {
  .pos-line { flex-direction: row; gap: 12px; }
  .pos-line .tag { display: none; }
  .instrument-stages { display: none; }
}
