/**
 * RW Gutenberg Animations - Video Background
 * Version: 3.0.1
 * 
 * Stili per video background fixed globale
 * Posiziona in: assets/css/video-background.css
 */

/* ==================== BACKGROUND CHANGES ==================== */

/* Transizione smooth per i cambi di background */
.changing-bg {
    color: var(--body-color);
    transition: background-color 1s ease, color 1s ease;
}

/* Se NON esiste NESSUNA classe bg-* */
.changing-bg:not([class^="bg-"]):not([class*=" bg-"]) {
    background-color: var(--body-bg-color);
}

/* Video background - transparent quando video attivo */
.changing-bg.is-playing-video:not([class^="bg-"]):not([class*=" bg-"]) {
    background-color: transparent;
}

/* ==================== VIDEO BACKGROUND CONTAINER ==================== */

#rwga-video-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -5;
    overflow: hidden;
    pointer-events: none;
    background-color: var(--dark);
}

#rwga-video-bg::after {
    content:'';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,.4);
    z-index: 1;
}

/* Video elements */
#rwga-video-bg video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
    opacity: 0; 
    transition: opacity 0.3s ease-in-out;
    z-index: 1;
}

#rwga-video-bg video.is-active {
    opacity: 1;
}

/* Poster/placeholder */
#rwga-video-bg .rwga-video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: 0;
}

#rwga-video-bg .rwga-video-poster.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rwga-spin 0.8s linear infinite;
}

@keyframes rwga-spin {
    to { transform: rotate(360deg); }
}

/* ==================== ACCESSIBILITY ==================== */

@media (prefers-reduced-motion: reduce) {
    #rwga-video-bg video {
        transition: none;
        animation: none;
    }
    
    #rwga-video-bg .rwga-video-poster {
        transition: none;
    }
}

/* ==================== PRINT ==================== */

@media print {
    #rwga-video-bg {
        display: none;
    }
}

/* ==================== UTILITY CLASSES ==================== */

/* Nascondi video background temporaneamente */
.rwga-video-bg-hidden #rwga-video-bg {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Forza video ad essere sempre visibile (debug) */
.rwga-video-bg-debug #rwga-video-bg {
    z-index: 9999;
    border: 3px solid red;
}

/* ==================== CUSTOM DIMENSIONS (future feature) ==================== */

/* Placeholder per dimensioni custom video (da implementare) */
/*
.rwga-video-section[data-videow="50"] #rwga-video-bg {
    width: 50vw;
}

.rwga-video-section[data-videoh="50"] #rwga-video-bg {
    height: 50vh;
}
*/