/* ─────────────────────────────────────────────────────────────
   jmLightbox — shared image viewer
   ───────────────────────────────────────────────────────────── */

body.jm-lb-locked { overflow: hidden; }

.jm-lb {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    /* arrows get their own columns so the image can never cover them */
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    align-items: center;
    gap: clamp(4px, 1.5vw, 18px);
    padding: clamp(8px, 2vw, 28px);
    opacity: 0;
    transition: opacity 0.3s var(--ease);
}

/* Must beat `display: grid` above, or the closed viewer blankets the page
   and silently swallows every click on the site. */
.jm-lb[hidden] { display: none; }

.jm-lb.is-open { opacity: 1; }

.jm-lb__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 28, 0.94);
    backdrop-filter: blur(3px);
}

/* ─── Top bar ──────────────────────────────────────────────── */
.jm-lb__bar {
    grid-column: 1 / -1;
    grid-row: 1;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: 0 clamp(4px, 1vw, 12px);
}

.jm-lb__counter {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
}

.jm-lb__close {
    width: 44px;
    height: 44px;
    padding: 0;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    cursor: pointer;
    transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}

/* ─── Figure ───────────────────────────────────────────────── */
.jm-lb__figure {
    grid-column: 2;
    grid-row: 2;
    position: relative;
    z-index: 1;
    margin: 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
}

.jm-lb__img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
    background: rgba(255, 255, 255, 0.04);
}

.jm-lb__caption {
    flex: none;
    color: rgba(255, 255, 255, 0.88);
    font-size: var(--fs-small);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
}

/* ─── Arrows ───────────────────────────────────────────────── */
.jm-lb__nav {
    grid-row: 2;
    position: relative;
    z-index: 2;
    width: 48px;
    height: 48px;
    flex: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    cursor: pointer;
    transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}

.jm-lb__nav--prev { grid-column: 1; }
.jm-lb__nav--next { grid-column: 3; }

/* Keep the grid columns steady when an arrow is hidden, so a single image
   does not sit off-centre. */
.jm-lb__nav[hidden] {
    display: flex;
    visibility: hidden;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .jm-lb__close:hover,
    .jm-lb__nav:hover {
        background: rgba(255, 255, 255, 0.22);
        border-color: var(--accent);
    }
}

.jm-lb__close:focus-visible,
.jm-lb__nav:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* ─── Phones ───────────────────────────────────────────────────
   At 412px a pair of 48px arrows either side leaves too little for the
   image, so they move below it into the caption row instead.          */
@media (max-width: 620px) {
    .jm-lb {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr) auto;
        gap: var(--sp-3);
    }
    .jm-lb__figure { grid-column: 1; grid-row: 2; }
    .jm-lb__nav {
        grid-row: 3;
        width: 52px;
        height: 52px;
        justify-self: center;
    }
    .jm-lb__nav--prev { grid-column: 1; justify-self: start; }
    .jm-lb__nav--next { grid-column: 1; justify-self: end; }
}

/* Editor-content images opt in to the viewer; show they are interactive. */
.jm-project__content [data-lightbox] { cursor: zoom-in; }
