/* ==========================================================================
   ALFATH MEDIA — FULLSCREEN GALLERY LIGHTBOX
   Reusable, injected-at-runtime component (see gallery-lightbox.js).
   Opens any [data-gallery-images] set in an immersive fullscreen viewer.
   ========================================================================== */

.af-lightbox {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.af-lightbox.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.af-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 4, 6, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.af-lightbox__top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    /* Extra right padding reserves room for the absolutely-positioned
       close button so the counter never sits underneath it. */
    padding: 22px 92px 22px 26px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
    pointer-events: none;
}

.af-lightbox__title {
    color: #FFFFFF;
    font-family: var(--font-heading, 'Bebas Neue', sans-serif);
    font-size: 1.5rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.af-lightbox__counter {
    color: rgba(255, 255, 255, 0.75);
    font-family: var(--font-body, sans-serif);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.af-lightbox__close {
    position: absolute;
    top: 18px;
    right: 22px;
    z-index: 4;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #FFFFFF;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
    pointer-events: all;
}

.af-lightbox__close:hover {
    background: rgba(159, 24, 80, 0.55);
    border-color: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg);
}

.af-lightbox__close svg {
    width: 20px;
    height: 20px;
}

.af-lightbox__stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 90px 100px 130px;
    box-sizing: border-box;
}

.af-lightbox__img-wrap {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.af-lightbox__img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.3s ease, transform 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
}

.af-lightbox__img.is-visible {
    opacity: 1;
    transform: scale(1);
}

.af-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.af-lightbox__nav:hover {
    background: rgba(26, 93, 172, 0.55);
    border-color: rgba(255, 255, 255, 0.4);
}

.af-lightbox__nav:active {
    transform: translateY(-50%) scale(0.92);
}

.af-lightbox__nav svg {
    width: 22px;
    height: 22px;
}

.af-lightbox__nav--prev { left: 24px; }
.af-lightbox__nav--next { right: 24px; }

.af-lightbox__nav[disabled] {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

.af-lightbox__thumbs {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: flex;
    gap: 10px;
    padding: 18px 26px 24px;
    overflow-x: auto;
    scrollbar-width: thin;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    -webkit-overflow-scrolling: touch;
}

.af-lightbox__thumbs::-webkit-scrollbar {
    height: 5px;
}
.af-lightbox__thumbs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}

.af-lightbox__thumb {
    flex: 0 0 auto;
    width: 62px;
    height: 62px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    padding: 0;
    opacity: 0.55;
    transition: opacity 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.af-lightbox__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.af-lightbox__thumb:hover {
    opacity: 0.85;
    transform: translateY(-2px);
}

.af-lightbox__thumb.is-active {
    opacity: 1;
    border-color: #1A5DAC;
}

/* Loading spinner while a large image decodes */
.af-lightbox__spinner {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: #FFFFFF;
    animation: afLightboxSpin 0.8s linear infinite;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.af-lightbox__spinner.is-active {
    opacity: 1;
}

@keyframes afLightboxSpin {
    to { transform: rotate(360deg); }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .af-lightbox__stage {
        padding: 80px 56px 120px;
    }
    .af-lightbox__nav {
        width: 46px;
        height: 46px;
    }
    .af-lightbox__nav--prev { left: 10px; }
    .af-lightbox__nav--next { right: 10px; }
}

@media (max-width: 640px) {
    .af-lightbox__top {
        padding: 16px 60px 16px 16px;
    }
    .af-lightbox__title {
        font-size: 1.15rem;
    }
    .af-lightbox__counter {
        font-size: 0.78rem;
    }
    .af-lightbox__close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }
    .af-lightbox__stage {
        padding: 74px 14px 110px;
    }
    .af-lightbox__nav {
        width: 42px;
        height: 42px;
        background: rgba(0, 0, 0, 0.45);
    }
    .af-lightbox__nav--prev { left: 6px; }
    .af-lightbox__nav--next { right: 6px; }
    .af-lightbox__thumbs {
        padding: 12px 14px 16px;
        gap: 8px;
    }
    .af-lightbox__thumb {
        width: 50px;
        height: 50px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .af-lightbox,
    .af-lightbox__img,
    .af-lightbox__close,
    .af-lightbox__nav,
    .af-lightbox__thumb {
        transition: none !important;
    }
}
