/**
 * Frontend CSS for Youtube Video Gallery
 * Premium design tokens and micro-interactions
 */

.ytvg-container {
    width: 100%;
    margin: 20px 0;
    box-sizing: border-box;
}

/* Grid Layout */
.ytvg-grid {
    display: grid;
    grid-template-columns: repeat(var(--ytvg-cols-desktop, 3), 1fr);
    gap: var(--ytvg-gap, 20px);
}

/* Responsive Breakpoints using variables loaded from settings */
@media (max-width: 1024px) {
    .ytvg-grid {
        grid-template-columns: repeat(var(--ytvg-cols-tablet, 2), 1fr);
    }
}

@media (max-width: 640px) {
    .ytvg-grid {
        grid-template-columns: repeat(var(--ytvg-cols-mobile, 1), 1fr);
    }
}

/* Video Card Item */
.ytvg-item {
    background: #ffffff;
    border: var(--ytvg-border-width, 1px) solid var(--ytvg-border-color, #e5e7eb);
    border-radius: var(--ytvg-border-radius, 8px);
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.ytvg-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Thumbnail Wrapper with 16:9 Aspect Ratio */
.ytvg-thumbnail-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
}

.ytvg-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.ytvg-item:hover .ytvg-thumbnail {
    transform: scale(1.05);
}

/* Premium Play Button Hover Overlay */
.ytvg-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ytvg-item:hover .ytvg-play-overlay {
    opacity: 1;
}

.ytvg-play-btn {
    background: #ef4444; /* Modern YouTube red */
    color: #ffffff;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}

.ytvg-play-btn svg {
    margin-left: 3px; /* visual center adjustment */
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.ytvg-item:hover .ytvg-play-btn {
    transform: scale(1);
}

.ytvg-play-btn:hover {
    background: #dc2626;
}

/* Video Card Title Area */
.ytvg-meta {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.ytvg-title {
    margin: 0;
    font-size: var(--ytvg-title-font-size, 15px);
    line-height: 1.4;
    font-weight: 600;
    color: var(--ytvg-title-color, #111827);
    font-family: inherit;
    /* Limit long titles to two lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Lightbox Modal Window */
.ytvg-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ytvg-fade-in 0.3s ease;
}

/* Premium Glassmorphism Backdrop Overlay */
.ytvg-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Container of Lightbox content */
.ytvg-modal-container {
    position: relative;
    width: 90%;
    max-width: 850px;
    background: #0f172a; /* Slate 900 background for cinema mode */
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 10;
    transform: scale(0.95);
    animation: ytvg-scale-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Responsive Responsive Video Container */
.ytvg-video-responsive {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background: #000;
}

.ytvg-video-responsive iframe,
.ytvg-video-responsive .plyr {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Close Button styling */
.ytvg-modal-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ytvg-modal-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Title on Modal window footer */
.ytvg-modal-title {
    padding: 16px 20px;
    margin: 0;
    color: var(--ytvg-modal-title-color, #ffffff);
    font-size: var(--ytvg-modal-title-font-size, 16px);
    font-weight: 500;
    background: var(--ytvg-modal-title-bg, #1e293b);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Scroll Lock helper */
.ytvg-overflow-hidden {
    overflow: hidden !important;
}

/* CSS Keyframes */
@keyframes ytvg-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ytvg-scale-up {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Handle mobile viewport spacing */
@media screen and (max-width: 640px) {
    .ytvg-modal-container {
        width: 95%;
    }
    
    .ytvg-modal-close {
        top: 10px;
        right: 10px;
        background: rgba(15, 23, 42, 0.6);
        border-radius: 50%;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        z-index: 12;
    }
}
