/**
 * Deities - Hero Video Background
 * Implements accessible, performant video background with fallbacks
 */

/* ===== HERO VIDEO CONTAINER ===== */
.deity-hero {
    position: relative;
    overflow: hidden;
    background-color: #fef7ed;
    background-size: cover;
    background-position: center;
}

/* ===== VIDEO ELEMENT ===== */
.deity-hero__video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: 1;
    object-fit: cover;
    pointer-events: none;
}

/* Hide video by default until JS confirms it should play */
.deity-hero__video {
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.deity-hero__video.is-playing {
    opacity: 1;
}

/* ===== OVERLAY FOR TEXT READABILITY ===== */
.deity-hero__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(254, 247, 237, 0.85) 0%,
        rgba(254, 243, 199, 0.8) 50%,
        rgba(255, 247, 237, 0.85) 100%
    );
    z-index: 2;
    pointer-events: none;
}

/* Darker overlay when video is playing for better contrast */
.deity-hero.has-video .deity-hero__overlay {
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.4) 0%,
        rgba(245, 158, 11, 0.3) 50%,
        rgba(0, 0, 0, 0.45) 100%
    );
}

/* Adjust text colors when video is playing */
.deity-hero.has-video .hero-title {
    color: white;
    text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.deity-hero.has-video .hero-subtitle {
    color: rgba(255, 255, 255, 0.9);
}

.deity-hero.has-video .hero-count {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
}

/* ===== HERO CONTENT (above overlay) ===== */
.deity-hero .hero-content {
    position: relative;
    z-index: 10;
}

/* ===== SOUND TOGGLE BUTTON ===== */
.deity-sound-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 15;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(245, 158, 11, 0.4);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    color: #f59e0b;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
}

/* Show button only when video is active */
.deity-hero.has-video .deity-sound-toggle {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.4);
    color: white;
}

.deity-sound-toggle:hover {
    background: rgba(245, 158, 11, 0.8);
    border-color: rgba(255, 255, 255, 0.6);
    color: white;
    transform: scale(1.1);
}

.deity-sound-toggle:focus {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}

.deity-sound-toggle[aria-pressed="true"] {
    background: rgba(245, 158, 11, 0.9);
    border-color: white;
    color: white;
}

/* Icon states */
.deity-sound-toggle .icon-sound-off,
.deity-sound-toggle .icon-sound-on {
    position: absolute;
    transition: opacity 0.2s ease;
}

.deity-sound-toggle .icon-sound-on {
    opacity: 0;
}

.deity-sound-toggle[aria-pressed="true"] .icon-sound-off {
    opacity: 0;
}

.deity-sound-toggle[aria-pressed="true"] .icon-sound-on {
    opacity: 1;
}

/* ===== PREFERS REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .deity-hero__video {
        display: none !important;
    }
    
    .deity-sound-toggle {
        display: none !important;
    }
    
    /* Ensure gradient overlay is visible without video */
    .deity-hero .deity-hero__overlay {
        background: linear-gradient(
            135deg,
            rgba(254, 247, 237, 0.9) 0%,
            rgba(254, 243, 199, 0.85) 100%
        );
    }
}

/* ===== MOBILE: Poster fallback by default ===== */
@media (max-width: 768px) {
    .deity-hero__video {
        display: none;
    }
    
    .deity-sound-toggle {
        width: 42px;
        height: 42px;
        bottom: 15px;
        right: 15px;
        font-size: 1rem;
    }
    
    /* Mobile gets static gradient background */
    .deity-hero:not(.has-video) .deity-hero__overlay {
        background: linear-gradient(
            135deg,
            rgba(254, 247, 237, 0.9) 0%,
            rgba(254, 243, 199, 0.85) 100%
        );
    }
}

/* ===== VIDEO LOADING STATE ===== */
.deity-hero.video-loading .deity-hero__video {
    opacity: 0;
}

/* ===== NO-JS FALLBACK ===== */
.no-js .deity-hero__video,
.no-js .deity-sound-toggle {
    display: none !important;
}
