/**
 * Thumbnail Carousel - Filmstrip Style
 *
 * Uses theme CSS variables with fallbacks for cross-theme compatibility.
 * videotube: --accent-color, --border-color, --bg-secondary, --bg-tertiary
 * videobox:  --accent,       --border,       --bg-secondary, --bg-tertiary
 *
 * @package VideoTubePro
 */

.vtp-carousel {
    position: relative;
    background: var(--bg-secondary, #1a1a1a);
    border-radius: var(--radius-lg, 8px);
    padding: 10px 40px;
    margin-top: 8px;
    overflow: hidden;
}

/* Arrow buttons */
.vtp-carousel-arrow {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: 40px;
    background: var(--bg-secondary, #1a1a1a);
    border: none;
    color: var(--text-primary, #fff);
    font-size: 28px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.25s ease, background 0.2s ease;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vtp-carousel:hover .vtp-carousel-arrow {
    opacity: 1;
}

.vtp-carousel-arrow:hover {
    background: var(--bg-tertiary, #2a2a2a);
}

.vtp-carousel-arrow:disabled {
    opacity: 0 !important;
    cursor: default;
}

.vtp-carousel-prev {
    left: 0;
}

.vtp-carousel-next {
    right: 0;
}

/* Track — overflow hidden, JS controls the slide offset */
.vtp-carousel-track {
    display: flex;
    gap: 8px;
    overflow: hidden;
    position: relative;
}

/* Inner wrapper moved by JS via transform */
.vtp-carousel-slider {
    display: flex;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: transform;
}

/* Thumbnails — large, ~25% width each so ~4 visible */
.vtp-carousel-thumb {
    flex: 0 0 calc(25% - 6px);
    border: 2px solid transparent;
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    cursor: default;
    padding: 0;
    background: var(--bg-tertiary, #2a2a2a);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.vtp-carousel-thumb:hover {
    border-color: var(--text-muted, rgba(255, 255, 255, 0.4));
    transform: scale(1.03);
}

.vtp-carousel-thumb.is-active {
    border-color: var(--accent-color, var(--accent, #e50914));
}

.vtp-carousel-thumb img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--bg-tertiary, #2a2a2a);
}

/* Dot indicators */
.vtp-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
}

.vtp-carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: var(--border-color, var(--border, #444));
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
}

.vtp-carousel-dot:hover {
    background: var(--text-muted, #888);
}

.vtp-carousel-dot.is-active {
    background: var(--accent-color, var(--accent, #e50914));
}

/* Mobile — 3 visible, touch swipe */
@media (max-width: 768px) {
    .vtp-carousel {
        padding: 8px 6px;
    }

    .vtp-carousel-arrow {
        display: none;
    }

    .vtp-carousel-track {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .vtp-carousel-track::-webkit-scrollbar {
        display: none;
    }

    .vtp-carousel-slider {
        transition: none;
    }

    .vtp-carousel-thumb {
        flex: 0 0 calc(33.333% - 6px);
        scroll-snap-align: start;
    }

    .vtp-carousel-dots {
        display: none;
    }
}

/* Small mobile — 2 visible */
@media (max-width: 480px) {
    .vtp-carousel-thumb {
        flex: 0 0 calc(50% - 4px);
    }
}
