/* === ANIMATION PÈRE NOËL - PHOTO + VIDÉO - LAYOUT VISIOPHONE === */

.santa-animation-video {
    position: relative;
    width: 100%;
    /* PAS de hauteurs fixes - s'adapte au contenu */
    z-index: 10;
    background: linear-gradient(180deg, #0a1f3d 0%, #1a2f4d 100%);
    border-radius: 20px 20px 0 0;
    /* PAS de overflow: hidden - laisse le cadre visible */
    /* Hardware acceleration */
    transform: translateZ(0);
    will-change: transform;
    padding: 70px; /* Desktop - équilibré */
    display: flex;
    align-items: center;
    justify-content: center;
}

.santa-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Optimisation GPU */
    transform: translateZ(0);
}

.santa-video-frame {
    position: relative;
    width: 90%;
    max-width: 340px;
    max-height: 60vh; /* Fallback pour navigateurs anciens */
    max-height: 60svh; /* 60% small viewport - laisse 40% pour header+footer */
    aspect-ratio: 464 / 688; /* Ratio réel de la vidéo (format portrait) - height calculée auto */
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border: 5px solid #ffd700;
    animation: frame-idle-glow 3s ease-in-out infinite;
    /* Isolation pour les performances */
    isolation: isolate;
    contain: layout style paint;
}

@keyframes frame-idle-glow {
    0%, 100% {
        border-color: #ffd700;
        box-shadow: 0 10px 40px rgba(255, 215, 0, 0.5);
    }
    50% {
        border-color: #ffb84d;
        box-shadow: 0 12px 45px rgba(255, 180, 77, 0.5);
    }
}

.santa-animation-video.speaking .santa-video-frame {
    animation: frame-speaking-pulse 0.8s ease-in-out infinite;
}

@keyframes frame-speaking-pulse {
    0%, 100% {
        transform: scale(1);
        border-color: #ffd700;
        box-shadow: 0 15px 50px rgba(255, 215, 0, 0.6);
    }
    50% {
        transform: scale(1.008);
        border-color: #ffed4e;
        box-shadow: 0 18px 55px rgba(255, 237, 78, 0.7);
    }
}

/* Vidéos superposées - Optimisé pour performances */
.santa-idle-video,
.santa-speaking-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Centrer la vidéo */
    object-position: center center;

    /* Transitions optimisées GPU - FONDU DOUX 0.8s */
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    backface-visibility: hidden;
    transform: translateZ(0);

    /* Anti-aliasing pour meilleure qualité */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Par défaut: vidéo d'attente visible et en lecture */
.santa-idle-video {
    opacity: 1;
    z-index: 1;
    pointer-events: none;
}

/* Vidéos de parole cachées par défaut */
.santa-speaking-video {
    opacity: 0;
    z-index: 2;
    display: none;
    pointer-events: none;

    /* Optimisation vidéo HTML5 */
    will-change: opacity;
}

/* Forcer greeting video TOUJOURS cachée sauf si active */
.santa-greeting-video:not(.active) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Vidéo active - Prête à être affichée */
.santa-speaking-video.active {
    display: block;
    pointer-events: auto;
}

/* Quand il parle: transition fluide vidéo attente -> vidéo parole */
.santa-animation-video.speaking .santa-idle-video {
    opacity: 0;
    will-change: opacity;
}

.santa-animation-video.speaking .santa-speaking-video.active {
    opacity: 1;
    will-change: opacity;
}

/* Bulle de parole - Position visiophone */
.santa-speaking-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.santa-animation-video.speaking .santa-speaking-indicator {
    opacity: 1;
}

.speech-bubble {
    background: linear-gradient(135deg, #c41e3a, #8b0000);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(196, 30, 58, 0.6);
    font-size: 24px;
    animation: bubble-pulse 0.8s ease-in-out infinite;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.speech-bubble::before {
    content: '🔴';
    font-size: 12px;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.3; }
}

@keyframes bubble-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 25px rgba(196, 30, 58, 0.6);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 35px rgba(255, 215, 0, 0.9);
    }
}

/* === Interférences vidéo pendant réflexion - Optimisé GPU === */
.santa-video-frame.loading {
    animation: video-glitch 0.3s infinite;
    will-change: transform, filter;
}

.santa-video-frame.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0) 2px,
        rgba(0, 0, 0, 0) 4px,
        rgba(0, 0, 0, 0.1) 6px
    );
    z-index: 100;
    pointer-events: none;
    animation: scanlines 4s linear infinite;
    will-change: transform;
    transform: translateZ(0);
}

.santa-video-frame.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.05);
    z-index: 101;
    pointer-events: none;
    animation: flicker 0.15s infinite;
    will-change: opacity;
}

@keyframes video-glitch {
    0%, 100% {
        filter: hue-rotate(0deg) saturate(1);
    }
    25% {
        filter: hue-rotate(5deg) saturate(1.2);
        transform: translateX(2px);
    }
    50% {
        filter: hue-rotate(-5deg) saturate(0.8);
    }
    75% {
        filter: hue-rotate(3deg) saturate(1.1);
        transform: translateX(-2px);
    }
}

@keyframes scanlines {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(10px);
    }
}

@keyframes flicker {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* === Bouton d'arrêt d'urgence (haut gauche) === */
.network-lost-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    transform: none;
    z-index: 200;
    background: rgba(220, 53, 69, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 12px 18px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-width: auto;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

/* Effet hover pour le bouton d'arrêt */
.network-lost-indicator:hover {
    background: rgba(200, 35, 51, 1);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.5);
}

/* Effet actif/clic */
.network-lost-indicator:active {
    transform: scale(0.95);
}

/* Visible seulement quand .loading est actif */
.santa-video-frame.loading .network-lost-indicator {
    opacity: 1;
    visibility: visible;
    animation: network-pulse 1.5s ease-in-out infinite;
}

/* Les deux états se superposent */
.network-state {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Animation d'alternance entre les deux états */
.santa-video-frame.loading .network-lost {
    animation: show-hide-lost 3s ease-in-out infinite;
}

.santa-video-frame.loading .network-recovering {
    animation: show-hide-recovering 3s ease-in-out infinite;
}

@keyframes show-hide-lost {
    0%, 45% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

@keyframes show-hide-recovering {
    0%, 50% {
        opacity: 0;
    }
    55%, 95% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

.network-state svg {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 0 10px rgba(255, 51, 51, 0.6));
}

/* Couleur rouge pour "connexion perdue" */
.network-lost svg {
    color: #ff3333;
}

/* Couleur orange pour "récupération" */
.network-recovering svg {
    color: #ff9933;
    filter: drop-shadow(0 0 10px rgba(255, 153, 51, 0.6));
}

.network-state span {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

@keyframes network-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        border-color: rgba(255, 50, 50, 0.5);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        border-color: rgba(255, 153, 51, 0.7);
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    .santa-animation-video {
        /* PAS de hauteurs fixes - s'adapte au contenu */
        padding: 45px 15px 10px 15px; /* Mobile - 45px top pour bordure visible */
    }

    .santa-video-frame {
        width: 95%;
        max-width: 380px;
        max-height: 55vh; /* Fallback */
        max-height: 55svh; /* Plus petit sur mobile */
    }

    .speech-bubble {
        font-size: 18px;
        padding: 6px 12px;
    }

    .santa-speaking-indicator {
        top: 20px;
        left: 10px;
    }

    .network-lost-indicator {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        gap: 6px;
        min-width: auto;
        min-height: auto;
        border-radius: 8px;
    }

    .network-state svg {
        width: 35px;
        height: 35px;
    }

    .network-state span {
        font-size: 11px;
    }
}

/* === Mobile + Landscape = Viewport TRÈS court === */
@media (max-width: 768px) and (orientation: landscape) {
    .santa-video-frame {
        max-height: 50vh; /* Fallback */
        max-height: 50svh; /* Encore plus petit */
        max-width: 250px;
    }

    .santa-animation-video {
        padding: 15px 10px;
    }

    .speech-bubble {
        font-size: 14px;
        padding: 4px 8px;
    }
}

/* === ÉCRAN DE DÉCONNEXION === */
.santa-video-frame::after {
    content: '📞 Déconnexion...';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 24px;
    font-weight: bold;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.santa-video-frame.disconnecting::after {
    opacity: 1;
}

/* === EFFET PARTICULES DE NOËL PENDANT LES TRANSITIONS === */
.video-transition-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

/* Visible uniquement pendant les transitions */
.santa-video-frame.transitioning .video-transition-particles {
    opacity: 1;
}

/* Particule individuelle - VERSION LÉGÈRE */
.transition-particle {
    position: absolute;
    top: -10%;
    font-size: 16px;
    animation: particle-fall linear forwards;
    will-change: transform;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.7));
}

/* Animation de chute */
@keyframes particle-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(360deg);
        opacity: 0.3;
    }
}

/* Variations de taille - VERSION LÉGÈRE */
.transition-particle.small {
    font-size: 12px;
    animation-duration: 1.5s;
}

.transition-particle.medium {
    font-size: 16px;
    animation-duration: 1.8s;
}

.transition-particle.large {
    font-size: 20px;
    animation-duration: 2s;
}
