/* ======================================================
   Section 1: Gallery Page Foundation
========================================================= */

.gallery-page {
    --gallery-ink: #082f33;
    --gallery-green: #2e6b47;
    --gallery-aqua: #49a8a6;
    --gallery-sage: #edf3ec;
    --gallery-cream: #f8f7f1;
}

.gallery-hero {
    min-height: 390px;
    max-height: 460px;
}

.gallery-hero .story-hero-image img {
    object-position: center 48%;
}

.gallery-introduction {
    padding-top: clamp(46px, 5vw, 72px);
    padding-bottom: clamp(36px, 4vw, 58px);
}

.gallery-introduction-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: clamp(48px, 8vw, 128px);
    align-items: start;
}

.gallery-introduction h2 {
    max-width: 650px;
    margin: 0;
}

.gallery-introduction-copy {
    max-width: 700px;
}

.gallery-introduction-copy p:last-child {
    margin-bottom: 0;
}


/* ======================================================
   Section 2: Gallery Toolbar and Filters
========================================================= */

.gallery-showcase {
    padding-top: clamp(42px, 4.5vw, 66px);
    padding-bottom: clamp(68px, 8vw, 108px);
}

.gallery-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 32px;
    align-items: end;
    margin-bottom: clamp(34px, 5vw, 58px);
}

.gallery-toolbar h2 {
    margin-bottom: 0;
}

.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.gallery-filter {
    min-height: 42px;
    padding: 9px 17px;
    border: 1px solid rgba(8, 47, 51, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--gallery-ink);
    font: 700 0.82rem/1 "DM Sans", sans-serif;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition:
        color 180ms ease,
        background 180ms ease,
        border-color 180ms ease,
        transform 180ms ease;
}

.gallery-filter:hover,
.gallery-filter:focus-visible {
    border-color: var(--gallery-aqua);
    transform: translateY(-2px);
}

.gallery-filter.is-active {
    border-color: var(--gallery-ink);
    background: var(--gallery-ink);
    color: #fff;
}


/* ======================================================
   Section 3: Gallery Collection
========================================================= */

.gallery-collection {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: dense;
    gap: clamp(14px, 2vw, 24px);
}

.gallery-card {
    grid-column: span 4;
    min-height: 360px;
    overflow: hidden;
    border-radius: 22px;
    background: var(--gallery-ink);
    box-shadow: 0 18px 46px rgba(8, 47, 51, 0.1);
}

.gallery-card-wide {
    grid-column: span 8;
}

.gallery-card-tall {
    min-height: 520px;
}

.gallery-card-feature {
    grid-column: span 8;
    min-height: 520px;
}

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

.gallery-card-open {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: inherit;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: var(--gallery-ink);
    color: #fff;
    text-align: left;
    cursor: zoom-in;
}

.gallery-card-open img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card-shade {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(
            180deg,
            rgba(4, 31, 35, 0.02) 20%,
            rgba(4, 31, 35, 0.88) 100%
        );
    transition: background 300ms ease;
}

.gallery-card-content {
    position: absolute;
    inset: auto 0 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: clamp(24px, 3vw, 38px);
}

.gallery-card-category {
    display: inline-flex;
    margin-bottom: 12px;
    color: #98dfcf;
    font: 700 0.72rem/1.2 "DM Sans", sans-serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.gallery-card-content strong {
    max-width: 620px;
    color: #fff;
    font: 700 clamp(1.3rem, 2vw, 1.9rem)/1.15 "Manrope", sans-serif;
}

.gallery-card-description {
    max-width: 640px;
    max-height: 0;
    margin-top: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.94rem;
    line-height: 1.55;
    opacity: 0;
    transform: translateY(8px);
    transition:
        max-height 300ms ease,
        margin 300ms ease,
        opacity 300ms ease,
        transform 300ms ease;
}

.gallery-card-action {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-top: 18px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
}

.gallery-card-action > span {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 50%;
}

.gallery-card-open:hover img,
.gallery-card-open:focus-visible img {
    transform: scale(1.055);
}

.gallery-card-open:hover .gallery-card-shade,
.gallery-card-open:focus-visible .gallery-card-shade {
    background:
        linear-gradient(
            180deg,
            rgba(4, 31, 35, 0.08) 10%,
            rgba(4, 31, 35, 0.94) 100%
        );
}

.gallery-card-open:hover .gallery-card-description,
.gallery-card-open:focus-visible .gallery-card-description {
    max-height: 120px;
    margin-top: 10px;
    opacity: 1;
    transform: translateY(0);
}

.gallery-empty {
    margin: 42px 0 0;
    padding: 32px;
    border: 1px dashed rgba(8, 47, 51, 0.2);
    border-radius: 18px;
    color: var(--gallery-ink);
    text-align: center;
}


/* ======================================================
   Section 4: Gallery Image Viewer
========================================================= */

.gallery-lightbox {
    width: min(1180px, calc(100% - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.34);
}

.gallery-lightbox::backdrop {
    background: rgba(2, 20, 23, 0.88);
    backdrop-filter: blur(8px);
}

.gallery-lightbox-panel {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
    min-height: min(740px, calc(100dvh - 32px));
}

.gallery-lightbox-image {
    min-height: 480px;
    background: #041f23;
}

.gallery-lightbox-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gallery-lightbox-copy {
    align-self: center;
    padding: clamp(34px, 5vw, 64px);
}

.gallery-lightbox-copy h2 {
    color: var(--gallery-ink);
    font-size: clamp(1.7rem, 3vw, 2.8rem);
}

.gallery-lightbox-copy p:last-child {
    margin-bottom: 0;
}

.gallery-lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--gallery-ink);
    color: #fff;
    font: 400 2rem/1 sans-serif;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.gallery-lightbox-close:hover,
.gallery-lightbox-close:focus-visible {
    background: var(--gallery-aqua);
}


/* ======================================================
   Section 5: Gallery Call to Action
========================================================= */

.gallery-cta .story-cta-media img {
    object-position: center;
}


/* ======================================================
   Section 6: Gallery Responsive Styles
========================================================= */

@media (max-width: 980px) {
    .gallery-introduction-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .gallery-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .gallery-filters {
        justify-content: flex-start;
    }

    .gallery-card,
    .gallery-card-wide {
        grid-column: span 6;
    }

    .gallery-card-feature {
        grid-column: span 12;
    }

    .gallery-lightbox-panel {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .gallery-lightbox-image {
        min-height: 54vh;
    }
}

@media (max-width: 680px) {
    .gallery-hero {
        min-height: 330px;
    }

    .gallery-showcase {
        padding-top: 36px;
        padding-bottom: 58px;
    }

    .gallery-filters {
        width: 100%;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding-bottom: 8px;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .gallery-filter {
        flex: 0 0 auto;
    }

    .gallery-collection {
        grid-template-columns: 1fr;
    }

    .gallery-card,
    .gallery-card-wide,
    .gallery-card-tall,
    .gallery-card-feature {
        grid-column: 1;
        min-height: 390px;
    }

    .gallery-card-description {
        max-height: 120px;
        margin-top: 10px;
        opacity: 1;
        transform: none;
    }

    .gallery-lightbox {
        width: calc(100% - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
    }

    .gallery-lightbox-panel {
        min-height: calc(100dvh - 16px);
    }

    .gallery-lightbox-image {
        min-height: 52vh;
    }

    .gallery-lightbox-copy {
        padding: 30px 24px 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-card-open img,
    .gallery-card-description,
    .gallery-filter {
        transition: none;
    }
}