/* YouTube Gallery Plugin Stylesheet */

.youtube-gallery-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

/* Featured Video Player */
.youtube-gallery-featured {
    width: 100%;
    margin-bottom: 24px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    background-color: #000;
}

.youtube-gallery-player-wrapper {
    position: relative;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
}

.youtube-gallery-player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Video Grid Layout */
.youtube-gallery-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

/* Video Grid Items */
.youtube-gallery-item {
    cursor: pointer;
    grid-column: span 3; /* Default to 4 columns in row */
}

/* Make first 3 items in the grid span 4 columns (3 columns in row) */
.youtube-gallery-item:nth-child(-n+3) {
    grid-column: span 4;
}

.youtube-gallery-thumbnail-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
    background-color: #1a1a1a;
}

.youtube-gallery-item:hover .youtube-gallery-thumbnail-wrapper {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.youtube-gallery-thumbnail-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.youtube-gallery-item:hover img {
    transform: scale(1.04);
}

/* Play Overlay */
.youtube-gallery-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.youtube-gallery-item:hover .youtube-gallery-play-overlay {
    background-color: rgba(0, 0, 0, 0.3);
}

.youtube-gallery-play-icon {
    width: 48px;
    height: 48px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s ease;
}

.youtube-gallery-play-icon::after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 0 7px 12px;
    border-color: transparent transparent transparent #ffffff;
    margin-left: 3px; /* visual center adjustment */
}

.youtube-gallery-item:hover .youtube-gallery-play-icon {
    transform: scale(1.12);
    background-color: #ff0000; /* YouTube Red */
}

/* Footer Buttons Styling */
.youtube-gallery-footer {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 16px !important;
    margin-top: 24px !important;
    width: 100% !important;
}

/* High-specificity base layout & resets for buttons */
.youtube-gallery-container .youtube-gallery-load-more,
.youtube-gallery-container .youtube-gallery-visit-channel {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 24px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease !important;
    text-decoration: none !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif !important;
    border: none !important;
    line-height: 1.5 !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    text-shadow: none !important;
    background-image: none !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    width: auto !important;
    margin: 0 !important;
    opacity: 1 !important;
    vertical-align: middle !important;
    text-align: center !important;
}

/* Load More - Dark button and overrides */
.youtube-gallery-container .youtube-gallery-load-more {
    background-color: #27272a !important;
    color: #ffffff !important;
}

.youtube-gallery-container .youtube-gallery-load-more:hover {
    background-color: #3f3f46 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.youtube-gallery-container .youtube-gallery-load-more:active {
    transform: scale(0.98) !important;
}

.youtube-gallery-container .youtube-gallery-load-more:disabled {
    background-color: #71717a !important;
    color: #a1a1aa !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Visit Channel / Subscribe - Blue button and overrides */
.youtube-gallery-container .youtube-gallery-visit-channel {
    background-color: #3182ce !important;
    color: #ffffff !important;
}

.youtube-gallery-container .youtube-gallery-visit-channel:hover {
    background-color: #2b6cb0 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3) !important;
}

.youtube-gallery-container .youtube-gallery-visit-channel:active {
    transform: scale(0.98) !important;
}

/* Icon resets */
.youtube-gallery-container .youtube-gallery-icon-svg {
    width: 16px !important;
    height: 16px !important;
    margin: 0 8px 0 0 !important;
    fill: currentColor !important;
    display: inline-block !important;
    vertical-align: middle !important;
    background: none !important;
    padding: 0 !important;
    border: none !important;
    opacity: 1 !important;
    box-shadow: none !important;
    float: none !important;
}

/* Error Message */
.youtube-gallery-error {
    background-color: #fff5f5;
    border-left: 4px solid #e53e3e;
    color: #c53030;
    padding: 12px 16px;
    margin: 15px 0;
    border-radius: 4px;
    font-size: 14px;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
    .youtube-gallery-grid {
        grid-template-columns: repeat(12, 1fr);
        gap: 12px;
    }
    
    .youtube-gallery-item,
    .youtube-gallery-item:nth-child(-n+3) {
        grid-column: span 6; /* 2 columns on tablet */
    }
}

@media (max-width: 600px) {
    .youtube-gallery-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .youtube-gallery-item,
    .youtube-gallery-item:nth-child(-n+3) {
        grid-column: span 1; /* 1 column on mobile */
    }
    
    .youtube-gallery-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .youtube-gallery-load-more,
    .youtube-gallery-visit-channel {
        width: 100%;
        box-sizing: border-box;
    }
}

/* ==========================================================================
   Grid Only Layout Modifier
   ========================================================================== */
.youtube-gallery-grid-only .youtube-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    display: grid;
    gap: 16px;
}

.youtube-gallery-grid-only .youtube-gallery-item {
    grid-column: auto !important;
}

/* ==========================================================================
   Lightbox Popup Styles
   ========================================================================== */
body.youtube-gallery-lightbox-open {
    overflow: hidden !important;
}

.youtube-gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.youtube-gallery-lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.youtube-gallery-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--ytg-overlay-color, #000000);
    opacity: var(--ytg-overlay-opacity, 0.8);
    transition: opacity 0.3s ease;
}

.youtube-gallery-lightbox-content {
    position: relative;
    width: 90%;
    max-width: 960px;
    background: #000000;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000000;
}

/* Ensure the player wrapper inside the lightbox has rounded corners */
.youtube-gallery-lightbox-content .youtube-gallery-player-wrapper {
    border-radius: 12px;
    overflow: hidden;
}

.youtube-gallery-lightbox.active .youtube-gallery-lightbox-content {
    transform: scale(1);
}

.youtube-gallery-lightbox-close {
    position: absolute;
    top: -48px;
    right: 0;
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 48px !important;
    width: 48px !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    z-index: 1000010 !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
}

.youtube-gallery-lightbox-close:hover {
    color: #ff0000 !important;
    transform: scale(1.1) !important;
}

/* Responsive adjustments for lightbox */
@media (max-width: 768px) {
    .youtube-gallery-lightbox-close {
        top: -44px !important;
        right: 0 !important;
        font-size: 42px !important;
        width: 44px !important;
        height: 44px !important;
    }
    .youtube-gallery-lightbox-content {
        margin-top: 48px !important;
    }
}

/* ==========================================================================
   Video Item Title Under Thumbnail
   ========================================================================== */
.youtube-gallery-item-title {
    margin-top: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #1a1a1a;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
    word-break: break-word;
}

/* Hover effect on title when hovering over the item */
.youtube-gallery-item:hover .youtube-gallery-item-title {
    color: #ff0000; /* YouTube Red */
}

/* Dark mode fallback if the theme defines prefers-color-scheme dark */
@media (prefers-color-scheme: dark) {
    .youtube-gallery-item-title {
        color: #e2e8f0;
    }
}