/* Smart Gallery Pro - Frontend v6 — All Fixes */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Scroll lock ── */
html.sgp-no-scroll,
body.sgp-no-scroll { overflow: hidden !important; }

/* ════════════════════════════════════════════
   WRAPPER
   ════════════════════════════════════════════ */
.sgp-gallery-wrap {
    font-family: 'Inter', sans-serif !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.sgp-gallery-wrap *,
.sgp-gallery-wrap *::before,
.sgp-gallery-wrap *::after {
    box-sizing: border-box !important;
}

/* ── Hide header/title & filter bar ── */
.sgp-gallery-wrap .sgp-gallery-header,
.sgp-gallery-wrap .sgp-filter-bar,
.sgp-filter-bar {
    display: none !important;
}

/* ════════════════════════════════════════════
   BENTO GRID
   ════════════════════════════════════════════ */
.sgp-gallery-wrap .sgp-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-auto-rows: 240px !important;
    grid-auto-flow: dense !important;
    gap: 8px !important;
    width: 100% !important;
}

/* Bento spans via CSS classes (overridable by media queries) */
.sgp-gallery-wrap .sgp-grid .sgp-item.sgp-col-2 {
    grid-column: span 2 !important;
}
.sgp-gallery-wrap .sgp-grid .sgp-item.sgp-row-2 {
    grid-row: span 2 !important;
}

/* Item */
.sgp-gallery-wrap .sgp-item {
    position: relative !important;
    display: block !important;
    overflow: hidden !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    background: #e8e8e8 !important;
    min-height: 0 !important;
}
.sgp-gallery-wrap .sgp-item.sgp-hidden {
    display: none !important;
}

.sgp-gallery-wrap .sgp-item-inner {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    right: 0 !important; bottom: 0 !important;
    overflow: hidden !important;
    border-radius: 12px !important;
}
.sgp-gallery-wrap .sgp-media-wrap {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    right: 0 !important; bottom: 0 !important;
}

/* Image fills cell */
.sgp-gallery-wrap .sgp-thumb {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    transition: transform 0.42s cubic-bezier(0.4,0,0.2,1) !important;
}
.sgp-gallery-wrap .sgp-item:not(.sgp-item-video):hover .sgp-thumb {
    transform: scale(1.06) !important;
}

/* Serial badge */
.sgp-gallery-wrap .sgp-serial-badge {
    position: absolute !important;
    top: 10px !important; left: 10px !important; z-index: 5 !important;
    background: rgba(0,0,0,0.5) !important;
    color: #fff !important; font-size: 10px !important;
    font-weight: 700 !important; padding: 4px 9px !important;
    border-radius: 6px !important; letter-spacing: 0.6px !important;
    backdrop-filter: blur(6px) !important;
    pointer-events: none !important; line-height: 1 !important;
}

/* ════════════════════════════════════════════
   VIDEO ITEM
   ════════════════════════════════════════════ */

/* Dark bg fallback (when no thumbnail) */
.sgp-gallery-wrap .sgp-video-no-thumb {
    position: absolute !important;
    inset: 0 !important;
    background: #1a1a2e !important;
    z-index: 0 !important;
}

/* Thumbnail — always visible by default */
.sgp-gallery-wrap .sgp-video-thumb-img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    z-index: 1 !important;
    opacity: 1 !important;
    transition: opacity 0.35s ease, transform 0.42s cubic-bezier(0.4,0,0.2,1) !important;
}
.sgp-gallery-wrap .sgp-item-video:hover .sgp-video-thumb-img {
    transform: scale(1.04) !important;
}

/* Video element — hidden until hover */
.sgp-gallery-wrap .sgp-hover-video {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    z-index: 2 !important;
    opacity: 0 !important;
    transition: opacity 0.35s ease !important;
}

/* Play icon — centered, above thumbnail, below overlay */
.sgp-gallery-wrap .sgp-play-icon {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 4 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    opacity: 1 !important;
    transition: opacity 0.25s ease !important;
}
.sgp-gallery-wrap .sgp-play-icon-inner {
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.92) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 6px 28px rgba(0,0,0,0.4) !important;
    transition: transform 0.22s ease !important;
    flex-shrink: 0 !important;
}
.sgp-gallery-wrap .sgp-play-icon-inner svg {
    width: 22px !important;
    height: 22px !important;
    margin-left: 4px !important;
    display: block !important;
}
.sgp-gallery-wrap .sgp-item-video:hover .sgp-play-icon-inner {
    transform: scale(1.12) !important;
}

/* ════════════════════════════════════════════
   HOVER OVERLAY
   ════════════════════════════════════════════ */
.sgp-gallery-wrap .sgp-overlay {
    position: absolute !important;
    inset: 0 !important;
    z-index: 6 !important;
    background: rgba(0,0,0,0) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0 !important;
    transition: background 0.28s, opacity 0.28s !important;
}
.sgp-gallery-wrap .sgp-item:not(.sgp-item-video):hover .sgp-overlay {
    background: rgba(0,0,0,0.3) !important;
    opacity: 1 !important;
}
.sgp-gallery-wrap .sgp-item-video:hover .sgp-overlay {
    background: rgba(0,0,0,0.12) !important;
    opacity: 1 !important;
}

.sgp-gallery-wrap .sgp-lightbox-btn {
    width: 48px !important; height: 48px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.18) !important;
    border: 1.5px solid rgba(255,255,255,0.5) !important;
    color: #fff !important; cursor: pointer !important;
    display: flex !important; align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(10px) !important;
    transform: scale(0.8) !important;
    transition: transform 0.2s, background 0.2s !important;
    padding: 0 !important;
}
.sgp-gallery-wrap .sgp-item:hover .sgp-lightbox-btn {
    transform: scale(1) !important;
}
.sgp-gallery-wrap .sgp-lightbox-btn:hover {
    background: #fff !important; color: #111 !important;
    transform: scale(1.1) !important;
}
.sgp-gallery-wrap .sgp-lightbox-btn svg {
    width: 18px !important; height: 18px !important;
    pointer-events: none !important; display: block !important;
}

/* Empty state */
.sgp-gallery-wrap .sgp-empty {
    grid-column: 1 / -1 !important;
    text-align: center !important; padding: 80px 20px !important;
    color: #bbb !important; font-size: 14px !important;
}

/* ════════════════════════════════════════════
   LIGHTBOX
   ════════════════════════════════════════════ */
#sgp-lightbox-global {
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    right: 0 !important; bottom: 0 !important;
    z-index: 9999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transition: opacity 0.22s ease, visibility 0.22s ease !important;
    pointer-events: none !important;
}
#sgp-lightbox-global.sgp-active {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: all !important;
}
#sgp-lightbox-global .sgp-lb-bg {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    right: 0 !important; bottom: 0 !important;
    background: rgba(0,0,0,0.93) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    cursor: pointer !important;
}
#sgp-lightbox-global .sgp-lb-stage {
    position: relative !important; z-index: 2 !important;
    display: flex !important; flex-direction: column !important;
    align-items: center !important;
    max-width: 90vw !important;
    animation: sgpLbPop 0.26s cubic-bezier(0.34,1.4,0.64,1) both !important;
}
#sgp-lightbox-global:not(.sgp-active) .sgp-lb-stage {
    animation: none !important;
}
@keyframes sgpLbPop {
    from { transform: scale(0.88); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}
#sgp-lightbox-global .sgp-lb-media-wrap {
    display: flex !important;
    align-items: center !important; justify-content: center !important;
    max-width: 90vw !important; max-height: 82vh !important;
    overflow: hidden !important; border-radius: 12px !important;
    line-height: 0 !important;
}
#sgp-lightbox-global .sgp-lb-media-wrap img {
    display: block !important;
    max-width: 90vw !important; max-height: 82vh !important;
    width: auto !important; height: auto !important;
    object-fit: contain !important;
    border-radius: 12px !important;
    box-shadow: 0 32px 80px rgba(0,0,0,0.7) !important;
}
#sgp-lightbox-global .sgp-lb-media-wrap video {
    display: block !important;
    max-width: 90vw !important; max-height: 82vh !important;
    border-radius: 12px !important; outline: none !important;
}
#sgp-lightbox-global .sgp-lb-info {
    display: flex !important; align-items: center !important;
    gap: 10px !important; padding: 12px 2px 0 !important;
}
#sgp-lightbox-global .sgp-lb-serial {
    background: rgba(255,255,255,0.12) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    color: #fff !important; padding: 3px 10px !important;
    border-radius: 6px !important; font-size: 11px !important;
    font-weight: 700 !important; letter-spacing: 1px !important;
    white-space: nowrap !important; flex-shrink: 0 !important;
}
#sgp-lightbox-global .sgp-lb-title {
    color: rgba(255,255,255,0.65) !important;
    font-size: 13px !important; font-weight: 400 !important;
    margin: 0 !important; overflow: hidden !important;
    text-overflow: ellipsis !important; white-space: nowrap !important;
}
#sgp-lightbox-global .sgp-lb-close,
#sgp-lightbox-global .sgp-lb-prev,
#sgp-lightbox-global .sgp-lb-next {
    position: fixed !important; z-index: 3 !important;
    background: rgba(255,255,255,0.1) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    color: #fff !important; cursor: pointer !important;
    border-radius: 50% !important;
    display: flex !important; align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(8px) !important;
    transition: background 0.2s !important; line-height: 1 !important;
    font-family: sans-serif !important;
}
#sgp-lightbox-global .sgp-lb-close {
    top: 18px !important; right: 18px !important;
    width: 44px !important; height: 44px !important;
    font-size: 22px !important;
}
#sgp-lightbox-global .sgp-lb-prev {
    left: 16px !important; top: 50% !important;
    transform: translateY(-50%) !important;
    width: 50px !important; height: 50px !important;
    font-size: 32px !important; padding-right: 3px !important;
}
#sgp-lightbox-global .sgp-lb-next {
    right: 16px !important; top: 50% !important;
    transform: translateY(-50%) !important;
    width: 50px !important; height: 50px !important;
    font-size: 32px !important; padding-left: 3px !important;
}
#sgp-lightbox-global .sgp-lb-close:hover { background: rgba(255,255,255,0.22) !important; }
#sgp-lightbox-global .sgp-lb-prev:hover  { background: rgba(255,255,255,0.18) !important; }
#sgp-lightbox-global .sgp-lb-next:hover  { background: rgba(255,255,255,0.18) !important; }

/* ════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .sgp-gallery-wrap .sgp-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-auto-rows: 200px !important;
    }
}

@media (max-width: 700px) {
    .sgp-gallery-wrap .sgp-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: 155px !important;
        gap: 6px !important;
    }
    /* Kill ALL bento spans on mobile */
    .sgp-gallery-wrap .sgp-grid .sgp-item.sgp-col-2,
    .sgp-gallery-wrap .sgp-grid .sgp-item.sgp-row-2,
    .sgp-gallery-wrap .sgp-grid .sgp-item:nth-child(7n+1),
    .sgp-gallery-wrap .sgp-grid .sgp-item:nth-child(7n+3),
    .sgp-gallery-wrap .sgp-grid .sgp-item:nth-child(7n+5) {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
    /* Smaller play button on mobile */
    .sgp-gallery-wrap .sgp-play-icon-inner {
        width: 40px !important;
        height: 40px !important;
    }
    .sgp-gallery-wrap .sgp-play-icon-inner svg {
        width: 16px !important;
        height: 16px !important;
        margin-left: 3px !important;
    }
    #sgp-lightbox-global .sgp-lb-prev { left: 8px !important; }
    #sgp-lightbox-global .sgp-lb-next { right: 8px !important; }
    #sgp-lightbox-global .sgp-lb-media-wrap img,
    #sgp-lightbox-global .sgp-lb-media-wrap video {
        max-width: 96vw !important; max-height: 75vh !important;
    }
}

@media (max-width: 380px) {
    .sgp-gallery-wrap .sgp-grid {
        grid-auto-rows: 130px !important;
    }
}
