:root {
  --void: #080a0e;
  --deep: #0d1117;
  --surface: #141820;
  --panel: #1a2030;
  --border: #2a3448;
  --muted: #4a5568;
  --text: #c8d0e0;
  --bright: #e8edf5;
  --gold: #c8922a;
  --gold-dim: #8a6018;
  --gold-glow: rgba(200,146,42,0.15);
  --teal: #2a8a8a;
  --teal-bright: #3ab8b8;
  --teal-glow: rgba(58,184,184,0.12);
  --amber: #d4820a;
  --rose: #c04848;
}

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

body {
  background: var(--void);
  color: var(--text);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px;
  line-height: 1.8;
  overflow-x: hidden;
}

/* ── CANVAS HEADER ─────────────────────────────────── */
.hero {
  position: relative;
  height: 100vh;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#heroCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-text {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 2rem;
}

.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin-bottom: 1.5rem;
  opacity: 0;
  animation: fadeIn 1s ease 0.5s forwards;
}

.hero-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.2rem, 6vw, 5rem);
  font-weight: 300;
  letter-spacing: 0.05em;
  line-height: 1.15;
  color: var(--bright);
  margin-bottom: 1rem;
  opacity: 0;
  animation: fadeIn 1s ease 0.8s forwards;
}

.hero-title .accent { color: var(--gold); }

.hero-subtitle {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  font-weight: 300;
  color: var(--muted);
  letter-spacing: 0.15em;
  opacity: 0;
  animation: fadeIn 1s ease 1.1s forwards;
}

.scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  z-index: 10;
  opacity: 0;
  animation: fadeIn 1s ease 1.8s forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.scroll-arrow {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--muted), transparent);
  animation: scrollPulse 2s ease infinite;
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.3; transform: scaleY(1); }
  50% { opacity: 1; transform: scaleY(1.2); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── JOURNEY RAIL ──────────────────────────────────── */
.journey {
  max-width: 1100px;
  margin: 0 auto;
  padding: 5rem 2rem 8rem;
  position: relative;
}

/* Vertical rail line */
.journey::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--border) 8%, var(--border) 92%, transparent);
  transform: translateX(-50%);
}

/* ── STEP ──────────────────────────────────────────── */
.step {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 0;
  margin-bottom: 6rem;
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
  transform: translateY(30px);
}

.step.visible { opacity: 1; transform: translateY(0); }

/* Every other step flips */
.step:nth-child(even) .step-content { order: 3; text-align: right; }
.step:nth-child(even) .step-visual { order: 1; }
.step:nth-child(even) .step-node { order: 2; }

.step-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  z-index: 2;
}

.node-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--gold);
  position: relative;
  transition: border-color 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
  margin-top: 1.5rem;
}

.step.visible .node-dot {
  border-color: var(--gold-dim);
  box-shadow: 0 0 20px var(--gold-glow), 0 0 40px var(--gold-glow);
}

.node-line {
  width: 1px;
  flex: 1;
  min-height: 40px;
  background: linear-gradient(to bottom, var(--gold-dim), var(--border));
  opacity: 0.4;
}

/* ── STEP CONTENT ──────────────────────────────────── */
.step-content {
  padding: 0 2.5rem;
  padding-top: 1rem;
}

.step-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin-bottom: 0.6rem;
  display: block;
}

.step-title {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--bright);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.step-body {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.9;
  margin-bottom: 1.2rem;
}

.step-key {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--gold);
  background: var(--gold-glow);
  border: 1px solid var(--gold-dim);
  padding: 0.5rem 1rem;
  border-radius: 2px;
  line-height: 1.5;
}

/* ── STEP VISUAL ───────────────────────────────────── */
.step-visual {
  padding: 0 2.5rem;
  padding-top: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.step-visual canvas,
.step-visual svg {
  border: 1px solid var(--border);
  background: var(--deep);
  border-radius: 4px;
}

/* ── BRIDGE SECTION ────────────────────────────────── */
.bridge {
  max-width: 900px;
  margin: 2rem auto 6rem;
  padding: 0 2rem;
}

.bridge-header {
  text-align: center;
  margin-bottom: 4rem;
}

.bridge-title {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  font-weight: 300;
  color: var(--bright);
  margin-bottom: 0.8rem;
}

.bridge-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--teal-bright);
}

/* ── ANALOGY TABLE ─────────────────────────────────── */
.analogy {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 0;
  margin: 3rem 0;
}

.analogy-col {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 2rem;
}

.analogy-col:first-child { border-radius: 4px 0 0 4px; }
.analogy-col:last-child { border-radius: 0 4px 4px 0; }

.analogy-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  gap: 1.2rem;
}

.analogy-arrow {
  font-size: 1.2rem;
  color: var(--gold);
  writing-mode: vertical-rl;
  letter-spacing: 0.2em;
}

.analogy-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  writing-mode: vertical-rl;
}

.analogy-head {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.analogy-row {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.analogy-row::before {
  content: '—';
  color: var(--gold-dim);
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

/* ── EQUATION BLOCKS ───────────────────────────────── */
.eq {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: var(--deep);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-dim);
  padding: 1rem 1.4rem;
  margin: 1.2rem 0;
  color: var(--bright);
  letter-spacing: 0.05em;
  border-radius: 0 3px 3px 0;
  overflow-x: auto;
}

.eq .comment {
  color: var(--muted);
  font-size: 0.75rem;
}

/* ── SYNTHESIS ARC ─────────────────────────────────── */
.arc-wrap {
  margin: 4rem 0;
  padding: 3rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.arc-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--teal-glow) 0%, transparent 70%);
  pointer-events: none;
}

.arc-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--teal-bright);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
}

.arc-steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  position: relative;
}

.arc-step {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  border-radius: 2px;
  font-family: 'EB Garamond', serif;
  font-size: 0.9rem;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}

.arc-arrow {
  color: var(--gold);
  font-size: 1.1rem;
  font-family: 'JetBrains Mono', monospace;
}

/* ── FINAL STATEMENT ───────────────────────────────── */
.final {
  text-align: center;
  padding: 5rem 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.final-line {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  font-weight: 300;
  color: var(--bright);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.final-line .gold { color: var(--gold); }
.final-line .teal { color: var(--teal-bright); }

.final-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2rem;
}

/* ── EXTENSIONS ────────────────────────────────────── */
.extensions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 3rem 0;
}

.ext-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 1.8rem;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}

.ext-card:hover { border-color: var(--gold-dim); }

.ext-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-dim), var(--teal));
}

.ext-eq {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--gold);
  margin-bottom: 0.8rem;
  letter-spacing: 0.05em;
}

.ext-arrow {
  color: var(--muted);
  margin: 0 0.5rem;
}

.ext-body {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.7;
}

/* ── MUQARNAS PHOTO ────────────────────────────────── */
.step-visual-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.muqarnas-photo {
  width: 240px;
  height: 240px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
}

/* ── FANO CANVAS ───────────────────────────────────── */
#fanoCanvas { cursor: default; }

/* ── SYMMETRY CANVAS ───────────────────────────────── */

/* ── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 800px) {
  .journey::before { display: none; }
  .step { grid-template-columns: 1fr; }
  .step-node { display: none; }
  .step:nth-child(even) .step-content { order: 1; text-align: left; }
  .step:nth-child(even) .step-visual { order: 2; }
  .analogy { grid-template-columns: 1fr; }
  .analogy-col:first-child { border-radius: 4px 4px 0 0; }
  .analogy-col:last-child { border-radius: 0 0 4px 4px; }
  .analogy-mid { flex-direction: row; padding: 1rem; border: 1px solid var(--border); border-left: none; border-right: none; }
  .analogy-label { writing-mode: horizontal-tb; }
  .analogy-arrow { writing-mode: horizontal-tb; }
  .extensions { grid-template-columns: 1fr; }
}
