/* =========================================================
   Gallery — masonry grid + lightbox
   ========================================================= */

/* ---- Masonry grid (CSS columns keeps mixed portrait/landscape tidy) ---- */
.gallery-grid {
    column-count: 3;
    column-gap: 1rem;
}

@media (max-width: 991.98px) { .gallery-grid { column-count: 2; } }
@media (max-width: 575.98px) { .gallery-grid { column-count: 1; } }

.gallery-card {
    position: relative;
    display: block;
    width: 100%;
    margin: 0 0 1rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--cream);
    overflow: hidden;
    cursor: pointer;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1),
                box-shadow 0.45s ease;
}

.gallery-card img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
                filter 0.45s ease;
}

.gallery-card:hover,
.gallery-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px -18px rgba(38, 34, 30, 0.45);
    outline: none;
}

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

/* ---- Caption overlay ---- */
.gallery-caption {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 2.5rem 1rem 0.9rem;
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: linear-gradient(to top, rgba(38, 34, 30, 0.78), transparent);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.gallery-card:hover .gallery-caption,
.gallery-card:focus-visible .gallery-caption {
    opacity: 1;
    transform: none;
}

.gallery-caption__icon {
    flex: none;
    font-size: 0.95rem;
    opacity: 0.85;
}

/* ---- Lightbox ---- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.25rem, 2vw, 1.5rem);
    padding: clamp(1rem, 4vw, 3rem);
    background: rgba(24, 21, 18, 0.92);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }

.lightbox__stage {
    margin: 0;
    max-width: min(1100px, 90vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
}

.lightbox__img {
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
    transform: scale(0.97);
    transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

.lightbox__caption {
    color: #f3ece1;
    font-family: var(--font-display);
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    text-align: center;
}

.lightbox__btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.15rem;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.lightbox__btn:hover {
    background: var(--brand);
    border-color: var(--brand);
    transform: scale(1.06);
}

.lightbox__close {
    position: absolute;
    top: clamp(1rem, 3vw, 2rem);
    right: clamp(1rem, 3vw, 2rem);
}

@media (max-width: 575.98px) {
    .lightbox__nav {
        position: absolute;
        bottom: clamp(1rem, 4vw, 2rem);
        z-index: 2;
    }
    .lightbox__prev { left: clamp(1rem, 6vw, 3rem); }
    .lightbox__next { right: clamp(1rem, 6vw, 3rem); }
}
