/* =========================================================
   RECURSIVE REALITY — GALLERY PAGE
   Dark archive: masonry columns, images muted until touched,
   fine grain, and a quiet full-screen viewer.
   Loaded after rr-redesign.css and rr-images.css.
========================================================= */

/* ---------- Archive section ---------- */
.rr-archive {
    position: relative;
    padding: clamp(56px, 7vw, 96px) 0 clamp(80px, 10vw, 130px);
}

/* Masonry: natural proportions, nothing is cropped. */
.rr-archive-grid {
    columns: 4 240px;
    column-gap: 18px;
}

.rr-archive-item {
    position: relative;
    margin: 0 0 18px;
    break-inside: avoid;
    opacity: 0;
    transform: translateY(26px);
    transition:
        opacity .9s cubic-bezier(.16, 1, .3, 1),
        transform .9s cubic-bezier(.16, 1, .3, 1);
    transition-delay: var(--delay, 0ms);
}

.rr-archive-item.is-visible {
    opacity: 1;
    transform: none;
}

.rr-gallery-open {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    cursor: zoom-in;
    isolation: isolate;
    transition: border-color .5s ease;
}

.rr-gallery-open img {
    display: block;
    width: 100%;
    height: auto;
    filter: grayscale(.55) sepia(.18) brightness(.72) contrast(1.06);
    transform: scale(1.001);
    transition:
        filter .8s cubic-bezier(.16, 1, .3, 1),
        transform 1.2s cubic-bezier(.16, 1, .3, 1);
}

/* Grain and a soft vignette on every image. */
.rr-gallery-open::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, .45) 100%),
        var(--grain);
    background-size: auto, 180px 180px;
    opacity: .9;
    mix-blend-mode: multiply;
    pointer-events: none;
    transition: opacity .8s ease;
}

.rr-archive-number {
    position: absolute;
    left: 12px;
    bottom: 10px;
    z-index: 2;
    color: rgba(235, 231, 219, .7);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .18em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 8px rgba(0, 0, 0, .8);
    transition: color .5s ease;
}

.rr-gallery-open:hover,
.rr-gallery-open:focus-visible { border-color: rgba(var(--accent-rgb), .45); }

.rr-gallery-open:hover img,
.rr-gallery-open:focus-visible img {
    filter: none;
    transform: scale(1.025);
}

.rr-gallery-open:hover::after,
.rr-gallery-open:focus-visible::after { opacity: .35; }

.rr-gallery-open:hover .rr-archive-number { color: var(--accent); }

.rr-gallery-open:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.rr-archive-item figcaption {
    margin-top: 10px;
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.5;
}

html[data-theme="light"] .rr-gallery-open img { filter: grayscale(.4) sepia(.12) brightness(.92); }
html[data-theme="light"] .rr-gallery-open::after { opacity: .5; }

/* ---------- Viewer ---------- */
.rr-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 64px 84px;
    border: 0;
    background:
        radial-gradient(ellipse at 50% 45%, #171613 0%, #0a0a09 70%, #050505 100%);
    color: #ebe7db;
    overscroll-behavior: contain;
}

.rr-lightbox::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--grain);
    background-size: 220px 220px;
    opacity: .08;
    mix-blend-mode: overlay;
    pointer-events: none;
}

.rr-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rrViewerIn .35s ease both;
}

.rr-lightbox::backdrop { background: rgba(0, 0, 0, .85); }

@keyframes rrViewerIn { from { opacity: 0; } to { opacity: 1; } }

.rr-lightbox-bar {
    position: absolute;
    top: 26px;
    left: 30px;
    z-index: 2;
}

.rr-lightbox-count {
    color: #a19d90;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .2em;
    font-variant-numeric: tabular-nums;
}

.rr-lightbox-figure {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(1200px, 100%);
    max-height: 100%;
    margin: 0;
}

.rr-lightbox-figure img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 150px);
    max-height: calc(100dvh - 150px);
    object-fit: contain;
    border: 1px solid rgba(235, 231, 219, .1);
    border-radius: 3px;
    box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9);
    transition: opacity .3s ease;
}

.rr-lightbox-figure img.is-loading { opacity: .25; }

.rr-lightbox-caption {
    min-height: 1em;
    margin-top: 16px;
    color: #a19d90;
    font-size: .85rem;
    text-align: center;
}

.rr-lightbox-close,
.rr-lightbox-nav {
    position: absolute;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(235, 231, 219, .16);
    border-radius: 50%;
    background: rgba(12, 11, 10, .6);
    color: #ebe7db;
    cursor: pointer;
    transition: color .2s ease, border-color .2s ease;
}

.rr-lightbox-close:hover,
.rr-lightbox-nav:hover {
    color: #b7c9a8;
    border-color: #b7c9a8;
}

.rr-lightbox-close { top: 18px; right: 18px; }
.rr-lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.rr-lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); }

.rr-lightbox-close:focus-visible,
.rr-lightbox-nav:focus-visible {
    outline: 2px solid #b7c9a8;
    outline-offset: 3px;
}

/* ---------- Small screens ---------- */
@media (max-width: 700px) {
    .rr-archive-grid { columns: 2; column-gap: 10px; }
    .rr-archive-item { margin-bottom: 10px; }
    .rr-archive-number { left: 8px; bottom: 6px; font-size: 9px; }

    /* Touch screens have no hover: show images a little clearer. */
    .rr-gallery-open img { filter: grayscale(.4) sepia(.14) brightness(.8) contrast(1.05); }

    .rr-lightbox { padding: 64px 10px 92px; }
    .rr-lightbox-bar { top: 30px; left: 20px; }
    .rr-lightbox-prev,
    .rr-lightbox-next { top: auto; bottom: 22px; transform: none; }
    .rr-lightbox-prev { left: 20px; }
    .rr-lightbox-next { right: 20px; }
    .rr-lightbox-figure img {
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
    }
}

@media (max-width: 380px) {
    .rr-archive-grid { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .rr-archive-item { opacity: 1; transform: none; transition: none; }
    .rr-gallery-open img,
    .rr-gallery-open::after { transition: none; }
    .rr-lightbox[open] { animation: none; }
}
