/**
 * Estilos de Vídeos Destacados - Divi Phergal
 * 
 * Hoja de estilos responsiva para la galería de vídeos destacados.
 * Incluye soporte completo para accesibilidad, CSS custom properties
 * para personalización, y responde a diferentes tamaños de pantalla.
 * 
 * Estructura de breakpoints:
 * - Desktop (≥1025px): 4 columnas
 * - Tablet (769–1024px): 3 columnas  
 * - Mobile (481–768px): 2 columnas
 * - Small mobile (≤480px): 1 columna
 * 
 * @package PhergalVideos
 * @since 1.0.0
 */

/* ========================================
   VARIABLES CSS (Custom Properties)
   ======================================== */

:root {
    /* Colores base */
    --vd-bg: #ffffff;
    --vd-text: #333333;
    --vd-muted: #666666;
    --vd-accent: #e74c3c;
    --vd-border: #e0e0e0;
    --vd-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --vd-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.15);
    
    /* Diseño */
    --vd-radius: 8px;
    --vd-gap: 20px;
    --vd-gap-small: 12px;
    
    /* Accesibilidad */
    --vd-focus-ring: 2px solid #4a90e2;
    --vd-focus-offset: 2px;
    
    /* Tipografía */
    --vd-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --vd-font-size-title: 1.25rem;
    --vd-font-size-card-title: 1rem;
    --vd-font-size-meta: 0.875rem;
    --vd-line-height-compact: 1.3;
    
    /* Transiciones (respetan prefers-reduced-motion) */
    --vd-transition: all 0.3s ease;
}

/* Respetar preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    :root {
        --vd-transition: none;
    }
}

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */

.videos-destacados {
    background-color: var(--vd-bg);
    color: var(--vd-text);
    padding: var(--vd-gap);
    font-family: var(--vd-font-family);
    line-height: 1.5;
}

/* Barra de encabezado con título y CTA */
.vd-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--vd-gap);
    margin-bottom: var(--vd-gap);
    flex-wrap: wrap;
}

/* Título de la sección */
.vd-section-title {
    font-size: var(--vd-font-size-title);
    font-weight: 600;
    margin: 0;
    padding: 0;
    color: var(--vd-text);
    letter-spacing: -0.3px;
}

/* Enlace CTA (Ver todos los vídeos) */
.vd-cta {
    color: var(--vd-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: var(--vd-radius);
    transition: var(--vd-transition);
    display: inline-block;
}

.vd-cta:hover,
.vd-cta:active {
    text-decoration: underline;
    color: var(--vd-accent);
    opacity: 0.8;
}

/* Focus ring para accesibilidad */
.vd-cta:focus {
    outline: var(--vd-focus-ring);
    outline-offset: var(--vd-focus-offset);
}

/* ========================================
   CONTENEDOR CARROUSEL
   ======================================== */

.vd-carousel-wrapper {
    position: relative;
    margin-bottom: var(--vd-gap);
}

.vd-carousel {
    display: grid;
    gap: var(--vd-gap);
    grid-template-columns: repeat(4, 1fr);
    list-style: none;
    margin: 0;
    padding: 0;
    /* Grid por defecto Desktop */
}

/* ========================================
   TARJETAS DE VÍDEO
   ======================================== */

.vd-card {
    display: flex;
    flex-direction: column;
    border-radius: var(--vd-radius);
    overflow: hidden;
    transition: var(--vd-transition);
    background: var(--vd-bg);
    border: 1px solid var(--vd-border);
    /* Visibilidad controlada por JavaScript */
    opacity: 1;
}

/* Ocultar tarjetas no visibles (paginación) */
.vd-card.vd-hidden {
    display: none;
}

/* Hover: elevar sombra */
.vd-card:hover {
    box-shadow: var(--vd-shadow-hover);
    transform: translateY(-2px);
}

/* Focus-within para accesibilidad */
.vd-card:focus-within {
    box-shadow: var(--vd-shadow-hover), 0 0 0 3px rgba(74, 144, 226, 0.2);
}

/* ========================================
   MINIATURA (THUMB) DEL VÍDEO
   ======================================== */

.vd-thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: #f0f0f0;
    text-decoration: none;
    border-radius: var(--vd-radius);
}

/* Imagen dentro del thumb */
.vd-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--vd-transition);
    display: block;
}

/* Hover en thumb: zoom suave */
.vd-thumb:hover img {
    transform: scale(1.05);
}

/* ========================================
   OVERLAY DEL PLAY
   ======================================== */

.vd-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    transition: var(--vd-transition);
    line-height: 1;
}

/* Mostrar play en hover o focus */
.vd-thumb:hover .vd-play,
.vd-thumb:focus .vd-play {
    opacity: 1;
}

/* Animación del play en hover (pulse suave) */
.vd-thumb:hover .vd-play {
    animation: vd-pulse 0.6s ease-in-out infinite;
}

@keyframes vd-pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        background-color: rgba(0, 0, 0, 0.85);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ========================================
   DURACIÓN DEL VÍDEO (BADGE)
   ======================================== */

.vd-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.5px;
}

/* ========================================
   CONTENIDO DE LA TARJETA (TÍTULO Y META)
   ======================================== */

.vd-content {
    flex: 1;
    padding: var(--vd-gap-small);
    display: flex;
    flex-direction: column;
    gap: var(--vd-gap-small);
}

/* Título del vídeo */
.vd-title {
    font-size: var(--vd-font-size-card-title);
    font-weight: 600;
    margin: 0;
    padding: 0;
    color: var(--vd-text);
    
    /* Limitar a 2 líneas con elipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: var(--vd-line-height-compact);
}

/* Metadatos (marca, fecha, vistas) */
.vd-meta {
    font-size: var(--vd-font-size-meta);
    color: var(--vd-muted);
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

/* Marca con estilo especial */
.vd-brand {
    font-weight: 600;
    color: var(--vd-accent);
}

/* ========================================
   CONTROLES (BOTONES ANTERIOR/SIGUIENTE)
   ======================================== */

.vd-controls {
    display: flex;
    justify-content: center;
    gap: var(--vd-gap);
    margin-top: var(--vd-gap);
    flex-wrap: wrap;
}

.vd-button {
    padding: 12px 24px;
    /* Hit area mínima: 44x44px para accesibilidad */
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    /* Estilos */
    background-color: var(--vd-accent);
    color: white;
    border: 1px solid var(--vd-accent);
    border-radius: var(--vd-radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--vd-transition);
    font-family: var(--vd-font-family);
}

/* Hover: cambiar fondo y elevar */
.vd-button:hover:not(:disabled) {
    background-color: var(--vd-accent);
    opacity: 0.85;
    box-shadow: var(--vd-shadow);
    transform: translateY(-1px);
}

/* Focus: ring visible */
.vd-button:focus {
    outline: var(--vd-focus-ring);
    outline-offset: var(--vd-focus-offset);
}

/* Active: press effect */
.vd-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Deshabilitado */
.vd-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   ESTADO VACÍO
   ======================================== */

.vd-empty-state {
    text-align: center;
    padding: var(--vd-gap);
    color: var(--vd-muted);
}

.vd-empty-state p {
    font-size: 1.1rem;
    margin: 0;
}

/* ========================================
   SKELETAL LOADING (Fallback placeholders)
   ======================================== */

.vd-skeleton {
    background: linear-gradient(
        90deg,
        var(--vd-border) 25%,
        rgba(255, 255, 255, 0.2) 50%,
        var(--vd-border) 75%
    );
    background-size: 200% 100%;
    animation: vd-loading 1.5s infinite;
}

@keyframes vd-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Respetar prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .vd-skeleton {
        animation: none;
        opacity: 0.6;
    }
}

/* ========================================
   TABLET (769px – 1024px)
   ======================================== */

@media (max-width: 1024px) and (min-width: 769px) {
    .vd-carousel {
        grid-template-columns: repeat(3, 1fr);
    }

    .vd-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .vd-button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* ========================================
   MOBILE (481px – 768px)
   ======================================== */

@media (max-width: 768px) and (min-width: 481px) {
    .vd-carousel {
        grid-template-columns: repeat(2, 1fr);
    }

    .vd-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .vd-section-title {
        font-size: 1.1rem;
    }

    .vd-button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .videos-destacados {
        padding: var(--vd-gap-small);
    }

    .vd-carousel {
        gap: var(--vd-gap-small);
    }
}

/* ========================================
   SMALL MOBILE (≤480px)
   ======================================== */

@media (max-width: 480px) {
    .vd-carousel {
        grid-template-columns: 1fr;
    }

    .vd-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: var(--vd-gap-small);
    }

    .vd-section-title {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .vd-cta {
        font-size: 0.875rem;
        padding: 6px 10px;
    }

    .videos-destacados {
        padding: var(--vd-gap-small);
    }

    .vd-carousel {
        gap: var(--vd-gap-small);
    }

    .vd-content {
        padding: 8px;
        gap: 6px;
    }

    .vd-title {
        font-size: 0.95rem;
    }

    .vd-meta {
        font-size: 0.8rem;
    }

    .vd-button {
        flex: 1;
        min-width: 100px;
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .vd-controls {
        gap: 8px;
    }

    .vd-play {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* ========================================
   ACCESIBILIDAD: MODO ALTO CONTRASTE
   ======================================== */

@media (prefers-contrast: more) {
    .vd-card {
        border: 2px solid var(--vd-text);
    }

    .vd-button {
        border-width: 2px;
    }

    .vd-play {
        border: 2px solid white;
    }
}

/* ========================================
   ACCESIBILIDAD: DARK MODE
   ======================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --vd-bg: #1a1a1a;
        --vd-text: #f0f0f0;
        --vd-muted: #a0a0a0;
        --vd-border: #333333;
        --vd-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
        --vd-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.5);
    }
}

/* ========================================
   PRINT STYLES (para impresión)
   ======================================== */

@media print {
    .vd-carousel {
        grid-template-columns: repeat(2, 1fr);
    }

    .vd-controls {
        display: none;
    }

    .vd-card {
        page-break-inside: avoid;
    }
}

/* ========================================
   UTILITIES Y HELPERS
   ======================================== */

/* Sin decoración de hipervínculo para focus visible */
.vd-thumb:focus-visible {
    outline: transparent;
    box-shadow: inset 0 0 0 3px var(--vd-focus-ring);
    border-radius: var(--vd-radius);
}

/* Ocultar visualmente pero mantener accesible para lectores de pantalla */
.vd-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
