/* Low specificity lets existing responsive/absolute positioning take precedence. */
:where(.ne-lightbox-ready .ne-lightbox-anchor) {
    position: relative;
}

html.ne-lightbox-ready img[data-lightbox-src],
html.ne-lightbox-ready .ne-lightbox-anchor,
html.ne-lightbox-ready .ne-lightbox-anchor .overlay {
    cursor: pointer;
}

/* Existing teaser cursors describe navigation, while an opted-in image opens the dialog. */
html.ne-lightbox-ready .ne-lightbox-anchor .styled_cursor {
    display: none;
}

.ne-lightbox-ready img[data-lightbox-src]:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -5px;
    box-shadow: inset 0 0 0 7px #222;
}

.ne-lightbox-indicator {
    display: none;
    position: absolute;
    z-index: 3;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgb(0 0 0 / 70%);
    color: #fff;
    pointer-events: none;
}

.ne-lightbox-ready .ne-lightbox-indicator {
    display: block;
}

.ne-lightbox-indicator::before {
    content: '';
    position: absolute;
    top: 7px;
    left: 7px;
    box-sizing: content-box;
    width: 11px;
    height: 11px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.ne-lightbox-indicator::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 19px;
    width: 8px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    transform: rotate(45deg);
    transform-origin: left center;
}

html.ne-lightbox-open {
    overflow: hidden;
}

dialog.ne-lightbox {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 56px 24px;
    border: 0;
    background: transparent;
    color: #fff;
    overflow: auto;
    opacity: 0;
    transition: opacity 180ms ease;
}

dialog.ne-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

dialog.ne-lightbox::backdrop {
    background: rgb(0 0 0 / 85%);
    opacity: 0;
    transition: opacity 180ms ease;
}

dialog.ne-lightbox.is-visible,
dialog.ne-lightbox.is-visible::backdrop {
    opacity: 1;
}

dialog.ne-lightbox .ne-lightbox-image {
    display: block;
    flex: 0 1 auto;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    object-fit: contain;
    transform: scale(.96);
    transition: transform 180ms ease;
}

dialog.ne-lightbox.is-visible .ne-lightbox-image {
    transform: scale(1);
}

dialog.ne-lightbox .ne-lightbox-close {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    appearance: none;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgb(255 255 255 / 60%);
    border-radius: 50%;
    background: #222;
    color: #fff;
    cursor: pointer;
}

dialog.ne-lightbox .ne-lightbox-close::before,
dialog.ne-lightbox .ne-lightbox-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(45deg);
    transform-origin: center;
    pointer-events: none;
}

dialog.ne-lightbox .ne-lightbox-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

dialog.ne-lightbox .ne-lightbox-close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

dialog.ne-lightbox .ne-lightbox-status {
    color: #fff;
    text-align: center;
}

.ne-lightbox-indicator[hidden],
dialog.ne-lightbox [hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    dialog.ne-lightbox,
    dialog.ne-lightbox::backdrop,
    dialog.ne-lightbox .ne-lightbox-image {
        transition: none;
        transform: none;
    }
}
