/* Lightbox image viewer (js/lightbox.js). Self-contained; works on any page. */

html.lb-open, html.lb-open body { overflow: hidden; }

.lb {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    background: rgba(8, 6, 12, 0.94);
    color: #ece8f6;
    opacity: 0;
    transition: opacity 0.18s ease, background-color 0.2s ease;
    touch-action: none;            /* gestures are handled in JS */
    overscroll-behavior: contain;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.lb[hidden] { display: none; }
.lb.is-visible { opacity: 1; }

/* top bar: counter + close */
.lb__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: max(0.5rem, env(safe-area-inset-top)) max(0.6rem, env(safe-area-inset-right)) 0.3rem max(1rem, env(safe-area-inset-left));
    min-height: 3.2rem;
}
.lb__count { font-size: 0.9rem; letter-spacing: 0.08em; color: #a39bb8; font-variant-numeric: tabular-nums; }

/* stage */
.lb__stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0 0.5rem;
}
.lb__img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
    cursor: zoom-in;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.lb.is-zoomed .lb__img { cursor: grab; }
.lb.is-loading .lb__img { opacity: 0; }
.lb.is-error .lb__img { display: none; }

.lb__spinner {
    position: absolute;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: 3px solid rgba(183, 148, 255, 0.2);
    border-top-color: #b794ff;
    animation: lbSpin 0.8s linear infinite;
    display: none;
}
.lb.is-loading .lb__spinner { display: block; }
@keyframes lbSpin { to { transform: rotate(360deg); } }

/* bottom bar: prev · caption · next (mobile); arrows move to the sides on wide screens */
.lb__bottom {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem max(0.6rem, env(safe-area-inset-right)) max(0.7rem, env(safe-area-inset-bottom)) max(0.6rem, env(safe-area-inset-left));
    min-height: 3.6rem;
}
.lb__cap {
    flex: 1;
    margin: 0;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #d7d1e4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* buttons — 48px touch targets */
.lb__btn {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: rgba(40, 32, 56, 0.75);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}
.lb__btn svg { width: 1.4rem; height: 1.4rem; fill: currentColor; }
.lb__btn:hover { background: rgba(70, 56, 98, 0.95); }
.lb__btn:active { transform: scale(0.94); }
.lb__btn:focus-visible { outline: 2px solid #F5B400; outline-offset: 2px; }
.lb.is-single .lb__nav { visibility: hidden; }

@media (min-width: 760px) {
    .lb__stage { padding: 0 5.5rem; }
    .lb__nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 3.5rem;
        height: 3.5rem;
    }
    .lb__nav:active { transform: translateY(-50%) scale(0.94); }
    .lb__prev { left: max(1.2rem, env(safe-area-inset-left)); }
    .lb__next { right: max(1.2rem, env(safe-area-inset-right)); }
    .lb__bottom { justify-content: center; }
    .lb__cap { max-width: 70ch; }
}

@media (prefers-reduced-motion: reduce) {
    .lb, .lb__img, .lb__btn { transition: none; }
    .lb__spinner { animation-duration: 2s; }
}

/* Cursor hint on thumbnails that open in the viewer. */
[data-lightbox] { cursor: zoom-in; }
