.stack-gallery {
    width: 100%;
}

.stack-gallery__stack {
    position: relative;
    display: block;
    width: 100%;
    max-width: 25rem;
    height: clamp(31rem, 48vw, 35.625rem);
    padding: 0;
    border: 0;
    margin: 0 auto;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.stack-gallery__card {
    position: absolute;
    top: 0;
    left: 50%;
    width: min(90%, 22.5rem);
    aspect-ratio: 0.72;
    margin: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: var(--glass-radius);
    background: rgba(255, 255, 255, 0.22);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        0 18px 40px rgba(16, 21, 23, 0.14);
    transition:
        transform 350ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 350ms ease,
        border-color 350ms ease;
    -webkit-backdrop-filter: blur(var(--glass-blur-subtle)) saturate(130%);
    backdrop-filter: blur(var(--glass-blur-subtle)) saturate(130%);
}

.stack-gallery__card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.stack-gallery__card:nth-child(1) {
    z-index: 3;
    transform: translateX(calc(-50% - 20%)) translateY(68px) rotate(-6deg);
}

.stack-gallery__card:nth-child(2) {
    z-index: 2;
    transform: translateX(-50%) translateY(34px) rotate(0deg);
}

.stack-gallery__card:nth-child(3) {
    z-index: 1;
    transform: translateX(calc(-50% + 20%)) translateY(0) rotate(8deg);
}

.stack-gallery__stack.is-awaiting-reveal .stack-gallery__card {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        0 14px 30px rgba(16, 21, 23, 0.12);
}

.stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1),
.stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2),
.stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
    transform: translateX(-50%) translateY(34px) rotate(0deg);
}

.stack-gallery__stack:hover .stack-gallery__card,
.stack-gallery__stack:focus-visible .stack-gallery__card {
    border-color: rgba(255, 255, 255, 0.82);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.52),
        0 24px 55px rgba(16, 21, 23, 0.2);
}

.stack-gallery__stack:hover .stack-gallery__card:nth-child(1),
.stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(1) {
    transform: translateX(calc(-50% - 24%)) translateY(60px) rotate(-8deg);
}

.stack-gallery__stack:hover .stack-gallery__card:nth-child(2),
.stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(2) {
    transform: translateX(-50%) translateY(26px) rotate(0deg);
}

.stack-gallery__stack:hover .stack-gallery__card:nth-child(3),
.stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(3) {
    transform: translateX(calc(-50% + 24%)) translateY(-4px) rotate(10deg);
}

.stack-gallery__stack.is-awaiting-reveal:hover .stack-gallery__card:nth-child(1),
.stack-gallery__stack.is-awaiting-reveal:hover .stack-gallery__card:nth-child(2),
.stack-gallery__stack.is-awaiting-reveal:hover .stack-gallery__card:nth-child(3),
.stack-gallery__stack.is-awaiting-reveal:focus-visible .stack-gallery__card:nth-child(1),
.stack-gallery__stack.is-awaiting-reveal:focus-visible .stack-gallery__card:nth-child(2),
.stack-gallery__stack.is-awaiting-reveal:focus-visible .stack-gallery__card:nth-child(3) {
    transform: translateX(-50%) translateY(34px) rotate(0deg);
}

.stack-gallery__items[hidden] {
    display: none;
}

@media (max-width: 767px) {
    .stack-gallery__stack {
        max-width: 100%;
        height: min(118vw, 27rem);
    }

    .stack-gallery__card {
        width: min(68vw, 15rem);
    }

    .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 10%)) translateY(48px) rotate(-5deg);
    }

    .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(24px) rotate(0deg);
    }

    .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 10%)) translateY(0) rotate(6deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(-50%) translateY(24px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(1),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 12%)) translateY(44px) rotate(-6deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(2),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(20px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(3),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 12%)) translateY(-2px) rotate(7deg);
    }
}

@media (min-width: 768px) and (max-width: 1199px) and (min-height: 600px) {
    .stack-gallery__stack {
        max-width: 22rem;
        height: 31rem;
    }

    .stack-gallery__card {
        width: min(82%, 18.5rem);
    }

    .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 16%)) translateY(52px) rotate(-5deg);
    }

    .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(26px) rotate(0deg);
    }

    .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 16%)) translateY(0) rotate(7deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(-50%) translateY(26px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(1),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 18%)) translateY(48px) rotate(-7deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(2),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(22px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(3),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 18%)) translateY(-2px) rotate(8deg);
    }
}

@media (orientation: landscape) and (min-width: 640px) and (max-width: 979px) and (max-height: 520px) {
    .stack-gallery__stack {
        max-width: 18rem;
        height: 18.5rem;
    }

    .stack-gallery__card {
        width: min(68%, 11.75rem);
    }

    .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 14%)) translateY(32px) rotate(-5deg);
    }

    .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(16px) rotate(0deg);
    }

    .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 14%)) translateY(0) rotate(6deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(-50%) translateY(16px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(1),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 17%)) translateY(28px) rotate(-7deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(2),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(12px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(3),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 17%)) translateY(-2px) rotate(8deg);
    }
}

@media (orientation: landscape) and (min-width: 640px) and (max-width: 820px) and (max-height: 380px) {
    .stack-gallery__stack {
        max-width: 16.5rem;
        height: 17rem;
    }

    .stack-gallery__card {
        width: min(66%, 10.5rem);
    }

    .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 12%)) translateY(28px) rotate(-5deg);
    }

    .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(14px) rotate(0deg);
    }

    .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 12%)) translateY(0) rotate(6deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2),
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(-50%) translateY(14px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(1),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 14%)) translateY(24px) rotate(-6deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(2),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(10px) rotate(0deg);
    }

    .stack-gallery__stack:hover .stack-gallery__card:nth-child(3),
    .stack-gallery__stack:focus-visible .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 14%)) translateY(-2px) rotate(7deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .stack-gallery__card {
        transition: none;
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 20%)) translateY(68px) rotate(-6deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(34px) rotate(0deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 20%)) translateY(0) rotate(8deg);
    }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
    .stack-gallery__card {
        background: rgba(255, 255, 255, 0.92);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 10%)) translateY(48px) rotate(-5deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(24px) rotate(0deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 10%)) translateY(0) rotate(6deg);
    }
}

@media (min-width: 768px) and (max-width: 1199px) and (min-height: 600px) and (prefers-reduced-motion: reduce) {
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 16%)) translateY(52px) rotate(-5deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(26px) rotate(0deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 16%)) translateY(0) rotate(7deg);
    }
}

@media (orientation: landscape) and (min-width: 640px) and (max-width: 979px) and (max-height: 520px) and (prefers-reduced-motion: reduce) {
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 14%)) translateY(32px) rotate(-5deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(16px) rotate(0deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 14%)) translateY(0) rotate(6deg);
    }
}

@media (orientation: landscape) and (min-width: 640px) and (max-width: 820px) and (max-height: 380px) and (prefers-reduced-motion: reduce) {
    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(1) {
        transform: translateX(calc(-50% - 12%)) translateY(28px) rotate(-5deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(2) {
        transform: translateX(-50%) translateY(14px) rotate(0deg);
    }

    .stack-gallery__stack.is-awaiting-reveal .stack-gallery__card:nth-child(3) {
        transform: translateX(calc(-50% + 12%)) translateY(0) rotate(6deg);
    }
}
