.bsg-event-gallery,
.bsg-event-gallery * {
    box-sizing: border-box;
}

.bsg-event-gallery__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(12px, 2vw, 24px);
}

.bsg-event-gallery__item {
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 12px;
    background: #f3f3f3;
    cursor: zoom-in;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
}

.bsg-event-gallery__item:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

.bsg-event-gallery__image {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 180ms ease;
}

.bsg-event-gallery__item:hover .bsg-event-gallery__image {
    transform: scale(1.015);
}

.bsg-event-gallery__empty {
    text-align: center;
}

.bsg-event-gallery__empty[hidden] {
    display: none !important;
}

.bsg-event-gallery__lightbox[hidden] {
    display: none;
}

.bsg-event-gallery__lightbox {
    position: fixed !important;
    z-index: 2147483646 !important;
    inset: 0 !important;
    display: grid;
    place-items: center;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding:
        max(24px, env(safe-area-inset-top))
        max(24px, env(safe-area-inset-right))
        max(24px, env(safe-area-inset-bottom))
        max(24px, env(safe-area-inset-left));
    isolation: isolate;
}

.bsg-event-gallery__backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.86);
    cursor: zoom-out;
}

.bsg-event-gallery__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    width: fit-content;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    align-items: center;
    justify-content: center;
}

.bsg-event-gallery__large-image {
    display: block;
    width: auto !important;
    height: auto !important;
    max-width: calc(100vw - 48px) !important;
    max-height: calc(100vh - 48px) !important;
    max-height: calc(100dvh - 48px) !important;
    object-fit: contain !important;
}

.bsg-event-gallery__close {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 8px;
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #111;
    font: 32px/1 sans-serif;
    cursor: pointer;
}

body.bsg-event-gallery-open {
    overflow: hidden;
}

@media (max-width: 600px) {
    .bsg-event-gallery__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .bsg-event-gallery__lightbox {
        padding:
            max(12px, env(safe-area-inset-top))
            max(12px, env(safe-area-inset-right))
            max(12px, env(safe-area-inset-bottom))
            max(12px, env(safe-area-inset-left));
    }

    .bsg-event-gallery__dialog,
    .bsg-event-gallery__large-image {
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100vh - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bsg-event-gallery__image {
        transition: none;
    }
}
