/* =========================================
   Lightbox – Full-screen image viewer
   ========================================= */

.lightbox-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: var(--lightbox-viewport-height, 100dvh);
    height: 100vh;
    height: 100dvh;
    height: var(--lightbox-viewport-height, 100dvh);
    z-index: 10001;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.lightbox-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

html.lightbox-open,
body.lightbox-open {
    overflow: hidden;
    overscroll-behavior: none;
    height: 100%;
}

/* Close button */
.lightbox-close {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.lightbox-close:focus-visible {
    outline: none;
    border-color: rgba(241, 181, 95, 0.8);
    background: rgba(241, 181, 95, 0.16);
    box-shadow: 0 0 0 3px rgba(241, 181, 95, 0.22);
}

/* Image container */
.lightbox-img-wrap {
    position: relative;
    max-width: 90vw;
    max-height: calc(var(--lightbox-viewport-height, 100dvh) - 2rem);
    overflow: visible;
    touch-action: none;
    cursor: zoom-in;
}

.lightbox-img-wrap.is-zoomed {
    cursor: zoom-out;
}

.lightbox-img-wrap.is-dragging {
    cursor: grabbing;
}

.lightbox-img-wrap img {
    display: block;
    max-width: 90vw;
    max-height: calc(var(--lightbox-viewport-height, 100dvh) - 2rem);
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
    transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

.lightbox-overlay.is-wide-media .lightbox-img-wrap,
.lightbox-overlay.is-wide-media .lightbox-img-wrap img {
    max-width: min(76vw, 1120px);
    max-height: calc(var(--lightbox-viewport-height, 100dvh) - 4rem);
}

.lightbox-overlay.is-wide-media .lightbox-img-wrap,
.lightbox-overlay.is-wide-media .lightbox-img-wrap.is-zoomed,
.lightbox-overlay.is-wide-media .lightbox-img-wrap.is-dragging {
    cursor: default;
}

.lightbox-img-wrap.is-dragging img {
    transition: none;
}

/* Raise custom cursor above lightbox when open */
body.lightbox-open .cursor,
body.lightbox-open .cursor-follower {
    z-index: 10002;
}

/* SP: disable default touch behaviors inside lightbox */
.lightbox-overlay {
    touch-action: none;
    -webkit-touch-callout: none;
}

@media (max-width: 768px) {
    .lightbox-overlay {
        padding-top: env(safe-area-inset-top, 0);
        padding-right: env(safe-area-inset-right, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
    }

    .lightbox-close {
        top: calc(env(safe-area-inset-top, 0px) + 0.8rem);
        right: calc(env(safe-area-inset-right, 0px) + 0.8rem);
    }

    .lightbox-img-wrap {
        max-width: 96vw;
        max-height: calc(var(--lightbox-viewport-height, 100dvh) - 3rem);
    }

    .lightbox-img-wrap img {
        max-width: 96vw;
        max-height: calc(var(--lightbox-viewport-height, 100dvh) - 3rem);
    }

    .lightbox-overlay.is-wide-media .lightbox-img-wrap,
    .lightbox-overlay.is-wide-media .lightbox-img-wrap img {
        max-width: 92vw;
        max-height: calc(var(--lightbox-viewport-height, 100dvh) - 5rem);
    }
}
