/*
 * Gallery camere: lightbox nativo (<dialog>) con zoom.
 * Foto a tutto schermo (contain), zoom con click / doppio tap / pinch / pulsante, trascinamento quando ingrandita.
 */
html.gc-no-scroll {
    overflow: hidden;
}

.gc-lightbox {
    box-sizing: border-box;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background-color: rgba(41, 39, 35, .96);
    color: var(--color-white);
    /* Niente zoom della pagina (doppio tap / pinch) su frecce, pulsanti e sfondo */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.gc-lightbox button.gc-btn {
    touch-action: manipulation;
}

.gc-lightbox::backdrop {
    background-color: transparent;
}

.gc-lightbox[open] {
    display: block;
    animation: gc-fade .25s ease both;
}

@keyframes gc-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Barra in alto: contatore + zoom + chiudi */
.gc-toolbar {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px clamp(16px, 3vw, 32px);
    pointer-events: none;
}

.gc-toolbar > * {
    pointer-events: auto;
}

.gc-lightbox p.gc-counter {
    flex: 1;
    margin: 0;
    font-family: var(--font-family-secondary) !important;
    font-size: 14px !important;
    line-height: 20px !important;
    color: var(--color-quaternary) !important;
}

/* Area immagine: occupa tutto lo schermo, gesti gestiti dal JS (niente zoom/scroll del browser) */
.gc-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 72px clamp(8px, 6vw, 96px);
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.gc-lightbox img.gc-img {
    display: block;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    object-fit: contain;
    transform-origin: center center;
    cursor: zoom-in;
    -webkit-user-drag: none;
}

.gc-lightbox.is-zoomed img.gc-img {
    cursor: grab;
}

.gc-lightbox.is-dragging img.gc-img {
    cursor: grabbing;
}

.gc-lightbox.is-animating img.gc-img {
    transition: transform .25s ease;
}

/* Pulsanti */
.gc-lightbox button.gc-btn {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    min-width: 0;
    margin: 0;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, .6) !important;
    border-radius: 50% !important;
    background: rgba(41, 39, 35, .35) !important;
    color: var(--color-white) !important;
    cursor: pointer;
    transition: background-color .25s ease, color .25s ease;
}

.gc-lightbox button.gc-btn:hover,
.gc-lightbox button.gc-btn:focus-visible,
.gc-lightbox button.gc-btn[aria-pressed="true"] {
    background: var(--color-white) !important;
    color: var(--color-dark) !important;
}

.gc-lightbox button.gc-close {
    background: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
}

.gc-lightbox button.gc-btn[hidden] {
    display: none;
}

.gc-lightbox button.gc-prev,
.gc-lightbox button.gc-next {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
}

.gc-lightbox button.gc-prev {
    left: clamp(8px, 2vw, 32px);
}

.gc-lightbox button.gc-next {
    right: clamp(8px, 2vw, 32px);
}

.gc-lightbox button.gc-next svg {
    transform: rotate(180deg);
}

/* Con la foto ingrandita le frecce si nascondono per non coprirla */
.gc-lightbox.is-zoomed button.gc-prev,
.gc-lightbox.is-zoomed button.gc-next {
    opacity: 0;
    pointer-events: none;
}

/* Mobile: foto a tutta larghezza, frecce in basso */
@media (max-width: 767px) {
    .gc-toolbar {
        padding: 12px;
    }

    .gc-stage {
        padding: 64px 0 88px;
    }

    .gc-lightbox button.gc-btn {
        width: 44px;
        height: 44px;
    }

    .gc-lightbox button.gc-prev,
    .gc-lightbox button.gc-next {
        top: auto;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        transform: none;
    }

    .gc-lightbox button.gc-prev {
        left: 20px;
    }

    .gc-lightbox button.gc-next {
        right: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gc-lightbox[open] {
        animation: none;
    }

    .gc-lightbox.is-animating img.gc-img,
    .gc-lightbox button.gc-btn {
        transition: none;
    }
}
