.gallery-item {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 3px;
    box-shadow: 0 8px 24px rgba(8, 24, 48, 0.05);
    transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
}

.gallery-item:hover,
.gallery-item:focus-visible {
    transform: translateY(-4px);
    border-color: rgba(177, 138, 67, .55);
    box-shadow: 0 18px 42px rgba(8, 24, 48, .13);
}

.gallery-item img {
    transition: transform .65s cubic-bezier(.2, .7, .2, 1), filter .35s ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
    transform: scale(1.045);
    filter: saturate(1.04) contrast(1.02);
}

.image-viewer {
    width: min(1240px, calc(100vw - 48px));
    max-width: none;
    max-height: calc(100vh - 32px);
    margin: auto;
    padding: 0;
    border: 1px solid rgba(177, 138, 67, .45);
    border-radius: 4px;
    overflow: hidden;
    color: #fff;
    background: #06152c;
    box-shadow: 0 32px 90px rgba(0, 0, 0, .48);
}

.image-viewer[open] {
    animation: gallery-viewer-in .3s cubic-bezier(.2, .8, .2, 1);
}

.image-viewer::backdrop {
    background: rgba(2, 9, 21, .86);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: gallery-backdrop-in .25s ease-out;
}

.image-viewer-shell {
    position: relative;
    padding: 28px 72px 20px;
}

.image-viewer-figure {
    margin: 0;
}

.image-viewer-media {
    height: min(76vh, 780px);
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #030d1e;
}

.image-viewer img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    transition: opacity .2s ease, transform .34s cubic-bezier(.2, .75, .2, 1);
    will-change: opacity, transform;
}

.image-viewer img.gallery-exit-left {
    opacity: 0;
    transform: translate3d(-34px, 0, 0) scale(.985);
}

.image-viewer img.gallery-exit-right {
    opacity: 0;
    transform: translate3d(34px, 0, 0) scale(.985);
}

.image-viewer img.gallery-enter-right {
    opacity: 0;
    transform: translate3d(34px, 0, 0) scale(.985);
}

.image-viewer img.gallery-enter-left {
    opacity: 0;
    transform: translate3d(-34px, 0, 0) scale(.985);
}

.image-viewer img.gallery-no-transition {
    transition: none;
}

.image-viewer figcaption {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 4px 0;
}

.image-viewer figcaption p {
    margin: 0;
    color: #fff;
    font-size: 13px;
    font-weight: 550;
    letter-spacing: .15px;
    text-align: left;
}

.image-viewer figcaption span {
    flex-shrink: 0;
    color: rgba(255, 255, 255, .65);
    font-size: 10px;
    letter-spacing: 1.8px;
}

.image-viewer-nav,
.image-viewer-close {
    position: absolute;
    z-index: 3;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .28);
    color: #fff;
    background: rgba(6, 21, 44, .72);
    cursor: pointer;
    transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}

.image-viewer-nav {
    top: 50%;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    transform: translateY(-50%);
}

.image-viewer-prev {
    left: 12px;
}

.image-viewer-prev svg {
    transform: rotate(180deg);
}

.image-viewer-next {
    right: 12px;
}

.image-viewer-nav:hover,
.image-viewer-nav:focus-visible,
.image-viewer-close:hover,
.image-viewer-close:focus-visible {
    color: #fff;
    border-color: var(--gold);
    background: var(--gold);
}

.image-viewer-nav:hover {
    transform: translateY(-50%) scale(1.06);
}

.image-viewer-close {
    top: 9px;
    right: 9px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
}

@keyframes gallery-viewer-in {
    from { opacity: 0; transform: translateY(12px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gallery-backdrop-in {
    from { background: rgba(2, 9, 21, 0); }
    to { background: rgba(2, 9, 21, .86); }
}

@media (max-width: 740px) {
    .image-viewer {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }

    .image-viewer-shell {
        padding: 52px 10px 14px;
    }

    .image-viewer-media {
        height: min(68vh, 620px);
    }

    .image-viewer-nav {
        width: 42px;
        height: 42px;
    }

    .image-viewer-prev { left: 16px; }
    .image-viewer-next { right: 16px; }

    .image-viewer figcaption {
        padding: 13px 4px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-item img,
    .image-viewer[open],
    .image-viewer::backdrop,
    .image-viewer img {
        animation: none;
        transition: none;
    }
}
