/* ===== Variables ===== */
:root {
  --bg-deep: #050a12;
  --bg-card: rgba(12, 20, 35, 0.75);
  --bg-card-hover: rgba(18, 30, 52, 0.85);
  --text: #e8edf5;
  --text-muted: rgba(232, 237, 245, 0.55);
  --accent-ocean: #22d3ee;
  --accent-ocean-dim: #0e7490;
  --accent-desert: #fbbf24;
  --accent-desert-dim: #b45309;
  --accent-violet: #a78bfa;
  --border: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(34, 211, 238, 0.25);
  --font-serif: 'Noto Serif SC', 'Cormorant Garamond', Georgia, serif;
  --font-display: 'Cormorant Garamond', 'Noto Serif SC', serif;
  --font-mono: 'JetBrains Mono', monospace;
  --nav-h: 72px;
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-serif);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Ambient ===== */
.noise {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(14, 116, 144, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(180, 83, 9, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 50%, rgba(167, 139, 250, 0.08) 0%, transparent 60%),
    var(--bg-deep);
  animation: auroraShift 20s ease-in-out infinite alternate;
}

@keyframes auroraShift {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(15deg); }
}

.container {
  width: min(1140px, 92vw);
  margin: 0 auto;
}

/* ===== Nav ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-h);
  background: rgba(5, 10, 18, 0.6);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.nav.scrolled {
  background: rgba(5, 10, 18, 0.92);
}

.nav-inner {
  width: min(1140px, 92vw);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
}

.logo-mark {
  font-size: 1.4rem;
  color: var(--accent-ocean);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  font-weight: 500;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  letter-spacing: 0.05em;
  transition: color var(--transition);
}

.nav-links a:hover { color: var(--accent-ocean); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: var(--transition);
}

/* ===== Hero ===== */
.hero {
  min-height: 100vh;
  padding: calc(var(--nav-h) + 3rem) 4vw 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  width: min(1140px, 100%);
  margin: 0 auto;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-ocean);
  margin-bottom: 1.5rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 4.5rem);
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 1.5rem;
}

.title-line { display: block; }

.title-accent {
  background: linear-gradient(135deg, var(--accent-ocean), var(--accent-desert));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-style: italic;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 520px;
  margin-bottom: 2rem;
}

.hero-subtitle em {
  color: var(--accent-violet);
  font-style: italic;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.75rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-ocean-dim), var(--accent-ocean));
  color: var(--bg-deep);
  font-weight: 500;
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent-desert);
  color: var(--accent-desert);
}

.hero-stats {
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--accent-ocean);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Orbit visual */
.hero-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.orbit-system {
  position: relative;
  width: min(380px, 80vw);
  height: min(380px, 80vw);
}

.orbit-svg {
  width: 100%;
  height: 100%;
}

.orbit-body {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: transform 0.1s linear;
}

.body-icon { font-size: 2.5rem; filter: drop-shadow(0 0 12px rgba(255,255,255,0.3)); }

.body-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.shark-body {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: orbitShark 12s linear infinite;
}

.camel-body {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: orbitCamel 12s linear infinite;
}

@keyframes orbitShark {
  from { transform: translate(-50%, -50%) rotate(0deg) translateX(140px) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg) translateX(140px) rotate(-360deg); }
}

@keyframes orbitCamel {
  from { transform: translate(-50%, -50%) rotate(180deg) translateX(100px) rotate(-180deg); }
  to { transform: translate(-50%, -50%) rotate(540deg) translateX(100px) rotate(-540deg); }
}

.barrier-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  height: 60%;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(239, 68, 68, 0.4);
  border-radius: 50%;
  animation: barrierPulse 2s ease-in-out infinite;
}

@keyframes barrierPulse {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.05); }
}

.visual-caption {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

.scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.scroll-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--accent-ocean), transparent);
  animation: scrollLine 2s ease-in-out infinite;
}

@keyframes scrollLine {
  0%, 100% { transform: scaleY(0.3); opacity: 0.3; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ===== Sections ===== */
.section {
  padding: 6rem 0;
  position: relative;
}

.section-header {
  margin-bottom: 3rem;
  text-align: center;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--accent-desert);
  display: block;
  margin-bottom: 0.75rem;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.section-lead {
  color: var(--text-muted);
  font-style: italic;
  font-size: 1rem;
}

/* Theorem */
.theorem-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  backdrop-filter: blur(12px);
}

.theorem-formula {
  text-align: center;
  padding: 1.5rem;
  margin-bottom: 2rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  border: 1px solid var(--border-glow);
  overflow-x: auto;
}

.theorem-formula code {
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 2vw, 0.95rem);
  color: var(--accent-ocean);
  line-height: 1.8;
}

.theorem-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.theorem-item {
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.theorem-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.theorem-item h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--accent-ocean);
}

.theorem-item p {
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* Mechanism flow */
.mechanism-flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 1rem;
}

.flow-node {
  flex: 1;
  min-width: 180px;
  padding: 1.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  transition: all var(--transition);
}

.flow-node:hover {
  border-color: var(--accent-desert);
  box-shadow: 0 8px 32px rgba(251, 191, 36, 0.1);
}

.flow-node::before {
  content: attr(data-step);
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.node-icon { font-size: 2rem; margin-bottom: 0.75rem; }

.flow-node h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.flow-node p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.flow-connector {
  width: 24px;
  flex-shrink: 0;
  align-self: center;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-ocean), var(--accent-desert));
  opacity: 0.4;
}

/* Data charts */
.data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.chart-card.wide { grid-column: 1 / -1; }

.chart-card h3 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--accent-ocean);
}

.chart-note {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

#heatmap {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.compat-chart { width: 100%; }

.compat-svg { width: 100%; height: auto; }

.compat-curve {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: drawCurve 2s ease forwards;
}

@keyframes drawCurve {
  to { stroke-dashoffset: 0; }
}

.incompat-point { animation: blink 1.5s ease-in-out infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.timeline-mini {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mini-event {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-violet);
  font-size: 0.85rem;
}

.mini-event .year {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-desert);
  min-width: 50px;
}

/* Simulator */
.simulator-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
}

.sim-controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.slider-label {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.slider-label span { grid-column: 1; }

.slider-label output {
  grid-column: 2;
  font-family: var(--font-mono);
  color: var(--accent-ocean);
  font-size: 0.85rem;
}

.slider-label input[type="range"] {
  grid-column: 1 / -1;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  outline: none;
}

.slider-label input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-ocean), var(--accent-desert));
  cursor: pointer;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.4);
}

.sim-output {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.probability-ring {
  position: relative;
  width: 140px;
  height: 140px;
}

.probability-ring svg { width: 100%; height: 100%; }

.prob-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.prob-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent-ocean);
}

.prob-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.sim-log {
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.log-line {
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.log-line.log-system { color: var(--accent-ocean); }
.log-line.log-warn { color: var(--accent-desert); }
.log-line.log-fail { color: #ef4444; }

/* Timeline */
.timeline-track {
  position: relative;
  padding-left: 2rem;
  border-left: 2px solid var(--border);
}

.tl-item {
  position: relative;
  padding: 0 0 2.5rem 2rem;
}

.tl-item::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 0.4rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-ocean);
  transform: translateX(-5px);
  box-shadow: 0 0 12px var(--accent-ocean);
}

.tl-year {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-desert);
  display: block;
  margin-bottom: 0.35rem;
}

.tl-item p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Bibliography */
.bib-list {
  list-style: none;
  counter-reset: bib;
}

.bib-list li {
  counter-increment: bib;
  padding: 1rem 0 1rem 2.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
  position: relative;
}

.bib-list li::before {
  content: '[' counter(bib) ']';
  position: absolute;
  left: 0;
  font-family: var(--font-mono);
  color: var(--accent-ocean);
  font-size: 0.8rem;
}

.journal {
  font-style: italic;
  color: var(--accent-violet);
}

.disclaimer {
  margin-top: 2.5rem;
  padding: 1.5rem;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.disclaimer strong { color: var(--accent-desert); }

/* Footer */
.footer {
  padding: 3rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.footer-copy, .footer-easter {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-easter {
  font-style: italic;
  opacity: 0.6;
}

/* Reveal animation */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2rem; }
  .hero-visual { order: -1; }
  .theorem-grid { grid-template-columns: 1fr; }
  .data-grid { grid-template-columns: 1fr; }
  .simulator-panel { grid-template-columns: 1fr; }
  .mechanism-flow { flex-direction: column; }
  .flow-connector {
    width: 2px;
    height: 24px;
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(5, 10, 18, 0.98);
    padding: 1.5rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .nav-links.open { display: flex; }
  .nav-toggle { display: flex; }
  .hero-stats { gap: 1.5rem; }
}
