/**
 * VOD Grid Styles
 *
 * Provides styling for all 6 VOD display skins:
 * grid, list, carousel, overlay, overlay-carousel, minimal.
 *
 * Uses CSS custom properties for easy theming via shortcode
 * attributes, Elementor controls, and Gutenberg block settings.
 *
 * @package Tvstartup_OTT_Platform
 * @since   1.8.0
 */

/* ==========================================================================
   CSS Custom Properties (Defaults)
   ========================================================================== */

.ts-ott-vods {
    --ts-ott-font-family: inherit;
    --ts-ott-title-color: #1a1a2e;
    --ts-ott-desc-color: #6b7280;
    --ts-ott-bg-color: #ffffff;
    --ts-ott-accent-color: #6366f1;
    --ts-ott-border-radius: 12px;
    --ts-ott-card-padding: 1rem;
    --ts-ott-card-spacing: 1.25rem;
    /*
     * Note: --ts-ott-columns is intentionally NOT declared here so that
     * an inline style on the parent .ts-ott-vods-wrapper (set by the
     * shortcode / Elementor widget / Gutenberg block) can cascade down
     * to this element. The default fallback (3) is provided in the
     * var() consumers below. Responsive @media rules further down still
     * win on mobile because they target .ts-ott-vods--grid (etc.) directly.
     */
    --ts-ott-transition: 0.25s ease;

    font-family: var(--ts-ott-font-family);
    box-sizing: border-box;
    width: 100%;
}

.ts-ott-vods *,
.ts-ott-vods *::before,
.ts-ott-vods *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   Category Sections
   ========================================================================== */

.ts-ott-vods-wrapper {
    font-family: var(--ts-ott-font-family, inherit);
    box-sizing: border-box;
    width: 100%;
}

.ts-ott-vod-category {
    margin-bottom: 2.5rem;
}

.ts-ott-vod-category:last-child {
    margin-bottom: 0;
}

.ts-ott-vod-category__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ts-ott-category-title-color, var(--ts-ott-title-color, #1a1a2e));
    margin: 0 0 1rem 0;
    padding-bottom: 0;
    font-family: var(--ts-ott-font-family, inherit);
    line-height: 1.3;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.ts-ott-vods--empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ts-ott-desc-color);
    font-size: 1rem;
}

/* ==========================================================================
   VOD Card Link Wrapper
   ========================================================================== */

.ts-ott-vod-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.ts-ott-vod-card-link:hover,
.ts-ott-vod-card-link:focus,
.ts-ott-vod-card-link:active {
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   VOD Card (Base Styles)
   ========================================================================== */

.ts-ott-vod-card {
    background-color: var(--ts-ott-bg-color);
    border-radius: var(--ts-ott-border-radius);
    overflow: hidden;
    transition: transform var(--ts-ott-transition),
                box-shadow var(--ts-ott-transition);
    position: relative;
}

.ts-ott-vod-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* --- Thumbnail --- */

.ts-ott-vod-card__thumbnail {
    position: relative;
    overflow: hidden;
    background-color: #f3f4f6;
    aspect-ratio: 16 / 9;
}

.ts-ott-vod-card__thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--ts-ott-transition);
}

.ts-ott-vod-card:hover .ts-ott-vod-card__thumbnail img {
    transform: scale(1.05);
}

.ts-ott-vod-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    background-color: #f3f4f6;
    color: #d1d5db;
}

/* --- Duration Badge --- */

.ts-ott-vod-card__duration {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background-color: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.1875rem 0.5rem;
    border-radius: 4px;
    line-height: 1.4;
    z-index: 5;
    letter-spacing: 0.025em;
}

/* --- Content --- */

.ts-ott-vod-card__content {
    padding: var(--ts-ott-card-padding);
}

.ts-ott-vod-card__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ts-ott-title-color);
    margin: 0 0 0.375rem 0;
    line-height: 1.3;
    font-family: var(--ts-ott-font-family);
}

.ts-ott-vod-card__desc {
    font-size: 0.875rem;
    color: var(--ts-ott-desc-color);
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

/* --- Meta (Rating + Year) --- */

.ts-ott-vod-card__meta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    font-size: 0.75rem;
    color: var(--ts-ott-desc-color);
}

.ts-ott-vod-card__rating {
    display: inline-block;
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--ts-ott-accent-color);
    font-weight: 600;
    padding: 0.125rem 0.4375rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.ts-ott-vod-card__year {
    display: inline-block;
    color: var(--ts-ott-desc-color);
    font-weight: 500;
    font-size: 0.75rem;
}

/* --- Genre Tags --- */

.ts-ott-vod-card__genres {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.ts-ott-vod-genre-tag {
    display: inline-block;
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--ts-ott-accent-color);
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.1875rem 0.5rem;
    border-radius: 9999px;
    line-height: 1.4;
}

/* ==========================================================================
   Skin: Grid
   ========================================================================== */

.ts-ott-vods--grid {
    display: grid;
    grid-template-columns: repeat(var(--ts-ott-columns, 3), 1fr);
    gap: var(--ts-ott-card-spacing);
}

.ts-ott-vods--grid .ts-ott-vod-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-vods--grid .ts-ott-vod-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Skin: List
   ========================================================================== */

.ts-ott-vods--list {
    display: flex;
    flex-direction: column;
    gap: var(--ts-ott-card-spacing);
}

.ts-ott-vods--list .ts-ott-vod-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.ts-ott-vods--list .ts-ott-vod-card__thumbnail {
    width: 240px;
    min-width: 240px;
    flex-shrink: 0;
}

.ts-ott-vods--list .ts-ott-vod-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-ott-vods--list .ts-ott-vod-card__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

/* ==========================================================================
   Skin: Carousel
   ========================================================================== */

.ts-ott-vods--carousel {
    position: relative;
    overflow: hidden;
}

.ts-ott-vods__track {
    display: flex;
    gap: var(--ts-ott-card-spacing);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    padding-bottom: 0.5rem;
}

.ts-ott-vods__track::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.ts-ott-vods--carousel .ts-ott-vod-card {
    flex: 0 0 calc(100% / var(--ts-ott-columns, 3) - var(--ts-ott-card-spacing) * (var(--ts-ott-columns, 3) - 1) / var(--ts-ott-columns, 3));
    scroll-snap-align: start;
    min-width: 200px;
}

.ts-ott-vods--carousel .ts-ott-vod-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-vods--carousel .ts-ott-vod-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Carousel Buttons */

.ts-ott-vod-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background-color: var(--ts-ott-bg-color);
    color: var(--ts-ott-title-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--ts-ott-transition),
                box-shadow var(--ts-ott-transition),
                opacity var(--ts-ott-transition);
    opacity: 0;
    padding: 0;
}

.ts-ott-vods--carousel:hover .ts-ott-vod-carousel-btn,
.ts-ott-vods--overlay-carousel:hover .ts-ott-vod-carousel-btn {
    opacity: 1;
}

.ts-ott-vod-carousel-btn:hover {
    background-color: var(--ts-ott-accent-color);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.ts-ott-vod-carousel-btn--prev {
    left: 12px;
}

.ts-ott-vod-carousel-btn--next {
    right: 12px;
}

.ts-ott-vod-carousel-btn svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Skin: Overlay
   ========================================================================== */

.ts-ott-vods--overlay {
    display: grid;
    grid-template-columns: repeat(var(--ts-ott-columns, 3), 1fr);
    gap: var(--ts-ott-card-spacing);
}

.ts-ott-vods--overlay .ts-ott-vod-card {
    cursor: pointer;
}

.ts-ott-vods--overlay .ts-ott-vod-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-vods--overlay .ts-ott-vod-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-ott-vod-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--ts-ott-card-padding);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
    color: #ffffff;
    transform: translateY(100%);
    transition: transform var(--ts-ott-transition);
}

.ts-ott-vods--overlay .ts-ott-vod-card:hover .ts-ott-vod-card__overlay {
    transform: translateY(0);
}

.ts-ott-vod-card__overlay .ts-ott-vod-card__title {
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ts-ott-vod-card__overlay .ts-ott-vod-card__desc {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    margin-bottom: 0;
}

.ts-ott-vod-card__overlay .ts-ott-vod-card__meta {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.25rem;
}

.ts-ott-vod-card__overlay .ts-ott-vod-card__rating {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.ts-ott-vod-card__overlay .ts-ott-vod-card__year {
    color: rgba(255, 255, 255, 0.8);
}

/* Duration badge on overlay thumbnail */
.ts-ott-vods--overlay .ts-ott-vod-card__duration {
    bottom: 0.5rem;
    right: 0.5rem;
}

/* ==========================================================================
   Skin: Overlay Carousel
   ========================================================================== */

.ts-ott-vods--overlay-carousel {
    position: relative;
    overflow: hidden;
}

.ts-ott-vods--overlay-carousel .ts-ott-vods__track {
    display: flex;
    gap: var(--ts-ott-card-spacing);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.5rem;
}

.ts-ott-vods--overlay-carousel .ts-ott-vods__track::-webkit-scrollbar {
    display: none;
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card {
    flex: 0 0 calc(100% / var(--ts-ott-columns, 3) - var(--ts-ott-card-spacing) * (var(--ts-ott-columns, 3) - 1) / var(--ts-ott-columns, 3));
    scroll-snap-align: start;
    min-width: 200px;
    cursor: pointer;
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card__thumbnail {
    aspect-ratio: 16 / 9;
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Overlay text on hover */
.ts-ott-vods--overlay-carousel .ts-ott-vod-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--ts-ott-card-padding);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
    color: #ffffff;
    transform: translateY(100%);
    transition: transform var(--ts-ott-transition);
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card:hover .ts-ott-vod-card__overlay {
    transform: translateY(0);
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card__overlay .ts-ott-vod-card__title {
    color: #ffffff;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card__overlay .ts-ott-vod-card__desc {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    margin-bottom: 0;
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card__overlay .ts-ott-vod-card__meta {
    color: rgba(255, 255, 255, 0.9);
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card__overlay .ts-ott-vod-card__rating {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.ts-ott-vods--overlay-carousel .ts-ott-vod-card__overlay .ts-ott-vod-card__year {
    color: rgba(255, 255, 255, 0.8);
}

/* ==========================================================================
   Skin: Minimal
   ========================================================================== */

.ts-ott-vods--minimal {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ts-ott-vods--minimal .ts-ott-vod-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 0;
    border-radius: 0;
    border-bottom: 1px solid #f3f4f6;
    background: transparent;
}

.ts-ott-vods--minimal .ts-ott-vod-card:last-child {
    border-bottom: none;
}

.ts-ott-vods--minimal .ts-ott-vod-card:hover {
    transform: none;
    box-shadow: none;
    background-color: #fafafa;
}

.ts-ott-vods--minimal .ts-ott-vod-card__thumbnail {
    width: 80px;
    min-width: 80px;
    height: 45px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 1rem;
    aspect-ratio: auto;
}

.ts-ott-vods--minimal .ts-ott-vod-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-ott-vods--minimal .ts-ott-vod-card__placeholder {
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
}

.ts-ott-vods--minimal .ts-ott-vod-card__placeholder svg {
    width: 24px;
    height: 24px;
}

.ts-ott-vods--minimal .ts-ott-vod-card__duration {
    font-size: 0.5625rem;
    padding: 0.125rem 0.3125rem;
    bottom: 0.25rem;
    right: 0.25rem;
}

.ts-ott-vods--minimal .ts-ott-vod-card__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0;
    flex: 1;
    min-width: 0;
}

.ts-ott-vods--minimal .ts-ott-vod-card__title {
    font-size: 0.9375rem;
    margin-bottom: 0.125rem;
}

.ts-ott-vods--minimal .ts-ott-vod-card__desc {
    font-size: 0.8125rem;
    margin-bottom: 0;
}

.ts-ott-vods--minimal .ts-ott-vod-card__meta {
    margin-bottom: 0.125rem;
    font-size: 0.6875rem;
}

/* ==========================================================================
   Responsive: Tablet (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    /* Grid: reduce to 2 columns */
    .ts-ott-vods--grid {
        --ts-ott-columns: 2;
    }

    /* Overlay: reduce to 2 columns */
    .ts-ott-vods--overlay {
        --ts-ott-columns: 2;
    }

    /* List: reduce thumbnail width */
    .ts-ott-vods--list .ts-ott-vod-card__thumbnail {
        width: 180px;
        min-width: 180px;
    }

    /* Carousel: 2 items on tablet */
    .ts-ott-vods--carousel {
        --ts-ott-columns: 2;
    }
    .ts-ott-vods--carousel .ts-ott-vod-card {
        min-width: 220px;
    }

    /* Overlay Carousel: 2 items on tablet */
    .ts-ott-vods--overlay-carousel {
        --ts-ott-columns: 2;
    }
    .ts-ott-vods--overlay-carousel .ts-ott-vod-card {
        min-width: 220px;
    }

    /* Show carousel buttons on touch devices */
    .ts-ott-vod-carousel-btn {
        opacity: 1;
    }
}

/* ==========================================================================
   Responsive: Mobile (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {
    /* Grid: single column */
    .ts-ott-vods--grid {
        --ts-ott-columns: 1;
    }

    /* Overlay: single column */
    .ts-ott-vods--overlay {
        --ts-ott-columns: 1;
    }

    /* List: full-width stack */
    .ts-ott-vods--list .ts-ott-vod-card {
        flex-direction: column;
    }

    .ts-ott-vods--list .ts-ott-vod-card__thumbnail {
        width: 100%;
        min-width: 100%;
        aspect-ratio: 16 / 9;
    }

    /* Carousel: single item on mobile */
    .ts-ott-vods--carousel {
        --ts-ott-columns: 1;
    }
    .ts-ott-vods--carousel .ts-ott-vod-card {
        min-width: 100%;
    }

    /* Overlay Carousel: single item on mobile */
    .ts-ott-vods--overlay-carousel {
        --ts-ott-columns: 1;
    }
    .ts-ott-vods--overlay-carousel .ts-ott-vod-card {
        min-width: 100%;
    }

    /* Card spacing reduction */
    .ts-ott-vods {
        --ts-ott-card-spacing: 0.75rem;
    }

    .ts-ott-vod-card__title {
        font-size: 1rem;
    }

    .ts-ott-vod-card__desc {
        font-size: 0.8125rem;
    }

    .ts-ott-vod-category {
        margin-bottom: 1.75rem;
    }

    .ts-ott-vod-category__title {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   Gutenberg Editor Preview Wrapper
   ========================================================================== */

.ts-ott-block-preview {
    padding: 0;
}
