/* =========================================
   GALLERY
========================================= */

#gallery {
    background: var(--paper);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.9rem;
}

.gallery-item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 4/5;
    position: relative;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.gallery-item:hover {
    box-shadow: var(--shadow-lg);
}

.gallery-item-inner {
    width: 100%;
    height: 100%;
    display: block;
}

.gallery-item-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: grayscale(75%) contrast(1.02);
    transform: scale(1.02);
    transition: filter 0.5s var(--transition), transform 0.5s var(--transition);
}

.gallery-item:hover .gallery-item-inner img {
    filter: grayscale(0%) contrast(1.02);
    transform: scale(1.08);
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(28, 24, 21, 0.82) 100%);
    display: flex;
    align-items: flex-end;
    padding: 1.1rem 1.2rem;
}

.gallery-overlay span {
    color: var(--parchment);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: var(--font-display);
    position: relative;
    padding-left: 0.9rem;
}

.gallery-overlay span::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    bottom: 0.15em;
    width: 2px;
    background: var(--oak);
}

.gallery-item-inner {
    cursor: zoom-in;
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(23, 23, 23, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    z-index: 1000;
}

.gallery-lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.gallery-lightbox p {
    color: #f3ead9;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    text-align: center;
    margin: 0;
}

.gallery-lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.gallery-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.24);
}


/* =========================================
   GALLERY MARQUEE
   Continuous left-to-right auto-scroll, pauses on hover.

   Same seam-free math as the testimonials marquee, just running
   the other direction:

     • NO `gap` on the track — spacing is a trailing `margin-right`
       on every card, so one copy's total width is exactly half
       the row and `-50%` lands on a card boundary.

     • The track must hold TWO identical copies. The JS handles
       the duplication.

     • Every item is a fixed width so `flex: 0 0 Npx` guarantees
       uniform sizing regardless of image dimensions.
========================================= */

.gallery-marquee {
    overflow: hidden;
    width: 100%;
    -webkit-mask-image: linear-gradient(
        to right,
        transparent,
        black 5%,
        black 95%,
        transparent
    );
    mask-image: linear-gradient(
        to right,
        transparent,
        black 5%,
        black 95%,
        transparent
    );
}

.gallery-marquee .gallery-grid {
    display: flex;                     /* overrides the auto-fit grid */
    flex-wrap: nowrap;
    gap: 0;                            /* spacing lives on the items */
    width: max-content;
    grid-template-columns: none;       /* neutralise the grid rules */
    animation: gallery-scroll 40s linear infinite;
    will-change: transform;
}

.gallery-marquee:hover .gallery-grid {
    animation-play-state: paused;
}

.gallery-marquee .gallery-item {
    flex: 0 0 240px;
    width: 240px;
    margin-right: 0.9rem;              /* trailing margin on EVERY item */
}

/* Left-to-right: the track slides toward +X. Starting at -50%
   puts the second copy in view, and animating back to 0 slides
   the first copy in from the left while the second exits right. */
@keyframes gallery-scroll {
    from {
        transform: translateX(-50%);
    }
    to {
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-marquee .gallery-grid {
        animation: none;
    }
}