/* ==========================================================================
   MEDIA MODAL - Modale riutilizzabile per media (immagini, video, PDF)
   Fullscreen con overlay nero, identico al video modal
   ========================================================================== */

.s4w-media-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 400ms ease-in-out;
}

.s4w-media-modal[aria-hidden="false"] {
    display: flex;
    opacity: 1;
}

/* Overlay nero */
.s4w-media-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

/* Container - nessun background bianco, nessun padding */
.s4w-media-modal__container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    z-index: 1;
    padding: 0 var(--spacing-md);
    transform: scale(0.95);
    transition: transform 400ms ease-out;
}

.s4w-media-modal[aria-hidden="false"] .s4w-media-modal__container {
    transform: scale(1);
}

/* Pulsante chiudi - posizionato in alto a destra dello schermo */
.s4w-media-modal__close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    color: var(--text-main-900);
    transition: opacity var(--transition-fast);
    z-index: 10000;
}

.s4w-media-modal__close:hover {
    opacity: 0.8;
}

.s4w-media-modal__close:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.s4w-media-modal__close svg {
    width: 24px;
    height: 24px;
}

/* Content wrapper */
.s4w-media-modal__content-wrapper {
    position: relative;
    width: 100%;
}

/* Video wrapper - aspect ratio 16:9 */
.s4w-media-modal__video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
}

.s4w-media-modal__video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Image wrapper - immagine centrata, max dimensioni viewport */
.s4w-media-modal__image-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: 90vh;
}

.s4w-media-modal__image-wrapper img {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* PDF wrapper - fullscreen iframe */
.s4w-media-modal__pdf-wrapper {
    position: relative;
    width: 100%;
    height: 90vh;
    background: #fff;
}

.s4w-media-modal__pdf-wrapper iframe {
    width: 100%;
    height: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .s4w-media-modal__container {
        padding: 0 var(--spacing-sm);
    }

    .s4w-media-modal__close {
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
    }

    .s4w-media-modal__close svg {
        width: 20px;
        height: 20px;
    }

    .s4w-media-modal__image-wrapper {
        max-height: 85vh;
    }

    .s4w-media-modal__image-wrapper img {
        max-height: 85vh;
    }

    .s4w-media-modal__pdf-wrapper {
        height: 85vh;
    }
}

/* ==========================================================================
   GALLERY SLIDER - Slider interno al modale gallery
   ========================================================================== */

.s4w-gallery-slider {
    position: relative;
    width: 100%;
}

.s4w-gallery-slider__track {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 85vh;
}

.s4w-gallery-slider__slide {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: center;
}

.s4w-gallery-slider__slide.is-active {
    display: flex;
}

.s4w-gallery-slider__slide img {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

/* Bottoni navigazione */
.s4w-gallery-slider__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    color: var(--bg-white-0);
    transition: background var(--transition-fast);
    z-index: 2;
}

.s4w-gallery-slider__nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.s4w-gallery-slider__nav--prev {
    left: 0;
}

.s4w-gallery-slider__nav--next {
    right: 0;
}

.s4w-gallery-slider__nav svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Counter */
.s4w-gallery-slider__counter {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-white-0);
    opacity: 0.7;
    white-space: nowrap;
}


@media (max-width: 768px) {
    .s4w-gallery-slider__slide img {
        max-height: 75vh;
    }

    .s4w-gallery-slider__track {
        max-height: 75vh;
    }

    .s4w-gallery-slider__nav {
        width: 36px;
        height: 36px;
    }

    .s4w-gallery-slider__nav svg {
        width: 18px;
        height: 18px;
    }
}

/* Credits card nel listing */
.media-kit-card__credits {
    color: var(--text-sub-500);
    margin: 4px 0 0 0;
}

/* ==========================================================================
   ACCESSIBILITÀ
   ========================================================================== */

/* Accessibilità - classe helper per nascondere visualmente */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
