/**
 * LongView Renovation - Weather Effects CSS
 * Unified styling for all weather animations (snow, rain, hail)
 * GPU-accelerated and mobile-responsive
 */

/* Base weather container — positioned by JS inside .hp-hero-composite (z-index: 2)
   or fixed-viewport fallback on non-homepage pages (z-index: 40) */
#weather-effects-container {
    pointer-events: none;
    overflow: hidden;
    transform: translateZ(0); /* Force GPU acceleration */
    isolation: isolate; /* Contains child z-index values within this stacking context */
}

/* Base particle styling */
.weather-particle {
    position: absolute;
    pointer-events: none;
    user-select: none;
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: Arial, sans-serif;
}

/* Snow particles */
.snow-particle {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

/* Rain particles */
.rain-particle {
    color: rgba(100, 149, 237, 0.7);
    font-size: 12px;
    transform: scaleX(0.3);
    text-shadow: none;
    font-weight: bold;
}

/* Hail particles */
.hail-particle {
    color: rgba(200, 200, 255, 0.8);
    font-size: 10px;
    text-shadow: 0 0 3px rgba(200, 200, 255, 0.6);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(200,200,255,0.6) 100%);
    width: 8px;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Base animations for each weather type */
@keyframes snow-fall {
    0% {
        transform: translate3d(0, -20px, 0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 100vh, 0) rotate(360deg);
        opacity: 0;
    }
}

@keyframes rain-fall {
    0% {
        transform: translate3d(0, -20px, 0);
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    95% {
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 100vh, 0);
        opacity: 0;
    }
}

@keyframes hail-fall {
    0% {
        transform: translate3d(0, -20px, 0) scale(0.5);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translate3d(0, 10vh, 0) scale(1.2);
    }
    30% {
        transform: translate3d(0, 30vh, 0) scale(0.8);
    }
    50% {
        transform: translate3d(0, 50vh, 0) scale(1.1);
    }
    70% {
        transform: translate3d(0, 70vh, 0) scale(0.9);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 100vh, 0) scale(1);
        opacity: 0;
    }
}

/* Size variations */
.weather-particle.small {
    font-size: 8px;
}

.weather-particle.medium {
    font-size: 12px;
}

.weather-particle.large {
    font-size: 16px;
}

/* Hail size variations */
.hail-particle.small {
    width: 6px;
    height: 6px;
    font-size: 6px;
}

.hail-particle.medium {
    width: 10px;
    height: 10px;
    font-size: 8px;
}

.hail-particle.large {
    width: 14px;
    height: 14px;
    font-size: 10px;
}

/* Rain length variations */
.rain-particle.small {
    transform: scaleX(0.2) scaleY(0.8);
}

.rain-particle.medium {
    transform: scaleX(0.3) scaleY(1);
}

.rain-particle.large {
    transform: scaleX(0.4) scaleY(1.2);
}

/* Wind effect variations for different weather types */
.snow-particle.windy {
    animation-timing-function: ease-in-out;
}

.rain-particle.windy {
    animation-timing-function: linear;
}

.hail-particle.windy {
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .weather-particle {
        font-size: 10px;
    }
    
    .weather-particle.small {
        font-size: 6px;
    }
    
    .weather-particle.medium {
        font-size: 8px;
    }
    
    .weather-particle.large {
        font-size: 12px;
    }
    
    .hail-particle {
        width: 6px;
        height: 6px;
        font-size: 6px;
    }
    
    .hail-particle.medium {
        width: 8px;
        height: 8px;
        font-size: 7px;
    }
    
    .hail-particle.large {
        width: 10px;
        height: 10px;
        font-size: 8px;
    }
    
    /* Reduce particle density on mobile */
    #weather-effects-container {
        opacity: 0.8;
    }
}

/* Performance optimizations */
#weather-effects-container * {
    contain: layout style paint;
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
    .weather-particle {
        animation-duration: 20s !important;
        animation-timing-function: linear !important;
    }
    
    #weather-effects-container {
        opacity: 0.5;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .snow-particle {
        color: rgba(255, 255, 255, 1);
        text-shadow: 0 0 1px rgba(0, 0, 0, 0.8);
    }
    
    .rain-particle {
        color: rgba(0, 100, 255, 0.9);
    }
    
    .hail-particle {
        color: rgba(255, 255, 255, 1);
        background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(150,150,255,0.8) 100%);
    }
}

/* Print styles - hide weather effects when printing */
@media print {
    #weather-effects-container {
        display: none !important;
    }
}

/* Depth effect variations */
.weather-particle.distant {
    opacity: 0.3;
    filter: blur(0.5px);
    z-index: 999;
}

.weather-particle.near {
    opacity: 0.9;
    filter: blur(0px);
    z-index: 1001;
}

/* Special seasonal effects */
.weather-particle.intense {
    animation-duration: 0.5s;
    opacity: 0.8;
}

/* Loading state */
.weather-loading {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.weather-loaded {
    opacity: 1;
}

/* Debug mode styles */
.weather-debug .weather-particle {
    border: 1px solid red;
    background: rgba(255, 0, 0, 0.1);
}

.weather-debug .weather-particle::after {
    content: attr(data-weather-type);
    position: absolute;
    top: -15px;
    left: 0;
    font-size: 8px;
    color: red;
    background: white;
    padding: 1px 3px;
    border-radius: 2px;
}