/**
 * Framework - Estilos para Banners Publicitarios
 * 
 * Sistema anti-pixelado con reserva de espacio y renderizado responsive.
 * Basado en especificación de formatos estándar de AdsAdmin.
 * 
 * Compartido entre todos los portales del framework.
 */

/* ============================================
   SLOT DE BANNER - Contenedor Principal
   ============================================ */

.ad-slot {
    /* Tope = tamaño del formato (evita upscaling) */
    max-width: calc(var(--ad-w, 300) * 1px);

    /* Reserva espacio antes de cargar (evita layout shift) */
    aspect-ratio: var(--ad-w, 300) / var(--ad-h, 250);

    /* Centrado automático */
    margin-inline: auto;

    /* Background durante carga */
    background-color: #f4f4f5;

    /* Contenedor flexible */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Posicionamiento para tracking pixel */
    position: relative;

    /* Overflow oculto por seguridad */
    overflow: hidden;

    /* Borde sutil (opcional) */
    border: 1px solid #e4e4e7;
    border-radius: 4px;
}

/* Variante sin fondo ni borde (para banners con fondo propio) */
.ad-slot--transparent {
    background-color: transparent;
    border: none;
}

/* ============================================
   IMAGEN DEL BANNER
   ============================================ */

.ad-slot img {
    /* CRÍTICO: Tope = tamaño del formato (anti-upscaling) */
    max-width: calc(var(--ad-w, 300) * 1px);
    max-height: calc(var(--ad-h, 250) * 1px);

    /* Fit sin deformación */
    object-fit: contain;

    /* Dimensiones naturales (responsive) */
    width: auto;
    height: auto;

    /* Centrado automático */
    display: block;
}

/* ============================================
   ENLACE WRAPPER
   ============================================ */

.ad-slot a {
    /* Ocupa todo el slot */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Sin decoración */
    text-decoration: none;

    /* Cursor pointer */
    cursor: pointer;

    /* Transición sutil */
    transition: opacity 0.2s ease;
}

.ad-slot a:hover {
    opacity: 0.95;
}

/* ============================================
   ZONAS ESPECÍFICAS
   ============================================ */

/* Zona: full-horizontal-1 (portada horizontal) */
.zona-publicitaria.zona-full-horizontal-1 {
    margin-block: 2rem;
}

/* Zona: flotante-horizontal (zócalo móvil) */
.zona-publicitaria.zona-flotante-horizontal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Botón de cerrar en flotante */
.zona-flotante-horizontal .ad-close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.zona-flotante-horizontal .ad-close-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* ============================================
   ESTADOS DE CARGA
   ============================================ */

/* Loading state */
.ad-slot[data-loading="true"] {
    min-height: 100px;
}

.ad-slot[data-loading="true"]::after {
    content: "Cargando publicidad...";
    font-size: 0.875rem;
    color: #71717a;
}

/* Error state (oculto por defecto) */
.ad-slot[data-error="true"] {
    display: none;
}

/* ============================================
   RESPONSIVE - Mobile First
   ============================================ */

@media (max-width: 768px) {

    /* En móvil, los banners de PC se ocultan */
    .ad-slot[data-device="pc"] {
        display: none;
    }

    /* Banners móviles ocupan todo el ancho disponible */
    .ad-slot[data-device="movil"] {
        max-width: 100%;
    }

    /* Reducir márgenes en móvil */
    .zona-publicitaria {
        margin-block: 1rem;
    }
}

@media (min-width: 769px) {

    /* En desktop, los banners móviles se ocultan */
    .ad-slot[data-device="movil"] {
        display: none;
    }

    /* Separación vertical homogénea de los slots publicitarios entre módulos de Portada */
    .modulos-dinamicos > .zona-publicitaria {
        margin-block: 1.5rem;
    }
}

/* ============================================
   UTILIDADES
   ============================================ */

/* Centrado de zona */
.zona-publicitaria {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Ocultar zona completa si está vacía */
.zona-publicitaria:empty {
    display: none;
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

/* Skip link para saltar publicidad */
.ad-skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999;
}

.ad-skip-link:focus {
    left: 0;
    top: 0;
    background: white;
    padding: 0.5rem 1rem;
    border: 2px solid #000;
}

/* Indicador de publicidad (screen readers) */
.ad-label {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}