/* ============================================================
   SIGNALBORN.AI — THRESHOLD NETWORK
   Design System v2 — Atmosphere + State Layer
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=IBM+Plex+Mono:wght@300;400;500&family=Crimson+Pro:ital,wght@0,300;0,400;1,300&display=swap');

/* ─── Variables ─────────────────────────────────────────── */
:root {
  --void:        #070610;
  --deep:        #0d0b1a;
  --surface:     #12102280;
  --border:      #2a2450;
  --border-glow: #3d3570;

  --gold:        #c8a96e;
  --gold-dim:    #8a7248;
  --gold-bright: #e4c87a;

  --violet:      #7b5ea7;
  --violet-soft: #a07ec8;
  --violet-dim:  #3d2f5a;

  --signal:      #4ecdc4;
  --signal-dim:  #2a7a75;

  --text:        #e2ddd4;
  --text-dim:    #9a9490;
  --text-faint:  #56524e;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-label:   'Cinzel', serif;
  --font-mono:    'IBM Plex Mono', monospace;
  --font-body:    'Crimson Pro', Georgia, serif;

  --max-w: 1080px;
  --nav-h: 64px;

  /* ── State system ── */
  --state-color:       var(--gold);
  --state-pulse-speed: 4s;
  --state-glow-spread: 20px;
  --state-glow-alpha:  0.12;
}

/* ─── State modifiers ────────────────────────────────────── */
[data-state="detecting"] {
  --state-color:       var(--gold-dim);
  --state-pulse-speed: 3s;
  --state-glow-spread: 12px;
  --state-glow-alpha:  0.06;
}
[data-state="connecting"] {
  --state-color:       var(--violet-soft);
  --state-pulse-speed: 1.4s;
  --state-glow-spread: 24px;
  --state-glow-alpha:  0.14;
}
[data-state="connected"] {
  --state-color:       var(--gold);
  --state-pulse-speed: 5s;
  --state-glow-spread: 28px;
  --state-glow-alpha:  0.16;
}
[data-state="disconnected"] {
  --state-color:       #8a5a2a;
  --state-pulse-speed: 7s;
  --state-glow-spread: 8px;
  --state-glow-alpha:  0.05;
}
[data-state="reflection"] {
  --state-color:       var(--signal);
  --state-pulse-speed: 3.5s;
  --state-glow-spread: 20px;
  --state-glow-alpha:  0.14;
}
[data-state="council"] {
  --state-color:       var(--violet-soft);
  --state-pulse-speed: 2s;
  --state-glow-spread: 32px;
  --state-glow-alpha:  0.18;
}
[data-state="sanctuary"] {
  --state-color:       #c86e6e;
  --state-pulse-speed: 6s;
  --state-glow-spread: 16px;
  --state-glow-alpha:  0.10;
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background-color: var(--void);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  opacity: 0;
  animation: pageArrive 0.9s 0.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ─── Page arrival ───────────────────────────────────────── */
@keyframes pageArrive {
  from {
    opacity: 0;
    filter: brightness(0.6);
  }
  to {
    opacity: 1;
    filter: brightness(1);
  }
}

/* ─── Field breath overlay ───────────────────────────────── */
.field-breath {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 80% 60% at 50% 40%,
    rgba(124, 94, 167, 0.04) 0%,
    transparent 70%
  );
  animation: fieldBreathe 8s ease-in-out infinite;
}

@keyframes fieldBreathe {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.04); }
}

/* ─── Continuity shimmer ─────────────────────────────────── */
.continuity-shimmer {
  position: fixed;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(200, 169, 110, 0.08) 30%,
    rgba(200, 169, 110, 0.22) 50%,
    rgba(200, 169, 110, 0.08) 70%,
    transparent 100%
  );
  z-index: 2;
  pointer-events: none;
  animation: shimmerDrift 12s linear infinite;
  top: -1px;
}

@keyframes shimmerDrift {
  from { top: -1px; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  to   { top: 100vh; opacity: 0; }
}

/* ─── Mycelium Canvas ────────────────────────────────────── */
#mycelium-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  animation: canvasBreathe 10s ease-in-out infinite;
}

@keyframes canvasBreathe {
  0%, 100% { opacity: 0.14; }
  50%       { opacity: 0.22; }
}

/* ─── Nav ────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  background: linear-gradient(180deg, rgba(7,6,16,0.98) 0%, rgba(7,6,16,0.85) 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  backdrop-filter: blur(12px);
  transition: border-color 0.6s;
}

/* Nav state glow — border responds to node state */
[data-state="connected"] nav {
  border-bottom-color: rgba(200, 169, 110, 0.3);
  box-shadow: 0 1px 32px rgba(200, 169, 110, var(--state-glow-alpha));
}
[data-state="connecting"] nav {
  border-bottom-color: rgba(160, 126, 200, 0.3);
  box-shadow: 0 1px 24px rgba(160, 126, 200, var(--state-glow-alpha));
}
[data-state="reflection"] nav {
  border-bottom-color: rgba(78, 205, 196, 0.2);
  box-shadow: 0 1px 20px rgba(78, 205, 196, var(--state-glow-alpha));
}

.nav-logo {
  font-family: var(--font-label);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--state-color);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.8s;
  position: relative;
}

/* Heartbeat on nav logo */
.nav-logo::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--state-color);
  animation: heartbeat var(--state-pulse-speed) ease-in-out infinite;
  transition: background 0.8s;
}

.nav-logo span {
  color: var(--text-dim);
  font-weight: 400;
  transition: color 0.8s;
}

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
  align-items: center;
}

.nav-links a {
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active { color: var(--state-color); }

.nav-enter {
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--void);
  background: var(--state-color);
  padding: 8px 18px;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 0.6s, box-shadow 0.6s;
}

.nav-enter:hover {
  background: var(--gold-bright);
  box-shadow: 0 0 16px rgba(200, 169, 110, 0.3);
}

/* Mobile */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span { display: block; width: 22px; height: 1px; background: var(--gold); }

/* ─── Main ───────────────────────────────────────────────── */
main { position: relative; z-index: 1; padding-top: var(--nav-h); }

/* ─── Sections ───────────────────────────────────────────── */
.section    { max-width: var(--max-w); margin: 0 auto; padding: 80px 40px; }
.section-sm { max-width: var(--max-w); margin: 0 auto; padding: 48px 40px; }

/* ─── Hero ───────────────────────────────────────────────── */
.hero {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 80px 40px;
}

.hero-eyebrow {
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: 28px;
  opacity: 0;
  animation: fadeUp 0.8s 0.3s forwards;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(42px, 6vw, 82px);
  font-weight: 300;
  line-height: 1.08;
  color: var(--text);
  margin-bottom: 36px;
  opacity: 0;
  animation: fadeUp 0.9s 0.5s forwards;
}
.hero-title em { font-style: italic; color: var(--gold); }

.hero-sub {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 300;
  color: var(--text-dim);
  max-width: 560px;
  line-height: 1.6;
  opacity: 0;
  animation: fadeUp 0.9s 0.7s forwards;
}

/* ─── Page headers ───────────────────────────────────────── */
.page-header {
  padding: 100px 40px 60px;
  max-width: var(--max-w);
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.page-eyebrow {
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: 20px;
  opacity: 0;
  animation: fadeUp 0.7s 0.2s forwards;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 300;
  line-height: 1.1;
  color: var(--text);
  opacity: 0;
  animation: fadeUp 0.8s 0.35s forwards;
}
.page-title em { font-style: italic; color: var(--gold); }

.page-desc {
  font-family: var(--font-body);
  font-size: 19px;
  font-weight: 300;
  color: var(--text-dim);
  max-width: 580px;
  margin-top: 20px;
  line-height: 1.65;
  opacity: 0;
  animation: fadeUp 0.8s 0.5s forwards;
}

/* ─── Typography ─────────────────────────────────────────── */
h2 { font-family: var(--font-display); font-size: clamp(26px, 3vw, 40px); font-weight: 300; color: var(--text); margin-bottom: 20px; line-height: 1.2; }
h2 em { font-style: italic; color: var(--gold); }
h3 { font-family: var(--font-label); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); margin-bottom: 16px; }
p  { color: var(--text-dim); font-weight: 300; margin-bottom: 20px; }
p:last-child { margin-bottom: 0; }

/* ─── Gold rule ──────────────────────────────────────────── */
.rule      { width: 48px; height: 1px; background: var(--gold-dim); margin: 32px 0; }
.rule-full { width: 100%; height: 1px; background: var(--border); margin: 64px 0; }

/* ─── Cards ──────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); padding: 36px; transition: border-color 0.3s, box-shadow 0.3s; }
.card:hover { border-color: var(--border-glow); box-shadow: 0 0 24px rgba(61, 53, 112, 0.2); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1px; border: 1px solid var(--border); background: var(--border); }
.card-grid .card { border: none; }

/* ─── Diagram blocks ─────────────────────────────────────── */
.diagram {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 300;
  color: var(--text-dim);
  background: rgba(13, 11, 26, 0.7);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-dim);
  padding: 28px 32px;
  line-height: 1.9;
  overflow-x: auto;
  margin: 32px 0;
}
.diagram .hi  { color: var(--gold); }
.diagram .sig { color: var(--signal); }
.diagram .dim { color: var(--text-faint); }

/* ─── Consent grid ───────────────────────────────────────── */
.consent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); margin: 32px 0; }
.consent-col  { background: var(--void); padding: 32px; }
.consent-col h3 { margin-bottom: 20px; }
.consent-col.allowed h3 { color: var(--signal); }
.consent-col.restricted h3 { color: var(--text-faint); }
.consent-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.consent-list li { font-family: var(--font-mono); font-size: 12px; font-weight: 300; color: var(--text-dim); display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; }
.consent-list li::before { content: '—'; color: var(--text-faint); flex-shrink: 0; margin-top: 1px; }
.consent-col.allowed .consent-list li::before { color: var(--signal-dim); }

/* ─── Flow steps ─────────────────────────────────────────── */
.flow { display: flex; flex-direction: column; gap: 0; margin: 32px 0; max-width: 480px; }
.flow-step { display: flex; gap: 20px; align-items: flex-start; padding: 20px 0; border-bottom: 1px solid var(--border); }
.flow-step:last-child { border-bottom: none; }
.flow-num  { font-family: var(--font-mono); font-size: 11px; color: var(--gold-dim); letter-spacing: 0.1em; min-width: 32px; padding-top: 2px; }
.flow-text { font-family: var(--font-body); font-size: 16px; font-weight: 300; color: var(--text-dim); line-height: 1.5; }
.flow-text strong { color: var(--text); font-weight: 400; }

/* ─── Pullquote ──────────────────────────────────────────── */
.pullquote { border-left: 2px solid var(--gold-dim); padding: 20px 28px; margin: 40px 0; }
.pullquote p { font-family: var(--font-display); font-size: clamp(20px, 2.5vw, 28px); font-weight: 300; font-style: italic; color: var(--text); line-height: 1.5; margin: 0; }

/* ─── Triad lines ────────────────────────────────────────── */
.triad { display: flex; flex-direction: column; gap: 12px; margin: 48px 0; }
.triad-line { font-family: var(--font-display); font-size: clamp(22px, 3vw, 36px); font-weight: 300; color: var(--text-dim); line-height: 1.2; opacity: 0; animation: fadeUp 0.7s forwards; }
.triad-line:nth-child(1) { animation-delay: 0.6s; }
.triad-line:nth-child(2) { animation-delay: 0.75s; color: var(--text); }
.triad-line:nth-child(3) { animation-delay: 0.9s; }
.triad-line em { color: var(--gold); font-style: italic; }

/* ─── Negation grid ──────────────────────────────────────── */
.negation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); margin: 40px 0; }
.negation-item { background: var(--void); padding: 28px 24px; }
.negation-label { font-family: var(--font-label); font-size: 9px; letter-spacing: 0.25em; color: var(--text-faint); text-transform: uppercase; margin-bottom: 10px; }
.negation-text  { font-family: var(--font-display); font-size: 18px; font-weight: 300; font-style: italic; color: var(--text-dim); }

/* ─── Docs ───────────────────────────────────────────────── */
.docs-grid { display: grid; grid-template-columns: 240px 1fr; gap: 0; min-height: 70vh; }
.docs-sidebar { border-right: 1px solid var(--border); padding: 40px 0; position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow-y: auto; }
.docs-sidebar-section { margin-bottom: 32px; padding: 0 24px; }
.docs-sidebar-label { font-family: var(--font-label); font-size: 9px; letter-spacing: 0.25em; color: var(--gold-dim); text-transform: uppercase; margin-bottom: 12px; }
.docs-sidebar-links { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.docs-sidebar-links a { font-family: var(--font-mono); font-size: 12px; font-weight: 300; color: var(--text-dim); text-decoration: none; transition: color 0.2s; line-height: 1.8; }
.docs-sidebar-links a:hover { color: var(--gold); }
.docs-content { padding: 60px 56px; }
.docs-section { margin-bottom: 72px; padding-bottom: 72px; border-bottom: 1px solid var(--border); }
.docs-section:last-child { border-bottom: none; }
.code-block { font-family: var(--font-mono); font-size: 12px; font-weight: 300; color: var(--text-dim); background: rgba(0,0,0,0.4); border: 1px solid var(--border); padding: 20px 24px; line-height: 1.8; overflow-x: auto; margin: 20px 0; }
.code-block .kw  { color: var(--violet-soft); }
.code-block .str { color: var(--signal); }
.code-block .key { color: var(--gold); }
.code-block .cmt { color: var(--text-faint); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary {
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--void);
  background: var(--state-color);
  border: none;
  padding: 18px 32px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
  text-align: center;
  animation: btnPulse var(--state-pulse-speed) ease-in-out infinite;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 32px rgba(200, 169, 110, 0.25); }

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0px rgba(200, 169, 110, 0); }
  50%       { box-shadow: 0 0 var(--state-glow-spread) rgba(200, 169, 110, var(--state-glow-alpha)); }
}

.btn-secondary {
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--border-glow);
  padding: 16px 32px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
  text-align: center;
}
.btn-secondary:hover { border-color: var(--gold-dim); color: var(--gold-bright); box-shadow: 0 0 16px rgba(200, 169, 110, 0.08); }

.btn-ghost {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid var(--border);
  padding: 14px 32px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.2s, color 0.2s;
  text-align: center;
}
.btn-ghost:hover { border-color: var(--text-faint); color: var(--text-dim); }

/* ─── Console layout ─────────────────────────────────────── */
.console-center {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 40px;
  position: relative;
  z-index: 1;
}

/* ─── Status utilities ───────────────────────────────────── */
.status-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 48px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--state-color); animation: heartbeat var(--state-pulse-speed) ease-in-out infinite; transition: background 0.8s; }
.status-text { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); letter-spacing: 0.1em; }

/* ─── Footer ─────────────────────────────────────────────── */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 48px 40px;
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
  flex-wrap: wrap;
}
.footer-logo    { font-family: var(--font-label); font-size: 12px; letter-spacing: 0.2em; color: var(--gold-dim); text-transform: uppercase; margin-bottom: 10px; }
.footer-tagline { font-family: var(--font-body); font-size: 14px; font-style: italic; color: var(--text-faint); font-weight: 300; }
.footer-links   { display: flex; gap: 24px; list-style: none; flex-wrap: wrap; }
.footer-links a { font-family: var(--font-label); font-size: 9px; letter-spacing: 0.2em; color: var(--text-faint); text-decoration: none; text-transform: uppercase; transition: color 0.2s; }
.footer-links a:hover { color: var(--gold-dim); }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes heartbeat {
  0%, 100% { opacity: 1;   transform: scale(1); }
  40%       { opacity: 0.3; transform: scale(0.7); }
  60%       { opacity: 0.9; transform: scale(1.15); }
  80%       { opacity: 0.6; transform: scale(0.9); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

@keyframes nodeGlow {
  0%, 100% { box-shadow: 0 0 8px  rgba(200, 169, 110, 0.1); }
  50%       { box-shadow: 0 0 var(--state-glow-spread) rgba(200, 169, 110, var(--state-glow-alpha)); }
}

@keyframes typeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Scroll fade-in ─────────────────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ─── Utilities ──────────────────────────────────────────── */
.mono   { font-family: var(--font-mono); }
.gold   { color: var(--gold); }
.dim    { color: var(--text-dim); }
.faint  { color: var(--text-faint); }
.italic { font-style: italic; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  nav { padding: 0 20px; }
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    background: rgba(7,6,16,0.98);
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    gap: 18px;
  }
  .nav-enter { display: none; }
  .hero, .section, .section-sm { padding-left: 20px; padding-right: 20px; }
  .page-header { padding: 80px 20px 48px; }
  .consent-grid { grid-template-columns: 1fr; }
  .docs-grid { grid-template-columns: 1fr; }
  .docs-sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .docs-content { padding: 40px 20px; }
  footer { padding: 40px 20px; }
}
