/**
 * LIVE SORTEO - Componente de transmisión en vivo
 * Desktop: barra fija debajo del navbar (slide-down)
 * Móvil:   modal centrado con overlay oscuro
 */

/* ===== BANNER DESKTOP (debajo del navbar) ===== */
#live-sorteo-banner {
    display: none; /* Oculto en móvil — se activa en desktop con media query */
}

/* ===== OVERLAY (solo visible en móvil) ===== */
#live-sorteo-overlay {
    display: none;
}

/* ===== SECCIÓN PRINCIPAL — DESKTOP ===== */
#live-sorteo-section {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    z-index: 1025;
    background: rgba(10, 25, 47, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 2px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 215, 0, 0.06);
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}

#live-sorteo-section.live-sorteo--visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.live-sorteo-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 20px;
}

/* ===== ENCABEZADO ===== */
.live-sorteo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.live-sorteo-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--secondary-gold);
    font-family: 'Cinzel', serif;
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.live-sorteo-close {
    background: transparent;
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: rgba(255, 255, 255, 0.6);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
    flex-shrink: 0;
}

.live-sorteo-close:hover {
    background: rgba(255, 215, 0, 0.1);
    color: var(--secondary-gold);
    border-color: rgba(255, 215, 0, 0.6);
}

/* Countdown dentro del header de la sección — solo desktop */
.live-section-countdown {
    display: none;
}

/* "Gira tu teléfono" — nunca en desktop */
.live-rotate-hint {
    display: none;
}

/* ===== BADGE "EN VIVO" ===== */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid rgba(244, 67, 54, 0.4);
    border-radius: 20px;
    padding: 4px 10px;
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #ff5252;
    flex-shrink: 0;
}

.live-badge-dot {
    width: 7px;
    height: 7px;
    background: #f44336;
    border-radius: 50%;
    flex-shrink: 0;
    animation: liveDotPulse 1.2s ease-in-out infinite;
}

@keyframes liveDotPulse {
    0%   { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7); }
    70%  { box-shadow: 0 0 0 6px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}

/* ===== IFRAME RESPONSIVE 16:9 ===== */
.live-sorteo-iframe-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 215, 0, 0.2);
    background: #000;
}

.live-sorteo-iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== BOTÓN FLOTANTE ===== */
#live-sorteo-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 1028;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    transform: translateY(80px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
    text-align: left;
}

#live-sorteo-btn.live-sorteo-btn--visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

#live-sorteo-btn:hover .live-sorteo-btn-label {
    box-shadow: 0 6px 28px rgba(255, 215, 0, 0.65), 0 2px 10px rgba(0, 0, 0, 0.4);
    transform: translateY(-1px);
}

.live-sorteo-btn-inner {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Línea superior: cuenta regresiva */
.live-sorteo-countdown {
    display: block;
    background: rgba(10, 25, 47, 0.92);
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-radius: 20px;
    padding: 4px 12px;
    color: rgba(255, 255, 255, 0.75);
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: color 0.3s ease;
}

.live-sorteo-countdown.live-countdown--vivo {
    color: #ff5252;
    border-color: rgba(244, 67, 54, 0.4);
    background: rgba(244, 67, 54, 0.1);
    animation: liveDotPulse 1.2s ease-in-out infinite;
}

/* Línea inferior: botón principal */
.live-sorteo-btn-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    background: linear-gradient(135deg, var(--secondary-gold), var(--secondary-gold-dark));
    color: var(--primary-blue-dark);
    border-radius: 50px;
    font-family: 'Cinzel', serif;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: btnGlow 2.5s ease-in-out infinite;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3); }
    50%       { box-shadow: 0 4px 32px rgba(255, 215, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.3); }
}

/* ===== DESKTOP: BANNER Y AJUSTES ===== */
@media (min-width: 769px) {

    /* Ocultar botón flotante en desktop — el banner lo reemplaza */
    #live-sorteo-btn {
        display: none;
    }

    /* Banner visible solo en desktop */
    #live-sorteo-banner {
        display: block;
        position: fixed;
        top: 80px;
        left: 0;
        right: 0;
        z-index: 1022;
        height: 48px;
        background: linear-gradient(90deg, rgba(10, 25, 47, 0.98) 0%, rgba(15, 35, 65, 0.98) 50%, rgba(10, 25, 47, 0.98) 100%);
        border-bottom: 1px solid rgba(255, 215, 0, 0.25);
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
        overflow: hidden;
    }

    /* Shimmer sutil de fondo */
    #live-sorteo-banner::before {
        content: '';
        position: absolute;
        top: 0; left: -100%;
        width: 40%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.06), transparent);
        animation: shine 4s infinite;
    }

    #live-sorteo-banner.live-sorteo-banner--visible {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }

    #live-sorteo-banner.live-sorteo-banner--hidden {
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .live-sorteo-banner-inner {
        max-width: 1400px;
        margin: 0 auto;
        padding: 0 24px;
        height: 100%;
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .live-sorteo-banner-text {
        color: rgba(255, 255, 255, 0.7);
        font-family: 'Cinzel', serif;
        font-size: 0.8rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        flex: 1;
    }

    .live-sorteo-banner-countdown {
        color: var(--secondary-gold);
        font-family: var(--font-primary);
        font-size: 0.9rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        min-width: 120px;
        text-align: right;
    }

    .live-sorteo-banner-countdown.live-countdown--vivo {
        color: #ff5252;
        animation: liveDotPulse 1.2s ease-in-out infinite;
    }

    .live-sorteo-banner-cta {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 8px 18px;
        background: linear-gradient(135deg, var(--secondary-gold), var(--secondary-gold-dark));
        color: var(--primary-blue-dark);
        border: none;
        border-radius: 50px;
        cursor: pointer;
        font-family: 'Cinzel', serif;
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        white-space: nowrap;
        box-shadow: 0 2px 12px rgba(255, 215, 0, 0.35);
        transition: box-shadow 0.2s ease, transform 0.2s ease;
    }

    .live-sorteo-banner-cta:hover {
        box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
        transform: translateY(-1px);
    }

    .live-sorteo-banner-cta i {
        font-size: 0.7rem;
    }

    /* Countdown en el header del modal — visible solo en desktop */
    .live-section-countdown {
        display: inline-flex;
        align-items: center;
        color: rgba(255, 255, 255, 0.55);
        font-family: var(--font-primary);
        font-size: 0.8rem;
        font-weight: 500;
        letter-spacing: 0.02em;
    }

    .live-section-countdown::before {
        content: '·';
        margin: 0 8px;
        color: rgba(255, 215, 0, 0.3);
    }

    .live-section-countdown.live-countdown--vivo {
        color: #ff5252;
    }

    /* ── Sección ocupa toda la pantalla disponible debajo del navbar ── */
    #live-sorteo-section {
        height: calc(100vh - 80px);
    }

    .live-sorteo-inner {
        height: 100%;
        max-width: 1400px;
        display: flex;
        flex-direction: column;
        padding: 12px 24px 16px;
    }

    .live-sorteo-header {
        flex-shrink: 0;
    }

    /* En desktop el iframe llena todo el espacio restante (sin ratio fijo) */
    .live-sorteo-iframe-wrapper {
        flex: 1;
        padding-bottom: 0;
        height: 0; /* flex: 1 maneja el alto */
        overflow: hidden;
    }

    /* Zoom-out: iframe renderiza más grande y se escala visualmente para mostrar todo */
    .live-sorteo-iframe-wrapper iframe {
        width: calc(100% / 0.62);
        height: calc(100% / 0.62);
        top: 0;
        left: 0;
        transform: scale(0.62);
        transform-origin: top left;
    }
}

/* ===== MÓVIL: MODAL CENTRADO ===== */
@media (max-width: 768px) {

    /* Overlay oscuro de fondo */
    #live-sorteo-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1033;
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.35s ease;
    }

    #live-sorteo-overlay.live-sorteo--visible {
        opacity: 1;
        pointer-events: all;
    }

    /* Panel modal — portrait (vertical) */
    #live-sorteo-section {
        top: 50%;
        left: 50%;
        right: auto;
        width: 92vw;
        max-width: 420px;
        border-radius: 20px;
        border: 1px solid rgba(255, 215, 0, 0.35);
        border-bottom: 1px solid rgba(255, 215, 0, 0.35);
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(255, 215, 0, 0.1);
        z-index: 1035;
        transform: translate(-50%, -50%) scale(0.92);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
    }

    #live-sorteo-section.live-sorteo--visible {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        pointer-events: all;
    }

    /* Zoom-out portrait: iframe renderiza más ancho para mostrar las 3 máquinas */
    .live-sorteo-iframe-wrapper iframe {
        width: calc(100% / 0.46);
        height: calc(100% / 0.46);
        transform: scale(0.46);
        transform-origin: top left;
    }

    /* ── Rotación landscape (portrait con clase JS) ── */
    #live-sorteo-section.live-sorteo--rotado {
        /* Girar 90°: el ancho del panel pasa a ser el alto visual */
        width: 100vh;
        max-width: 100vh;
        border-radius: 0;
        transform: translate(-50%, -50%) rotate(90deg) scale(0.92);
    }

    #live-sorteo-section.live-sorteo--rotado.live-sorteo--visible {
        transform: translate(-50%, -50%) rotate(90deg) scale(1);
    }

    /* Iframe ocupa todo el alto disponible al girar */
    #live-sorteo-section.live-sorteo--rotado .live-sorteo-iframe-wrapper {
        padding-bottom: 0;
        height: calc(100vw - 64px);
        overflow: hidden;
    }

    /* Zoom-out: toda la escala reducida para mostrar las 3 máquinas */
    #live-sorteo-section.live-sorteo--rotado .live-sorteo-iframe-wrapper iframe {
        width: calc(100% / 0.45);
        height: calc(100% / 0.45);
        top: 0;
        left: 0;
        transform: scale(0.45);
        transform-origin: top left;
    }

    /* Hint "Gira tu teléfono" — solo visible en modo rotado */
    .live-rotate-hint {
        display: none;
    }

    #live-sorteo-section.live-sorteo--rotado .live-rotate-hint {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        color: rgba(255, 255, 255, 0.55);
        font-family: var(--font-primary);
        font-size: 0.72rem;
        font-weight: 500;
        letter-spacing: 0.03em;
        animation: hintFade 2.5s ease-in-out infinite;
    }

    #live-sorteo-section.live-sorteo--rotado .live-rotate-hint i {
        font-size: 0.85rem;
        transform: rotate(90deg);
    }

    @keyframes hintFade {
        0%, 100% { opacity: 0.5; }
        50%       { opacity: 1; }
    }

    /* Header compacto en modo rotado para no perder espacio */
    #live-sorteo-section.live-sorteo--rotado .live-sorteo-inner {
        padding: 10px 12px;
    }

    #live-sorteo-section.live-sorteo--rotado .live-sorteo-header {
        margin-bottom: 8px;
    }

    #live-sorteo-section.live-sorteo--rotado .live-sorteo-title > span:last-child {
        display: none; /* Ocultar texto largo, solo queda el badge EN VIVO */
    }

    .live-sorteo-inner {
        padding: 16px;
    }

    .live-sorteo-title {
        font-size: 0.95rem;
    }

    /* Botón centrado en la parte inferior */
    #live-sorteo-btn {
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%) translateY(80px);
        text-align: center;
    }

    #live-sorteo-btn.live-sorteo-btn--visible {
        transform: translateX(-50%) translateY(0);
    }

    #live-sorteo-btn:hover .live-sorteo-btn-label {
        transform: translateY(-1px);
    }

    .live-sorteo-btn-inner {
        align-items: center;
    }

    .live-sorteo-countdown {
        font-size: 0.72rem;
    }

    .live-sorteo-btn-label {
        font-size: 0.82rem;
        padding: 10px 18px;
    }
}
