/* ============================================================
   Lightbox — LLM (Lepontii Lupus Militibus) Companion to lightbox.js.

   Usage:
     <link rel="stylesheet" href="style.css">   <!-- for --white / --accent-color -->
     <link rel="stylesheet" href="lightbox.css">
     ...
     <script src="lightbox.js" defer></script>

   Todo: quando consolido tutto in style.css, questo file può sparire.
   ============================================================ */

/* --- Overlay --- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox img {
    max-width: 90vw;
    max-height: 75vh;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

/* --- Caption --- */
.lightbox-caption {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--white, #ffffff);
    font-size: 0.95rem;
    background: rgba(0,0,0,0.6);
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    max-width: 85%;
    text-align: center;
    line-height: 1.4;
}

/* --- Counter --- */
.lightbox-count {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--white, #ffffff);
    font-size: 0.85rem;
    background: rgba(0,0,0,0.5);
    padding: 0.4rem 1rem;
    border-radius: 50px;
}

/* --- Close button --- */
.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255,255,255,0.15);
    border: none;
    color: var(--white, #ffffff);
    font-size: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.25);
}

/* --- Prev / Next arrows --- */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--white, #ffffff);
    font-size: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
    user-select: none;
}

.lightbox-nav:hover {
    background: rgba(255,255,255,0.25);
}

.lightbox-prev { left: 2rem; }
.lightbox-next { right: 2rem; }

/* --- Keyboard focus rings --- */
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
    outline: 2px solid var(--accent-color, #e43725);
    outline-offset: 3px;
}

/* --- Al fine di evitare scroll quando aperto --- */
body.lightbox-open {
    overflow: hidden;
}

/* --- Single-photo galleries: nothing to navigate --- */
.lightbox.is-single .lightbox-nav,
.lightbox.is-single .lightbox-count {
    display: none;
}

/* --- Mobile --- */
@media (max-width: 768px) {
    .lightbox img {
        max-height: 66vh;
    }

    .lightbox-nav {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }

    .lightbox-prev { left: 1rem; }
    .lightbox-next { right: 1rem; }

    .lightbox-close {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        font-size: 1.6rem;
    }

    .lightbox-count {
        top: 1rem;
        font-size: 0.78rem;
    }

    .lightbox-caption {
        bottom: 1.25rem;
        font-size: 0.85rem;
        max-width: 92%;
    }
}

/* --- Respect reduced-motion preferences --- */
@media (prefers-reduced-motion: reduce) {
    .lightbox {
        transition: none;
    }
}
