/**
 * Gallery page — filter pills, packed grid and pagination.
 *
 * The grid positions come from js/gallery.js as custom properties on each item,
 * because the packing has to be computed against the live column count. The
 * column counts in the media queries below and activeColumns() in that file are
 * two halves of the same decision — change one and you must change the other.
 */

.squirrel-gallery {
    --gallery-gap: 20px;
    max-width: 1170px;
    margin: 0 auto;
}

/* ── Filter pills ─────────────────────────────────────────────────────────── */

.squirrel-gallery__pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 0 0 30px;
}

/* The parent theme styles EVERY button on :focus and :active with its own red
   (`button:active, button:focus { background: #f14e4e; outline: none; }`) at
   (0,1,1) specificity. A plain `.squirrel-gallery__pill` is (0,1,0) and loses,
   so a pill kept its background after being clicked until focus moved
   elsewhere. Every rule below is therefore scoped under `.squirrel-gallery` to
   outrank it, and :focus/:active are restated explicitly rather than left to
   inherit. The outline the parent removes is put back on :focus-visible only,
   so keyboard users get a focus ring without the mouse leaving one behind. */

.squirrel-gallery .squirrel-gallery__pill,
.squirrel-gallery .squirrel-gallery__pill:focus,
.squirrel-gallery .squirrel-gallery__pill:active {
    padding: 8px 18px;
    border: 1px solid var(--squig-brown, #4a160e);
    border-radius: 999px;
    background: transparent;
    color: var(--squig-brown, #4a160e);
    font-family: artico_extracond_light, sans-serif;
    font-size: .95rem;
    text-transform: uppercase;
    letter-spacing: .15rem;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.squirrel-gallery .squirrel-gallery__pill:hover {
    background: var(--squig-gold, #82672d);
    border-color: var(--squig-gold, #82672d);
    color: var(--squig-off-white, #f9f9f9);
}

.squirrel-gallery .squirrel-gallery__pill--active,
.squirrel-gallery .squirrel-gallery__pill--active:focus,
.squirrel-gallery .squirrel-gallery__pill--active:active,
.squirrel-gallery .squirrel-gallery__pill--active:hover {
    background: var(--squig-brown, #4a160e);
    border-color: var(--squig-brown, #4a160e);
    color: var(--squig-off-white, #f9f9f9);
}

.squirrel-gallery .squirrel-gallery__pill--active:hover {
    opacity: .85;
}

.squirrel-gallery .squirrel-gallery__pill:focus-visible,
.squirrel-gallery .squirrel-gallery__page:focus-visible,
.squirrel-gallery .squirrel-gallery__step:focus-visible {
    outline: 2px solid var(--squig-gold, #82672d);
    outline-offset: 2px;
}

/* ── The grid ─────────────────────────────────────────────────────────────── */

.squirrel-gallery__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: var(--cell-size, 280px);
    gap: var(--gallery-gap);
}

/* Explicit placement: every cell of every row is filled, so the grid is a
   complete rectangle rather than whatever a greedy packer happened to produce. */
.squirrel-gallery__item {
    grid-column: var(--cell-col) / span var(--cell-col-span, 1);
    grid-row: var(--cell-row) / span var(--cell-row-span, 1);
    display: block;
    overflow: hidden;
    background: rgba(74, 22, 14, .06);
}

.squirrel-gallery__item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .45s ease;
}

.squirrel-gallery__item:hover img,
.squirrel-gallery__item:focus-visible img {
    transform: scale(1.06);
}

.squirrel-gallery__empty {
    margin: 40px 0;
    text-align: center;
    font-size: 1.1rem;
}

/* ── Pagination ───────────────────────────────────────────────────────────── */

.squirrel-gallery__pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.squirrel-gallery__pagination:not(:empty) {
    margin: 30px 0;
}

/* Same specificity fight as the pills above — see the note there. */
.squirrel-gallery .squirrel-gallery__page,
.squirrel-gallery .squirrel-gallery__step,
.squirrel-gallery .squirrel-gallery__page:focus,
.squirrel-gallery .squirrel-gallery__step:focus,
.squirrel-gallery .squirrel-gallery__page:active,
.squirrel-gallery .squirrel-gallery__step:active {
    min-width: 40px;
    padding: 8px 14px;
    border: 1px solid var(--squig-brown, #4a160e);
    background: transparent;
    color: var(--squig-brown, #4a160e);
    font-family: artico_extracond_light, sans-serif;
    text-transform: uppercase;
    letter-spacing: .12rem;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

.squirrel-gallery .squirrel-gallery__page:hover:not(.squirrel-gallery__page--current),
.squirrel-gallery .squirrel-gallery__step:hover:not(:disabled) {
    background: var(--squig-gold, #82672d);
    border-color: var(--squig-gold, #82672d);
    color: var(--squig-off-white, #f9f9f9);
}

.squirrel-gallery .squirrel-gallery__page--current,
.squirrel-gallery .squirrel-gallery__page--current:focus,
.squirrel-gallery .squirrel-gallery__page--current:active,
.squirrel-gallery .squirrel-gallery__page--current:hover {
    background: var(--squig-brown, #4a160e);
    border-color: var(--squig-brown, #4a160e);
    color: var(--squig-off-white, #f9f9f9);
    cursor: default;
}

.squirrel-gallery .squirrel-gallery__step:disabled,
.squirrel-gallery .squirrel-gallery__step:disabled:focus,
.squirrel-gallery .squirrel-gallery__step:disabled:active {
    background: transparent;
    color: var(--squig-brown, #4a160e);
    opacity: .35;
    cursor: default;
}

.squirrel-gallery__gap {
    padding: 0 4px;
    color: var(--squig-brown, #4a160e);
}

/* ── Breakpoints ──────────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
    .squirrel-gallery__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 700px) {
    .squirrel-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .squirrel-gallery__grid {
        grid-template-columns: 1fr;
    }

    .squirrel-gallery__pill {
        font-size: .85rem;
        padding: 6px 14px;
    }
}
