/* --- Gallery Page Specific Styles --- */

/* --- Gallery Hero Header --- */
.gallery-header {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
    padding: 8rem 2rem;
    min-height: 50vh;
    text-align: center;
    color: white;
    /* Using the image of brochures for a branded, soft-focus feel */
    background-image: url('/static/img/outside-mobile.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gallery-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(58, 90, 64, 0.6); /* --color-primary */
    z-index: 1;
}

.gallery-header h1,
.gallery-header .lead-text {
    position: relative;
    z-index: 2;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}

.gallery-header h1 {
    font-size: 3.5rem;
}

/* --- Gallery Section --- */
.gallery-section {
    background-color: #F1ECE7; /* A warm, inviting off-white */
    padding: 6rem 2rem;
}

.gallery-section-intro {
    max-width: 900px;
    margin: 0 auto 3rem auto;
    text-align: center;
}

/* CORRECTED GRID: This is the updated, stable grid layout */
.gallery-grid-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 1.5rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    /* This ensures all grid items have a consistent shape and prevents overlapping */
    aspect-ratio: 4 / 3;
    cursor: pointer;
    transition: box-shadow 0.4s ease, transform 0.4s ease;
}

.gallery-item:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

.gallery-item:hover {
    box-shadow: 0 16px 36px rgba(0,0,0,0.18);
}

/* Soft branded overlay with a subtle zoom cue on hover */
.gallery-item::after {
    content: '\f00e'; /* font-awesome search-plus */
    font-family: 'Willow Icons';
    font-weight: 900;
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    background: rgba(58, 90, 64, 0.35);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.gallery-item:hover::after {
    opacity: 1;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease, filter 0.4s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
    filter: brightness(1.08);
}

/* --- CTA Section for Social Media --- */
.social-cta-section {
    text-align: center;
    padding: 4rem 2rem;
}

.social-secondary {
    background-color: var(--color-secondary);
}

/* --- Lightbox (full-size image viewer) --- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    background: rgba(20, 28, 24, 0.93);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.open {
    opacity: 1;
    visibility: visible;
}

/* Fixed-size stage so controls never shift with image dimensions.
   Smaller images are centered and the surrounding space is filled. */
.lightbox-figure {
    position: relative;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(1100px, 90vw);
    height: min(82vh, 780px);
    background: #1b231e;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.lightbox-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform: scale(0.96);
    transition: transform 0.3s ease;
}

.lightbox.open .lightbox-img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.75rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.lightbox-close:hover {
    transform: scale(1.12);
    color: var(--color-accent);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

.lightbox-nav:hover {
    background: var(--color-accent);
    transform: translateY(-50%) scale(1.08);
}

.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

@media (max-width: 640px) {
    .gallery-header {
        padding: 6rem 1rem;
        min-height: 72vh;
    }
    .gallery-header h1 {
        width: 100%;
        max-width: 280px;
        margin-left: auto;
        margin-right: auto;
        font-size: 1.85rem;
    }
    .gallery-header .lead-text {
        width: 100%;
        max-width: 290px;
        font-size: 1rem;
    }
    .gallery-section-intro {
        max-width: 290px;
    }
    .gallery-section-intro h2 {
        font-size: 1.7rem;
    }
    .lightbox {
        padding: 1rem;
        gap: 0.5rem;
    }
    .lightbox-figure {
        width: 94vw;
        height: 70vh;
    }
    .lightbox-nav {
        width: 42px;
        height: 42px;
        font-size: 1.3rem;
    }
    .lightbox-prev {
        left: 0.5rem;
    }
    .lightbox-next {
        right: 0.5rem;
    }
    .lightbox-close {
        top: 0.75rem;
        right: 1rem;
        font-size: 2.4rem;
    }
}

@media (min-width: 769px) {
    .gallery-header { background-image: url('/static/img/outside.webp'); }
}

/* --- In-person Tour CTA (distinct green band) --- */
.gallery-tour-cta {
    text-align: center;
    padding: 5rem 2rem;
    background: var(--color-primary);
    color: #fff;
}

.gallery-tour-cta h2 {
    margin-bottom: 1rem;
    color: #fff;
}

.gallery-tour-cta .lead-text {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
    color: rgba(255, 255, 255, 0.9);
}
