/* =====================================================
   WHAT?studio v2 — Gallery foto + lightbox immagini
   Griglia cliccabile -> visore a schermo intero con
   frecce, contatore, tastiera e swipe.
   ===================================================== */

/* ---------- Griglia ---------- */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
}
.gallery__item {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    cursor: zoom-in;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
}
.gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur) var(--ease);
    opacity: 0.92;
}
@media (hover: hover) and (pointer: fine) {
    .gallery__item:hover img { transform: scale(1.05); opacity: 1; }
}
.gallery__item:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

/* ---------- Lightbox immagini ---------- */
.ilx {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 3rem);
}
.ilx__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 10, 0.92);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    animation: ilx-fade var(--dur) var(--ease) both;
}
.ilx__figure {
    position: relative;
    margin: 0;
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    animation: ilx-rise var(--dur-slow) var(--ease-out) both;
}
.ilx__img {
    max-width: min(1400px, 92vw);
    max-height: 84vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6);
}
.ilx__cap {
    color: var(--text-secondary);
    font-size: var(--fs-small);
}
.ilx__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    font-size: 2rem;
    line-height: 1;
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    z-index: 2;
    transition: background var(--dur) var(--ease);
}
.ilx__nav:hover { background: rgba(255, 255, 255, 0.16); }
.ilx__nav:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.ilx__prev { left: clamp(0.5rem, 3vw, 2rem); }
.ilx__next { right: clamp(0.5rem, 3vw, 2rem); }
.ilx__close {
    position: absolute;
    top: clamp(0.75rem, 3vw, 1.75rem);
    right: clamp(0.75rem, 3vw, 1.75rem);
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    z-index: 2;
}
.ilx__close:hover { background: rgba(255, 255, 255, 0.16); }
.ilx__count {
    position: absolute;
    bottom: clamp(0.75rem, 3vw, 1.75rem);
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: var(--fs-small);
    letter-spacing: 0.06em;
}

@media (max-width: 640px) {
    .ilx__nav { width: 44px; height: 44px; font-size: 1.6rem; }
}

@keyframes ilx-fade { from { opacity: 0; } }
@keyframes ilx-rise { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) {
    .ilx__backdrop, .ilx__figure { animation: none; }
    .gallery__item img { transition: none; }
}
