/**
 * Videos Grid Widget - Styles
 *
 * Onglets catégories, grille vidéos, scroll infini.
 *
 * @package xstore-child
 */

/* ========================================
   Tabs Navigation
   ======================================== */

.videos-grid__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
}

.videos-grid__tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: 6px;
    background: #e8e8e8;
    color: #0b3954;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.videos-grid__tab:hover:not(.is-active) {
    background: #d4d4d4;
}

.videos-grid__tab:focus-visible {
    outline: 2px solid #e3001a;
    outline-offset: 2px;
}

.videos-grid__tab.is-active {
    background: #e3001a;
    color: #fff;
}

.videos-grid__tab-icon {
    display: inline-flex;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.videos-grid__tab-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* ========================================
   Video Grid
   ======================================== */

.videos-grid {
    display: grid;
    gap: 20px;
}

.videos-grid--cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.videos-grid--cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.videos-grid--cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Card */
.videos-grid__item {
    border-radius: 4px;
    overflow: hidden;
}

/* Thumbnail container */
.videos-grid__thumbnail {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    cursor: pointer;
    background-color: #000;
}

.videos-grid__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s ease;
}

.videos-grid__thumbnail:hover img {
    opacity: 0.85;
}

/* Play button overlay */
.videos-grid__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px;
    height: 48px;
    pointer-events: none;
    transition: transform 0.2s ease;
}

.videos-grid__thumbnail:hover .videos-grid__play {
    transform: translate(-50%, -50%) scale(1.1);
}

.videos-grid__play svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* iframe (replaces image on click) */
.videos-grid__thumbnail iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Hide overlay when playing */
.videos-grid__thumbnail.is-playing .videos-grid__play,
.videos-grid__thumbnail.is-playing img {
    display: none;
}

/* Title */
.videos-grid__title {
    margin: 10px 0 0;
    padding: 0 4px;
    font-family: "Lato", Sans-serif;
    font-size: 20px;
    font-weight: 600;
    text-transform: none;
    line-height: 1.4;
    color: #2B2B2B;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
   Tab Loading Overlay
   ======================================== */

.videos-grid {
    position: relative;
}

.videos-grid__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 200px;
    background: rgba(255, 255, 255, 0.7);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.videos-grid__overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.videos-grid__overlay-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e8e8e8;
    border-top-color: #e3001a;
    border-radius: 50%;
    animation: videos-grid-spin 0.7s linear infinite;
}

/* ========================================
   Infinite Scroll Sentinel & Spinner
   ======================================== */

.videos-grid__sentinel {
    display: flex;
    justify-content: center;
    padding: 30px 0;
    min-height: 1px;
}

.videos-grid__spinner {
    display: none;
}

.videos-grid__sentinel.is-loading .videos-grid__spinner {
    display: block;
    width: 36px;
    height: 36px;
    border: 3px solid #e8e8e8;
    border-top-color: #c8102e;
    border-radius: 50%;
    animation: videos-grid-spin 0.7s linear infinite;
}

@keyframes videos-grid-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Single Mode (video player)
   ======================================== */

.videos-grid-single__player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 60vh;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

.videos-grid-single__player iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1024px) {
    .videos-grid--cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {

    .videos-grid-single__player {
        max-height: none;
    }

    .videos-grid--cols-3,
    .videos-grid--cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .videos-grid__tab {
        padding: 12px 16px;
        font-size: 13px;
        gap: 6px;
    }

    .videos-grid__tab-icon {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {

    .videos-grid--cols-2,
    .videos-grid--cols-3,
    .videos-grid--cols-4 {
        grid-template-columns: 1fr;
    }

    .videos-grid__tabs {
        flex-direction: column;
        gap: 6px;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {

    .videos-grid__tab,
    .videos-grid__thumbnail img,
    .videos-grid__play {
        transition: none;
    }

    .videos-grid__spinner,
    .videos-grid__overlay-spinner {
        animation: none;
    }

    .videos-grid__overlay {
        transition: none;
    }
}