/* Photo viewer for the projects gallery (javascript/lightbox.js).
   Built on <dialog>, so focus containment, Esc and the top layer come from
   the browser rather than from script. */

.lb-trigger {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    width: 100%;
}
.lb-trigger:focus-visible {
    outline: 3px solid #e3cca1;
    outline-offset: 3px;
}
.lb-trigger img {
    display: block;
    width: 100%;
    height: auto;
}

.lb {
    --lb-bg: rgba(12, 16, 26, 0.95);
    --lb-fg: #fff;
    --lb-accent: #e3cca1;
    --lb-btn: rgba(255, 255, 255, 0.12);
    --lb-btn-hover: rgba(255, 255, 255, 0.24);

    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--lb-bg);
    color: var(--lb-fg);
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y pinch-zoom;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}
.lb[open] { display: block; }
.lb.is-visible { opacity: 1; }
.lb::backdrop { background: transparent; }

.lb__stage {
    position: absolute;
    inset: 64px 72px 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb__img {
    display: block;
    /* Size is set by lightbox.js: fit the stage, keep the aspect ratio,
       and stop at 1.75x natural size — the photos are 570px wide and turn
       to mush beyond that. */
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-drag: none;
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}
.lb__img.is-loading { opacity: 0; transform: scale(0.98); }

.lb__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--lb-accent);
    border-radius: 50%;
    animation: lb-spin 0.8s linear infinite;
    display: none;
}
.lb.is-loading .lb__spinner { display: block; }
@keyframes lb-spin { to { transform: rotate(360deg); } }

.lb__btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--lb-btn);
    color: var(--lb-fg);
    cursor: pointer;
    transition: background-color 0.15s ease-out, transform 0.15s ease-out;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    z-index: 2;
}
.lb__btn:hover { background: var(--lb-btn-hover); }
.lb__btn:active { transform: scale(0.94); }
.lb__btn:focus-visible {
    outline: 3px solid var(--lb-accent);
    outline-offset: 2px;
}
.lb__btn svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.lb__btn[disabled] { opacity: 0.35; cursor: default; }

.lb__close { top: 12px; right: 12px; }
.lb__prev, .lb__next { top: 50%; margin-top: -24px; }
.lb__prev { left: 12px; }
.lb__next { right: 12px; }
.lb__prev:active, .lb__next:active { transform: scale(0.94); }

.lb__counter {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    text-align: center;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.85);
    pointer-events: none;
}

/* Phones: arrows move to the bottom bar, flanking the counter, so the photo
   gets the full width and the thumbs can reach them. Swiping also works. */
@media (max-width: 767px) {
    .lb__stage { inset: 64px 8px 88px; }
    .lb__prev, .lb__next { top: auto; bottom: 14px; margin-top: 0; }
    .lb__prev { left: 16px; }
    .lb__next { right: 16px; }
    .lb__counter { bottom: 26px; }
    .lb__img { border-radius: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .lb, .lb__img, .lb__btn { transition: none; }
    .lb__spinner { animation-duration: 2s; }
}

html.lb-lock, html.lb-lock body { overflow: hidden; }
