/* ===========================================================================
   /gallery only (scripts/build_gallery.py). Loaded after style.css, landing-page.css and
   site.css; the photo cards, before/after pairs and dark section come from the landers.
   Bump GALLERY_CSS_VERSION in build_gallery.py on every edit, then rebuild.
   =========================================================================== */

/* --- Jump links: plain text links that wrap, no pills and no hidden scroller --- */
.gal-jump {
    background: var(--clr-white);
    border-bottom: 1px solid var(--clr-border);
}

.gal-jump ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-xl);
    margin: 0;
    padding: 0;
    list-style: none;
}

.gal-jump a {
    display: inline-block;
    padding: 16px 0 14px;
    border-bottom: 2px solid transparent;
    color: var(--clr-navy);
    font-family: var(--font-heading);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    text-decoration: none;
}

.gal-jump a:hover {
    border-bottom-color: var(--clr-teal);
}

.gal-jump a:focus-visible {
    border-bottom-color: var(--clr-teal);
    outline: 3px solid var(--clr-navy);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .gal-jump ul {
        gap: 0 var(--space-lg);
        padding-block: 4px;
    }

    .gal-jump a {
        padding: 10px 0 8px;
        font-size: 0.95rem;
    }
}

/* --- Sections --- */
.gal-head {
    max-width: 42em;
    margin-bottom: var(--space-xl);
}

/* Light sections alternate white and off-white (the builder marks every other one). */
.gal-section--alt {
    background-color: var(--clr-off-white);
}

.gal-section--text {
    padding-block: var(--space-3xl);
}

.gal-section--text .gal-head {
    margin-bottom: var(--space-md);
}

.gal-note {
    max-width: 42em;
    margin: 0;
    color: var(--clr-text-body);
}

/* An upload filed under a text-only section (screens) brings its own grid under the note. */
.gal-note + .gal-grid {
    margin-top: var(--space-xl);
}

.gal-pairs {
    margin-bottom: var(--space-2xl);
}

/* Photo grid: masonry columns, so portrait and landscape photos keep their own shape. */
.gal-grid {
    columns: 3 280px;
    column-gap: var(--space-lg);
}

/* Four photos or fewer: two columns, so two photos sit side by side and four fill a 2x2,
   instead of leaving a third column empty. */
.gal-grid--few {
    columns: 2;
    max-width: 820px;
}

.gal-grid .gal-shot {
    display: block;
    width: 100%;
    margin: 0 0 var(--space-lg);
    break-inside: avoid;
}

@media (max-width: 640px) {
    .gal-grid {
        columns: 2;
        column-gap: 12px;
    }

    .gal-grid .gal-shot {
        margin-bottom: var(--space-md);
    }

    .gal-grid :is(.lp-ba, .lp-shot) figcaption {
        font-size: 0.82rem;
    }

    .gal-grid :is(.lp-ba, .lp-shot) figcaption strong {
        font-size: 0.92rem;
    }
}

/* Every photo is a button that opens the larger view. */
.gal-open {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: zoom-in;
}

.gal-grid .gal-open {
    overflow: hidden;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    background-color: var(--clr-navy-light);
}

/* Each photo keeps its own shape: build_gallery.py sets --lp-shot-ratio from its width and
   height, so a photo holds its space before it loads. */
.lp-page--quote .gal-grid .gal-open img {
    border-radius: 0;
    box-shadow: none;
    content-visibility: visible;
}

/* Uploads from the admin dashboard have no size attributes: a fixed frame keeps the page still. */
.lp-page--quote .gal-grid .gal-shot--upload img {
    aspect-ratio: 4 / 5;
    object-fit: cover;
}

.lp-ba-shot.gal-open {
    position: relative;
    overflow: hidden;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .gal-open img {
        transition: transform 0.35s ease;
    }

    .gal-open:hover img {
        transform: scale(1.03);
    }
}

.gal-open:focus-visible {
    outline: 3px solid var(--clr-navy);
    outline-offset: 3px;
}

.lp-work--dark .gal-open:focus-visible {
    outline-color: var(--clr-teal);
}

/* --- Under each section: the service's own page, then a call link --- */
.gal-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm) var(--space-xl);
    margin-top: var(--space-md);
}

/* .gal-more / .gal-call (the links above) are styled in css/site.css: home and /services use
   .gal-more too. */

/* --- The larger view --- */
.gal-lightbox {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--clr-white);
}

.gal-lightbox::backdrop {
    background: rgba(12, 17, 33, 0.97);
}

.gal-lightbox-inner {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    padding: 64px 80px 56px;
}

.gal-lightbox-figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
}

.gal-lightbox-figure img {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 190px);
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    touch-action: pan-y;
}

.gal-lightbox-figure figcaption {
    max-width: 44em;
    margin-top: var(--space-md);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    text-align: center;
}

.gal-lightbox-figure figcaption strong {
    color: var(--clr-white);
}

.gal-lightbox-close,
.gal-lightbox-nav {
    position: absolute;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--clr-white);
    cursor: pointer;
}

.gal-lightbox-close svg,
.gal-lightbox-nav svg {
    width: 22px;
    height: 22px;
}

.gal-lightbox-close {
    top: 12px;
    right: 12px;
}

.gal-lightbox-prev {
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.gal-lightbox-next {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.gal-lightbox-nav[hidden] {
    display: none;
}

.gal-lightbox :focus-visible {
    outline: 3px solid var(--clr-teal);
    outline-offset: 2px;
}

.gal-lightbox-count {
    position: absolute;
    top: 24px;
    left: 0;
    right: 0;
    margin: 0;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
    text-align: center;
    pointer-events: none;
}

@media (max-width: 640px) {
    .gal-lightbox-inner {
        padding: 60px 12px 88px;
    }

    .gal-lightbox-figure img {
        max-height: calc(100dvh - 230px);
    }

    .gal-lightbox-prev,
    .gal-lightbox-next {
        top: auto;
        bottom: 20px;
        transform: none;
    }

    .gal-lightbox-prev {
        left: calc(50% - 64px);
    }

    .gal-lightbox-next {
        right: calc(50% - 64px);
    }
}

body.gal-locked {
    overflow: hidden;
}
