.image-modal-trigger {
    position: relative;
    display: block;
    width: max-content;
    max-width: 100%;
}

.image-modal-trigger img {
    cursor: zoom-in;
}

.image-modal-trigger__button,
.image-modal__close {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 999px;
    background: rgba(7, 21, 45, .88);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .24);
}

.image-modal-trigger__button {
    position: absolute;
    top: 12px;
    right: 12px;
    transition: background-color .18s ease, transform .18s ease;
}

.image-modal-trigger__button svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.image-modal-trigger__button:hover,
.image-modal-trigger__button:focus-visible,
.image-modal__close:hover,
.image-modal__close:focus-visible {
    background: #1769aa;
    outline: 3px solid rgba(126, 203, 255, .72);
    outline-offset: 3px;
}

.image-modal-trigger__button:hover {
    transform: scale(1.06);
}

body.has-image-modal {
    overflow: hidden;
}

.image-modal[hidden] {
    display: none;
}

.image-modal {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 32px;
    overflow: auto;
    background: rgba(2, 8, 20, .9);
    overscroll-behavior: contain;
}

.image-modal__panel {
    position: relative;
    display: grid;
    justify-items: center;
    width: min(94vw, 1800px);
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
    animation: image-modal-enter .18s ease-out;
}

.image-modal__close {
    position: fixed;
    z-index: 1;
    top: max(18px, env(safe-area-inset-top));
    right: max(18px, env(safe-area-inset-right));
    font-size: 2rem;
    line-height: 1;
}

.image-modal__stage {
    position: relative;
    display: grid;
    min-width: min(320px, 82vw);
    min-height: min(220px, 52vh);
    place-items: center;
}

.image-modal__image {
    display: block;
    max-width: 94vw;
    max-height: calc(100vh - 150px);
    max-height: calc(100dvh - 150px);
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}

.image-modal__status {
    margin: 0;
    color: #fff;
    font-weight: 700;
    text-align: center;
}

.image-modal__meta {
    width: min(82ch, 92vw);
}

.image-modal__caption {
    margin: 14px auto 0;
    color: rgba(255, 255, 255, .92);
    line-height: 1.55;
    text-align: center;
}

@keyframes image-modal-enter {
    from { opacity: 0; transform: scale(.985); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 640px) {
    .image-modal {
        padding: 64px 12px 20px;
    }

    .image-modal__panel {
        width: 96vw;
        max-height: calc(100vh - 84px);
        max-height: calc(100dvh - 84px);
    }

    .image-modal__image {
        max-width: 96vw;
        max-height: calc(100vh - 170px);
        max-height: calc(100dvh - 170px);
        border-radius: 8px;
    }

    .image-modal-trigger__button,
    .image-modal__close {
        width: 48px;
        height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .image-modal__panel {
        animation: none;
    }

    .image-modal-trigger__button {
        transition: none;
    }
}
