/* Gallery fullscreen lightbox (mobile + desktop) */
.mg-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.mg-gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

.mg-gallery-lightbox__stage {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 56px 88px;
    box-sizing: border-box;
}

.mg-gallery-lightbox__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    gap: 10px;
    min-width: 0;
}

.mg-gallery-lightbox__title {
    margin: 0;
    padding: 0 12px;
    max-width: min(100%, 720px);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.mg-gallery-lightbox__media {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-height: 0;
    max-width: 100%;
    max-height: calc(100vh - 200px);
}

.mg-gallery-lightbox__img {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.mg-gallery-lightbox__author-wrap {
    margin: 0;
    padding: 0 12px;
    max-width: min(100%, 720px);
    text-align: center;
}

.mg-gallery-lightbox__author {
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.mg-gallery-lightbox__author:hover,
.mg-gallery-lightbox__author:focus-visible {
    color: #fff;
    text-decoration: underline;
}

.mg-gallery-lightbox__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mg-gallery-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mg-gallery-lightbox__nav:hover {
    background: rgba(0, 0, 0, 0.75);
}

.mg-gallery-lightbox__nav--prev {
    left: 12px;
}

.mg-gallery-lightbox__nav--next {
    right: 12px;
}

.mg-gallery-lightbox__nav svg {
    width: 22px;
    height: 22px;
    display: block;
}

.mg-gallery-lightbox__counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.mg-gallery-lightbox__nav:disabled {
    opacity: 0.35;
    cursor: default;
}

@media (max-width: 767.98px) {
    .mg-gallery-lightbox__stage {
        padding: 48px 8px 80px;
    }

    .mg-gallery-lightbox__title {
        font-size: 0.95rem;
    }

    .mg-gallery-lightbox__media,
    .mg-gallery-lightbox__img {
        max-height: calc(100vh - 220px);
    }

    .mg-gallery-lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .mg-gallery-lightbox__nav--prev {
        left: 6px;
    }

    .mg-gallery-lightbox__nav--next {
        right: 6px;
    }
}

/* Cursore zoom-in sulle thumb delle gallery abilitate */
.mg_masonry_a .gallery-item-img,
.mg_masonry_a .mg-card-img,
#user-gallery .gallery-item-img,
#homepage-gallery .gallery-item-img,
.gallery_minimal .gallery-item-img {
    cursor: zoom-in;
}
