/* VIDEO CARDS - Estilo PornHub (grid denso y plano)
   ================================================= */

/* Grid: cards chicas, muchas columnas. Aplica al home y a relacionados. */
#videosGrid,
.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem 0.875rem;
}

/* Card plana: el thumbnail manda, el texto va suelto debajo (sin caja) */
.video-card {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    cursor: pointer;
    position: relative;
}

/* Thumbnail - 16:9 fijo, imagen siempre cubre, esquinas redondeadas */
.video-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-card);
    overflow: hidden;
    border-radius: 6px;
}

.video-thumbnail img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.video-thumbnail img.loading {
    opacity: 0;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.06);
}

/* Borde de acento sutil al pasar el mouse (estilo PH) */
.video-thumbnail::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    box-shadow: inset 0 0 0 2px transparent;
    transition: box-shadow 0.2s ease;
    pointer-events: none;
    z-index: 3;
}

.video-card:hover .video-thumbnail::before {
    box-shadow: inset 0 0 0 2px var(--primary);
}

/* Preview de video en hover (desktop) */
.video-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    z-index: 2;
    background: #000;
}

.video-card.previewing .video-preview {
    opacity: 1;
}

.video-card.previewing .play-overlay {
    opacity: 0;
}

/* Gradiente inferior sutil en hover (para que el badge se lea siempre) */
.video-thumbnail::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.55) 0%, transparent 35%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 1;
}

.video-card:hover .video-thumbnail::after {
    opacity: 1;
}

/* Botón de play central */
.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    width: 52px;
    height: 52px;
    background: rgba(220, 38, 38, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

.play-overlay i {
    color: white;
    font-size: 1.1rem;
    margin-left: 3px;
}

.video-card:hover .play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Badge de duración (abajo-derecha, estilo PH) */
.video-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.3px;
    z-index: 10;
    line-height: 1.3;
}

/* Badge HD (arriba-derecha) */
.hd-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--primary);
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    z-index: 10;
}

/* Info: compacta y plana, texto directo bajo el thumbnail */
.video-info {
    padding: 0.5rem 0.125rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.video-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s ease;
}

.video-card:hover .video-title {
    color: var(--primary-light);
}

/* PH no muestra descripción en el grid */
.video-description {
    display: none;
}

/* Fila de metadatos: vistas + likes en gris, compacta */
.video-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.video-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.video-meta i {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Categoría como chip discreto (no un botón grande) */
.video-category {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0;
    background: transparent;
    color: var(--primary-light);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Etiquetas: chips chicos y discretos */
.video-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.125rem;
}

.video-card-tags .tag {
    font-size: 0.6875rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.video-card-tags .tag:hover {
    color: #fff;
    background: var(--primary);
}

/* Buffering Overlay (reproductor) */
.buffering-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 20;
}

.buffering-overlay.active {
    opacity: 1;
}

.buffering-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bufferSpin 1s linear infinite;
}

@keyframes bufferSpin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   RESPONSIVE
   ========================================== */

/* Desktop grande: 5-6 columnas */
@media (min-width: 1400px) {
    #videosGrid,
    .videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    }
}

/* Desktop: 4 columnas */
@media (min-width: 1024px) and (max-width: 1399px) {
    #videosGrid,
    .videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* Tablet: 3 columnas */
@media (min-width: 768px) and (max-width: 1023px) {
    #videosGrid,
    .videos-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
}

/* Móvil grande: 2 columnas */
@media (min-width: 480px) and (max-width: 767px) {
    #videosGrid,
    .videos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem 0.625rem;
    }

    .video-title {
        font-size: 0.8125rem;
    }

    .video-meta {
        font-size: 0.6875rem;
        gap: 0.5rem;
    }
}

/* Móvil pequeño: 2 columnas compactas */
@media (max-width: 479px) {
    #videosGrid,
    .videos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem 0.5rem;
    }

    .video-info {
        padding: 0.375rem 0.125rem 0;
    }

    .video-title {
        font-size: 0.75rem;
    }

    .video-meta {
        font-size: 0.625rem;
        gap: 0.375rem;
    }

    .video-duration {
        font-size: 0.6875rem;
        padding: 1px 4px;
    }

    .play-overlay {
        width: 40px;
        height: 40px;
    }

    .play-overlay i {
        font-size: 0.85rem;
    }

    .video-card-tags {
        display: none;
    }
}
