/* 3D Starfield Background Styles */

#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
}

/* Star particles for CSS fallback */
.star {
    position: absolute;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.8;
    animation: twinkle 3s ease-in-out infinite alternate;
}

.star:nth-child(odd) {
    animation-delay: 1s;
}

.star:nth-child(even) {
    animation-delay: 2s;
}

.star.bright {
    background: #ffd700;
    box-shadow: 0 0 10px #ffd700;
    animation: pulse 2s ease-in-out infinite;
}

.star.medium {
    background: #87ceeb;
    box-shadow: 0 0 5px #87ceeb;
}

.star.dim {
    background: #b0c4de;
    opacity: 0.6;
}

/* Nebula effect */
.nebula {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.1;
    animation: drift 30s ease-in-out infinite;
}

.nebula.purple {
    background: radial-gradient(circle, #8a2be2 0%, transparent 70%);
}

.nebula.blue {
    background: radial-gradient(circle, #4169e1 0%, transparent 70%);
}

.nebula.pink {
    background: radial-gradient(circle, #ff69b4 0%, transparent 70%);
}

/* Shooting stars */
.shooting-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 10px #ffffff;
    animation: shoot 3s linear infinite;
    opacity: 0;
}

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

/* Animations */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
        box-shadow: 0 0 10px currentColor;
    }
    50% {
        opacity: 1;
        transform: scale(1.5);
        box-shadow: 0 0 20px currentColor;
    }
}

@keyframes drift {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(100px, -50px) rotate(90deg);
    }
    50% {
        transform: translate(-50px, 100px) rotate(180deg);
    }
    75% {
        transform: translate(-100px, -100px) rotate(270deg);
    }
}

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

/* Galaxy spiral effect */
.galaxy {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        rgba(138, 43, 226, 0.1) 30%,
        rgba(65, 105, 225, 0.1) 50%,
        rgba(255, 105, 180, 0.1) 70%,
        transparent 100%
    );
    animation: rotate-galaxy 60s linear infinite;
    opacity: 0.3;
}

.galaxy::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(
        circle,
        rgba(255, 215, 0, 0.2) 0%,
        transparent 70%
    );
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: counter-rotate 30s linear infinite;
}

@keyframes rotate-galaxy {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes counter-rotate {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(-360deg);
    }
}

/* Parallax layers for depth */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.parallax-layer.far {
    transform: translateZ(-1000px) scale(10);
}

.parallax-layer.mid {
    transform: translateZ(-500px) scale(5);
}

.parallax-layer.near {
    transform: translateZ(-100px) scale(1);
}

/* Constellation patterns */
.constellation {
    position: absolute;
    width: 300px;
    height: 300px;
    opacity: 0.3;
}

.constellation-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.2);
    height: 1px;
    transform-origin: left center;
}

/* Asteroid field */
.asteroid {
    position: absolute;
    background: #8b7d6b;
    border-radius: 30% 70% 70% 30%;
    animation: float-asteroid 20s ease-in-out infinite;
    opacity: 0.4;
}

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

/* Cosmic dust effect */
.cosmic-dust {
    position: absolute;
    width: 1px;
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: dust-drift 15s linear infinite;
}

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

/* Aurora effect */
.aurora {
    position: absolute;
    width: 100%;
    height: 200px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 255, 127, 0.1) 25%,
        rgba(127, 255, 212, 0.1) 50%,
        rgba(0, 191, 255, 0.1) 75%,
        transparent 100%
    );
    animation: aurora-wave 8s ease-in-out infinite;
    opacity: 0.6;
    filter: blur(2px);
}

@keyframes aurora-wave {
    0%, 100% {
        transform: translateX(-100%) skewX(-10deg);
        opacity: 0.3;
    }
    50% {
        transform: translateX(100%) skewX(10deg);
        opacity: 0.8;
    }
}

/* Performance optimizations */
.starfield-container {
    will-change: transform;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.star, .nebula, .shooting-star, .asteroid, .cosmic-dust {
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .star, .nebula, .shooting-star, .galaxy, .asteroid, .cosmic-dust, .aurora {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
