/*
 * USAMuscle Browse Lightbox — Fullscreen Media Viewer
 *
 * Vanilla CSS for image/video lightbox overlay.
 * Relies on luxe CSS custom properties for theming.
 */

/* =========================================================================
   Overlay
   ========================================================================= */

.usm-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.92);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.usm-lightbox.open {
    opacity: 1;
    visibility: visible;
}

/* =========================================================================
   Close Button
   ========================================================================= */

.usm-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.usm-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =========================================================================
   Navigation Arrows
   ========================================================================= */

.usm-lightbox__prev,
.usm-lightbox__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
    opacity: 0.7;
}

.usm-lightbox__prev:hover,
.usm-lightbox__next:hover {
    background: rgba(255, 255, 255, 0.18);
    opacity: 1;
}

.usm-lightbox__prev:disabled,
.usm-lightbox__next:disabled {
    opacity: 0.2;
    cursor: default;
}

.usm-lightbox__prev { left: 16px; }
.usm-lightbox__next { right: 16px; }

/* =========================================================================
   Counter
   ========================================================================= */

.usm-lightbox__counter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* =========================================================================
   Content Area
   ========================================================================= */

.usm-lightbox__content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 60px 80px;
    box-sizing: border-box;
}

.usm-lightbox__content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
}

.usm-lightbox__content video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    background: #000;
}

/* =========================================================================
   Loading Spinner
   ========================================================================= */

.usm-lightbox__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: usm-lb-spin 0.7s linear infinite;
}

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

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 768px) {
    .usm-lightbox__content {
        padding: 60px 16px;
    }

    .usm-lightbox__prev,
    .usm-lightbox__next {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .usm-lightbox__prev { left: 8px; }
    .usm-lightbox__next { right: 8px; }
}

@media (max-width: 480px) {
    .usm-lightbox__prev,
    .usm-lightbox__next {
        display: none; /* swipe on mobile instead */
    }

    .usm-lightbox__content {
        padding: 56px 8px;
    }
}

/* =========================================================================
   Reduced Motion
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
    .usm-lightbox {
        transition: none;
    }

    .usm-lightbox__spinner {
        animation: none;
        opacity: 0.5;
    }
}

/* Trigger: a photo that opens in the lightbox rather than linking to the file */
.usm-photo-open { cursor: zoom-in; }
.usm-photo-open:focus-visible { outline: 3px solid var(--refresh-primary, #f44336); outline-offset: 2px; }
/* A single photo needs no counter or arrows */
.usm-lightbox.single .usm-lightbox__counter, .usm-lightbox.single .usm-lightbox__prev, .usm-lightbox.single .usm-lightbox__next { display: none; }
