/* Immersive post-section gallery: fixed-height stage, scroll-snap track, thumbnails. Uncropped photos. */
.gal {
    --gal-teal: #0e4a5a;
    --gal-muted: #56636a;
    --gal-accent: #c8431f;
    --gal-stage: min(72vh, 560px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 900px;
    margin: 20px auto;
}

.gal-stage {
    position: relative;
    height: var(--gal-stage);
    overflow: hidden;
}

.gal-track {
    display: flex;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
}

.gal-track::-webkit-scrollbar {
    display: none;
}

.gal-slide {
    flex: 0 0 100%;
    height: 100%;
    margin: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gal-slide img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
}

.gal-count {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 3;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: normal;
    color: var(--gal-teal);
    background: rgba(255, 255, 255, .9);
    padding: 5px 10px;
    border-radius: 999px;
}

/* the site theme styles every <button> (orange inset outline, uppercase, fixed height) - reset for the gallery */
.gal button {
    appearance: none;
    box-shadow: none;
    height: auto;
    line-height: normal;
    padding: 0;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
}

.gal button.gal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, .92);
    color: var(--gal-teal) !important;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    transition: opacity .25s;
}

.gal button.gal-nav:hover,
.gal button.gal-nav:active {
    background: #fff;
}

.gal button.gal-nav.prev {
    left: 14px;
}

.gal button.gal-nav.next {
    right: 14px;
}

.gal button.gal-nav:disabled {
    opacity: 0;
    pointer-events: none;
}

.gal-cap {
    margin: 0 2px;
    font-size: 14.5px;
    line-height: 1.45;
    color: var(--gal-muted);
    min-height: 21px;
    text-align: center;
}

/* thumbnails: same height, natural width = no crop */
.gal-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 3px 2px 4px;
    scroll-behavior: smooth;
}

.gal-thumbs::-webkit-scrollbar {
    display: none;
}

/* centered when they fit; auto margins (not justify-content:center) keep the start reachable when the strip overflows */
.gal .gal-thumbs button:first-child {
    margin-left: auto;
}

.gal .gal-thumbs button:last-child {
    margin-right: auto;
}

.gal .gal-thumbs button {
    flex: 0 0 auto;
    height: 68px;
    min-width: 40px;
    border: 0;
    background: none;
    border-radius: 9px;
    cursor: pointer;
    position: relative;
    opacity: .55;
    transition: opacity .25s;
}

.gal .gal-thumbs button:hover,
.gal .gal-thumbs button:active {
    background: none;
    opacity: .85;
}

.gal .gal-thumbs button.on {
    opacity: 1;
}

.gal-thumbs button.on::after {
    content: "";
    position: absolute;
    inset: -3px;
    border: 2.5px solid var(--gal-accent);
    border-radius: 12px;
}

.gal-thumbs img {
    height: 100%;
    width: auto;
    display: block;
    border-radius: 9px;
}

.gal :focus-visible {
    outline: 3px solid #2f7fd1;
    outline-offset: 2px;
}

@media (min-width: 768px) {
    .gal button.gal-nav {
        display: inline-flex;
    }

    .gal-thumbs {
        gap: 10px;
    }

    .gal .gal-thumbs button {
        height: 80px;
    }
}

/* phones: stage runs edge to edge (#main > .inner has 2em side padding at this width) */
@media (max-width: 736px) {
    .gal-stage {
        margin: 0 -2em;
        --gal-stage: min(64vh, 500px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gal *, .gal-track {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* fullscreen viewer, opened by tapping a photo */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.7);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.modal img {
    max-width: 90%;
    max-height: 90%;
}

.modal span {
    color: white;
    font-weight: bold;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

