/* Final cross-gallery lightbox contract. Loaded after page-specific styles. */
.lightbox {
    box-sizing: border-box !important;
    overflow: hidden !important;
    padding: clamp(12px, 2vw, 28px) !important;
    gap: 0 !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

.lightbox .lightbox-content,
.lightbox .lightbox-img-wrapper {
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    width: auto !important;
    height: auto !important;
    max-width: min(92vw, 1600px) !important;
    max-height: 90vh !important;
    margin-left: auto !important;
    margin-right: auto !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
}

/* Keep the same visual order in every artwork viewer, regardless of whether
   the page places the caption inside an image wrapper or directly in the
   lightbox: artwork first, caption underneath, optional Yin/Yang hint last. */
.lightbox > img,
.lightbox .lightbox-content > img,
.lightbox .lightbox-img-wrapper > img,
.lightbox > .lightbox-img-wrapper,
.lightbox > .lightbox-content {
    order: 1 !important;
}

.lightbox > .lightbox-title,
.lightbox .lightbox-content > .lightbox-title,
.lightbox .lightbox-img-wrapper > .lightbox-title {
    order: 2 !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    z-index: 1 !important;
}

.lightbox > .lightbox-flip-hint,
.lightbox .lightbox-content > .lightbox-flip-hint,
.lightbox .lightbox-img-wrapper > .lightbox-flip-hint {
    order: 3 !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
}

.lightbox > img,
.lightbox .lightbox-content > img,
.lightbox .lightbox-img-wrapper > img {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: min(92vw, 1600px) !important;
    max-height: 84vh !important;
    object-fit: contain !important;
    object-position: center center !important;
    transform-origin: center center !important;
    margin-left: auto !important;
    margin-right: auto !important;
    will-change: transform;
}

.lightbox .lightbox-title,
.lightbox .lightbox-flip-hint {
    flex: 0 0 auto !important;
    align-self: center !important;
    justify-self: center !important;
    width: auto !important;
    max-width: min(92vw, 1100px) !important;
    margin: clamp(10px, 1.5vh, 16px) auto 0 !important;
    box-sizing: border-box !important;
    text-align: center !important;
}

.lightbox .lightbox-flip-hint {
    margin-top: 6px !important;
}

.lightbox .lightbox-nav {
    display: flex !important;
    z-index: 10040 !important;
}

@media (max-width: 768px) {
    .lightbox .lightbox-nav {
        width: 38px !important;
        height: 38px !important;
        background: rgba(0, 0, 0, 0.42) !important;
        border-color: rgba(255, 255, 255, 0.52) !important;
    }

    .lightbox .lightbox-prev {
        left: max(8px, env(safe-area-inset-left)) !important;
    }

    .lightbox .lightbox-next {
        right: max(8px, env(safe-area-inset-right)) !important;
    }

    .lightbox > img,
    .lightbox .lightbox-content > img,
    .lightbox .lightbox-img-wrapper > img {
        max-width: 94vw !important;
        max-height: 80vh !important;
    }
}
