/* ==========================================================================
   Video Resource Library — Frontend Styles
   ========================================================================== */

.vrl-library {
    --vrl-bg: #0a1628;
    --vrl-card-bg: #0f1f3a;
    --vrl-accent: #2563eb;
    --vrl-text: #ffffff;
    --vrl-cols-desktop: 2;
    --vrl-cols-tablet: 2;
    --vrl-cols-mobile: 1;
    --vrl-radius: 16px;
    --vrl-radius-sm: 10px;

    background: var(--vrl-bg);
    color: var(--vrl-text);
    padding: clamp(20px, 4vw, 60px) clamp(14px, 3vw, 32px) clamp(28px, 5vw, 80px);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    box-sizing: border-box;
}
.vrl-library *,
.vrl-library *::before,
.vrl-library *::after {
    box-sizing: border-box;
}

.vrl-empty-state {
    padding: 60px 24px;
    text-align: center;
    background: #0f1f3a;
    color: #fff;
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Header
   ========================================================================== */
.vrl-header {
    max-width: 760px;
    margin: 0 auto clamp(24px, 4vw, 48px);
    text-align: center;
}
.vrl-page-title {
    font-size: clamp(24px, 4vw, 42px);
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--vrl-text);
    line-height: 1.2;
    letter-spacing: -0.02em;
}
.vrl-page-subtitle {
    font-size: clamp(14px, 1.6vw, 16px);
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    line-height: 1.6;
}

/* Main layout: player + side column
   ========================================================================== */
.vrl-main {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: clamp(20px, 2.4vw, 32px);
    max-width: 1320px;
    margin: 0 auto;
    align-items: start;
}

.vrl-player-col {
    scroll-margin-top: 16px;
}

.vrl-player-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: var(--vrl-radius);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.vrl-player-wrapper > iframe,
.vrl-player-wrapper > video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}
.vrl-player-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    text-align: center;
    padding: 20px;
}

/* Side column (title + subtitle + cards)
   ========================================================================== */
.vrl-side-col {
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-width: 0;
}

.vrl-featured-info {
    display: flex;
    flex-direction: column;
    padding: 4px 2px 0;
}
.vrl-now-playing {
    display: inline-flex;
    align-items: center;
    background: var(--vrl-accent);
    color: #fff;
    padding: 5px 12px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.8px;
    border-radius: 999px;
    margin-bottom: 14px;
    width: max-content;
    text-transform: uppercase;
}
.vrl-now-playing::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    margin-right: 7px;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    animation: vrl-pulse 1.6s ease-out infinite;
}
@keyframes vrl-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.75); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.vrl-featured-title {
    font-size: clamp(18px, 1.8vw, 22px);
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--vrl-text);
    line-height: 1.3;
    letter-spacing: -0.01em;
}
.vrl-featured-subtitle {
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.55;
    font-size: 13.5px;
    margin: 0 0 18px;
}

/* Watch Video button
   ========================================================================== */
.vrl-watch-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--vrl-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 22px 11px 14px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    width: max-content;
    box-shadow: none;
    transition: transform 0.2s ease, background 0.2s ease, filter 0.2s ease;
    font-family: inherit;
    line-height: 1;
    margin-top: 4px;
}
.vrl-watch-button,
.vrl-watch-button:hover,
.vrl-watch-button:focus,
.vrl-watch-button:active {
    color: #fff;
}
.vrl-watch-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: none;
}
.vrl-watch-button:active {
    transform: translateY(0);
}
.vrl-watch-button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
.vrl-watch-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 2px;
}

/* Grid Section
   ========================================================================== */
.vrl-grid-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 1320px;
    margin: clamp(48px, 6vw, 80px) auto 0;
}
.vrl-grid-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 2px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 14px;
}
.vrl-grid-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--vrl-text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.vrl-grid-count {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
}
.vrl-grid-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    margin: 0;
}

.vrl-grid {
    display: grid;
    grid-template-columns: repeat(var(--vrl-cols-desktop, 2), minmax(0, 1fr));
    gap: 12px;
}

/* Card
   ========================================================================== */
.vrl-card {
    background: var(--vrl-card-bg);
    border-radius: var(--vrl-radius-sm);
    overflow: hidden;
    display: flex;
    gap: 12px;
    padding: 10px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    color: var(--vrl-text);
    min-width: 0;
    align-items: stretch;
    -webkit-tap-highlight-color: transparent;
}
.vrl-card:hover {
    background: color-mix(in srgb, var(--vrl-card-bg) 86%, #fff 14%);
    border-color: rgba(255, 255, 255, 0.12);
}
.vrl-card.is-active {
    border-color: var(--vrl-accent);
    box-shadow: 0 0 0 1px var(--vrl-accent), 0 10px 28px rgba(37, 99, 235, 0.22);
    background: color-mix(in srgb, var(--vrl-card-bg) 80%, var(--vrl-accent) 20%);
}
.vrl-card:focus-visible {
    outline: 2px solid var(--vrl-accent);
    outline-offset: 2px;
}

.vrl-card-media {
    position: relative;
    width: 132px;
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}
.vrl-card-thumb {
    position: absolute;
    inset: 0;
    background: #000;
}
.vrl-card-thumb img {
    width: 100%;
    height: 100% !important;
    object-fit: cover;
    display: block;
}
.vrl-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2f4d 0%, #0a1628 100%);
}

.vrl-card-number {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--vrl-accent);
    color: #fff;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
    line-height: 1;
}

.vrl-card-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.1));
    transition: background 0.25s ease;
}
.vrl-card:hover .vrl-card-play-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.25));
}
.vrl-card-play-circle {
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.55);
    border: 1.5px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    padding-left: 2px;
    backdrop-filter: blur(4px);
    transition: transform 0.25s ease, background 0.25s ease;
}
.vrl-card:hover .vrl-card-play-circle {
    transform: scale(1.08);
    background: var(--vrl-accent);
    border-color: var(--vrl-accent);
}
.vrl-card.is-active .vrl-card-play-circle {
    background: var(--vrl-accent);
    border-color: var(--vrl-accent);
}

.vrl-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    padding: 2px 4px 2px 0;
}
.vrl-card-title {
    font-size: var(--vrl-card-title-size, 14px);
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--vrl-text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.vrl-card-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.5;
    margin: 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.vrl-card-duration {
    align-self: flex-end;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Tablet / narrow desktop
   ========================================================================== */
@media (max-width: 1024px) {
    .vrl-main {
        grid-template-columns: 1fr;
        gap: 26px;
    }
    .vrl-grid {
        grid-template-columns: repeat(var(--vrl-cols-tablet, 2), minmax(0, 1fr));
        gap: 12px;
    }
}

/* Mobile
   ========================================================================== */
@media (max-width: 720px) {
    .vrl-library {
        padding: 18px 14px 40px;
    }
    .vrl-header { margin-bottom: 18px; }
    .vrl-page-title { font-size: 22px; margin-bottom: 6px; }
    .vrl-page-subtitle { font-size: 13.5px; }

    /* Linearize: player → featured info → grid */
    .vrl-main {
        gap: 18px;
    }
    .vrl-side-col {
        display: contents;
    }
    .vrl-featured-info {
        padding: 2px 0 0;
        order: 2;
    }
    .vrl-grid-section {
        order: 3;
    }
    .vrl-player-col {
        order: 1;
        scroll-margin-top: 12px;
    }
    .vrl-player-wrapper {
        border-radius: 12px;
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    }

    .vrl-now-playing {
        font-size: 10px;
        padding: 4px 11px;
        margin-bottom: 10px;
    }
    .vrl-featured-title {
        font-size: 18px;
        margin-bottom: 6px;
    }
    .vrl-featured-subtitle {
        font-size: 13.5px;
        margin-bottom: 14px;
    }
    .vrl-watch-button {
        font-size: 14px;
        padding: 12px 22px 12px 14px;
        width: 100%;
        justify-content: center;
    }

    .vrl-grid-header {
        padding: 4px 0 10px;
        margin-bottom: 10px;
    }
    .vrl-grid-title { font-size: 16px; }
    .vrl-grid-subtitle { font-size: 12.5px; }

    .vrl-grid {
        grid-template-columns: repeat(var(--vrl-cols-mobile, 1), minmax(0, 1fr));
        gap: 12px;
    }

    /* Mobile cards keep the compact horizontal layout (thumb left, text right)
       — matches the screenshot. When 1 column is selected the card spans
       full width; 2 columns gives a denser grid. */
    .vrl-card {
        padding: 8px;
        gap: 10px;
        border-radius: 12px;
    }
    .vrl-card-media {
        width: 112px;
    }
    .vrl-card-number {
        top: 5px;
        left: 5px;
        min-width: 20px;
        height: 20px;
        font-size: 10.5px;
        padding: 0 5px;
    }
    .vrl-card-play-circle {
        width: 34px;
        height: 34px;
    }
    .vrl-card-play-circle svg {
        width: 14px;
        height: 14px;
    }
    .vrl-card-body {
        padding: 2px 2px 2px 0;
    }
    .vrl-card-title {
        font-size: 13.5px;
        -webkit-line-clamp: 2;
    }
    .vrl-card-desc {
        font-size: 11.5px;
        -webkit-line-clamp: 2;
    }
    .vrl-card-duration {
        margin-top: 4px;
        font-size: 11px;
    }
}

/* Extra-small / 2-cols-mobile breathing room
   ========================================================================== */
@media (max-width: 480px) {
    .vrl-card-media {
        width: 104px;
    }
}

@media (max-width: 380px) {
    .vrl-library[style*="--vrl-cols-mobile:2;"] .vrl-card,
    .vrl-card {
        gap: 8px;
    }
    .vrl-card-media {
        width: 96px;
    }
    .vrl-card-title { font-size: 13px; }
}

/* When mobile is set to 2 columns, drop the description so each card stays
   compact instead of stretching tall. */
@media (max-width: 720px) {
    .vrl-library[style*="--vrl-cols-mobile:2;"] .vrl-card {
        flex-direction: column;
        gap: 0;
        padding: 0;
        overflow: hidden;
    }
    .vrl-library[style*="--vrl-cols-mobile:2;"] .vrl-card-media {
        width: 100%;
        border-radius: 0;
    }
    .vrl-library[style*="--vrl-cols-mobile:2;"] .vrl-card-body {
        padding: 10px 10px 12px;
    }
    .vrl-library[style*="--vrl-cols-mobile:2;"] .vrl-card-desc {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .vrl-library *,
    .vrl-library *::before,
    .vrl-library *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
