/* === Page-level overrides (undo homepage snap-scroll/overflow) === */
html, body {
    overflow: auto !important;
    overflow-x: hidden;
    height: auto;
}
.gallery-page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    box-sizing: border-box;
}
section {
    height: auto;
    min-height: auto;
    scroll-snap-align: none;
    scroll-snap-stop: normal;
    display: block;
    padding: 0;
    position: static;
}

/* === Header === */
.gallery-header {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
}
.gallery-header h1 {
    margin-bottom: 0.5rem;
}
.back-link {
    position: absolute;
    left: 0; top: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid var(--primary);
    padding-bottom: 2px;
    transition: opacity 0.3s ease;
}
.back-link:hover { opacity: 0.6; }

/* === Masonry grid === */
.gallery-masonry {
    column-count: 3;
    column-gap: 0.75rem;
}
.gallery-masonry img {
    width: 100%;
    display: block;
    margin-bottom: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    background: #eee;
    aspect-ratio: 4 / 3;
    transition: transform 0.4s cubic-bezier(0.25,1,0.5,1), box-shadow 0.4s ease;
}
.gallery-masonry img:hover {
    transform: scale(1.015);
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}
.gallery-masonry img.reveal {
    opacity: 0; transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.gallery-masonry img.reveal.active {
    opacity: 1; transform: translateY(0);
}
.gallery-masonry img.reveal.active:hover {
    transform: scale(1.015);
}

@media (max-width: 900px) {
    .gallery-masonry { column-count: 2; }
}
@media (max-width: 500px) {
    .gallery-masonry { column-count: 1; }
    .back-link { position: static; display: inline-block; margin-bottom: 1rem; }
    .gallery-header { text-align: center; }
}

/* === Lightbox dialog === */
#lightbox-modal {
    padding: 0;
    border: none;
    background: transparent;
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
}
#lightbox-modal::backdrop {
    background: rgba(0,0,0,0.92);
}
.lightbox-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: 100vw;
    max-width: 100vw !important;
    height: 100vh;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.lightbox-img-wrap {
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-img-wrap img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.lightbox-close {
    position: absolute; top: 1.5rem; right: 1.5rem;
    z-index: 10;
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 2rem;
    width: 48px; height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    line-height: 1;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.25); }
.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }
.lightbox-counter {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.85rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: rgba(0,0,0,0.4);
    padding: 0.4rem 1rem;
    border-radius: 20px;
}
@media (max-width: 600px) {
    .lightbox-nav { width: 38px; height: 38px; font-size: 1.5rem; }
    .lightbox-prev { left: 0.5rem; }
    .lightbox-next { right: 0.5rem; }
}

/* === Status message === */
#gallery-status { padding: 3rem 0; }
