/* ---------------------------------------------------------------------------
   Custom lightbox for the Our Work gallery.
   Zero dependencies, no library, no CDN race conditions.
   Triggered by the JS in /js/lightbox.js, which listens for clicks on any
   <a class="gallery-tile" href="..."> inside .gallery-grid.
   --------------------------------------------------------------------------- */

.lb {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 17, 21, 0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    user-select: none;
    -webkit-user-select: none;
    opacity: 0;
    transition: opacity .18s ease;
}
.lb.is-open {
    display: flex;
    opacity: 1;
}

/* The image stage — keeps the image inside the viewport with safe padding */
.lb__stage {
    position: relative;
    max-width: min(1400px, 92vw);
    max-height: 86vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lb__img {
    display: block;
    max-width: min(1400px, 92vw);
    max-height: 86vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    background: #0a0d12; /* keeps a letterbox colour while the image loads */
    opacity: 0;
    transition: opacity .2s ease;
}
.lb__img.is-loaded { opacity: 1; }

/* Spinner — visible only while the image is loading */
.lb__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lb-spin 0.85s linear infinite;
    pointer-events: none;
}
.lb.is-loaded .lb__spinner { display: none; }
@keyframes lb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .lb__spinner { animation: none; }
    .lb__img, .lb { transition: none; }
}

/* Buttons — top-right cluster + side arrows */
.lb__btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
    font-size: 18px;
    line-height: 1;
}
.lb__btn:hover { background: rgba(255, 255, 255, 0.18); }
.lb__btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.lb__btn--close { top: 16px; right: 16px; }
.lb__btn--prev  { left: 16px;  top: 50%; transform: translateY(-50%); }
.lb__btn--next  { right: 16px; top: 50%; transform: translateY(-50%); }
.lb__btn--prev:hover { transform: translateY(-50%) translateX(-2px); }
.lb__btn--next:hover { transform: translateY(-50%) translateX(2px); }

/* Counter — bottom-center */
.lb__counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font: 500 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: .04em;
    background: rgba(0, 0, 0, 0.35);
    padding: 6px 12px;
    border-radius: 999px;
    pointer-events: none;
}

/* Caption — bottom-left, optional, populated by data-pswp-* alt fallback */
.lb__caption {
    position: absolute;
    bottom: 18px;
    left: 18px;
    color: rgba(255, 255, 255, 0.75);
    font: 400 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 50%;
    pointer-events: none;
}

/* Mobile: shrink the buttons and bring the counter up so the caption can show */
@media (max-width: 600px) {
    .lb__btn { width: 38px; height: 38px; font-size: 16px; }
    .lb__btn--close { top: 10px; right: 10px; }
    .lb__btn--prev  { left: 8px; }
    .lb__btn--next  { right: 8px; }
    .lb__counter { bottom: 12px; }
    .lb__caption { bottom: 44px; left: 12px; max-width: calc(100% - 24px); }
}

/* Touch target for the image: clicking the image itself does nothing
   (so users don't accidentally close by misclick). They must hit the
   close button or the dark backdrop. */
.lb__img { cursor: default; }
