/* Horizontal gallery page — 5-row grid, generous gaps for a gallery-wall feel */

.gallery-page #site-header {
    transition:
        transform 0.45s ease,
        opacity 0.45s ease;
    will-change: transform, opacity;
}

.gallery-page #site-header.is-hidden {
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
}

.gallery-page #gallery-sticky {
    position: relative;
    box-sizing: border-box;
    height: 100vh;
    max-height: 100vh;
    padding-top: 3rem;
    padding-bottom: 3rem;
}

.gallery-page #gallery-scroller {
    box-sizing: border-box;
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
}

.gallery-page .gallery-grid {
    display: grid;
    box-sizing: border-box;
    height: 100%;
    width: max-content;
    padding-inline: 2rem;
    gap: 2rem;
    /* Five equal-height rows */
    grid-template-rows: repeat(5, minmax(0, 1fr));
    /* 26 tracks (content ends at line 27); col width from 12-col viewport in JS */
    grid-template-columns: repeat(26, minmax(3.5rem, 1fr));
    align-items: stretch;
}

.gallery-page .gallery-cell {
    min-width: 0;
    min-height: 0;
}

.gallery-page .gallery-cell--image {
    position: relative;
    overflow: hidden;
    background: #e8e4df;
}

.gallery-page .gallery-cell--image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-page .gallery-cell--text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.gallery-page .gallery-cell--text h3 {
    font-family: 'Bungee', cursive;
    font-size: 1rem;
    line-height: 1.15;
    text-transform: uppercase;
}

.gallery-page .gallery-cell--text p {
    font-family: 'Fira Mono', monospace;
    font-size: 1rem;
    line-height: 1.45;
    color: #1e2023;
}

.gallery-page #gallery-legal {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    pointer-events: none;
    transition:
        transform 0.45s ease,
        opacity 0.45s ease;
}

.gallery-page #gallery-legal.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.gallery-page #gallery-legal:not(.is-visible) {
    transform: translateY(100%);
    opacity: 0;
}

/* —— Mobile only: vertical strip, images full width.
   Tablet keeps the horizontal scroller. —— */
@media (max-width: 767.98px) {
    .gallery-page #gallery-lead {
        padding-top: 8rem;
        padding-bottom: 2.5rem;
        min-height: 0;
    }

    .gallery-page #gallery-lead h2 {
        font-size: 3rem;
    }

    .gallery-page #gallery-sticky {
        height: auto;
        min-height: 100vh;
        max-height: none;
        padding-top: 1rem;
        padding-bottom: 1rem;
        /* Drop the desktop overflow clip so stacked cells aren't cut off */
        overflow: visible !important;
    }

    .gallery-page #gallery-scroller {
        overflow-x: visible;
        overflow-y: visible;
        /* Desktop uses flex:1 1 0 so the scroller fills the 100vh sticky; on
           mobile that flex-basis: 0 collapses the scroller to zero height
           because the parent has no fixed height. Size to content instead. */
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: 0 !important;
    }

    /* Legal strip never needs the absolute-bottom trick once the rail stacks */
    .gallery-page #gallery-legal {
        position: relative;
        transform: none !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        margin-top: 2rem;
    }

    .gallery-page .gallery-grid {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        min-height: 0;
        height: auto;
        gap: 1.5rem;
        padding-inline: 1rem;
        box-sizing: border-box;
    }

    .gallery-page .gallery-cell {
        width: 100% !important;
        max-width: 100%;
        min-height: 0;
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }

    .gallery-page .gallery-cell--image {
        min-height: 200px;
        max-height: none;
    }

    .gallery-page .gallery-cell--image img {
        width: 100%;
        height: auto;
        min-height: 180px;
        max-height: 72vh;
        object-fit: contain;
    }
}
