/* ---- Project screenshot gallery (retired projects) ---- */
.gallery {
    width: min(68rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    margin: auto;           /* the global reset zeroes dialog centering */
    padding: 0;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--rule-strong);
    box-shadow: 0 0 0 1px var(--rule), 0 24px 80px rgba(0, 0, 0, 0.6);
}
.gallery::backdrop {
    background: rgba(5, 7, 6, 0.78);
    backdrop-filter: blur(3px);
}
.gallery[open] {
    display: flex;
    flex-direction: column;
    animation: gallery-in 0.28s var(--ease);
}
@keyframes gallery-in {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
}

.gallery-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0.8rem 0.7rem 1.1rem;
    border-bottom: 1px solid var(--rule);
}
.gallery-head h2 {
    font-size: 0.98rem;
    font-weight: 700;
    font-stretch: 108%;
    margin-right: auto;
}
.gallery-count,
.gallery figcaption {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-faint);
}
.gallery-count { font-variant-numeric: tabular-nums; }

.gallery-btn {
    display: inline-grid;
    place-items: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.6rem;
    color: var(--fg);
    background: var(--bg-elev);
    border: 1px solid var(--rule-strong);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.gallery-btn:hover:not(:disabled) { background: var(--bg-inset); border-color: var(--accent); }
.gallery-btn:disabled { opacity: 0.35; cursor: default; }
.gallery-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.gallery-track:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }

.gallery-track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--rule-strong) transparent;
}
.gallery figure {
    margin: 0;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.gallery img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: calc(100dvh - 10rem);
    object-fit: contain;
    background: var(--bg-inset);
}
.gallery figcaption { padding: 0.65rem 1.1rem 0.8rem; }

.gallery-nav {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 0.8rem 0.8rem;
}

/* card trigger: same look as .card-link, but it opens the gallery. Its ::after
   stretches over the whole card, so a click anywhere on the card opens it. */
.card:has(.card-link[data-gallery]) { position: relative; cursor: zoom-in; }
.card .card-link[data-gallery] { cursor: zoom-in; }
.card:hover .card-link[data-gallery] { text-decoration: underline; }
.card .card-link[data-gallery]::after {
    content: "";
    position: absolute;
    inset: 0;
}
.card .card-link[data-gallery]:focus-visible { outline: none; }
.card:has(.card-link[data-gallery]:focus-visible) {
    outline: 2px solid var(--ring);
    outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
    .gallery[open] { animation: none; }
}
