@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background: #000;
  overflow-x: hidden;
  color: white;
}

/* Crossfade the 3D canvas when entering map */
body.map-immersive #cosmic-container {
  filter: blur(calc(2px * var(--overlayOpacity, 0)));
  opacity: calc(1 - 0.65 * var(--overlayOpacity, 0));
  transition: opacity 0.6s ease, filter 0.6s ease;
}

body #cosmic-container {
  transition: opacity 0.6s ease, filter 0.6s ease;
}

/* Fade out the 3D scene during cinematic transition */
body.transition-active #cosmic-container {
  opacity: 0.15;
  filter: blur(6px) brightness(0.7);
}

#cosmic-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

#cosmic-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Scrollable container for the journey */
body::after {
  content: "";
  display: block;
  height: 500vh;
  /* 5x viewport height for smooth scrolling */
  pointer-events: none;
}

/* Loading Screen */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #0b1426 0%, #1a1a2e 50%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.loading-logo {
  width: 120px;
  height: 120px;
  margin: 0 auto 40px;
  display: block;
  animation: float 4s ease-in-out infinite,
    logoGlow 2s ease-in-out infinite alternate;
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3),
    inset 0 0 10px rgba(255, 255, 255, 0.1);
}

@keyframes logoGlow {
  from {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3),
      inset 0 0 10px rgba(255, 255, 255, 0.1);
  }

  to {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.6),
      inset 0 0 15px rgba(255, 255, 255, 0.2);
  }
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
  max-width: 400px;
  padding: 0 20px;
}

.loading-spinner {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-top: 2px solid #6366f1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.loading-content h2 {
  font-size: 1.5rem;
  font-weight: 300;
  margin-bottom: 20px;
  color: #e2e8f0;
}

.loading-bar {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1px;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  width: 0%;
  animation: loadProgress 2s ease-out forwards;
}

@keyframes loadProgress {
  0% {
    width: 0%;
  }

  100% {
    width: 100%;
  }
}

/* UI Overlay */
#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px;
  align-items: center;
  /* Center children horizontally */
}

/* Thematic text styles */
.thematic-text {
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #e2e8f0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.thematic-text h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.thematic-text p {
  font-size: 1.2rem;
  font-weight: 300;
}

/* Scroll prompt styles */
.scroll-prompt {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 500;
  color: #e2e8f0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.progress-indicator {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px 30px;
  min-width: 250px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin-bottom: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: #e2e8f0;
}

/* Responsive Design */
@media (max-width: 768px) {
  #ui-overlay {
    padding: 20px;
  }

  .thematic-text h1 {
    font-size: 1.8rem;
  }

  .thematic-text p {
    font-size: 1rem;
  }

  .progress-indicator {
    padding: 15px 20px;
    min-width: auto;
    max-width: none;
    width: 100%;
  }

  .loading-content h2 {
    font-size: 1.2rem;
  }
}

/* Additional animations for cosmic feel */
@keyframes twinkle {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 1;
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }
}

.twinkle {
  animation: twinkle 2s ease-in-out infinite;
}

.float {
  animation: float 3s ease-in-out infinite;
}

/* Egyptian Desert Scene Overlay */
.desert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: radial-gradient(ellipse at center,
      rgba(135, 206, 235, 0.1) 0%,
      rgba(210, 180, 140, 0.2) 30%,
      rgba(139, 115, 85, 0.3) 60%,
      rgba(0, 0, 0, 0.8) 100%);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: var(--overlayOpacity, 0);
  visibility: hidden;
  transition: opacity 0.8s ease, visibility 0.8s ease, backdrop-filter 0.8s ease;
  overflow: hidden;
}

.desert-overlay.visible {
  opacity: var(--overlayOpacity, 1);
  visibility: visible;
}

.desert-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg,
      #87ceeb 0%,
      #b0e0e6 15%,
      #f5e6d3 25%,
      #e6d3b7 40%,
      #d4c4a8 60%,
      #c4b59a 80%,
      #b8a68c 100%);
}

#desert-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Desert Atmosphere Effects */
.desert-atmosphere {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.sand-particles {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 20% 30%,
      rgba(244, 228, 188, 0.1) 0%,
      transparent 50%),
    radial-gradient(circle at 80% 70%,
      rgba(244, 228, 188, 0.08) 0%,
      transparent 50%);
  animation: sandDrift 15s ease-in-out infinite;
}

.heat-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.1) 25%,
      rgba(255, 255, 255, 0.2) 50%,
      rgba(255, 255, 255, 0.1) 75%,
      transparent 100%);
  animation: heatShimmer 3s ease-in-out infinite;
  transform: translateX(-100%);
}

.wind-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(45deg,
      transparent,
      transparent 2px,
      rgba(244, 228, 188, 0.1) 2px,
      rgba(244, 228, 188, 0.1) 4px);
  animation: windFlow 8s linear infinite;
}

/* Desert Details */
.desert-details {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: linear-gradient(135deg,
      rgba(139, 115, 85, 0.9) 0%,
      rgba(193, 154, 107, 0.8) 50%,
      rgba(210, 180, 140, 0.7) 100%);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(244, 228, 188, 0.3);
  border-radius: 15px;
  padding: 25px;
  max-width: 350px;
  z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.desert-details h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f4e4bc;
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

.desert-details p {
  font-size: 0.95rem;
  color: #e6d7c3;
  line-height: 1.5;
  margin-bottom: 15px;
  font-style: italic;
}

.desert-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-top: 15px;
}

.stat {
  text-align: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid rgba(244, 228, 188, 0.2);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: #c19a6b;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #f4e4bc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}


/* Desert Animations */
@keyframes sandDrift {

  0%,
  100% {
    transform: translateX(0) translateY(0);
    opacity: 0.1;
  }

  25% {
    transform: translateX(10px) translateY(-5px);
    opacity: 0.15;
  }

  50% {
    transform: translateX(-5px) translateY(-10px);
    opacity: 0.2;
  }

  75% {
    transform: translateX(5px) translateY(-3px);
    opacity: 0.12;
  }
}

@keyframes heatShimmer {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }

  50% {
    opacity: 0.3;
  }

  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes windFlow {
  0% {
    transform: translateX(-100px);
  }

  100% {
    transform: translateX(100px);
  }
}

/* Crossfade the 3D canvas when entering desert */
body.desert-immersive #cosmic-container {
  filter: blur(calc(3px * var(--overlayOpacity, 0))) sepia(0.3) hue-rotate(30deg);
  opacity: calc(1 - 0.7 * var(--overlayOpacity, 0));
  transition: opacity 0.8s ease, filter 0.8s ease;
}

/* Enhanced Desert Atmosphere */
.desert-overlay::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 30% 20%,
      rgba(255, 255, 255, 0.1) 0%,
      transparent 50%),
    radial-gradient(ellipse at 70% 80%,
      rgba(244, 228, 188, 0.15) 0%,
      transparent 50%),
    linear-gradient(45deg,
      transparent 30%,
      rgba(255, 255, 255, 0.05) 50%,
      transparent 70%);
  animation: atmosphericShimmer 12s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes atmosphericShimmer {

  0%,
  100% {
    opacity: 0.3;
    transform: scale(1) rotate(0deg);
  }

  25% {
    opacity: 0.6;
    transform: scale(1.02) rotate(1deg);
  }

  50% {
    opacity: 0.4;
    transform: scale(1.05) rotate(-1deg);
  }

  75% {
    opacity: 0.7;
    transform: scale(1.03) rotate(0.5deg);
  }
}

/* Desert Sound Wave Visualization */
.desert-sound-waves {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border: 2px solid rgba(244, 228, 188, 0.2);
  border-radius: 50%;
  animation: soundWave 4s ease-out infinite;
  pointer-events: none;
  z-index: 2;
}

.desert-sound-waves::before,
.desert-sound-waves::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(244, 228, 188, 0.15);
  border-radius: 50%;
  animation: soundWave 4s ease-out infinite;
}

.desert-sound-waves::before {
  width: 300px;
  height: 300px;
  animation-delay: 1s;
}

.desert-sound-waves::after {
  width: 400px;
  height: 400px;
  animation-delay: 2s;
}

@keyframes soundWave {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.8;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

/* Enhanced Sand Particle Effects */
.sand-particles::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 10% 20%,
      rgba(244, 228, 188, 0.2) 0%,
      transparent 30%),
    radial-gradient(circle at 90% 80%,
      rgba(244, 228, 188, 0.15) 0%,
      transparent 40%),
    radial-gradient(circle at 50% 50%,
      rgba(244, 228, 188, 0.1) 0%,
      transparent 60%);
  animation: sandSwirl 20s linear infinite;
}

@keyframes sandSwirl {
  0% {
    transform: rotate(0deg) scale(1);
  }

  25% {
    transform: rotate(90deg) scale(1.1);
  }

  50% {
    transform: rotate(180deg) scale(0.9);
  }

  75% {
    transform: rotate(270deg) scale(1.05);
  }

  100% {
    transform: rotate(360deg) scale(1);
  }
}

/* Desert Mirage Effect */
.desert-mirage {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30%;
  background: linear-gradient(0deg,
      rgba(244, 228, 188, 0.3) 0%,
      rgba(255, 255, 255, 0.1) 50%,
      transparent 100%);
  animation: mirageShimmer 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

@keyframes mirageShimmer {

  0%,
  100% {
    opacity: 0.2;
    transform: translateY(0) scaleY(1);
  }

  50% {
    opacity: 0.4;
    transform: translateY(-10px) scaleY(1.1);
  }
}

.hidden {
  display: none !important;
}

/* Astronaut-perspective transition overlay */
#transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 50% 50%,
      rgba(0, 0, 0, 0.15) 0%,
      rgba(0, 0, 0, 0.6) 60%,
      rgba(0, 0, 0, 0.95) 100%);
}

#transition-overlay.hidden {
  display: none;
}

#transition-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.transition-hud {
  position: relative;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.hud-ring {
  width: 220px;
  height: 220px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  animation: hudSpin 6s linear infinite;
}

.hud-text {
  margin-top: 20px;
  color: #e2e8f0;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@keyframes hudSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Responsive Desert Scene */
@media (max-width: 768px) {
  .desert-container {
    width: 100%;
    height: 100%;
  }

  .desert-controls {
    top: 10px;
    right: 10px;
    flex-direction: column;
    gap: 8px;
  }

  .control-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .desert-details {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: linear-gradient(135deg,
        rgba(139, 115, 85, 0.9) 0%,
        rgba(193, 154, 107, 0.8) 50%,
        rgba(210, 180, 140, 0.7) 100%);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(244, 228, 188, 0.3);
    border-radius: 15px;
    padding: 25px;
    max-width: 350px;
    z-index: 10;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  }

  .desert-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}