#gallery {
    padding: 2rem 9rem;
    font-family: var(--font-main);
    color: var(--color-text);
}

#gallery h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Categories buttons */
.gallery-categories {
    text-align: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    display: flex;
    justify-content: center;
}

.category-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 20px;
    background-color: var(--color-blue);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.category-btn:hover {
    filter: brightness(0.8);
}

.category-btn.active {
    background-color: var(--color-red);
    color: #fff;
}

/* Gallery grid */
.gallery-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-rows: 180px; /* fixed row height */
    grid-auto-flow: dense;
    position: relative;
}

.gallery-item {
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.5s ease, opacity 0.5s ease;
    opacity: 1;
    transform: scale(1);
    height: 180px;
    position: absolute;
    width: 220px;
    filter: contrast(1.2);
}

.gallery-item.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.gallery-item img {
    width: 100%;
    height: 100%; /* fill entire container */
    object-fit: cover; /* crop to fit exactly */
    border-radius: 12px;
    display: block;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.modal.show {
    opacity: 1;
}

.modal.hide {
    opacity: 0;
}

/* Image animations */
.modal-content {
    max-width: 90%;
    max-height: 80%;
    border-radius: 12px;
    transform: translateY(-100vh); /* start off-screen */
    transition: transform 0.5s ease;
}

.modal.show .modal-content {
    transform: translateY(0); /* slide in */
}

.modal.hide .modal-content {
    transform: translateY(-100vh); /* slide out */
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
}

/* Responsive */
@media (min-width: 769px) {
    .gallery-item:hover {
        filter: brightness(0.8);
    }
}
@media (max-width: 768px) {
    #gallery {
        padding: 2rem 3rem;
    }
}
