:root {
  --bg-deep: #030712;
  --bg-surface: #0a1526;
  --bg-surface-raised: #10243e;
  --bg-surface-glass: rgba(10, 21, 38, 0.85);
  --border-subtle: #1a365d;
  --border-accent: #2563eb;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-gold: #fbbf24;
  --accent-emerald: #34d399;
  --accent-coral: #fb7185;
  --font-serif: "Charter", "Bitstream Charter", "Sitka Text", "Cambria", "Georgia", serif;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Consolas", "Liberation Mono", Menlo, Courier, monospace;
}

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

html {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0%, #0d2342 0%, #030712 65%);
  background-attachment: fixed;
}

.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.brand-link:hover {
  color: var(--accent-cyan);
}

.lang-switch {
  display: flex;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.lang-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.lang-link:hover {
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.lang-link.active {
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
  font-weight: 600;
}

main {
  flex: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  width: 100%;
}

.hero {
  margin-bottom: 3.5rem;
  max-width: 820px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  margin-bottom: 0.75rem;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.15;
  color: #ffffff;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.lead {
  font-size: clamp(1.15rem, 2.5vw, 1.35rem);
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 2.5rem 0;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-cyan);
}

.stat-card.gold::before {
  background: var(--accent-gold);
}

.stat-card.emerald::before {
  background: var(--accent-emerald);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.interactive-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.75rem;
  margin: 3rem 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.section-header {
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-desc {
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.basin-selector-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
  scrollbar-width: thin;
}

.basin-btn {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.basin-btn:hover {
  background: rgba(56, 189, 248, 0.1);
  color: var(--text-primary);
  border-color: rgba(56, 189, 248, 0.3);
}

.basin-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  font-weight: 600;
}

.sim-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .sim-container {
    grid-template-columns: 3fr 1.2fr;
  }
}

.canvas-wrapper {
  position: relative;
  background: #020617;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  min-height: 380px;
}

#rayCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.sim-controls {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.control-value {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

input[type="range"] {
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.sim-badge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.sim-badge {
  background: rgba(0, 0, 0, 0.4);
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sim-badge-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sim-badge-val {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
}

/* Audio Player Section */
.audio-box {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.audio-info {
  flex: 1;
  min-width: 240px;
}

.audio-title {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.25rem;
}

.audio-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-sans);
}

.audio-btn {
  background: var(--accent-cyan);
  color: #030712;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.audio-btn:hover {
  background: #7dd3fc;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.audio-btn.playing {
  background: var(--accent-gold);
}

/* Map & Journey Table */
.expedition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.station-card {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.15rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.station-card:hover, .station-card.active {
  border-color: var(--accent-cyan);
  background: rgba(16, 36, 62, 0.9);
  transform: translateY(-2px);
}

.station-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.station-name {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
}

.station-dist {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.station-meta {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.station-time {
  display: inline-block;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.1);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* Essay Content */
.prose {
  margin: 3.5rem 0;
  max-width: 720px;
}

.prose h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffffff;
  margin: 2.5rem 0 1rem;
  line-height: 1.25;
}

.prose p {
  margin-bottom: 1.35rem;
  color: #cbd5e1;
}

.prose strong {
  color: #ffffff;
  font-weight: 600;
}

.prose blockquote {
  border-left: 3px solid var(--accent-cyan);
  padding-left: 1.25rem;
  margin: 1.75rem 0;
  color: #e2e8f0;
  font-style: italic;
}

.method-note {
  background: rgba(10, 21, 38, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 3.5rem 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.method-note h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.method-note ul {
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

.method-note li {
  margin-bottom: 0.4rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  padding: 2.5rem 1.25rem;
  margin-top: auto;
}

.footer-container {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--accent-cyan);
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-accent);
  color: var(--accent-cyan);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.25s ease;
  z-index: 30;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-cyan);
  color: #030712;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
  html {
    font-size: 16px;
  }
  
  .interactive-section {
    padding: 1.15rem;
    margin: 2rem 0;
  }
  
  .stat-strip {
    grid-template-columns: 1fr;
  }
  
  .expedition-grid {
    grid-template-columns: 1fr;
  }
}
