/* =============================================================
   Gallery — image wall of every project, linked to case studies
   templates/page-gallery.php   Prefix: gal
   ============================================================= */

.gal {
    --gal-max: 1400px;
    --gal-gutter: clamp(1.25rem, 5vw, 3.5rem);
    --gal-green: #36452f;
    --gal-ink: #171717;
    --gal-line: rgba(23, 23, 23, 0.08);
}

/* ── Hero (flat green, matches the nav + other heroes) ─────── */
.gal-hero {
    background: var(--sd-color-primary, #36452f);
    padding: clamp(6.5rem, 11vw, 9rem) var(--gal-gutter) clamp(2.5rem, 5vw, 3.5rem);
}

.gal-hero__inner {
    max-width: var(--gal-max);
    margin-inline: auto;
}

.gal-hero__overline {
    display: inline-block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--sd-color-cta-hover, #8db35a);
    margin-bottom: 1rem;
}

.gal-hero__title {
    font-size: clamp(2.25rem, 5vw, 4rem); /* unified hero title scale */
    color: #ffffff;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.gal-hero__intro {
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 680px;
}

.gal-hero__intro p:last-child {
    margin-bottom: 0;
}

/* ── Body ──────────────────────────────────────────────────── */
.gal-body {
    max-width: var(--gal-max);
    margin-inline: auto;
    padding: clamp(2rem, 4vw, 3rem) var(--gal-gutter) clamp(3.5rem, 7vw, 6rem);
}

/* ── Segment toggle (Built | Designs) ──────────────────────── */
.gal-segment {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.25rem;
    margin-bottom: 1.75rem;
    background: var(--sd-color-gray-100, #f5f5f5);
    border-radius: 999px;
}

.gal-segment__btn {
    appearance: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    background: transparent;
    color: #5c6055;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.gal-segment__btn.is-active {
    background: #fff;
    color: var(--gal-ink, #171717);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.gal-segment__count {
    opacity: 0.5;
    font-variant-numeric: tabular-nums;
}

.gal-segment__btn.is-active .gal-segment__count {
    color: var(--sd-color-cta, #5f7d3a);
    opacity: 1;
}

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

.gal-designs__intro {
    color: #5c6055;
    font-size: 1.02rem;
    line-height: 1.6;
    max-width: 70ch;
    margin: 0 0 1.75rem;
}

.gal-designs__intro a {
    color: var(--sd-color-cta, #5f7d3a) !important; /* beat the global p a blue */
    text-decoration: underline;
}

/* ── Flagship callout (editable) ───────────────────────────── */
.gal-flagship {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
    background: var(--sd-color-primary, #36452f);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gal-flagship:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 44px -24px rgba(0, 0, 0, 0.55);
}

.gal-flagship__body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.75rem, 3.5vw, 3rem);
}

.gal-flagship__overline {
    color: var(--sd-color-cta-hover, #8db35a);
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
}

.gal-flagship__heading {
    color: #fff;
    font-size: clamp(1.5rem, 2.6vw, 2.15rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 0.75rem;
}

.gal-flagship__text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 1.5rem;
    max-width: 48ch;
}

.gal-flagship__cta {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 1.4rem;
    border-radius: 999px;
    background: var(--sd-color-cta, #5f7d3a);
    color: #fff;
    font-weight: 600;
    font-size: 0.92rem;
    transition: background-color 0.18s ease, gap 0.18s ease;
}

.gal-flagship:hover .gal-flagship__cta {
    background: var(--sd-color-cta-strong, #4f6b30);
    gap: 0.7rem;
}

.gal-flagship__media {
    position: relative;
    min-height: 250px;
}

.gal-flagship__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 700px) {
    .gal-flagship {
        grid-template-columns: 1fr;
    }

    .gal-flagship__media {
        order: -1; /* image on top when stacked */
        min-height: 200px;
    }
}

/* ── Filter chips ──────────────────────────────────────────── */
.gal-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.gal-filter__chip {
    appearance: none;
    border: 1px solid var(--gal-line);
    background: #fff;
    color: #3f4338;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 1.05rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.gal-filter__chip:hover {
    border-color: var(--sd-color-cta, #5f7d3a);
    color: var(--sd-color-cta, #5f7d3a);
}

.gal-filter__chip.is-active {
    background: var(--sd-color-cta, #5f7d3a);
    border-color: var(--sd-color-cta, #5f7d3a);
    color: #fff;
}

.gal-filter__count {
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
    margin-left: 0.15rem;
}

/* ── Masonry grid (CSS columns) ────────────────────────────── */
/* Twin-column grid of uniform tiles (client request 2026-07-02 — replaced
   the Pinterest-style CSS-columns masonry). */
.gal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 640px) {
    .gal-grid { grid-template-columns: 1fr; gap: 12px; }
}

.gal-item {
    position: relative;
    margin: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--sd-color-gray-100, #f5f5f5);
}

.gal-item__img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: zoom-in;
}

.gal-item:hover .gal-item__img {
    transform: scale(1.05);
}

/* Image takes priority: caption is hidden until hover (desktop). */
.gal-item__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(to top, rgba(20, 28, 16, 0.85) 0%, rgba(20, 28, 16, 0.2) 48%, transparent 75%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.gal-item__meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.gal-item__link {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: var(--sd-color-cta, #5f7d3a);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    pointer-events: none; /* interactive only while the overlay is visible */
    transition: background-color 0.18s ease;
}

.gal-item:hover .gal-item__link {
    pointer-events: auto;
}

.gal-item__link:hover {
    background: var(--sd-color-cta-strong, #4f6b30);
}

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

/* Touch devices: caption + link are always shown, so keep the link tappable. */
@media (hover: none) {
    .gal-item__link {
        pointer-events: auto;
    }
}

.gal-item:hover .gal-item__overlay,
.gal-item:focus-visible .gal-item__overlay {
    opacity: 1;
}

/* Touch devices have no hover — keep the caption visible there. */
@media (hover: none) {
    .gal-item__overlay {
        opacity: 1;
    }
}

.gal-item__title {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.25;
    /* keep long titles to two lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gal-item__type {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* filtered-out items */
.gal-item[hidden] {
    display: none;
}

.gal-empty {
    text-align: center;
    color: #6b6f64;
    padding: 3rem 1rem;
}

/* ── Lightbox ──────────────────────────────────────────────── */
.gal-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 3rem);
    background: rgba(12, 16, 10, 0.93);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

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

.gal-lightbox__figure {
    margin: 0;
    max-width: min(1100px, 94vw);
    display: flex;
    flex-direction: column;
}

.gal-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 78vh;
    margin: 0 auto;
    object-fit: contain;
    border-radius: 6px 6px 0 0;
    background: #0c100a;
}

.gal-lightbox__caption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    background: #1a1f15;
    border-radius: 0 0 6px 6px;
}

.gal-lightbox__type {
    display: block;
    color: var(--sd-color-cta-hover, #8db35a);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.25rem;
}

.gal-lightbox__title {
    color: #fff;
    font-size: 1.1rem;
    line-height: 1.25;
    margin: 0;
}

.gal-lightbox__cta {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: 999px;
    background: var(--sd-color-cta, #5f7d3a);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background-color 0.18s ease;
}

.gal-lightbox__cta:hover {
    background: var(--sd-color-cta-strong, #4f6b30);
}

.gal-lightbox__close,
.gal-lightbox__nav {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transition: background-color 0.18s ease;
}

.gal-lightbox__close:hover,
.gal-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.22);
}

.gal-lightbox__close {
    top: 1.1rem;
    right: 1.2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
}

.gal-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 1.75rem;
    line-height: 1;
}

.gal-lightbox__nav--prev { left: clamp(0.5rem, 2vw, 1.5rem); }
.gal-lightbox__nav--next { right: clamp(0.5rem, 2vw, 1.5rem); }

.gal-lightbox__nav[disabled] {
    opacity: 0.3;
    cursor: default;
}

.gal-lightbox__counter {
    position: absolute;
    bottom: 1.1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
    .gal-lightbox__caption {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.9rem;
    }

    .gal-lightbox__cta {
        width: 100%;
        justify-content: center;
    }

    .gal-lightbox__nav {
        width: 42px;
        height: 42px;
    }
}
