.gallery {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.gallery h1 {
    margin: 0 0 2rem;
    text-align: center;
}

/* Masonry-style desktop layout */
.gallery-grid {
    width: 100%;
    box-sizing: border-box;
    column-count: 4;
    column-gap: 10px;
}

/* IMPORTANT: do not use flex here */
.gallery-item {
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    break-inside: avoid;
    margin-bottom: 10px;
    border-radius: 4px;
}

.gallery-item a {
    display: block;
    width: 100%;
}

.gallery-item img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: cover;
    transition: transform 0.3s ease-in-out;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item:hover .image-overlay {
    transform: translateY(0);
}

/* Image overlay */
.image-overlay {
    font-family: 'Open Sans', sans-serif;
    font-weight: normal;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    text-align: left;
    padding: 15px;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.image-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0 0 5px;
}

.image-caption {
    font-size: 14px;
    opacity: 0.8;
    margin: 0;
}

/* Tablet */
@media (max-width: 768px) {
    .gallery-grid {
        column-count: 2;
        column-gap: 8px;
    }

    .image-overlay {
        font-size: 12px;
        padding: 8px;
        background: rgba(0, 0, 0, 0.5);
    }
}

/* Phone */
@media (max-width: 480px) {
    .gallery {
        width: 100%;
        padding-left: 0;
        padding-right: 0;
    }

    .gallery-grid {
        display: block;
        width: 100%;
        column-count: 1;
        column-gap: 0;
    }

    .gallery-item {
        display: block;
        width: 100%;
        margin-bottom: 2rem;
        border-radius: 0;
    }

    .gallery-item a {
        display: block;
        width: 100%;
    }

    .gallery-item img {
        display: block;
        width: 100%;
        max-width: none;
        border-radius: 0;
    }

    .gallery-item:hover img {
        transform: none;
    }

    .image-overlay {
        position: static;
        width: 100%;
        box-sizing: border-box;
        transform: none;
        background: none;
        color: inherit;
        font-size: 12px;
        padding: 0.5rem 0;
    }

    .gallery-item:hover .image-overlay {
        transform: none;
    }
}