.gallery-section {
    position: relative;
    z-index: 1;
    scroll-margin-top: 16px;
    padding-top: clamp(40px, 5vw, 70px);
    padding-bottom: 60px;
    background: linear-gradient(to bottom, transparent, var(--color-bg) clamp(100px, 20vw, 260px));
}

.gallery-title {
    text-align: center;
    font-family: inherit;
    font-size: clamp(2rem, 1.8rem + 1vw, 2.4rem);
    text-transform: uppercase;
    color: var(--color-accent);
    margin: 30px 0;
}

.gallery-categories {
    position: sticky;
    top: 12px;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 0 auto clamp(56px, 6vw, 84px);
    padding: 8px 10px;
    width: fit-content;
    border: 1px solid var(--color-border);
    border-radius: 32px;
    background: var(--color-surface);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.gallery-category {
    padding: 9px 20px;
    font-family: inherit;
    font-size: 0.95rem;
    text-transform: uppercase;
    border: 1px solid var(--color-border);
    border-radius: 30px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.gallery-category:hover,
.gallery-category.is-active {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: var(--color-on-accent);
}

.gallery-category:focus-visible,
.load-more-btn:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 3px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.gallery-item {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    background: var(--color-surface);
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 0 0 0 transparent;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.gallery-item:hover,
.gallery-item:focus-visible {
    border-color: var(--color-accent);
    box-shadow: 0 0 18px color-mix(in srgb, var(--color-accent) 45%, transparent);
}

.gallery-item:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 3px;
}

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

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

.gallery-more-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin: 30px 0 60px;
}

.gallery-count {
    margin: 0;
    font-family: inherit;
    font-size: 1rem;
    color: var(--color-text-muted);
}

.load-more-btn {
    padding: 12px 28px;
    font-size: 16px;
    font-family: inherit;
    text-transform: lowercase;
    border: 2px solid var(--color-accent);
    background: var(--color-bg);
    color: var(--color-accent);
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.load-more-btn:hover {
    background: var(--color-accent);
    color: var(--color-bg);
}

.load-more-btn[hidden] {
    display: none;
}

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

@media (max-width: 600px) {
    .gallery-categories {
        /* Clears the fixed sound-/lang-/theme-buttons (top:16px,
           up to ~64px tall) instead of sticking underneath them. */
        top: 76px;
        max-width: calc(100vw - 32px);
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 8px;
    }

    .gallery-category {
        padding: 7px 14px;
        font-size: 0.85rem;
    }

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


.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox[hidden] {
    display: none;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

:root[data-theme="light"] .lightbox-backdrop {
    background: rgba(255, 255, 255, 0.9);
}

.lightbox-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 66vw;
    max-height: 72vh;
}

.lightbox-image {
    position: relative;
    max-width: 66vw;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 20px;
    border: 3px solid var(--color-accent);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    z-index: 2;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.lightbox-close:hover,
.lightbox-close:focus-visible,
.lightbox-nav:hover,
.lightbox-nav:focus-visible {
    background: var(--color-accent);
    color: var(--color-on-accent);
}

.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.lightbox-close {
    top: -56px;
    right: -83px;
    width: 48px;
    height: 48px;
    font-size: 2.1rem;
    line-height: 1;
}

.lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 66px;
    height: 66px;
    font-size: 2.4rem;
    line-height: 1;
}

.lightbox-prev {
    left: -92px;
}

.lightbox-next {
    right: -92px;
}

@media (max-width: 900px) {
    .lightbox-stage,
    .lightbox-image {
        max-width: 84vw;
        max-height: 70vh;
    }

    .lightbox-close {
        top: -50px;
        right: -51px;
    }

    .lightbox-prev {
        left: -60px;
    }

    .lightbox-next {
        right: -60px;
    }
}

@media (max-width: 600px) {
    .lightbox-stage,
    .lightbox-image {
        max-width: 88vw;
        max-height: 64vh;
    }

    .lightbox-close {
        top: -46px;
        right: 0;
        width: 42px;
        height: 42px;
        font-size: 1.8rem;
    }

    .lightbox-nav {
        width: 46px;
        height: 46px;
        font-size: 1.7rem;
        background: rgba(0, 0, 0, 0.45);
    }

    .lightbox-prev {
        left: 6px;
    }

    .lightbox-next {
        right: 6px;
    }
}
