/**
 * Gallery page styles — grid + lightbox nativo
 *
 * @package respiroulivi-child
 */

/* =========================================================
   Gallery section
   ========================================================= */

.ru-gallery-section {
    padding: 3rem 0 5rem;
    background-color: var(--ru-secondary);
}

.ru-gallery-intro {
    text-align: center;
    margin-bottom: 2.5rem;
}

/* =========================================================
   Grid 3 colonne → 2 tablet → 1 mobile
   ========================================================= */

.ru-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .ru-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .ru-gallery-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* =========================================================
   Gallery item
   ========================================================= */

.ru-gallery__item {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    background-color: var(--ru-decorative);
    aspect-ratio: 4 / 3;
}

.ru-gallery__item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.ru-gallery__item:hover img,
.ru-gallery__item:focus-within img {
    transform: scale(1.04);
}

/* Overlay con icona "+" */
.ru-gallery__overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(26, 41, 20, 0); /* --ru-text con alpha */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    pointer-events: none;
}

.ru-gallery__item:hover .ru-gallery__overlay,
.ru-gallery__item:focus-within .ru-gallery__overlay {
    background-color: rgba(26, 41, 20, 0.45);
}

.ru-gallery__overlay-icon {
    color: #fff;
    font-size: 2.5rem;
    font-weight: 300;
    line-height: 1;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.25s ease, transform 0.25s ease;
    user-select: none;
}

.ru-gallery__item:hover .ru-gallery__overlay-icon,
.ru-gallery__item:focus-within .ru-gallery__overlay-icon {
    opacity: 1;
    transform: scale(1);
}

/* Keyboard focus ring */
.ru-gallery__item:focus-visible {
    outline: 3px solid var(--ru-accent);
    outline-offset: 2px;
}

/* Caption (screen reader only) */
.ru-gallery__caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================
   Lightbox — dialog HTML5
   ========================================================= */

.ru-lightbox {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ru-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.92);
}

/* Nasconde quando chiuso (dialog nativo) */
.ru-lightbox:not([open]) {
    display: none;
}

.ru-lightbox__img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 85vh;
}

.ru-lightbox__img {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 2px;
    user-select: none;
}

/* Pulsante chiudi */
.ru-lightbox__close {
    position: fixed;
    top: 1.25rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    z-index: 10000;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.ru-lightbox__close:hover,
.ru-lightbox__close:focus-visible {
    opacity: 1;
    outline: 2px solid var(--ru-accent);
    outline-offset: 3px;
}

/* Pulsanti navigazione */
.ru-lightbox__prev,
.ru-lightbox__next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10000;
}

.ru-lightbox__prev {
    left: 1rem;
}

.ru-lightbox__next {
    right: 1rem;
}

.ru-lightbox__prev:hover,
.ru-lightbox__next:hover,
.ru-lightbox__prev:focus-visible,
.ru-lightbox__next:focus-visible {
    background: rgba(255, 255, 255, 0.25);
    outline: 2px solid var(--ru-accent);
    outline-offset: 2px;
}

/* Contatore foto */
.ru-lightbox__counter {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-family: var(--ru-font-body);
    letter-spacing: 0.05em;
    z-index: 10000;
    user-select: none;
}

@media (max-width: 540px) {
    .ru-lightbox__prev {
        left: 0.5rem;
    }
    .ru-lightbox__next {
        right: 0.5rem;
    }
    .ru-lightbox__img {
        max-width: 96vw;
        max-height: 80vh;
    }
}
