/* Gallery block — slider (default) or grid (site/snippets/blocks/gallery.php) */

.block-gallery {
    --gallery-row-h: 12.5rem; /* 200px — Figma grid row height */
    margin-block: var(--space-l);
    background-color: var(--color-bg);
}
.block-gallery__cell,
.block-gallery__slide {
    scroll-margin-top: calc(var(--menubar-h) + var(--space-m));
}

/* --- Caption (both modes) ------------------------------------------------- */
/* Underlined label in a narrow ~1/6 column, the list/description in the wide
   one — mirrors the Figma caption grid over the 42rem body measure. */
.block-gallery__caption {
    margin-top: var(--space-s);
    font-size: var(--fs-meta);
    line-height: var(--leading-tight);
}
.block-gallery--grid .block-gallery__caption,
.block-gallery__caption-row {
    display: grid;
    grid-template-columns: 1fr 5fr;
    gap: 0 var(--space-s);
}
.block-gallery__label {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}
.block-gallery__list {
    grid-column: 2;
    margin: 0;
    padding-left: var(--space-l); /* room for the decimal markers = figure numbers */
    list-style: decimal;
}
.block-gallery__credits {
    display: block;
    font-style: italic;
    font-variation-settings: "ital" 40;
    color: var(--color-muted);
}
.block-gallery__shared {
    margin-top: var(--space-xs);
    font-size: var(--fs-meta);
    color: var(--color-muted);
}
/* Pre-Alpine: keep the stacked slider caption rows hidden until x-show takes over. */
.block-gallery__caption-row[x-cloak] {
    display: none;
}

/* --- Grid ---------------------------------------------------------------- */
/* Fixed-height images at natural widths that flow left-to-right and wrap. */
.block-gallery__grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s);
    margin: 0;
    padding: 0;
    list-style: none;
}
.block-gallery__cell {
    height: var(--gallery-row-h);
}
.block-gallery--grid .block-gallery__img {
    display: block;
    height: 100%;
    width: auto;
    object-fit: cover;
}

/* --- Slider -------------------------------------------------------------- */
.block-gallery__viewport {
    position: relative;
    overflow: hidden;
}
/* Native scroll-snap track — @fylgja/snap-slider drives it via scrollIntoView. */
.block-gallery__track {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
}
.block-gallery__track::-webkit-scrollbar {
    display: none; /* Safari / Chrome */
}
/* Uniform letterboxed frame so the overlaid arrows never jump between slides. */
.block-gallery__slide {
    flex: 0 0 100%;
    min-width: 0;
    scroll-snap-align: start;
    aspect-ratio: 16 / 9;
    background: var(--color-bar);
}
.block-gallery--slider .block-gallery__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.block-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: var(--space-2xs);
    color: var(--color-fg);
}
.block-gallery__nav--prev {
    left: var(--space-s);
}
.block-gallery__nav--next {
    right: var(--space-s);
}
.block-gallery__nav:hover {
    color: var(--color-note);
}
/* @fylgja/snap-slider disables a button at the track ends (no-loop) and hides
   both when there is nothing to scroll (a single-image gallery). */
.block-gallery__nav[disabled] {
    opacity: 0.35;
    cursor: default;
}
/* Figma arrow SVG (575:2380); the "next" button mirrors "prev". The dark arrow
   keeps a crisp white keyline (stacked tight shadows) plus a soft halo so it stays
   legible on both the light letterbox bars and dark, edge-to-edge images. */
.block-gallery__arrow {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    filter:
        drop-shadow(0 0 1px var(--color-white))
        drop-shadow(0 0 1px var(--color-white))
        drop-shadow(0 0 4px var(--color-white));
}
.block-gallery__nav--next .block-gallery__arrow {
    transform: scaleX(-1);
}

/* --- Mobile -------------------------------------------------------------- */
@media (max-width: 40rem) {
    .block-gallery--grid .block-gallery__caption,
    .block-gallery__caption-row {
        grid-template-columns: 1fr;
        gap: var(--space-3xs) 0;
    }
    .block-gallery__list {
        grid-column: 1;
    }
}
