/**
 * StChannel Animated Background - Futuristic Design
 * 
 * Sfondo animato con gradienti, particelle e elementi in movimento
 * Ottimizzato per performance mobile
 * 
 * Richiede: _variables.css caricato prima
 */

/* ========================================
   SFONDO PRINCIPALE ANIMATO
   ======================================== */

.st-animated-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1000;
    overflow: hidden;
    background: var(--st-gradient-black);
    pointer-events: none;
}

/* Gradiente di base con animazione lenta */
.st-bg-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        45deg,
        var(--st-black) 0%,
        var(--st-dark) 25%,
        var(--st-dark-surface) 50%,
        var(--st-dark) 75%,
        var(--st-black) 100%
    );
    animation: gradientShift 20s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
        filter: hue-rotate(0deg);
    }
    25% {
        background-position: 100% 50%;
        filter: hue-rotate(5deg);
    }
    50% {
        background-position: 50% 100%;
        filter: hue-rotate(10deg);
    }
    75% {
        background-position: 0% 100%;
        filter: hue-rotate(5deg);
    }
}

/* ========================================
   PARTICELLE FLUTTUANTI
   ======================================== */

.st-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.st-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--st-primary);
    border-radius: var(--st-radius-full);
    opacity: 0;
    animation: particleFloat linear infinite;
    box-shadow: 0 0 6px var(--st-primary);
}

/* Variazioni di particelle */
.st-particle:nth-child(odd) {
    background: var(--st-green-neon);
    box-shadow: 0 0 6px var(--st-green-neon);
    animation-duration: 15s;
}

.st-particle:nth-child(even) {
    background: var(--st-primary-light);
    box-shadow: 0 0 4px var(--st-primary-light);
    animation-duration: 20s;
}

.st-particle:nth-child(3n) {
    width: 3px;
    height: 3px;
    animation-duration: 25s;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(90vh) translateX(10px) scale(1);
    }
    90% {
        opacity: 1;
        transform: translateY(10vh) translateX(-10px) scale(1);
    }
    100% {
        transform: translateY(-10vh) translateX(0) scale(0);
        opacity: 0;
    }
}

/* ===== PARTICELLE SPECIALI ===== */
.st-particle-large {
    width: 4px !important;
    height: 4px !important;
    opacity: 0.9;
    box-shadow: 0 0 12px var(--st-primary);
}

.st-particle-trail {
    width: 1px !important;
    height: 15px !important;
    background: linear-gradient(180deg, 
        var(--st-primary) 0%, 
        transparent 100%) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* ===== PARTICELLE DI SCROLL ===== */
.st-scroll-particle {
    position: absolute;
    top: -20px;
    width: 8px;
    height: 8px;
    background: var(--st-primary);
    border-radius: 50%;
    animation: scrollParticleFlow linear infinite;
    opacity: 0.3; /* Semitrasparenza come richiesto */
    box-shadow: 0 0 8px rgba(var(--st-primary-rgb), 0.5);
    border: 1px solid rgba(var(--st-primary-rgb), 0.3);
}

@keyframes scrollParticleFlow {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }
    20% {
        opacity: 0.3;
    }
    80% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(calc(100vh + 20px));
        opacity: 0;
    }
}

/* ========================================
   ONDE LUMINOSE
   ======================================== */

.st-wave {
    position: absolute;
    width: 200%;
    height: 200px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--st-primary-rgb), 0.03),
        transparent
    );
    animation: waveMove 30s linear infinite;
    transform-origin: center;
}

.st-wave:nth-child(1) {
    top: 20%;
    animation-duration: 25s;
    animation-delay: -5s;
}

.st-wave:nth-child(2) {
    top: 60%;
    animation-duration: 35s;
    animation-delay: -15s;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--st-green-neon), 0.02),
        transparent
    );
}

@keyframes waveMove {
    0% {
        transform: translateX(-100%) rotate(0deg);
    }
    100% {
        transform: translateX(100%) rotate(360deg);
    }
}

/* ========================================
   ELEMENTI GEOMETRICI FLUTTUANTI
   ======================================== */

.st-geometric {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(var(--st-primary-rgb), 0.2);
    border-radius: var(--st-radius-sm);
    animation: geometricFloat 40s linear infinite;
    opacity: 0;
}

.st-geometric:nth-child(1) {
    top: 10%;
    left: 10%;
    animation-delay: -10s;
    transform: rotate(45deg);
}

.st-geometric:nth-child(2) {
    top: 70%;
    right: 15%;
    animation-delay: -25s;
    border-radius: var(--st-radius-full);
    width: 30px;
    height: 30px;
}

.st-geometric:nth-child(3) {
    top: 40%;
    left: 80%;
    animation-delay: -35s;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    border: none;
    background: linear-gradient(45deg, transparent, rgba(var(--st-primary-rgb), 0.1));
}

@keyframes geometricFloat {
    0%, 100% {
        opacity: 0;
        transform: translateY(0) rotate(0deg) scale(0.8);
    }
    25% {
        opacity: 0.6;
        transform: translateY(-30px) rotate(90deg) scale(1);
    }
    50% {
        opacity: 0.3;
        transform: translateY(-60px) rotate(180deg) scale(1.2);
    }
    75% {
        opacity: 0.6;
        transform: translateY(-30px) rotate(270deg) scale(1);
    }
}

/* ========================================
   EFFETTO SCANLINE FUTURISTICO
   ======================================== */

.st-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(var(--st-primary-rgb), 0.01) 2px,
        rgba(var(--st-primary-rgb), 0.01) 4px
    );
    animation: scanlineMove 3s linear infinite;
    opacity: 0.3;
}

@keyframes scanlineMove {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(4px);
    }
}

/* ========================================
   OTTIMIZZAZIONI MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Riduce animazioni su mobile per performance */
    .st-bg-gradient {
        animation-duration: 30s; /* Più lento */
    }
    
    .st-particle {
        animation-duration: 25s !important; /* Più lento */
    }
    
    .st-wave {
        animation-duration: 40s !important; /* Più lento */
        height: 100px; /* Più piccole */
    }
    
    .st-geometric {
        animation-duration: 50s; /* Più lento */
        width: 25px; /* Più piccoli */
        height: 25px;
    }
    
    .st-scanlines {
        opacity: 0.1; /* Meno visibili */
    }
    
    /* Ottimizzazioni per particelle di scroll */
    .st-scroll-particle {
        width: 6px;
        height: 6px;
        animation-duration: 10s; /* Più lento su mobile */
    }
}

@media (max-width: 480px) {
    /* Ulteriori ottimizzazioni per schermi molto piccoli */
    .st-particles .st-particle:nth-child(n+6) {
        display: none; /* Meno particelle */
    }
    
    .st-geometric:nth-child(n+3) {
        display: none; /* Meno elementi geometrici */
    }
    
    .st-wave:nth-child(n+2) {
        display: none; /* Meno onde */
    }
}

/* ========================================
   MODALITÀ RISPARMIO ENERGETICO
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .st-animated-background * {
        animation-duration: 60s !important;
        animation-iteration-count: 1 !important;
    }
    
    .st-scanlines {
        display: none;
    }
    
    .st-particles {
        display: none;
    }
}

/* ========================================
   OVERLAY GRADIENTE PER LEGGIBILITÀ
   ======================================== */

.st-content-overlay {
    position: relative;
    z-index: 1;
    background: linear-gradient(
        180deg,
        rgba(var(--st-black), 0.3) 0%,
        rgba(var(--st-black), 0.1) 50%,
        rgba(var(--st-black), 0.3) 100%
    );
    backdrop-filter: blur(0.5px);
}

/* ========================================
   CONTROLLI DI ATTIVAZIONE
   ======================================== */

/* Classe per attivare lo sfondo animato */
body.st-animated-bg .st-animated-background {
    display: block;
}

body:not(.st-animated-bg) .st-animated-background {
    display: none;
}

/* Variante ridotta per performance */
body.st-animated-bg.st-reduced-motion .st-animated-background .st-particles,
body.st-animated-bg.st-reduced-motion .st-animated-background .st-scanlines {
    display: none;
}

body.st-animated-bg.st-reduced-motion .st-animated-background * {
    animation-duration: 60s !important;
}
