/* ============================================================
   PB Lightbox v1.0.4 — Main Stylesheet
   ============================================================ */

/* Prevent body scroll when lightbox is open */
body.pb-lb-open {
    overflow: hidden;
}

/* ── Overlay ───────────────────────────────────────────────── */
#pb-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
}

#pb-lightbox-overlay.is-active {
    display: flex;
}

/* Dark backdrop */
#pb-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.93);
    cursor: default;
}

/* ── Main layout ───────────────────────────────────────────── */
#pb-lb-main {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 0 52px;
    box-sizing: border-box;
}

/* ── Image wrapper ─────────────────────────────────────────── */
#pb-lb-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

#pb-lb-img {
    display: block;
    max-width: calc(100vw - 120px);
    max-height: calc(100vh - 90px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    transition: opacity 0.25s ease;
    user-select: none;
}

/* Loading state */
#pb-lightbox-overlay.is-loading #pb-lb-img {
    opacity: 0;
}

#pb-lb-spinner {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
}

#pb-lightbox-overlay.is-loading #pb-lb-spinner {
    display: flex;
}

#pb-lb-spinner::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: pb-spin 0.8s linear infinite;
}

@keyframes pb-spin {
    to { transform: rotate(360deg); }
}

/* ── Navigation buttons (prev / next) ─────────────────────── */
#pb-lb-prev,
#pb-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    font-size: 1.4rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

#pb-lb-prev { left: 8px; }
#pb-lb-next { right: 8px; }

#pb-lb-prev:hover,
#pb-lb-next:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ── Close button ──────────────────────────────────────────── */
#pb-lb-close {
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    font-size: 1.1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#pb-lb-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Toolbar (bottom bar) ──────────────────────────────────── */
#pb-lb-toolbar {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 16px 14px;
    box-sizing: border-box;
    gap: 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.55));
}

#pb-lb-counter {
    color: rgba(255, 255, 255, 0.65);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

#pb-lb-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

#pb-lb-play,
#pb-lb-fullscreen {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    font-size: 1rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#pb-lb-play:hover,
#pb-lb-fullscreen:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Caption ───────────────────────────────────────────────── */
#pb-lb-caption-wrap {
    min-height: 1.2em;
}

#pb-lb-caption {
    color: rgba(255, 255, 255, 0.8);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    text-align: center;
    display: block;
}

/* ── Fullscreen adjustments ────────────────────────────────── */
#pb-lightbox-overlay:fullscreen #pb-lb-img {
    max-width: 100vw;
    max-height: 100vh;
}

#pb-lightbox-overlay:fullscreen #pb-lb-main {
    padding: 0;
}

/* Controls fade-out in fullscreen
   All interactive chrome transitions to invisible on controls-hidden class */
#pb-lb-close,
#pb-lb-prev,
#pb-lb-next,
#pb-lb-toolbar {
    transition:
        opacity 0.5s ease,
        background 0.2s;
}

#pb-lightbox-overlay.controls-hidden #pb-lb-close,
#pb-lightbox-overlay.controls-hidden #pb-lb-prev,
#pb-lightbox-overlay.controls-hidden #pb-lb-next,
#pb-lightbox-overlay.controls-hidden #pb-lb-toolbar {
    opacity: 0;
    pointer-events: none;
}

/* Hide the cursor too for a clean TV look */
#pb-lightbox-overlay.controls-hidden,
#pb-lightbox-overlay.controls-hidden * {
    cursor: none !important;
}

/* ── Focus ring (accessibility) ────────────────────────────── */
#pb-lightbox-overlay *:focus-visible {
    outline: 2px solid #4af;
    outline-offset: 2px;
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 600px) {
    #pb-lb-main {
        padding: 0 44px;
    }

    #pb-lb-img {
        max-width: calc(100vw - 96px);
    }

    #pb-lb-prev { left: 4px; }
    #pb-lb-next { right: 4px; }

    #pb-lb-prev,
    #pb-lb-next {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
}
