/* Image Galleries page — repeating titled gallery sections of small thumbnails,
   each opening a draggable, scroll-snapped lightbox. */

.galleries-main {
    background-color: #fff;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* Mobile Top Nav - Hidden on desktop */
.galleries-mobile-nav {
    display: none;
}

.galleries-mobile-menu-btn {
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
}

.galleries-mobile-menu-btn:focus {
    outline: none;
    border: none;
}

.galleries-mobile-menu-btn .hamburger-icon {
    display: block;
}

.galleries-mobile-menu-btn .close-icon {
    display: none;
}

.galleries-mobile-menu-btn.active .hamburger-icon {
    display: none;
}

.galleries-mobile-menu-btn.active .close-icon {
    display: block;
}

/* Hero — full content width, centered (mirrors the unified hero modifier) */
.galleries-hero-section {
    margin: 0 auto 32px auto;
    max-width: 1432px;
}

/* Content area (body grid below offsets the sidebar) */
.galleries-content {
    max-width: 1432px;
    margin: 0 auto;
    padding: 0 0 60px;
}

/* Repeating gallery sections */
.gallery-section {
    margin: 0 0 56px;
}

.gallery-section:last-child {
    margin-bottom: 0;
}

.gallery-section-title {
    font-size: 16px;
    font-weight: 400;
    color: var(--m-forest-100);
    margin: 0 0 20px;
    letter-spacing: 0.02em;
}

/* Small thumbnail grid */
.gallery-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.gallery-grid-item {
    margin: 0;
}

.gallery-grid-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--m-pine-80-t);
    border: none;
    padding: 0;
    cursor: pointer;
}

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

.gallery-grid-thumb:hover img {
    transform: scale(1.04);
}

/* Collapsed thumbnails hidden behind the "+N" tile */
.gallery-grid-item.is-collapsed {
    display: none;
}

/* "+N" overlay tile — dimmed preview of the next hidden image */
.gallery-more-btn {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: none;
    padding: 0;
    cursor: pointer;
    background: var(--m-forest-100, #173132);
}

.gallery-more-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.35;
    transition: opacity 0.3s ease;
}

.gallery-more-btn:hover img {
    opacity: 0.25;
}

.gallery-more-count {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 0.08em;
}

/* Circular collapse disc shown below an expanded grid */
.gallery-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #ededeb;
    color: var(--m-forest-100, #173132);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
}

.gallery-collapse:hover {
    background: #e1e1de;
}

.gallery-collapse[hidden] {
    display: none;
}

.galleries-empty {
    color: var(--m-forest-80-t);
}

/* ---------------------------------------------------------------------------
   Lightbox — light overlay with a horizontal, scroll-snapped strip of images.
   Center image large, neighbours peeking in from the sides. Drag on desktop,
   swipe on touch, arrow keys to navigate, Escape to close. */

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000000;
    background: rgba(255, 255, 255, 0.96);
    display: none;
}

.gallery-lightbox.is-open {
    display: block;
}

.gallery-lightbox-track {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    scrollbar-width: none; /* Firefox */
    /* Side padding so first/last slides can center; images anchor near the
       top, reserving a bottom band for the scrollbar + close button */
    padding: 28px 50vw 0;
}

.gallery-lightbox-track::-webkit-scrollbar {
    display: none;
}

.gallery-lightbox-track.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
}

.gallery-lightbox-slide {
    flex: 0 0 auto;
    scroll-snap-align: center;
    height: calc(100vh - 125px); /* 28px top + 97px bottom control band */
    display: flex;
    align-items: center;
}

.gallery-lightbox-slide img {
    height: 100%;
    width: auto;
    max-width: 88vw;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* Small custom scrollbar, bottom-left — mirrors the track's scroll position.
   Thick rounded thumb riding on a thin track, centered on the same baseline
   as the close button. Container is taller than the bar for an easier grab. */
.gallery-lightbox-scrollbar {
    position: absolute;
    left: 40px;
    bottom: 43px;
    width: 120px;
    height: 26px;
    cursor: pointer;
}

.gallery-lightbox-scrollbar::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    margin-top: -2px;
    border-radius: 2px;
    background: rgba(23, 49, 50, 0.14);
}

.gallery-lightbox-scrollbar-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    height: 6px;
    margin-top: -3px;
    border-radius: 3px;
    background: #5c6b6b;
    will-change: transform, width;
}

.gallery-lightbox-close {
    position: absolute;
    right: 35px;
    bottom: 40px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #ededeb;
    color: var(--m-forest-100, #173132);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}

.gallery-lightbox-close:hover {
    background: #e1e1de;
}

/* Keep the page from scrolling underneath the open lightbox */
body.gallery-lightbox-open {
    overflow: hidden;
}

/* Desktop: sticky sidebar + grid (mirrors the other content templates) */
@media (min-width: 901px) {
    body.page-template-template-galleries .sidebar-nav {
        top: 16px;
        position: sticky;
        padding: 0;
        left: 0;
    }

    body.page-template-template-galleries .site-wrapper {
        display: grid;
        gap: 16px;
        grid-template-columns: max-content 1fr;
    }
}

/* Mobile */
@media (max-width: 900px) {

    /* Hide default header menu toggle; use the in-template mobile nav instead */
    body.page-template-template-galleries .mobile-menu-toggle:not(.galleries-mobile-menu-btn) {
        display: none;
    }

    body.page-template-template-galleries .site-wrapper {
        padding: 0 !important;
    }

    body.page-template-template-galleries .main-content {
        padding: 0 16px;
    }

    .galleries-hero-section {
        margin-bottom: 24px;
    }

    .gallery-section {
        margin-bottom: 40px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
        gap: 8px;
    }

    .gallery-lightbox-track {
        gap: 16px;
        align-items: center;
        padding-top: 0;
    }

    .gallery-lightbox-slide {
        height: auto;
        max-height: 80vh;
    }

    .gallery-lightbox-slide img {
        height: auto;
        max-height: 80vh;
        max-width: 92vw;
    }

    /* Mobile Top Nav */
    .galleries-mobile-nav {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: 24px 48px;
        justify-content: space-between;
        align-items: center;
        z-index: 1000000;
        background: transparent;
        pointer-events: none;
    }

    .galleries-mobile-nav > * {
        pointer-events: auto;
    }

    .galleries-mobile-logo {
        display: flex;
        align-items: center;
    }

    .galleries-mobile-logo a {
        display: block;
        line-height: 0;
    }

    .galleries-mobile-logo img,
    .galleries-mobile-logo svg {
        height: 32px;
        width: auto;
    }

    .galleries-mobile-menu-btn .hamburger-icon {
        display: block;
        width: 40px;
        height: 40px;
    }

    .galleries-mobile-menu-btn .close-icon {
        display: none;
        width: 40px;
        height: 40px;
    }

    .galleries-mobile-menu-btn.active .hamburger-icon {
        display: none !important;
    }

    .galleries-mobile-menu-btn.active .close-icon {
        display: block !important;
    }
}
