/* ─────────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:    #a78bfa;
  --accent2:   #f0abfc;
  --accent3:   #38bdf8;
  --bg:        #02030a;
  --text:      #e2e8f0;
  --text-dim:  #94a3b8;
  --serif:     'Georgia', serif;
  --sans:      system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Panel glass — strong enough to always win against the background */
  --panel-bg:  rgba(4, 5, 18, 0.82);
}

html {
  scroll-behavior: auto;
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
}

/* ─────────────────────────────────────────────
   CANVAS
───────────────────────────────────────────── */
#cosmos {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  display: block;
}

/* ─────────────────────────────────────────────
   SCROLL CONTAINER
───────────────────────────────────────────── */
#scroll-container {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.scroll-section { height: 100vh; }

/* ─────────────────────────────────────────────
   LOADER
───────────────────────────────────────────── */
#loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loader-ring {
  width: 60px;
  height: 60px;
  border: 2px solid rgba(167,139,250,0.15);
  border-top-color: var(--accent);
  border-right-color: var(--accent2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.loader-bar-wrap {
  width: 200px;
  height: 2px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ─────────────────────────────────────────────
   FULL-SCREEN SCRIM  (sits between canvas & UI)
   Darkens the center so text always wins.
───────────────────────────────────────────── */
#scrim {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  /* Radial: very dark core, transparent edges so 3D still shows */
  background: radial-gradient(
    ellipse 70% 60% at 50% 50%,
    rgba(2, 3, 10, 0.55) 0%,
    rgba(2, 3, 10, 0.30) 55%,
    transparent 100%
  );
}

/* ─────────────────────────────────────────────
   VIGNETTE  (edges only)
───────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 45%,
    rgba(2,3,10,0.85) 100%
  );
}

/* ─────────────────────────────────────────────
   UI OVERLAY
───────────────────────────────────────────── */
#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* Panels stack at position:absolute so they all
   share the same space. opacity + visibility give
   proper fade without layout shifts. */
.ui-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.ui-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ─────────────────────────────────────────────
   HERO PANEL
───────────────────────────────────────────── */
.hero-content {
  width: 100%;
  text-align: center;
  padding: 0 2rem;
  /* Subtle radial backdrop so stars don't pierce the text */
  background: radial-gradient(
    ellipse 60% 55% at 50% 50%,
    rgba(2,3,14,0.65) 0%,
    transparent 100%
  );
}

.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  opacity: 0.85;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(3.5rem, 10vw, 8rem);
  line-height: 1.0;
  font-weight: 400;
  color: #fff;
  /* Stronger shadow creates its own legibility halo */
  text-shadow:
    0 0 40px rgba(167,139,250,0.6),
    0 2px 4px rgba(0,0,0,0.9),
    0 0 120px rgba(167,139,250,0.2);
  margin-bottom: 1.5rem;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 50%, var(--accent3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 3rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

/* Scroll hint */
.scroll-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.scroll-hint span {
  display: block;
  width: 1.5px;
  height: 50px;
  background: linear-gradient(to bottom, transparent, var(--accent));
  animation: scrollLine 2s ease-in-out infinite;
}

.scroll-hint p {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

@keyframes scrollLine {
  0%, 100% { transform: scaleY(0); transform-origin: top; opacity: 0; }
  50%       { transform: scaleY(1); transform-origin: top; opacity: 1; }
}

/* ─────────────────────────────────────────────
   SIDE TEXT PANELS
   Solid enough background so ANY nebula colour
   behind it cannot interfere with readability.
───────────────────────────────────────────── */
.side-text {
  max-width: 400px;
  padding: 2.5rem;
  background: var(--panel-bg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(167,139,250,0.18);
  border-radius: 4px;
  /* Soft outer glow so panel doesn't hard-clip */
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.5),
    0 8px 40px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.side-text.left  { margin-left: 6vw; }
.side-text.right { margin-left: auto; margin-right: 6vw; }

.tag {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 1rem;
  opacity: 0.8;
}

.side-text h2 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 3.5vw, 2.8rem);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: #fff;
}

.side-text p {
  font-size: 0.92rem;
  line-height: 1.8;
  color: #b0bec8;   /* slightly lighter than text-dim for clarity */
}

/* ─────────────────────────────────────────────
   CENTER END PANEL
───────────────────────────────────────────── */
.center-text {
  width: 100%;
  text-align: center;
  padding: 0 2rem;
  background: radial-gradient(
    ellipse 65% 60% at 50% 50%,
    rgba(2,3,14,0.72) 0%,
    transparent 100%
  );
}

.big-end {
  font-family: var(--serif);
  font-size: clamp(3rem, 8vw, 7rem);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  color: #fff;
  text-shadow:
    0 0 80px rgba(167,139,250,0.5),
    0 2px 6px rgba(0,0,0,0.9);
}

.end-sub {
  font-size: 1rem;
  line-height: 1.85;
  color: #b0bec8;
  max-width: 540px;
  margin: 0 auto 2.5rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

.cta-btn {
  display: inline-block;
  pointer-events: all;
  padding: 0.85rem 2.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  color: #fff;
  border: 1px solid rgba(167,139,250,0.45);
  border-radius: 3px;
  background: rgba(167,139,250,0.12);
  backdrop-filter: blur(8px);
  transition: background 0.3s, border-color 0.3s, transform 0.2s, box-shadow 0.3s;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.cta-btn:hover {
  background: rgba(167,139,250,0.25);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(167,139,250,0.3);
}

/* ─────────────────────────────────────────────
   PROGRESS DOTS
───────────────────────────────────────────── */
#progress-dots {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: background 0.4s, transform 0.4s, box-shadow 0.4s;
  cursor: pointer;
  pointer-events: all;
}

.dot.active {
  background: var(--accent);
  transform: scale(1.6);
  box-shadow: 0 0 10px var(--accent);
}

/* ─────────────────────────────────────────────
   AUDIO BUTTON
───────────────────────────────────────────── */
#audioBtn {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 20;
  background: rgba(4,5,18,0.80);
  border: 1px solid rgba(167,139,250,0.35);
  border-radius: 30px;
  height: 44px;
  padding: 0 14px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-dim);
  transition: color 0.3s, border-color 0.3s, background 0.3s, box-shadow 0.3s;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

#audioBtn:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(167,139,250,0.15);
  box-shadow: 0 4px 24px rgba(167,139,250,0.3);
}

#audioBtn.is-on {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(167,139,250,0.12);
  box-shadow: 0 0 20px rgba(167,139,250,0.25);
}

/* Pulse ring when active */
#audioBtn.is-on::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 34px;
  border: 1px solid rgba(167,139,250,0.4);
  animation: audioPulse 2s ease-out infinite;
}

@keyframes audioPulse {
  0%   { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.18); }
}

#audioBtn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#audioBtn .audio-wave1,
#audioBtn .audio-wave2 {
  transition: opacity 0.3s;
}

/* Muted state: hide the wave paths */
#audioBtn.is-muted .audio-wave1,
#audioBtn.is-muted .audio-wave2 {
  opacity: 0.2;
}

#audioBtnLabel {
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  font-weight: 600;
  text-transform: uppercase;
  transition: color 0.3s;
}

/* ─────────────────────────────────────────────
   SOUND NUDGE TOOLTIP
───────────────────────────────────────────── */
#soundNudge {
  position: fixed;
  bottom: 36px;
  left: 90px;
  z-index: 20;
  background: rgba(4,5,18,0.85);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}

#soundNudge.visible {
  opacity: 1;
  transform: translateX(0);
}

#soundNudge strong {
  color: var(--accent);
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 640px) {
  .side-text {
    max-width: 88vw;
    margin-left: 6vw !important;
    margin-right: 6vw !important;
    padding: 1.8rem;
  }

  .hero-title { font-size: clamp(2.8rem, 12vw, 5rem); }

  #progress-dots { right: 10px; }
}
