.gallery a {
    display: flex;
    aspect-ratio: 1;
    width: 100%;
    height: 100%;
}

.gallery a img {
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.gallery.cols-4 a {
    position: relative;
}

.gallery.cols-4 a::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: #959559;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.gallery.cols-4 a:hover::after,
.gallery.cols-4 a:focus-visible::after {
    opacity: 0.35;
}

.gallery.cols-4 a:focus-visible {
    outline: 2px solid #959559;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .gallery.cols-4 a::after {
        transition: none;
    }
}

*:has(>.gallery) {
    container-type: inline-size;
    container-name: gallery;
}

.gallery {
    display: grid;
    gap: 1rem;
}

.gallery.cols-1 {
    grid-template-columns: repeat(1, 1fr);
}

.gallery.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.gallery.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.gallery.cols-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .gallery.cols-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .gallery.cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container gallery (max-width: 1000px) {
    .gallery.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@container gallery (max-width: 500px) {
    .gallery.cols-3 {
        grid-template-columns: repeat(1, 1fr);
    }
}
