/* ================================================================
   styles.css — Presence of Presence: Process Documentation
   Light / museum aesthetic — white/warm grey ground
================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;1,400;1,500&family=IBM+Plex+Mono:wght@300;400;500&family=Playfair+Display+SC:wght@400&display=swap');

:root {
  --bg:       #f1f1f1;
  --bg2:      #e8e8e8;
  --bg3:      #dedede;
  --line:     #cccccc;
  --line2:    #b4b4b4;
  --t0:       #181818;
  --t1:       #484848;
  --t2:       #787878;
  --t3:       #ababab;
  --accent:   #181818;
  --accent2:  #585858;
  --gold:     #7a7264;
  --serif:    'Playfair Display', Georgia, serif;
  --sc:       'Playfair Display SC', serif;
  --mono:     'IBM Plex Mono', 'Courier New', monospace;
  --nav-h:    56px;
  --max-w:    1400px;
}

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

html {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--t0);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.75;
  cursor: default;
  overflow-x: hidden;
}

/* ─── PROGRESS BAR ─── */
#progressBar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--t0);
  z-index: 300;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

/* ─── NAV ─── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  border-bottom: 1px solid var(--line);
  background: rgba(241,241,241,0.94);
  backdrop-filter: blur(20px);
}

.nav-brand {
  font-family: var(--sc);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--t1);
  transition: color 0.2s;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-brand:hover { color: var(--t0); }

.nav-steps {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: center;
  overflow: hidden;
  flex: 1;
  justify-content: center;
  padding: 0 12px;
}

.nav-pill {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
  border: 1px solid transparent;
}
.nav-pill:hover { color: var(--t0); background: var(--bg2); }
.nav-pill.active { color: var(--t0); font-weight: 500; background: var(--bg2); border-color: var(--line); }

/* Presence pill — slightly separated */
.nav-pill--presence {
  margin-right: 8px;
}

/* Divider between Presence and layers */
.nav-divider {
  width: 1px;
  height: 14px;
  background: var(--line2);
  flex-shrink: 0;
  margin-right: 8px;
}
/* ─── NAV site link ─── */
.nav-site-link {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t3);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.2s;
}
.nav-site-link:hover { color: var(--t0); }

/* ─── FLOATING REGENERATE ─── */
/* Resolve Presence button — inside traits panel, weighty */
.resolve-btn {
  font-family: var(--sc);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--t0);
  border: none;
  padding: 13px 0;
  cursor: pointer;
  width: 100%;
  flex-shrink: 0;
  transition: opacity 0.2s;
  margin-top: 8px;
}
.resolve-btn:hover { opacity: 0.8; }
.resolve-btn:active { opacity: 0.95; }

/* Scroll hint at bottom of presence block */
.presence-scroll-hint {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 32px 0 40px;
  align-self: flex-start;
}

/* ─── OVERVIEW SECTION — visual start of layers ─── */
.overview-section {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 72px 72px 80px;
}

.overview-inner {
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ─── SECTIONS ─── */
section {
  scroll-snap-align: start;
  scroll-margin-top: var(--nav-h);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

#s0, .presence-section, .overview-section {
  min-height: unset;
  overflow: visible;
}

/* ─── ENCOUNTER SECTION ─── */
#s0 {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Upper block — has video bg */
.encounter-meta {
  position: relative;
  overflow: hidden;
  padding: calc(var(--nav-h) + 70px) 72px 110px;
  flex-shrink: 0;
}

/* Video — scoped inside meta only */
.encounter-video-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
}
.encounter-video-wrap:has(source) { opacity: 1; }
.encounter-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.35;
}

.encounter-meta-content {
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--t3);
  margin-bottom: 40px;
  text-transform: uppercase;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(56px, 8vw, 120px);
  line-height: 0.92;
  font-weight: 400;
  color: var(--t0);
  margin-bottom: 32px;
}
.hero-title em { font-style: italic; }

.hero-sub {
  font-family: var(--serif);
  font-size: clamp(15px, 1.8vw, 20px);
  font-style: italic;
  color: var(--t2);
  max-width: 540px;
  line-height: 1.55;
  margin-bottom: 0;
}

/* ─── PRESENCE BLOCK (inline) ─── */
.presence-section {
  background: var(--bg2);
  padding: 48px 72px 0;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.presence-inner {
  display: inline-flex;
  border: 1px solid var(--line);
  overflow: hidden;
}

/* Canvas — square, almost full viewport height */
.encounter-canvas {
  width: 78vh;
  height: 78vh;
  max-width: 55vw;
  max-height: 55vw;
  flex-shrink: 0;
  background: #505050;
}

/* Right panel — same height as canvas */
.encounter-traits {
  width: clamp(260px, 28vw, 360px);
  height: 78vh;
  max-height: 55vw;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.encounter-modal-top {
  flex-shrink: 0;
}

.encounter-modal-title {
  font-family: var(--sc);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--t1);
}

.encounter-work-title {
  font-family: var(--sc);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--t1);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.encounter-hash-header {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--t3);
  line-height: 1.2;
  word-break: break-all;
}
.encounter-hash-label {
  white-space: nowrap;
}
.encounter-hash-val {
  word-break: break-all;
}

.encounter-params-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t3);
  flex-shrink: 0;
}

.encounter-traits-list {
  flex: 1;
  overflow-y: scroll;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
}

.etrait-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}
.etrait-row:last-child { border-bottom: none; }

.etrait-k {
  color: var(--t2);
  flex-shrink: 0;
  max-width: 45%;
  word-break: break-word;
  line-height: 1.4;
}

.etrait-v {
  color: var(--t0);
  text-align: right;
  word-break: break-word;
  max-width: 55%;
  line-height: 1.4;
}

.etrait-divider { display: none; }

.scroll-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
  margin-top: 20px;
  animation: breathe 3s ease-in-out infinite;
}
.scroll-hint::before {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--t3);
  flex-shrink: 0;
}

@keyframes breathe { 0%,100%{opacity:0.25} 50%{opacity:0.75} }

/* ─── OVERVIEW DESC ─── */
.overview-desc {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--t1);
  line-height: 1.9;
  max-width: 680px;
}

.overview-desc--lead {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--t1);
  line-height: 1.9;
  max-width: 680px;
}

.overview-desc--small {
  font-size: 10px;
  color: var(--t3);
  margin-top: -16px;
}

/* Chain — simple inline blocks with arrows */
.overview-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  row-gap: 8px;
}

.overview-block {
  border: 1px solid var(--line);
  padding: 7px 14px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t1);
  transition: border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.overview-block:hover {
  border-color: var(--t0);
  color: var(--t0);
}
.overview-block-n {
  color: var(--t3);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.overview-arrow {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  font-size: 10px;
  color: var(--t3);
  font-family: var(--mono);
}

/* Traits cascade animation */
.etrait-row--new {
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.etrait-row--visible {
  opacity: 1;
  transform: translateY(0);
}

.layer-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.layer-meta {
  padding: calc(var(--nav-h) + 56px) 48px 56px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--bg);
}

.layer-content {
  padding: calc(var(--nav-h) + 56px) 60px 56px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--bg2);
}

/* Meta column elements */
.layer-n {
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 24px;
}

.layer-title {
  font-family: var(--serif);
  font-size: clamp(26px, 2.8vw, 42px);
  line-height: 1.05;
  font-weight: 400;
  color: var(--t0);
  margin-bottom: 4px;
}

.layer-subtitle {
  font-size: 10px;
  color: var(--t3);
  letter-spacing: 0.08em;
  font-style: italic;
  margin-bottom: 28px;
}

.layer-desc {
  font-size: 11.5px;
  color: var(--t1);
  line-height: 1.85;
  max-width: 300px;
}
.layer-desc + .layer-desc { margin-top: 14px; }

.layer-tag {
  display: inline-block;
  margin-top: 28px;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--t3);
  border: 1px solid var(--line);
  padding: 5px 14px;
}

/* ─── RESULT BADGE ─── */
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 10px 16px;
  border: 1px solid var(--line2);
  background: var(--bg);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.5s, transform 0.5s;
}
.result-badge.show { opacity: 1; transform: translateY(0); }
.result-badge-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
}
.result-badge-val {
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  color: var(--t0);
}

/* ─── LAYER 1: DNA ─── */
.dna-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
  max-width: 820px;
  width: 100%;
}

.dna-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 2px solid transparent;
  padding: 0 13px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s, transform 0.25s, border-left-color 0.4s, background 0.4s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 72px;
  box-sizing: border-box;
  overflow: hidden;
}
.dna-card.show { opacity: 1; transform: translateY(0); }

/* Corrected state — left border stays permanently */
.dna-card--corrected {
  border-left-color: var(--t0);
}

.dna-nm {
  font-size: 9px;
  color: var(--t2);
  margin-bottom: 3px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dna-vl {
  font-size: 11px;
  color: var(--t0);
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  /* Single line only — long values get … after last full word */
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color 0.12s;
}
.dna-vl--scanning { color: var(--t3); }
.dna-vl--settled  { color: var(--t0); }

/* Pole badge — small axis label bottom right */
.dna-pole {
  font-size: 7.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t3);
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.4s;
}
.dna-card.show .dna-pole { opacity: 1; }

.correction-note {
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--t0);
  background: var(--bg);
  max-width: 700px;
  opacity: 0;
  transition: opacity 0.5s;
}
.correction-note.show { opacity: 1; }
.correction-note strong {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--t2);
  display: block;
  margin-bottom: 6px;
}
.correction-note p {
  font-size: 11px;
  color: var(--t1);
  line-height: 1.7;
}
.correction-note p + p {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

/* ─── LAYER 2: ARCHETYPE ─── */
.axes-block {
  width: 100%;
  max-width: 580px;
}

.axis-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.ax-track-wrap {
  flex: 1;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.5s, transform 0.5s;
}
.ax-track-wrap.show { opacity: 1; transform: translateY(0); }

.ax-name {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 8px;
}

.ax-track {
  height: 1px;
  background: var(--line);
  position: relative;
  margin-bottom: 8px;
}

/* Center tick mark */
.ax-center-tick {
  position: absolute;
  left: 50%;
  top: -4px;
  width: 1px;
  height: 9px;
  background: var(--t0);
  transform: translateX(-50%);
  z-index: 2;
}

.ax-fill-center {
  position: absolute;
  top: -1px;
  height: 3px;
  background: var(--t0);
  width: 0%;
  transition: width 1.2s cubic-bezier(.4,0,.2,1);
}
.ax-fill--left  { right: 50%; left: auto; }
.ax-fill--right { left: 50%; }

.ax-poles {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--t3);
  text-transform: uppercase;
}
.ax-pole--winner { color: var(--t0); }
.ax-score {
  font-size: 8px;
  color: var(--t3);
  margin-left: 3px;
}

/* Winner label — hidden until bar settles */
.ax-winner-reveal {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t0);
  width: 88px;
  flex-shrink: 0;
  text-align: right;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.5s, transform 0.5s;
}
.ax-winner-reveal.show {
  opacity: 1;
  transform: translateX(0);
}

/* Archetype result block under axes */
.archetype-reveal {
  margin-top: 8px;
  max-width: 580px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--t0);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s, transform 0.6s;
}
.archetype-reveal.show {
  opacity: 1;
  transform: translateY(0);
}
.archetype-reveal-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 6px;
}
.archetype-reveal-val {
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  color: var(--t0);
  line-height: 1.3;
}

/* ─── LAYER 3: PROTOCOLS ─── */
.proto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  max-width: 680px;
  width: 100%;
}

.proto-card {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 11px 14px 10px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s, transform 0.3s, border-color 0.5s, background 0.5s;
}
.proto-card.show { opacity: 1; transform: translateY(0); }
.proto-card.selected {
  border-color: var(--t0);
  background: var(--bg2);
}
.proto-card.selected .proto-nm { color: var(--t0); font-weight: 500; }

.proto-cat {
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 3px;
}
.proto-nm {
  font-size: 11px;
  color: var(--t1);
  margin-bottom: 6px;
  transition: color 0.4s;
}

/* Protocol pole chips — archetype match visualisation */
.proto-poles {
  display: flex;
  gap: 3px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}
.proto-pole-chip {
  font-size: 7px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 1px 4px;
  border: 1px solid var(--line);
  color: var(--t3);
  transition: border-color 0.5s, color 0.5s;
}
.proto-pole-chip--match {
  border-color: var(--t2);
  color: var(--t1);
}
.proto-card.selected .proto-pole-chip--match {
  border-color: var(--t0);
  color: var(--t0);
}

/* Resonance bar */
.proto-bar-wrap { margin-top: 6px; }
.proto-bar-track {
  width: 100%;
  height: 2px;
  background: var(--line);
}
.proto-bar-fill {
  height: 2px;
  background: var(--t0);
  width: 0%;
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
  opacity: 0.25;
}
.proto-card.selected .proto-bar-fill { opacity: 1; }

/* ─── LAYER 4: STATEMENT ─── */
.statement-block {
  max-width: 680px;
  width: 100%;
}

/* Protocol header — subtle warm tint, left border */
.stmt-proto-header {
  background: var(--bg2);
  border-left: 2px solid var(--t0);
  padding: 16px 20px;
  margin-bottom: 2px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s, transform 0.4s;
}
.stmt-proto-header.show { opacity: 1; transform: translateY(0); }

.stmt-proto-header-left { display: flex; flex-direction: column; gap: 4px; }

.stmt-proto-type {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--t3);
}

.stmt-proto-name {
  font-family: var(--serif);
  font-size: 22px;
  font-style: italic;
  color: var(--t0);
  line-height: 1.2;
}

.stmt-proto-hint {
  font-size: 10px;
  color: var(--t2);
  letter-spacing: 0.04em;
  font-style: italic;
}

/* Anomaly alerts */
.stmt-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.4s;
}
.stmt-alert.show { opacity: 1; }

.stmt-alert--void {
  background: var(--t0);
  color: var(--bg);
}
.stmt-alert--paradox {
  background: var(--t0);
  color: var(--bg);
}
.stmt-alert--warning {
  background: var(--bg3);
  color: var(--t1);
  border: 1px solid var(--line2);
}

.stmt-alert-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Phrase blocks — light area below dark header */
.stmt-phrases {
  margin-top: 2px;
}

.stmt-phrase {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.5s, transform 0.5s;
}
.stmt-phrase.show { opacity: 1; transform: translateX(0); }

.stmt-role-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.stmt-role {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--t0);
  font-weight: 500;
}

.stmt-role-hint {
  font-size: 9px;
  color: var(--t3);
  font-style: italic;
}

.stmt-text {
  font-family: var(--serif);
  font-size: clamp(16px, 1.8vw, 21px);
  color: var(--t0);
  line-height: 1.45;
  font-style: italic;
  min-height: 1.45em; /* prevent layout jump before typing starts */
}

/* Blinking cursor during typewriter */
.stmt-cursor {
  display: inline;
  color: var(--t0);
  font-style: normal;
  animation: stmt-blink 0.6s steps(1) infinite;
}
@keyframes stmt-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* The highlight mark */
.stmt-hl {
  background: transparent;
  color: inherit;
  border-bottom: 2px solid var(--t0);
  padding-bottom: 1px;
  font-style: inherit;
  position: relative;
}

/* ─── LAYER 5: DENSITY ─── */
#densityCanvas {
  width: 480px;
  height: 480px;
  border: 1px solid var(--line);
  display: block;
  flex-shrink: 0;
  max-width: 100%;
  opacity: 0;
  transition: opacity 0.6s;
}
#densityCanvas.loaded { opacity: 1; }

/* Three-column stat row below canvas */
.density-stat {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  max-width: 480px;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.6s;
}
.density-stat.loaded { opacity: 1; }

.density-stat-item {
  border: 1px solid var(--line);
  padding: 14px 16px 12px;
  text-align: center;
}

.density-stat-label {
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 6px;
}

.density-stat-num {
  font-family: var(--serif);
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 400;
  color: var(--t0);
  line-height: 1;
  margin-bottom: 4px;
}

/* Manifestation name is smaller since it's a word not a number */
.density-stat-num--mani {
  font-size: clamp(11px, 1.3vw, 14px);
  font-style: italic;
  font-family: var(--serif);
  line-height: 1.3;
  margin-bottom: 2px;
}

.density-stat-unit {
  font-size: 8.5px;
  color: var(--t3);
  letter-spacing: 0.04em;
}

/* ─── LAYER 6: MANIFESTATION ─── */
.mani-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  max-width: 820px;
}

.mani-left {
  flex: 0 0 240px;
}

.mani-list { width: 100%; }

.mani-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 10px 8px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.4s, transform 0.4s, border-left-color 0.4s;
}
.mani-row.show { opacity: 1; transform: translateY(0); }
.mani-row.active {
  border-left-color: var(--t0);
}
.mani-row:first-child { padding-top: 0; }

.mani-swatch {
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.mani-row-label { flex: 1; }

.mani-name {
  font-size: 11px;
  color: var(--t0);
  font-weight: 400;
}
.mani-row.active .mani-name { font-weight: 500; }

.mani-range {
  font-size: 9px;
  color: var(--t3);
  letter-spacing: 0.04em;
  margin-top: 1px;
}

.mani-preview {
  width: 480px;
  height: 480px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  transition: background 0.5s, opacity 0.6s;
  max-width: 100%;
  opacity: 0;
}
.mani-preview.show { opacity: 1; }

.mani-preview-label {
  position: absolute;
  bottom: 16px;
  left: 16px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  mix-blend-mode: difference;
  color: rgba(255,255,255,0.6);
}

.mani-row--anomaly {
  border-top: 1px dashed var(--line);
  margin-top: 2px;
  padding-top: 14px;
}

.mani-anomaly-tag {
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t3);
  border: 1px solid var(--line);
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.mani-anomaly-note {
  margin-top: 12px;
  font-size: 10px;
  color: var(--t2);
  font-style: italic;
  opacity: 0;
  transition: opacity 0.5s;
}
.mani-anomaly-note.show { opacity: 1; }

/* ─── LAYER 7: PATCH ─── */
.patch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
  max-width: 640px;
  width: 100%;
}

.patch-card {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 16px;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.3s, transform 0.3s, border-color 0.4s, background 0.4s;
}
.patch-card.show { opacity: 1; transform: translateY(0); }
.patch-card.selected {
  border-color: var(--t0);
  background: var(--bg2);
}

.patch-icon {
  font-size: 18px;
  margin-bottom: 8px;
}
.patch-nm {
  font-size: 11px;
  color: var(--t0);
  font-weight: 500;
  margin-bottom: 4px;
}
.patch-effect {
  font-size: 10px;
  color: var(--t2);
  line-height: 1.5;
}

.patch-result {
  margin-top: 20px;
  padding: 16px 20px;
  border: 1px solid var(--t0);
  background: var(--bg);
  max-width: 640px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.5s, transform 0.5s;
}
.patch-result.show { opacity: 1; transform: translateY(0); }
.patch-result-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 4px;
}
.patch-result-label {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
  min-width: 100px;
}
.patch-result-val {
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: var(--t0);
}
#patchStatusVal[data-status="ACTIVATED"] { color: var(--t0); }
#patchStatusVal[data-status="PENDING"]   { color: var(--t2); }
#patchStatusVal[data-status="NONE"]      { color: var(--t2); }

/* Comparison canvases */
.patch-canvas-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  max-width: 640px;
  margin-top: 2px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.6s, transform 0.6s;
}
.patch-canvas-wrap.show { opacity: 1; transform: translateY(0); }

.patch-canvas-item {}

.patch-canvas-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 10px 0 6px;
}

.patch-canvas-item canvas {
  display: block;
  border: 1px solid var(--line);
  width: 100%;
}

.patch-canvas-sub {
  font-size: 9px;
  color: var(--t2);
  letter-spacing: 0.06em;
  font-style: italic;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

/* ─── FINAL SECTION — STATISTICS ─── */
#s_final {
  overflow: visible;
  display: block;
  min-height: 100vh;
  background: var(--bg);
}

.stat-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 80px 72px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 48px;
}

.stat-sub {
  font-family: var(--mono);
  font-size: clamp(11px, 1.1vw, 13px);
  color: var(--t2);
  line-height: 1.9;
  max-width: 640px;
  margin-top: 56px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.stat-item {
  padding: 32px 24px 28px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.stat-num {
  font-family: var(--serif);
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 400;
  color: var(--t0);
  line-height: 1;
  margin-bottom: 12px;
}

.stat-lbl {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t3);
}

.stat-patch-note {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--t3);
  text-align: center;
  margin-top: 32px;
}

.stat-item--wide {
  grid-column: span 2;
}

/* ─── UTILITY ─── */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s, transform 0.6s;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }

/* ─── RESPONSIVE ─── */

/* Tablet */
/* Intermediate — traits start getting squeezed */
@media (max-width: 1100px) {
  .presence-section { padding: 32px 40px 0; }
  .encounter-canvas {
    width: 62vh;
    height: 62vh;
    max-width: 52vw;
    max-height: 52vw;
  }
  .encounter-traits {
    height: 62vh;
    max-height: 52vw;
    width: clamp(240px, 34vw, 360px);
  }
  .overview-inner {
    max-width: calc(62vh + clamp(240px, 34vw, 360px));
  }
}

@media (max-width: 900px) {
  .nav { padding: 0 20px; }
  .nav-steps { display: none; }

  #s0 { padding: calc(var(--nav-h) + 40px) 32px 48px; }
  .scroll-hint { position: relative; bottom: auto; left: auto; margin-top: 20px; }

  /* Presence block — stack vertically */
  .presence-section { padding: 24px 24px 0; align-items: stretch; }
  .presence-inner { flex-direction: column; width: 100%; }
  .encounter-canvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1;
    max-width: 100% !important;
    max-height: unset !important;
  }
  .encounter-traits {
    width: 100% !important;
    height: 320px !important;
    max-height: unset !important;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .overview-inner { max-width: 100%; }
  .layer-grid { grid-template-columns: 1fr; }
  .layer-meta {
    min-height: unset;
    padding: calc(var(--nav-h) + 40px) 32px 32px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .layer-content { padding: 32px 32px 56px; }

  /* DNA */
  .dna-grid { grid-template-columns: 1fr 1fr; }

  /* Archetype */
  .ax-layout { gap: 24px; }

  /* Protocol */
  .proto-grid { grid-template-columns: 1fr; }

  /* Statement */
  .statement-block { max-width: 100%; }

  /* Density */
  #densityCanvas { width: 100% !important; height: auto !important; max-width: 480px; }

  /* Manifestation — list then preview */
  .mani-layout { flex-direction: column; }
  .mani-left { flex: none; width: 100%; }
  .mani-preview { width: 100%; height: auto; aspect-ratio: 1; max-width: 480px; }

  /* Patch */
  .patch-grid { grid-template-columns: 1fr 1fr; }
  .patch-canvas-wrap { grid-template-columns: 1fr 1fr; }

  /* Final */
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .stat-item { border-bottom: none; border-right: none; }
  .stat-page { padding: 64px 24px 64px; }
}

/* Mobile */
@media (max-width: 600px) {
  :root { --nav-h: 48px; }
  .nav { padding: 0 16px; }
  .nav-brand { font-size: 10px; letter-spacing: 0.08em; }
  .nav-collection { font-size: 8px; }

  #s0 { padding: calc(var(--nav-h) + 24px) 20px 40px; }
  .scroll-hint { position: relative; bottom: auto; left: auto; margin-top: 24px; }
  .hero-title { font-size: clamp(40px, 12vw, 72px); }

  .presence-section { padding: 16px 16px 32px; }
  .encounter-traits { height: 280px !important; }

  .layer-meta { padding: calc(var(--nav-h) + 24px) 20px 24px; }
  .layer-content { padding: 24px 20px 48px; }

  /* DNA */
  .dna-grid { grid-template-columns: 1fr; }

  /* Density canvas — square, full width */
  #densityCanvas { width: 100% !important; height: auto !important; }
  .density-stat { grid-template-columns: 1fr 1fr; }

  /* Patch — single column */
  .patch-grid { grid-template-columns: 1fr; }
  .patch-canvas-wrap { grid-template-columns: 1fr; }

  /* Manifestation */
  .mani-preview { max-width: 100%; }

  /* Final stats — 2 cols */
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .stat-item { border-bottom: none; border-right: none; }
  .stat-num { font-size: clamp(20px, 8vw, 32px); }
  .stat-page { padding: 48px 16px 48px; }

  /* Floating regen — smaller on mobile */
}


/* ─── Simulation File Icon ──────────────────────────────────── */
.sim-file-wrap {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.sim-file-icon {
  background: none;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 160px;
}

.sim-file-icon:hover {
  border-color: var(--line2);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.sim-file-card {
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.sim-file-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.sim-file-lines span {
  display: block;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
}

.sim-file-lines span:nth-child(1) { width: 100%; }
.sim-file-lines span:nth-child(2) { width: 85%; }
.sim-file-lines span:nth-child(3) { width: 100%; }
.sim-file-lines span:nth-child(4) { width: 70%; }
.sim-file-lines span:nth-child(5) { width: 90%; }
.sim-file-lines span:nth-child(6) { width: 55%; }

.sim-file-name {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--t1);
  text-align: left;
}

.sim-file-meta {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.10em;
  color: var(--t3);
  text-align: left;
}

.sim-file-caption {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--t3);
  text-align: center;
}

/* ─── Simulation Modal ──────────────────────────────────────── */
.sim-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 25, 23, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.sim-modal--open {
  opacity: 1;
  pointer-events: all;
}

.sim-modal-inner {
  background: var(--bg);
  width: min(780px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line2);
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}

.sim-modal-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sim-modal-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--t0);
}

.sim-modal-meta {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.10em;
  color: var(--t3);
  flex: 1;
}

.sim-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--t3);
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.sim-modal-close:hover {
  color: var(--t0);
}

.sim-modal-body {
  overflow-y: auto;
  padding: 24px;
  flex: 1;
  text-align: left;
}

.sim-modal-pre {
  font-family: var(--mono);
  font-size: clamp(9px, 1vw, 11px);
  line-height: 1.8;
  color: var(--t1);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: hidden;
  margin: 0;
}
