/* 
 * Enhanced Night Sky Starscape Background System
 * Comprehensive background implementation with dynamic star generation
 */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Starscape Container - Fixed background */
.starscape-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -10;
    overflow: hidden;
    background: #000;
    background-image: url('../../sitegfx/star.jpg') !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* Background Image Layer - Now just for overlay effects */
.starscape-background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    animation: slowDrift 600s linear infinite;
    opacity: 0.8;
    z-index: 1;
}

/* Fallback gradient if star image is missing */
.starscape-background-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        #0a0a28 0%,
        #1a1a3a 25%,
        #2a2a4a 50%,
        #1a1a3a 75%,
        #0a0a28 100%
    );
    z-index: -1;
}

/* Enhanced Stars Layer */
.starscape-stars-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    animation: slowDrift 800s linear infinite;
    z-index: 2;
    pointer-events: none;
}

/* Dynamic Star Styles */
.starscape-star {
    position: absolute;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
}

/* Star Size Variations */
.starscape-star.size-1 {
    width: 1px;
    height: 1px;
}

.starscape-star.size-2 {
    width: 1.5px;
    height: 1.5px;
}

.starscape-star.size-3 {
    width: 2px;
    height: 2px;
}

.starscape-star.size-4 {
    width: 2.5px;
    height: 2.5px;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
}

.starscape-star.size-5 {
    width: 3px;
    height: 3px;
    box-shadow: 0 0 5px rgba(255, 255, 255, 1);
}

/* Twinkling Effect */
.starscape-star.twinkle {
    animation: twinkleEffect 8s ease-in-out infinite;
}

/* Lens Effect for Enhanced Realism */
.starscape-lens-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 40%,
        rgba(255, 255, 255, 0.03) 70%,
        rgba(255, 255, 255, 0.08) 85%,
        rgba(200, 220, 255, 0.15) 100%
    );
    pointer-events: none;
    mix-blend-mode: screen;
    z-index: 3;
}

/* Gradient Overlay Layer */
.starscape-gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(5, 5, 20, 0.8),
        rgba(10, 5, 25, 0.7),
        rgba(5, 10, 30, 0.8),
        rgba(8, 5, 22, 0.7)
    );
    background-size: 400% 400%;
    animation: breathingGradient 60s ease-in-out infinite;
    mix-blend-mode: multiply;
}

/* Additional overlay for better content readability */
.starscape-content-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

/* Enhanced Animations */
@keyframes breathingGradient {
    0%, 100% {
        background-position: 0% 50%;
        opacity: 0.6;
    }
    50% {
        background-position: 100% 50%;
        opacity: 0.8;
    }
}

@keyframes slowDrift {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(-2%, 2%);
    }
}

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

@keyframes gentlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
}

/* Add twinkling effect to background */
.starscape-background-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle at 20% 20%, rgba(255, 255, 255, 0.1) 1px, transparent 1px
    ),
    radial-gradient(
        circle at 80% 30%, rgba(255, 255, 255, 0.1) 1px, transparent 1px
    ),
    radial-gradient(
        circle at 40% 70%, rgba(255, 255, 255, 0.1) 1px, transparent 1px
    ),
    radial-gradient(
        circle at 90% 80%, rgba(255, 255, 255, 0.1) 1px, transparent 1px
    );
    animation: twinkle 4s ease-in-out infinite;
}

/* Content positioning - ensure content appears above background */
body {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* Ensure all main content containers are properly positioned */
.container,
.main-content,
.content-wrapper,
.page-wrapper {
    position: relative;
    z-index: 2;
}

/* Enhanced responsive design for starscape */
@media (max-width: 768px) {
    .starscape-background-image {
        background-size: cover;
        background-position: center;
    }
    
    .starscape-gradient-overlay {
        opacity: 0.8;
    }
}

@media (max-width: 480px) {
    .starscape-background-image {
        background-size: cover;
        background-position: center;
    }
    
    .starscape-gradient-overlay {
        opacity: 0.9;
    }
}

/* Performance optimizations */
.starscape-container {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.starscape-background-image,
.starscape-gradient-overlay {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Dark mode compatibility */
@media (prefers-color-scheme: dark) {
    .starscape-content-overlay {
        background: rgba(0, 0, 0, 0.4);
    }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
    .starscape-background-image,
    .starscape-gradient-overlay,
    .starscape-background-image::after {
        animation: none;
    }
    
    .starscape-background-image {
        transform: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .starscape-gradient-overlay {
        opacity: 0.9;
    }
    
    .starscape-content-overlay {
        background: rgba(0, 0, 0, 0.6);
    }
}

/* Print styles - hide background for printing */
@media print {
    .starscape-container {
        display: none;
    }
}
