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

:root {
  --bg: #0a0e1e;
  --bg-alt: #0e1330;
  --panel: #151b3d;
  --panel-2: #1b2350;
  --ink: #eef1ff;
  --ink-dim: #a8b0d8;
  --accent: #ffd23f;
  --accent-2: #ff5c8a;
  --radius: 16px;
  --maxw: 1100px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.15; font-weight: 800; }

/* ============ nav ============ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.2rem;
  background: rgba(10, 14, 30, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.nav-brand { color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: 0.02em; }
.nav-links { display: flex; gap: 1.1rem; }
.nav-links a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent); }

.sound-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  width: 3rem; height: 3rem;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(21, 27, 61, 0.85);
  color: var(--ink);
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.15s;
}
.sound-toggle:hover { transform: scale(1.1); }

/* ============ hero ============ */
.hero {
  position: relative;
  height: 100svh;
  min-height: 560px;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: crosshair;
  background: radial-gradient(ellipse at 50% 120%, #1a2150 0%, var(--bg) 60%);
}
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-content {
  position: relative;
  text-align: center;
  pointer-events: none;
  padding: 1rem;
}
.hero h1 {
  font-size: clamp(3rem, 10vw, 6.5rem);
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff 30%, #ffd23f 75%, #ff5c8a 110%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 4px 30px rgba(255, 210, 63, 0.25));
}
.hero-sub {
  margin-top: 1rem;
  font-size: clamp(1rem, 2.4vw, 1.3rem);
  color: var(--ink-dim);
}
.hero-hint {
  margin-top: 1.6rem;
  font-size: 0.95rem;
  color: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }
.scroll-cue {
  pointer-events: auto;
  display: inline-block;
  margin-top: 2.2rem;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 1.3rem;
  animation: bob 1.8s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(9px); } }

/* ============ sections ============ */
.section { padding: 5.5rem 1.2rem; scroll-margin-top: 3.2rem; }
.section-alt { background: var(--bg-alt); }
.section-inner { max-width: var(--maxw); margin: 0 auto; }

.kicker {
  color: var(--accent-2);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}
.section h2, .footer h2 { font-size: clamp(1.8rem, 4.5vw, 2.7rem); margin-bottom: 1rem; }
.lede { max-width: 62ch; color: var(--ink-dim); font-size: 1.06rem; }
.lede strong, .fact strong, .fact-strip strong { color: var(--ink); }

/* ============ anatomy ============ */
.anatomy-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 2.5rem;
  margin-top: 2.5rem;
  align-items: start;
}
.anatomy-figure svg { width: 100%; height: auto; display: block; }

.shell-part { transition: filter 0.25s; }
.shell-part.active { filter: drop-shadow(0 0 14px rgba(255, 210, 63, 0.9)) brightness(1.25); }

.hotspot { cursor: pointer; }
.hotspot circle.dot {
  fill: var(--accent);
  animation: hotspotPulse 1.8s ease-in-out infinite;
}
.hotspot circle.halo {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.6;
  animation: halo 1.8s ease-out infinite;
}
.hotspot text { fill: #0a0e1e; font-size: 13px; font-weight: 800; pointer-events: none; }
@keyframes hotspotPulse { 0%,100% { opacity: 0.85; } 50% { opacity: 1; } }
@keyframes halo {
  0% { transform: scale(1); opacity: 0.65; }
  100% { transform: scale(2.1); opacity: 0; }
}
.hotspot .halo { transform-origin: center; transform-box: fill-box; }

.info-card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 1.5rem 1.7rem;
  min-height: 10rem;
}
.info-card h3 { color: var(--accent); margin-bottom: 0.6rem; font-size: 1.25rem; }
.info-card p { color: var(--ink-dim); }
.info-card.flash { animation: cardFlash 0.55s ease; }
@keyframes cardFlash {
  0% { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(255, 210, 63, 0.25); }
}

.info-nav { display: flex; align-items: center; gap: 0.9rem; margin-top: 1.1rem; }
.info-nav-btn {
  width: 2.6rem; height: 2.6rem;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.info-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.info-nav-btn:active { transform: scale(0.92); }
.info-counter {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  min-width: 3.2em;
  text-align: center;
}

.anatomy-legend {
  list-style: none;
  margin-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.anatomy-legend button {
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--panel);
  color: var(--ink-dim);
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.anatomy-legend button:hover { color: var(--ink); border-color: var(--accent); }
.anatomy-legend button.active {
  background: var(--accent);
  color: #0a0e1e;
  border-color: var(--accent);
}

/* ============ launch ============ */
.launch-wrap { margin-top: 2.2rem; position: relative; }
#launchCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #060918 0%, #10173a 78%, #1c2410 100%);
  border: 1px solid rgba(255,255,255,0.08);
}
.launch-hud {
  position: absolute;
  top: 1rem; left: 1rem; right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.altimeter {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  background: rgba(10,14,30,0.65);
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}
.altimeter span { font-size: 1.25rem; color: var(--accent); font-weight: 700; letter-spacing: 0; }
.launch-hud .btn { pointer-events: auto; }
.launch-caption {
  margin-top: 1rem;
  min-height: 3.2em;
  font-size: 1.05rem;
  color: var(--ink);
  text-align: center;
  font-weight: 600;
}

/* ============ buttons ============ */
.btn {
  border: none;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
  font-size: 1rem;
}
.btn:active { transform: scale(0.95); }
.btn-big {
  background: linear-gradient(135deg, var(--accent) 0%, #ff9500 100%);
  color: #201400;
  padding: 0.85rem 1.8rem;
  box-shadow: 0 6px 24px rgba(255, 165, 0, 0.35);
}
.btn-big:hover { box-shadow: 0 8px 32px rgba(255, 165, 0, 0.55); }
.btn-big:disabled { opacity: 0.45; cursor: wait; box-shadow: none; }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 0.75rem 1.6rem;
}
.btn-ghost:hover { background: rgba(255, 210, 63, 0.12); }

/* ============ chemistry ============ */
.chem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.9rem;
  margin: 2.2rem 0 1.4rem;
}
.chem-card {
  position: relative;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem 0.6rem 0.9rem;
  text-align: center;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}
.chem-card:hover { transform: translateY(-4px); border-color: var(--chem, #fff); box-shadow: 0 8px 26px -8px var(--chem, #fff); }
.chem-card.firing { animation: cardPop 0.35s ease; }
@keyframes cardPop { 40% { transform: scale(1.12); } }
.chem-symbol {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--chem, #fff);
  text-shadow: 0 0 18px var(--chem, transparent);
  display: block;
}
.chem-name { font-size: 0.82rem; color: var(--ink-dim); display: block; margin-top: 0.1rem; }
.chem-color {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0a0e1e;
  background: var(--chem, #fff);
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
}
.chem-stage { position: relative; }
#chemCanvas, #labCanvas {
  width: 100%;
  height: 420px;
  display: block;
  border-radius: var(--radius);
  background: radial-gradient(ellipse at 50% 130%, #131a42 0%, #070a18 65%);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: crosshair;
}
.chem-note {
  position: absolute;
  bottom: 0.9rem; left: 0; right: 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-dim);
  pointer-events: none;
}
.fact-strip {
  margin-top: 1.6rem;
  background: linear-gradient(90deg, rgba(84,169,255,0.12), rgba(84,169,255,0.03));
  border-left: 4px solid #54a9ff;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.1rem 1.4rem;
  color: var(--ink-dim);
}

/* ============ lab ============ */
.lab-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem 2.4rem;
  align-items: flex-end;
  margin-top: 2.2rem;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
}
.lab-group { display: flex; flex-direction: column; gap: 0.55rem; }
.lab-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  border: 1px solid rgba(255,255,255,0.16);
  background: var(--panel-2);
  color: var(--ink-dim);
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { color: var(--ink); transform: translateY(-1px); }
.chip.active { background: var(--ink); color: #0a0e1e; border-color: var(--ink); }
.chip-color { display: inline-flex; align-items: center; gap: 0.4rem; }
.chip-swatch {
  width: 0.75rem; height: 0.75rem;
  border-radius: 50%;
  background: var(--chem, #fff);
  box-shadow: 0 0 8px var(--chem, transparent);
}
.lab-group input[type="range"] { width: 160px; accent-color: var(--accent); }
.lab-size-label { font-weight: 800; color: var(--accent); font-size: 1.05rem; }
.lab-buttons { flex-direction: row; gap: 0.7rem; margin-left: auto; }
.pattern-desc {
  margin-top: 1rem;
  min-height: 2.6em;
  color: var(--ink-dim);
  font-size: 0.98rem;
  max-width: 70ch;
}
.pattern-desc strong { color: var(--accent); }
.lab-stage { margin-top: 1rem; }

/* ============ footer ============ */
.footer {
  padding: 5rem 1.2rem 4rem;
  background: linear-gradient(180deg, var(--bg) 0%, #05070f 100%);
  text-align: center;
}
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
  margin-top: 2rem;
  text-align: left;
}
.fact {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 1.4rem;
}
.fact-emoji { font-size: 1.8rem; display: block; margin-bottom: 0.6rem; }
.fact p { color: var(--ink-dim); font-size: 0.95rem; }
.footer-credit { margin-top: 3rem; color: #55608f; font-size: 0.88rem; }

/* ============ responsive ============ */
@media (max-width: 780px) {
  .nav-links { display: none; }
  /* anatomy becomes a guided tour: compact figure + card share one screen */
  .anatomy-grid { grid-template-columns: 1fr; gap: 1.1rem; }
  .anatomy-figure { display: flex; justify-content: center; }
  .anatomy-figure svg { height: min(44vh, 400px); width: auto; max-width: 100%; }
  .anatomy-legend { display: none; }
  .info-card { min-height: 0; padding: 1.1rem 1.2rem; }
  .info-nav { justify-content: center; }
  .lab-buttons { margin-left: 0; }
  .launch-hud { flex-direction: column; gap: 0.7rem; align-items: flex-start; }
  #chemCanvas, #labCanvas { height: 340px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-hint, .scroll-cue, .hotspot circle.dot, .hotspot circle.halo { animation: none; }
}
