/* ============================================
   LOADER MUNDIAL 2026 - Alcaldía Bolivariana JEL
   Animación de carga temática Copa Mundial FIFA 2026
   Colores oficiales basados en el escudo del torneo
   ============================================ */

/* Variables de colores del Mundial 2026 (basados en el escudo oficial) */
:root {
    /* Colores reales del logo 2026 */
    --mundial-navy: #081E43;        /* Azul profundo */
    --mundial-blue: #0E5CA7;        /* Azul brillante */
    --mundial-cyan: #18DAD4;        /* Aqua/cián vibrante */
    --mundial-red: #D3272D;         /* Rojo oficial */
    --mundial-gold: #F4B840;        /* Dorado oficial */
    --mundial-gold-light: #FFE19C;  /* Dorado claro */
    --mundial-white: #FFFFFF;
    --mundial-bg-dark: #050D1A;     /* Fondo muy oscuro */
}

/* Overlay del loader */
#mundial-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top, rgba(24, 218, 212, 0.15), transparent 22%),
        linear-gradient(180deg, rgba(8, 30, 67, 0.96) 0%, rgba(6, 15, 34, 0.98) 60%, var(--mundial-bg-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
    overflow: hidden;
}

#mundial-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Fondo animado con patrón geométrico */
#mundial-loader::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(24, 218, 212, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 25%, rgba(244, 184, 64, 0.08) 0%, transparent 35%),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23F4B840' fill-opacity='0.04'%3E%3Cpath d='M50 0 L100 25 L100 75 L50 100 L0 75 L0 25 Z M50 10 L86 28 L86 72 L50 90 L14 72 L14 28 Z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.65;
    animation: bgPulse 5s ease-in-out infinite;
}

@keyframes bgPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Partículas flotantes de fondo */
.particles {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: particleFloat linear infinite;
}

.particle:nth-child(1) { width: 4px; height: 4px; background: var(--mundial-gold); top: 10%; left: 10%; animation-duration: 8s; animation-delay: 0s; }
.particle:nth-child(2) { width: 6px; height: 6px; background: var(--mundial-red); top: 20%; left: 80%; animation-duration: 10s; animation-delay: 1s; }
.particle:nth-child(3) { width: 3px; height: 3px; background: var(--mundial-gold-light); top: 60%; left: 15%; animation-duration: 12s; animation-delay: 2s; }
.particle:nth-child(4) { width: 5px; height: 5px; background: var(--mundial-navy-light); top: 70%; left: 85%; animation-duration: 9s; animation-delay: 0.5s; box-shadow: 0 0 6px var(--mundial-gold); }
.particle:nth-child(5) { width: 4px; height: 4px; background: var(--mundial-gold); top: 40%; left: 50%; animation-duration: 11s; animation-delay: 3s; }
.particle:nth-child(6) { width: 7px; height: 7px; background: var(--mundial-red); top: 80%; left: 30%; animation-duration: 13s; animation-delay: 1.5s; }
.particle:nth-child(7) { width: 3px; height: 3px; background: var(--mundial-gold-light); top: 15%; left: 60%; animation-duration: 7s; animation-delay: 4s; }
.particle:nth-child(8) { width: 5px; height: 5px; background: var(--mundial-navy-light); top: 90%; left: 70%; animation-duration: 14s; animation-delay: 2.5s; box-shadow: 0 0 6px var(--mundial-gold); }

@keyframes particleFloat {
    0% { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100vh) translateX(50px) scale(0.5); opacity: 0; }
}

/* Contenedor principal del loader */
.loader-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

/* ============================================
   ESCUDO MUNDIAL 2026 - Diseño inspirado en el logo oficial
   Colores: Navy, Red/Burgundy, Gold
   ============================================ */
.mundial-shield {
    position: relative;
    width: 200px;
    height: 220px;
    animation: shieldFloat 3s ease-in-out infinite;
}

@keyframes shieldFloat {
    0%, 100% { transform: translateY(0) rotateY(0deg); }
    50% { transform: translateY(-15px) rotateY(8deg); }
}

/* Forma principal del escudo - inspirada en el logo oficial 2026 */
.shield-shape {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 20%, rgba(24, 218, 212, 0.28), transparent 40%),
        linear-gradient(180deg, var(--mundial-blue) 0%, var(--mundial-navy) 62%, rgba(0, 0, 0, 0.95) 100%);
    clip-path: polygon(50% 0%, 100% 18%, 100% 76%, 50% 100%, 0% 76%, 0% 18%);
    box-shadow: 
        0 0 45px rgba(8, 30, 67, 0.9),
        inset 0 0 32px rgba(24, 218, 212, 0.18);
    animation: shieldGlow 4s ease-in-out infinite;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.shield-logo {
    position: absolute;
    top: 18%;
    left: 50%;
    width: 86%;
    height: 54%;
    transform: translateX(-50%);
    border-radius: 24% 24% 32% 32% / 26% 26% 58% 58%;
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03) 32%, transparent 70%),
        url('https://preview.redd.it/world-cup-2026-logos-v0-qjko22j3gqke1.png?width=640&crop=smart&auto=webp&s=a411c44331e2da2e2c7f059a744a1ba7840524f4');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    box-shadow:
        inset 0 0 22px rgba(0, 0, 0, 0.22),
        0 0 28px rgba(24, 218, 212, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    z-index: 3;
}

.shield-logo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 14%, rgba(255,255,255,0.35), transparent 24%),
        linear-gradient(180deg, rgba(255,255,255,0.24), transparent 42%);
    opacity: 0.85;
    pointer-events: none;
}
@keyframes shieldGlow {
    0%, 100% { 
        box-shadow: 
            0 0 40px rgba(10, 22, 40, 0.8),
            0 0 80px rgba(139, 21, 56, 0.3),
            inset 0 0 30px rgba(200, 162, 61, 0.15);
    }
    50% { 
        box-shadow: 
            0 0 60px rgba(10, 22, 40, 1),
            0 0 120px rgba(139, 21, 56, 0.5),
            inset 0 0 50px rgba(200, 162, 61, 0.3);
    }
}

/* Borde dorado del escudo */
.shield-border {
    position: absolute;
    top: -4px;
    left: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    background: linear-gradient(135deg, var(--mundial-gold) 0%, var(--mundial-gold-light) 50%, var(--mundial-gold) 100%);
    clip-path: polygon(50% 0%, 100% 15%, 100% 75%, 50% 100%, 0% 75%, 0% 15%);
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite;
}

@keyframes borderGlow {
    0%, 100% { 
        filter: brightness(1);
        box-shadow: 0 0 20px var(--mundial-gold);
    }
    50% { 
        filter: brightness(1.2);
        box-shadow: 0 0 40px var(--mundial-gold), 0 0 60px rgba(200, 162, 61, 0.3);
    }
}

/* Texto "2026" en el escudo */
.shield-year {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.2rem;
    font-weight: 900;
    color: var(--mundial-white);
    text-shadow: 
        0 0 20px var(--mundial-gold),
        0 0 40px var(--mundial-gold),
        0 0 60px var(--mundial-red);
    z-index: 2;
    animation: yearPulse 2.5s ease-in-out infinite;
    letter-spacing: 4px;
}

@keyframes yearPulse {
    0%, 100% { 
        text-shadow: 
            0 0 20px var(--mundial-gold),
            0 0 40px var(--mundial-gold),
            0 0 60px var(--mundial-red);
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        text-shadow: 
            0 0 30px var(--mundial-gold),
            0 0 60px var(--mundial-gold),
            0 0 90px var(--mundial-red),
            0 0 120px var(--mundial-red-light);
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* Líneas decorativas del escudo (inspiradas en el diseño oficial) */
.shield-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    clip-path: polygon(50% 0%, 100% 15%, 100% 75%, 50% 100%, 0% 75%, 0% 15%);
}

.shield-line {
    position: absolute;
    background: linear-gradient(180deg, transparent, var(--mundial-gold), transparent);
    opacity: 0.3;
}

.shield-line:nth-child(1) {
    width: 2px;
    height: 100%;
    left: 30%;
    top: 0;
    animation: lineFade 3s ease-in-out infinite;
}

.shield-line:nth-child(2) {
    width: 2px;
    height: 100%;
    left: 70%;
    top: 0;
    animation: lineFade 3s ease-in-out infinite 0.5s;
}

.shield-line:nth-child(3) {
    width: 100%;
    height: 2px;
    top: 35%;
    left: 0;
    animation: lineFade 3s ease-in-out infinite 1s;
}

@keyframes lineFade {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.4; }
}

/* Balón de fútbol dentro del escudo */
.soccer-ball-mini {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: transparent url('../img/soccer-ball-spinner.png') center/92% 92% no-repeat;
    border: 2px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 24px rgba(255, 255, 255, 0.35), inset 0 0 16px rgba(0, 0, 0, 0.16);
    animation: miniBallSpin 3s linear infinite;
    z-index: 3;
}

.soccer-ball-mini::before,
.soccer-ball-mini::after {
    content: none;
}

@keyframes miniBallSpin {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

/* Líneas de energía alrededor del escudo */
.energy-lines {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 280px;
}

.energy-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 220px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--mundial-gold), transparent);
    transform-origin: left center;
    animation: energyRotate 5s linear infinite;
    opacity: 0.5;
}

.energy-line:nth-child(1) { animation-delay: 0s; }
.energy-line:nth-child(2) { animation-delay: -0.8s; transform: rotate(60deg); transform-origin: left center; }
.energy-line:nth-child(3) { animation-delay: -1.6s; transform: rotate(120deg); transform-origin: left center; }
.energy-line:nth-child(4) { animation-delay: -2.4s; transform: rotate(180deg); transform-origin: left center; }
.energy-line:nth-child(5) { animation-delay: -0.4s; transform: rotate(240deg); transform-origin: left center; }
.energy-line:nth-child(6) { animation-delay: -1.2s; transform: rotate(300deg); transform-origin: left center; }

@keyframes energyRotate {
    0% { 
        transform: rotate(var(--rotation, 0deg)) scaleX(0.3);
        opacity: 0;
    }
    30% { opacity: 0.6; }
    70% { 
        transform: rotate(var(--rotation, 0deg)) scaleX(1);
        opacity: 0.8;
    }
    100% { 
        transform: rotate(var(--rotation, 0deg)) scaleX(0.3);
        opacity: 0;
    }
}

/* ============================================
   TEXTO DEL LOADER
   ============================================ */
.loader-text {
    text-align: center;
    color: var(--mundial-white);
}

.loader-title {
    font-size: 2.4rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 5px;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, var(--mundial-cyan), var(--mundial-gold), var(--mundial-red), var(--mundial-cyan));
    background-size: 400% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textShimmer 4s ease-in-out infinite;
    filter: drop-shadow(0 0 14px rgba(24, 218, 212, 0.45));
}

@keyframes textShimmer {
    0% { background-position: 0% center; }
    100% { background-position: 400% center; }
}

.loader-subtitle {
    font-size: 1.1rem;
    font-weight: 500;
    color: rgba(244, 184, 64, 0.95);
    letter-spacing: 6px;
    text-transform: uppercase;
    animation: subtitlePulse 3s ease-in-out infinite;
}

@keyframes subtitlePulse {
    0%, 100% { opacity: 0.7; letter-spacing: 6px; }
    50% { opacity: 1; letter-spacing: 8px; }
}

/* ============================================
   BARRA DE PROGRESO OFICIAL
   ============================================ */
.loader-progress-container {
    width: 380px;
    max-width: 80vw;
    position: relative;
}

.loader-progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: 
        0 0 10px rgba(200, 162, 61, 0.2),
        inset 0 0 10px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(200, 162, 61, 0.2);
}

.loader-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, 
        var(--mundial-cyan) 0%, 
        var(--mundial-blue) 20%, 
        var(--mundial-gold) 45%, 
        var(--mundial-red) 75%, 
        var(--mundial-navy) 100%);
    background-size: 300% 100%;
    border-radius: 10px;
    animation: progressGradient 3s linear infinite, progressBar 7s ease-in-out infinite;
    box-shadow: 
        0 0 18px rgba(244, 184, 64, 0.7),
        inset 0 0 12px rgba(24, 218, 212, 0.5);
    position: relative;
}

.loader-progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.4), transparent);
    border-radius: 10px 10px 0 0;
}

.loader-progress-bar::after {
    content: '';
    position: absolute;
    right: -5px;
    top: -4px;
    width: 16px;
    height: 16px;
    background: var(--mundial-white);
    border-radius: 50%;
    box-shadow: 
        0 0 10px var(--mundial-gold),
        0 0 20px var(--mundial-gold),
        0 0 30px var(--mundial-gold),
        0 0 40px var(--mundial-red);
    animation: progressDot 1s ease-in-out infinite alternate;
}

@keyframes progressDot {
    0% { transform: scale(1); }
    100% { transform: scale(1.3); }
}

@keyframes progressGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 300% 50%; }
}

@keyframes progressBar {
    0% { width: 0%; }
    15% { width: 15%; }
    30% { width: 30%; }
    50% { width: 50%; }
    65% { width: 65%; }
    80% { width: 80%; }
    95% { width: 95%; }
    100% { width: 100%; }
}

/* Porcentaje de carga */
.loader-percentage {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--mundial-gold);
    font-weight: 600;
    letter-spacing: 3px;
    animation: percentagePulse 2s ease-in-out infinite;
}

@keyframes percentagePulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============================================
   FRASE INSTITUCIONAL - PAZ, AMOR Y TRABAJO
   ============================================ */
.loader-phrase {
    margin-top: 1rem;
    text-align: center;
}

.phrase-text {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    background: linear-gradient(90deg, 
        var(--mundial-gold) 0%, 
        var(--mundial-red-light) 25%, 
        var(--mundial-white) 50%, 
        var(--mundial-gold-light) 75%, 
        var(--mundial-gold) 100%);
    background-size: 300% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: phraseShimmer 5s linear infinite;
    filter: drop-shadow(0 0 8px rgba(200, 162, 61, 0.5));
}

@keyframes phraseShimmer {
    0% { background-position: 0% center; }
    100% { background-position: 300% center; }
}

.phrase-text {
    color: var(--mundial-gold);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 5px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(244, 184, 64, 0.6), 0 0 18px rgba(255, 255, 255, 0.12);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
}

/* Separadores decorativos */
.phrase-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.phrase-separator::before,
.phrase-separator::after {
    content: '';
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--mundial-gold), transparent);
    animation: separatorPulse 2s ease-in-out infinite;
}

@keyframes separatorPulse {
    0%, 100% { opacity: 0.4; width: 50px; }
    50% { opacity: 1; width: 70px; }
}

.phrase-dot {
    width: 8px;
    height: 8px;
    background: var(--mundial-gold);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--mundial-gold), 0 0 20px rgba(200, 162, 61, 0.3);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.5); opacity: 1; }
}

/* ============================================
   EFECTO DE ONDA EXPANSIVA
   ============================================ */
.shockwave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    border: 2px solid var(--mundial-gold);
    border-radius: 50%;
    animation: shockwaveExpand 4s ease-out infinite;
    opacity: 0;
}

.shockwave:nth-child(1) { animation-delay: 0s; }
.shockwave:nth-child(2) { animation-delay: 1.3s; border-color: var(--mundial-red); }
.shockwave:nth-child(3) { animation-delay: 2.6s; border-color: var(--mundial-gold-light); }

@keyframes shockwaveExpand {
    0% { 
        width: 100px;
        height: 100px;
        opacity: 0.7;
    }
    100% { 
        width: 500px;
        height: 500px;
        opacity: 0;
    }
}

/* ============================================
   VERSIÓN REDUCIDA (MÓVIL)
   ============================================ */
@media (max-width: 768px) {
    .mundial-shield {
        width: 150px;
        height: 165px;
    }
    
    .shield-year {
        font-size: 2.4rem;
    }
    
    .soccer-ball-mini {
        width: 45px;
        height: 45px;
        top: -20px;
    }
    
    .energy-lines {
        width: 220px;
        height: 220px;
    }
    
    .energy-line {
        width: 170px;
    }
    
    .loader-title {
        font-size: 1.6rem;
        letter-spacing: 3px;
    }
    
    .loader-subtitle {
        font-size: 0.9rem;
        letter-spacing: 3px;
    }
    
    .loader-progress-container {
        width: 280px;
    }
    
    .phrase-text {
        font-size: 1.1rem;
        letter-spacing: 2px;
    }
}

@media (max-width: 480px) {
    .mundial-shield {
        width: 120px;
        height: 132px;
    }
    
    .shield-year {
        font-size: 2rem;
        letter-spacing: 2px;
    }
    
    .soccer-ball-mini {
        width: 35px;
        height: 35px;
        top: -15px;
    }
    
    .energy-lines {
        width: 180px;
        height: 180px;
    }
    
    .energy-line {
        width: 140px;
    }
    
    .loader-title {
        font-size: 1.3rem;
        letter-spacing: 2px;
    }
    
    .loader-subtitle {
        font-size: 0.75rem;
        letter-spacing: 2px;
    }
    
    .loader-progress-container {
        width: 220px;
    }
    
    .phrase-text {
        font-size: 0.95rem;
        letter-spacing: 2px;
    }
    
    .phrase-separator::before,
    .phrase-separator::after {
        width: 35px;
    }
}

/* ============================================
   EFECTO DE CARGA COMPLETADA
   ============================================ */
#mundial-loader.loaded .mundial-shield {
    animation: shieldSuccess 0.8s ease-out forwards;
}

@keyframes shieldSuccess {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(2.5); opacity: 0; }
}

#mundial-loader.loaded .loader-progress-bar {
    animation: progressComplete 0.5s ease-out forwards;
}

@keyframes progressComplete {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Animación de explosión de partículas al completar */
#mundial-loader.loaded::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: var(--mundial-gold);
    border-radius: 50%;
    animation: explosion 1s ease-out forwards;
    box-shadow: 
        0 0 50px var(--mundial-gold),
        0 0 100px var(--mundial-red),
        0 0 150px var(--mundial-navy),
        0 0 200px var(--mundial-gold-light);
}

@keyframes explosion {
    0% { 
        transform: scale(1);
        opacity: 1;
    }
    100% { 
        transform: scale(60);
        opacity: 0;
    }
}