/* Explicit rows preserve the editor's sequence, including keyboard and mobile order. */
.grid12 > .editorial-gallery {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: clamp(32px, 6vw, 100px) clamp(12px, 2vw, 32px);
    padding: clamp(32px, 6vw, 96px) 0 0;
}
.editorial-gallery .editorial-gallery__item {
    display: block;
    min-width: 0;
    margin: 0;
    align-self: start;
}
.editorial-gallery__item--1 { grid-column: 2 / span 5; }
.editorial-gallery__item--2 { grid-column: 9 / span 3; margin-top: 12vw !important; }
.editorial-gallery__item--3 { grid-column: 3 / span 3; }
.editorial-gallery__item--4 { grid-column: 7 / span 6; margin-top: 8vw !important; }
.editorial-gallery__item--5 { grid-column: 1 / span 5; }
.editorial-gallery__item--6 { grid-column: 8 / span 4; margin-top: 10vw !important; }
.editorial-gallery__link { display: block; background: none; }
.editorial-gallery img {
    display: block;
    width: 100%;
    height: auto;
    opacity: 1;
}
.editorial-gallery__link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 6px;
}
/* A single photograph uses a balanced, centered composition. */
.editorial-gallery .editorial-gallery__item:only-child {
    grid-column: 1 / -1;
    width: 58.333%;
    justify-self: center;
}
@media (max-width: 600px) {
    .grid12 > .editorial-gallery { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .editorial-gallery .editorial-gallery__item { grid-column: 1 / -1; margin-top: 0 !important; }
    .editorial-gallery .editorial-gallery__item:nth-child(3n + 2) { grid-column: 3 / -1; }
    .editorial-gallery .editorial-gallery__item:nth-child(3n) { grid-column: 1 / 6; }
    .editorial-gallery .editorial-gallery__item:only-child { grid-column: 1 / -1; width: 100%; }
}

.editorial-gallery .editorial-gallery__caption {
    margin-top: var(--space-3);
    padding: 0;
    text-align: left;
    font-size: var(--font-size-small);
    line-height: var(--line-height-snug);
    color: var(--text-secondary);
}
.editorial-gallery__caption a:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 4px;
}

/* Viewer captions sit beneath the photograph on the page background. */
.sl-wrapper .sl-image .sl-caption.pos-outside {
    top: 100%;
    bottom: auto;
    padding: var(--space-3) 0 0;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-serif);
    font-size: var(--font-size-small);
    line-height: var(--line-height-snug);
    text-align: center;
}

/* Keep editorial pairs in the same row, with a gentle offset. */
.grid12 > .editorial-gallery--pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: clamp(16px, 4vw, 64px);
}
.editorial-gallery--pair .editorial-gallery__item:nth-child(n) {
    grid-column: auto;
    margin-top: 0 !important;
}
.editorial-gallery--pair .editorial-gallery__item:nth-child(2) {
    margin-top: clamp(24px, 6vw, 96px) !important;
}
@media (max-width: 600px) {
    .grid12 > .editorial-gallery--pair { column-gap: var(--space-3); }
    .editorial-gallery--pair .editorial-gallery__item:nth-child(2) { margin-top: var(--space-6) !important; }
}

/* Density presets use explicit row-order placement, never column packing. */
@media (min-width: 601px) {
    .grid12 > :is(.editorial-gallery--balanced, .editorial-gallery--dense) {
        row-gap: clamp(24px, 3vw, 48px);
    }
    :is(.editorial-gallery--balanced, .editorial-gallery--dense) .editorial-gallery__item:nth-child(n) {
        margin-top: 0 !important;
    }
    /* Varied rises and falls over four rows, preserving image order. */
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 1) { grid-column: 1 / span 4; margin-top: 1vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 2) { grid-column: 6 / span 3; margin-top: 12vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 3) { grid-column: 10 / span 3; margin-top: 5vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 4) { grid-column: 2 / span 3; margin-top: 15vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 5) { grid-column: 6 / span 4; margin-top: 0vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 6) { grid-column: 11 / span 2; margin-top: 9vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 7) { grid-column: 1 / span 3; margin-top: 6vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 8) { grid-column: 5 / span 4; margin-top: 17vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 9) { grid-column: 10 / span 3; margin-top: 2vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 10) { grid-column: 2 / span 4; margin-top: 13vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n + 11) { grid-column: 7 / span 2; margin-top: 4vw !important; }
    .editorial-gallery--balanced .editorial-gallery__item:nth-child(12n) { grid-column: 10 / span 3; margin-top: 19vw !important; }
    .grid12 > .editorial-gallery--dense {
        grid-template-columns: repeat(20, minmax(0, 1fr));
        column-gap: clamp(8px, 1vw, 16px);
        row-gap: clamp(64px, 8vw, 128px);
        isolation: isolate;
    }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(n) {
        grid-row: var(--dense-row);
        position: relative;
    }
    /* A longer composition avoids repeating the same silhouette every row. */
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 1) { grid-column: 1 / span 4; margin-top: 2vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 2) { grid-column: 5 / span 3; margin-top: 17vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 3) { grid-column: 9 / span 5; margin-top: 0vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 4) { grid-column: 13 / span 3; margin-top: 25vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 5) { grid-column: 17 / span 4; margin-top: 7vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 6) { grid-column: 2 / span 3; margin-top: 13vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 7) { grid-column: 5 / span 5; margin-top: 1vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 8) { grid-column: 10 / span 3; margin-top: 24vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 9) { grid-column: 14 / span 3; margin-top: 6vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 10) { grid-column: 17 / span 4; margin-top: 16vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 11) { grid-column: 1 / span 5; margin-top: 5vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 12) { grid-column: 6 / span 3; margin-top: 25vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 13) { grid-column: 9 / span 4; margin-top: 10vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n + 14) { grid-column: 14 / span 4; margin-top: 0vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(15n) { grid-column: 17 / span 4; margin-top: 18vw !important; }
    .editorial-gallery--dense .editorial-gallery__item:nth-child(even) { z-index: 1; }
    .editorial-gallery--dense .editorial-gallery__caption {
        position: relative;
        background: var(--bg-primary);
        width: fit-content;
        max-width: 100%;
    }
    :is(.editorial-gallery--balanced, .editorial-gallery--dense) .editorial-gallery__item:only-child {
        grid-column: 1 / -1;
        margin-top: 0 !important;
    }
}
