/* ───────────────────────────────────────────────────────
   Pandora Transit — Design System
   ─────────────────────────────────────────────────────── */

:root {
  --bg:            #050705;
  --accent:        #6fe3ff;
  --accent-mid:    rgba(111, 227, 255, 0.55);
  --accent-dim:    rgba(111, 227, 255, 0.35);
  --text:          #eaf7fb;
  --text-dim:      #9fd8e8;
  --nav-bg:        rgba(10, 14, 18, 0.38);
  --nav-border:    rgba(255, 255, 255, 0.10);
  --mono:          'Space Mono', monospace;
  --sans:          'Sora', sans-serif;
  --glow:          0 0 12px rgba(111, 227, 255, 0.65), 0 0 2px rgba(111, 227, 255, 0.9);
  --glow-sm:       0 0 8px rgba(111, 227, 255, 0.6);
  --glow-sector:   0 0 18px rgba(111, 227, 255, 0.5);
  --ease-out:      cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Reset ──────────────────────────────────────────── */

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

html {
  background: var(--bg);
  overflow: hidden;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 0; height: 0; }

button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: inherit;
}

/* ── Loading Screen ─────────────────────────────────── */

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

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

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

.loader-logo {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(111, 227, 255, 0.45), inset 0 0 18px rgba(111, 227, 255, 0.08);
  animation: loaderSpin 2.4s linear infinite;
}

.loader-ring::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: var(--glow);
}

.loader-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: var(--glow);
  animation: loaderPulse 1.3s ease-in-out infinite;
}

.loader-sys {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--text);
  opacity: 0.6;
}

.loader-ver {
  opacity: 0.45;
}

.loader-status {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--accent);
  opacity: 0.8;
  min-height: 14px;
  transition: opacity 0.3s ease;
}

.loader-bar-wrap {
  width: 180px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1px;
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(111, 227, 255, 0.9);
  transition: width 0.12s linear;
}

.loader-percent {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--accent-dim);
}

/* ── Fixed Viewport Background Layer ────────────────── */

#bgLayer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #000;
}

/* Scene gradient fallbacks (show when videos aren't loaded) */
#bgLayer::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(135deg, #0d1a0e 0%, #1a2d14 35%, #0c1a1e 70%, #050705 100%);
  transition: opacity 0.7s ease;
}

.scene-dawn::before   { background: linear-gradient(135deg, #1a120a 0%, #2d1f0a 35%, #1a2408 65%, #0c1208 100%); }
.scene-dusk::before   { background: linear-gradient(135deg, #1a0d15 0%, #2d1525 35%, #1a100e 65%, #0d0805 100%); }
.scene-night::before  { background: linear-gradient(135deg, #05080f 0%, #0a0f1a 35%, #060a0e 65%, #050705 100%); }

/* ── Videos ─────────────────────────────────────────── */

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.7s linear;
  z-index: 1;
  will-change: opacity;
}

/* ── Overlays ───────────────────────────────────────── */

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 38%,
    rgba(0, 0, 0, 0.35) 72%,
    rgba(0, 0, 0, 0.72) 100%
  );
}

.scan-lines {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.025) 2px,
    rgba(0, 0, 0, 0.025) 4px
  );
}

.film-grain {
  position: absolute;
  inset: -10%;
  z-index: 4;
  pointer-events: none;
  opacity: 0.048;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 1.1s steps(4) infinite;
}

/* Scene-transition horizontal sweep */
.transition-sweep {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(111, 227, 255, 0.04) 48%,
    rgba(111, 227, 255, 0.08) 50%,
    rgba(111, 227, 255, 0.04) 52%,
    transparent 100%
  );
  transform: translateY(-120%);
  transition: none;
}

.transition-sweep.sweeping {
  animation: sweepDown 0.55s var(--ease-out) forwards;
}

/* ── HUD Base ───────────────────────────────────────── */

.hud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  font-family: var(--mono);
}

.hud-label {
  font-size: 10px;
  letter-spacing: 0.26em;
  opacity: 0.65;
  margin-bottom: 5px;
  color: var(--text-dim);
}

/* ── HUD: Altitude ──────────────────────────────────── */

.hud-altitude {
  top: 36px;
  right: 44px;
  text-align: right;
  color: var(--accent);
  text-shadow: var(--glow);
}

.hud-altitude .hud-label {
  letter-spacing: 0.25em;
  font-size: 11px;
  color: var(--accent);
  opacity: 0.75;
}

.hud-value-lg {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud-unit {
  font-size: 17px;
  font-weight: 400;
  opacity: 0.65;
  margin-left: 3px;
}

/* ── HUD: Coordinates ───────────────────────────────── */

.hud-coords {
  top: 36px;
  left: 110px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: left 0.3s ease;
}

.hud-coord-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-coords .hud-label {
  font-size: 9px;
  letter-spacing: 0.22em;
  min-width: 22px;
  margin-bottom: 0;
  opacity: 0.5;
}

.hud-value-sm {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--accent-mid);
  text-shadow: 0 0 8px rgba(111, 227, 255, 0.35);
  font-variant-numeric: tabular-nums;
}

/* ── HUD: Sector Labels ─────────────────────────────── */

.hud-sector {
  left: 110px;
  bottom: 120px;
  width: min(80vw, 460px);
  height: 64px;
  overflow: hidden;
  transition: left 0.3s ease;
}

.sector-slide {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.65s ease, transform 0.65s var(--ease-out);
}

.sector-slide.active {
  opacity: 1;
  transform: translateY(0);
}

.sector-name {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-shadow: var(--glow-sector);
}

.sector-sub {
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--sans);
  font-weight: 400;
  margin-top: 5px;
  opacity: 0.8;
}

/* ── HUD: Progress Bar ──────────────────────────────── */

.hud-progress {
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  width: min(86vw, 520px);
  transition: bottom 0.3s ease;
}

.progress-track {
  position: relative;
  height: 2px;
  width: 100%;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  margin-bottom: 12px;
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(111, 227, 255, 0.8);
  transition: width 0.1s linear;
  will-change: width;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.18em;
}

.progress-label {
  color: rgba(255, 255, 255, 0.32);
  transition: color 0.45s ease, text-shadow 0.45s ease;
}

.progress-label.active {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(111, 227, 255, 0.75);
}

/* ── HUD: Auto-advance Toggle ───────────────────────── */

.hud-autoplay {
  position: absolute;
  bottom: 36px;
  right: 44px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--accent);
  cursor: pointer;
  pointer-events: all;
  padding: 6px 13px;
  border: 1px solid rgba(111, 227, 255, 0.28);
  border-radius: 20px;
  background: rgba(111, 227, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
  user-select: none;
}

.hud-autoplay:hover {
  background: rgba(111, 227, 255, 0.1);
  border-color: rgba(111, 227, 255, 0.5);
}

.hud-autoplay.manual {
  color: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.hud-autoplay.manual:hover {
  color: rgba(255, 255, 255, 0.55);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
}

.autoplay-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(111, 227, 255, 0.9);
  flex-shrink: 0;
  animation: autoPulse 1.6s ease-in-out infinite;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.manual .autoplay-dot {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: none;
  animation: none;
}

@keyframes autoPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ── Navigation ─────────────────────────────────────── */

#mainNav {
  position: fixed;
  z-index: 20;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 8px 32px rgba(0, 0, 0, 0.38);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Desktop: left sidebar */
  left: 20px;
  top: 20px;
  bottom: 20px;
  width: 72px;
  flex-direction: column;
  padding: 22px 0;
}

.nav-logo {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.nav-ring {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(111, 227, 255, 0.6);
  animation: navPulse 3.2s ease-in-out infinite;
}

.nav-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.nav-btn {
  width: 20px;
  height: 20px;
  color: rgba(234, 247, 251, 0.55);
  transition: color 0.22s ease, filter 0.22s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  color: var(--accent);
  filter: drop-shadow(0 0 5px rgba(111, 227, 255, 0.65));
}

.nav-btn.active {
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(111, 227, 255, 0.7));
}

.nav-launch {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.launch-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(111, 227, 255, 0.85);
  transition: transform 0.22s var(--ease-out), box-shadow 0.22s ease;
}

.nav-launch:hover .launch-dot {
  transform: scale(1.18);
  box-shadow: 0 0 28px rgba(111, 227, 255, 1), 0 0 6px rgba(111, 227, 255, 0.8);
}

/* ── Keyframe Animations ─────────────────────────────── */

@keyframes grainShift {
  0%   { transform: translate(0,    0);    }
  10%  { transform: translate(-1%, -2%);   }
  20%  { transform: translate(2%,   1%);   }
  30%  { transform: translate(-2%,  3%);   }
  40%  { transform: translate(1%,  -1%);   }
  50%  { transform: translate(-1%,  2%);   }
  60%  { transform: translate(3%,   0);    }
  70%  { transform: translate(-3%, -2%);   }
  80%  { transform: translate(2%,   2%);   }
  90%  { transform: translate(-1%, -1%);   }
  100% { transform: translate(0,    0);    }
}

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

@keyframes loaderPulse {
  0%, 100% { opacity: 1;   transform: scale(1);   }
  50%       { opacity: 0.3; transform: scale(0.75); }
}

@keyframes navPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(111, 227, 255, 0.6); }
  50%       { box-shadow: 0 0 20px rgba(111, 227, 255, 0.9), 0 0 40px rgba(111, 227, 255, 0.2); }
}

@keyframes sweepDown {
  0%   { transform: translateY(-120%); }
  100% { transform: translateY(220%);  }
}

/* ── Responsive: Mobile ─────────────────────────────── */

@media (max-width: 759px) {
  /* Nav: bottom bar */
  #mainNav {
    left: 12px;
    right: 12px;
    bottom: 16px;
    top: auto;
    width: auto;
    height: 64px;
    flex-direction: row;
    padding: 0 22px;
    border-radius: 14px;
  }

  .nav-icons {
    flex-direction: row;
    gap: 22px;
  }

  /* HUD: shift left edge for no sidebar */
  .hud-coords    { left: 24px; }
  .hud-sector    { left: 24px; bottom: 170px; }
  .hud-progress  { bottom: 104px; }
  .hud-autoplay  { bottom: 92px; right: 20px; }

  /* Altitude: tighten on small screens */
  .hud-altitude { top: 24px; right: 24px; }
  .hud-value-lg { font-size: 28px; }
}

@media (max-width: 480px) {
  .sector-name { font-size: 17px; }
  .sector-sub  { font-size: 12px; }
  .hud-altitude { top: 16px; right: 16px; }
  .hud-value-lg { font-size: 24px; }
}

/* ── Reduced Motion ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .film-grain        { animation: none; }
  .loader-ring       { animation: none; }
  .nav-ring          { animation: none; }
  .bg-video          { transition: opacity 0.1s; }
  .progress-fill     { transition: none; }
  .sector-slide      { transition: opacity 0.2s; }
  .transition-sweep  { display: none; }
}
