/* Animated Space Theme Background */

/* Space Background Base */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1000;
  background: 
    radial-gradient(ellipse at top, #0f1419, transparent),
    radial-gradient(ellipse at bottom, #1a0e2e, transparent),
    linear-gradient(180deg, #0a0a0f 0%, #1a0d2e 35%, #0f1419 70%, #0a0a0f 100%);
}

/* Animated Stars */
.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -999;
  pointer-events: none;
}

.stars::before,
.stars::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: transparent;
}

/* Small twinkling stars */
.stars::before {
  background-image: 
    radial-gradient(2px 2px at 20px 30px, #fff, transparent),
    radial-gradient(2px 2px at 40px 70px, #fff, transparent),
    radial-gradient(1px 1px at 90px 40px, #fff, transparent),
    radial-gradient(1px 1px at 130px 80px, #fff, transparent),
    radial-gradient(2px 2px at 160px 30px, #fff, transparent);
  background-repeat: repeat;
  background-size: 200px 100px;
  animation: twinkle 3s infinite ease-in-out alternate;
}

/* Medium stars */
.stars::after {
  background-image: 
    radial-gradient(1px 1px at 10px 10px, #4cc9f0, transparent),
    radial-gradient(2px 2px at 80px 50px, #9b87f5, transparent),
    radial-gradient(1px 1px at 120px 20px, #fff, transparent),
    radial-gradient(1px 1px at 170px 70px, #4cc9f0, transparent);
  background-repeat: repeat;
  background-size: 180px 120px;
  animation: twinkle 2s infinite ease-in-out alternate-reverse;
}

@keyframes twinkle {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

/* Shooting Stars */
.shooting-stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -998;
  pointer-events: none;
}

.shooting-star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: linear-gradient(45deg, #fff, transparent);
  border-radius: 50%;
  animation: shoot 3s linear infinite;
}

.shooting-star::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, #fff, transparent);
  transform: translateX(-50px);
}

.shooting-star:nth-child(1) {
  top: 10%;
  left: -10px;
  animation-delay: 0s;
  animation-duration: 4s;
}

.shooting-star:nth-child(2) {
  top: 20%;
  left: -10px;
  animation-delay: 2s;
  animation-duration: 3s;
}

.shooting-star:nth-child(3) {
  top: 40%;
  left: -10px;
  animation-delay: 5s;
  animation-duration: 5s;
}

.shooting-star:nth-child(4) {
  top: 60%;
  left: -10px;
  animation-delay: 8s;
  animation-duration: 3.5s;
}

.shooting-star:nth-child(5) {
  top: 80%;
  left: -10px;
  animation-delay: 12s;
  animation-duration: 4.5s;
}

@keyframes shoot {
  0% {
    transform: translateX(-100px) translateY(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(calc(100vw + 100px)) translateY(-200px);
    opacity: 0;
  }
}

/* Nebula Cloud Effects */
.nebula {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -997;
  pointer-events: none;
  opacity: 0.4;
}

.nebula::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 25% 25%, rgba(155, 135, 245, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(76, 201, 240, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 50% 10%, rgba(245, 158, 11, 0.1) 0%, transparent 40%);
  animation: nebulaDrift 20s infinite linear;
}

.nebula::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -30%;
  width: 150%;
  height: 150%;
  background: 
    radial-gradient(circle at 70% 30%, rgba(239, 68, 68, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 30% 70%, rgba(34, 197, 94, 0.1) 0%, transparent 50%);
  animation: nebulaDrift 25s infinite linear reverse;
}

@keyframes nebulaDrift {
  0% {
    transform: rotate(0deg) translateX(20px);
  }
  100% {
    transform: rotate(360deg) translateX(20px);
  }
}

/* Floating Planets */
.planets {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -996;
  pointer-events: none;
}

.planet {
  position: absolute;
  border-radius: 50%;
  opacity: 0.6;
  animation: float 15s infinite ease-in-out;
}

.planet-1 {
  width: 80px;
  height: 80px;
  background: radial-gradient(circle at 30% 30%, #9b87f5, #4c1d95);
  top: 15%;
  right: 10%;
  animation-delay: 0s;
  box-shadow: 0 0 30px rgba(155, 135, 245, 0.3);
}

.planet-2 {
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at 30% 30%, #4cc9f0, #0c4a6e);
  bottom: 20%;
  left: 15%;
  animation-delay: -5s;
  animation-duration: 20s;
  box-shadow: 0 0 25px rgba(76, 201, 240, 0.3);
}

.planet-3 {
  width: 40px;
  height: 40px;
  background: radial-gradient(circle at 30% 30%, #f59e0b, #92400e);
  top: 60%;
  right: 25%;
  animation-delay: -10s;
  animation-duration: 18s;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
  }
}

/* Cosmic Dust Particles */
.cosmic-dust {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -995;
  pointer-events: none;
}

.dust-particle {
  position: absolute;
  width: 1px;
  height: 1px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: dustFloat 10s infinite linear;
}

.dust-particle:nth-child(odd) {
  animation-duration: 15s;
  animation-delay: -5s;
}

.dust-particle:nth-child(3n) {
  animation-duration: 8s;
  background: rgba(76, 201, 240, 0.4);
}

.dust-particle:nth-child(5n) {
  animation-duration: 12s;
  background: rgba(155, 135, 245, 0.4);
}

@keyframes dustFloat {
  0% {
    transform: translateX(-10px) translateY(100vh);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(10px) translateY(-10px);
    opacity: 0;
  }
}

/* Constellation Lines (Optional decorative element) */
.constellation {
  position: fixed;
  top: 20%;
  right: 20%;
  width: 200px;
  height: 150px;
  z-index: -994;
  pointer-events: none;
  opacity: 0.3;
}

.constellation::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(45deg, transparent 49%, rgba(255, 255, 255, 0.5) 49%, rgba(255, 255, 255, 0.5) 51%, transparent 51%),
    linear-gradient(-45deg, transparent 49%, rgba(255, 255, 255, 0.5) 49%, rgba(255, 255, 255, 0.5) 51%, transparent 51%);
  background-size: 50px 50px, 60px 40px;
  background-position: 20px 30px, 80px 70px;
  background-repeat: no-repeat;
  animation: constellationGlow 4s infinite ease-in-out alternate;
}

@keyframes constellationGlow {
  0% { opacity: 0.3; }
  100% { opacity: 0.7; }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .nebula::before,
  .nebula::after {
    animation-duration: 30s;
  }
  
  .planet {
    animation-duration: 20s;
  }
  
  .shooting-star {
    display: none; /* Disable shooting stars on mobile for performance */
  }
  
  .cosmic-dust {
    opacity: 0.5; /* Reduce dust particles on mobile */
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .stars::before,
  .stars::after,
  .nebula::before,
  .nebula::after,
  .planet,
  .shooting-star,
  .dust-particle,
  .constellation::before {
    animation: none;
  }
  
  .nebula {
    opacity: 0.2;
  }
}