.php-gallery {
    display: grid;
    grid-template-columns: repeat(
        var(--gallery-columns-desktop, 3),
        minmax(0, 1fr)
    );
    gap: 16px;
    width: 100%;
}

.php-gallery__item {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    aspect-ratio: 4 / 3;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 6px;
    background-color: #e8e8e8;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    cursor: pointer;
    text-align: left;
}

.php-gallery__item::after {
    content: "";
    position: absolute;
    inset: 35% 0 0;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(0, 0, 0, 0.75)
    );
    pointer-events: none;
}

.php-gallery__caption {
    position: absolute;
    z-index: 1;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 16px;
    color: #fff;
    font-size: 15px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.php-gallery__item:focus-visible {
    outline: 3px solid #315be8;
    outline-offset: 3px;
}

.php-gallery-modal {
    position: fixed;
    z-index: 99999;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.88);
    cursor: zoom-out;
}

.php-gallery-modal.is-open {
    display: flex;
}

.php-gallery-modal__image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: default;
}

.php-gallery-modal__close {
    position: absolute;
    top: 12px;
    right: 18px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 32px;
    cursor: pointer;
}

@media (max-width: 767px) {
    .php-gallery {
        grid-template-columns: repeat(
            var(--gallery-columns-mobile, 1),
            minmax(0, 1fr)
        );
        gap: 10px;
    }

    .php-gallery__caption {
        padding: 10px;
        font-size: 13px;
    }

    .php-gallery-modal {
        padding: 10px;
    }

    .php-gallery-modal__image {
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
    }
}
