/**
 * Frontend Styles for GPR-YouTube
 *
 * Netflix-style horizontal scroll layout
 *
 * @package GPR_YouTube
 */

/* ========================================
   Main Container
   ======================================== */
.gpr-youtube-list {
    position: relative;
    margin: var(--gpr-spacing-xl, 2rem) 0;
    overflow: hidden;
}

/* ========================================
   Scroll Container
   ======================================== */
.gpr-yt-scroll-container {
    display: flex;
    gap: var(--gpr-spacing-md, 1rem);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: var(--gpr-spacing-sm, 0.5rem) 0;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar */
.gpr-yt-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.gpr-yt-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.gpr-yt-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.gpr-yt-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ========================================
   Video Card - Horizontal (16:9)
   ======================================== */
.gpr-yt-video-card {
    flex: 0 0 340px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.gpr-yt-video-card:hover {
    transform: scale(1.05);
    z-index: 1;
}

/* ========================================
   Thumbnail
   ======================================== */
.gpr-yt-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    background: #000;
    border-radius: var(--gpr-radius-lg, 8px);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease;
}

.gpr-yt-video-card:hover .gpr-yt-thumbnail {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.gpr-yt-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gpr-yt-video-card:hover .gpr-yt-thumbnail img {
    transform: scale(1.08);
}

/* ========================================
   Vertical (9:16) overrides
   ======================================== */
.gpr-youtube-list[data-orientation="vertical"] .gpr-yt-video-card {
    flex: 0 0 200px;
}

.gpr-youtube-list[data-orientation="vertical"] .gpr-yt-thumbnail {
    padding-bottom: 177.78%; /* 9:16 */
}

/* ========================================
   Play Button Overlay
   ======================================== */
.gpr-yt-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.gpr-yt-video-card:hover .gpr-yt-play-button {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.gpr-yt-play-button svg {
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

/* ========================================
   Modal
   ======================================== */
.gpr-yt-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gpr-yt-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.gpr-yt-modal-content {
    position: relative;
    width: 90%;
    max-width: 1280px;
    background: transparent;
    border-radius: var(--gpr-radius-xl, 12px);
    overflow: visible;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.gpr-yt-modal.active .gpr-yt-modal-content {
    transform: scale(1);
}

/* Close Button */
.gpr-yt-close {
    position: fixed;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    z-index: 1000000;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    transition: all 0.2s ease;
    line-height: 1;
}

.gpr-yt-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Player Wrapper */
.gpr-yt-player-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    background: #000;
    border-radius: var(--gpr-radius-xl, 12px);
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.gpr-youtube-list[data-orientation="vertical"] ~ .gpr-yt-modal .gpr-yt-player-wrapper {
    padding-bottom: 177.78%; /* 9:16 */
    max-width: 360px;
    margin: 0 auto;
}

.gpr-yt-player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--gpr-radius-xl, 12px);
}

/* ========================================
   Error Message
   ======================================== */
.gpr-yt-error {
    padding: var(--gpr-spacing-md, 1rem);
    background: var(--gpr-warning-light, #fff3cd);
    border: 1px solid var(--gpr-warning, #ffc107);
    border-radius: var(--gpr-radius-md, 6px);
    color: var(--gpr-warning-dark, #856404);
    margin: var(--gpr-spacing-md, 1rem) 0;
}

.gpr-yt-error p {
    margin: 0;
}

/* ========================================
   Responsive - Tablet
   ======================================== */
@media (max-width: 1023px) and (min-width: 768px) {
    .gpr-yt-video-card {
        flex: 0 0 300px;
    }

    .gpr-youtube-list[data-orientation="vertical"] .gpr-yt-video-card {
        flex: 0 0 170px;
    }
}

/* ========================================
   Responsive - Mobile Landscape
   ======================================== */
@media (max-width: 767px) and (min-width: 480px) {
    .gpr-yt-video-card {
        flex: 0 0 260px;
    }

    .gpr-youtube-list[data-orientation="vertical"] .gpr-yt-video-card {
        flex: 0 0 150px;
    }

    .gpr-yt-modal-content {
        width: 95%;
    }

    .gpr-yt-close {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
}

/* ========================================
   Responsive - Mobile Portrait
   ======================================== */
@media (max-width: 479px) {
    .gpr-youtube-list {
        margin: var(--gpr-spacing-md, 1rem) calc(var(--gpr-spacing-md, 1rem) * -1);
    }

    .gpr-yt-scroll-container {
        gap: var(--gpr-spacing-sm, 0.5rem);
        padding: var(--gpr-spacing-sm, 0.5rem) var(--gpr-spacing-md, 1rem);
    }

    .gpr-yt-video-card {
        flex: 0 0 200px;
    }

    .gpr-youtube-list[data-orientation="vertical"] .gpr-yt-video-card {
        flex: 0 0 130px;
    }

    .gpr-yt-modal-content {
        width: 98%;
    }

    .gpr-yt-close {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
}

/* ========================================
   Loading & Animation
   ======================================== */
.gpr-yt-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gpr-yt-spin 1s linear infinite;
}

@keyframes gpr-yt-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
