/* Swiper Gallery Styles - 3 immagini intere */

/* Wrapper esterno: position:relative per i bottoni di navigazione */
.gallery-swiper-outer {
    position: relative;
    width: 78%;
    margin: 20px auto;
}

/* Per risoluzioni superiori a 1440px, non ingrandire */
@media (min-width: 1441px) {
    .gallery-swiper-outer {
        max-width: 1100px;
    }
}

.gallery-swiper {
    position: relative;
    width: 100%;
    height: 65vh;
    overflow: hidden;
}

.gallery-swiper .swiper-wrapper {
    display: flex;
    align-items: center;
}

.gallery-swiper .swiper-slide {
    /* width è calcolata e impostata da Swiper JS via inline style */
    height: 85%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
}

.gallery-swiper .swiper-slide img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    transition: filter 0.3s ease;
}

/* Overlay grigio trasparente sulle slide non attive */
.gallery-swiper .swiper-slide:not(.swiper-slide-active) img {
    filter: brightness(0.85);
}

/* Slide attiva senza overlay */
.gallery-swiper .swiper-slide-active img {
    filter: brightness(1);
}

/* 
 * slide-caption-giostra: posizionata tramite JS con calcolo preciso.
 * I valori di default qui sotto sono solo un fallback.
 */
.gallery-swiper .slide-caption-giostra {
    position: absolute;
    bottom: 0px;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    background: rgba(18, 116, 127, 0.92);
    color: white;
    padding: 18px 15px 27px 15px;
    border-radius: 5px;
    text-align: center;
    z-index: 5;
    white-space: normal;
    overflow: hidden;
    word-wrap: break-word;
    box-sizing: border-box;
    /* Sarà sovrascritta da JS con posizione calcolata */
}

.gallery-swiper .slide-caption-giostra h3 {
    font-size:20px;
    font-weight: 600;
    margin: 0 0 18px 0;
    color: white;
    font-family: 'Rockwell Nova', Rockwell, 'Courier New', Georgia, serif;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
}

.gallery-swiper .slide-caption-giostra p {
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    margin: 0;
    color: white;
    font-family: 'Helvetica Neue', sans-serif;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
}

/* Bottoni di navigazione: posizionati rispetto al wrapper esterno (.gallery-swiper-outer)
   in modo che NON siano soggetti all'overflow:hidden del .gallery-swiper */
.gallery-swiper-outer .swiper-button-next,
.gallery-swiper-outer .swiper-button-prev {
    background: rgba(20, 135, 127, 0.9);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: white;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    pointer-events: auto !important;
    cursor: pointer;
}

.gallery-swiper-outer .swiper-button-next {
    right: -25px;
}

.gallery-swiper-outer .swiper-button-prev {
    left: -25px;
}

.gallery-swiper-outer .swiper-button-next:after,
.gallery-swiper-outer .swiper-button-prev:after {
    font-size: 20px;
    color: white;
    font-family: swiper-icons;
    font-weight: 900;
}

.gallery-swiper-outer .swiper-button-next:hover,
.gallery-swiper-outer .swiper-button-prev:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Disabilita frecce se non ci sono abbastanza slide */
.gallery-swiper-outer .swiper-button-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Compatibilità: stili vecchi ancora usabili se i bottoni sono dentro .gallery-swiper */
.gallery-swiper .swiper-button-next,
.gallery-swiper .swiper-button-prev {
    background: rgba(20, 135, 127, 0.9);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: white;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    pointer-events: auto !important;
}

.gallery-swiper .swiper-button-next {
    right: 5px;
}

.gallery-swiper .swiper-button-prev {
    left: 5px;
}

.gallery-swiper .swiper-button-next:after,
.gallery-swiper .swiper-button-prev:after {
    font-size: 20px;
}

.gallery-swiper .swiper-button-next:hover,
.gallery-swiper .swiper-button-prev:hover {
    background: rgba(0, 0, 0, 0.8);
}

.gallery-swiper .swiper-pagination {
    position: relative;
    margin-top: 29px;
}

.gallery-swiper .swiper-pagination-bullet {
    background: rgba(20, 135, 127, 0.4);
    width: 10px;
    height: 10px;
}

.gallery-swiper .swiper-pagination-bullet-active {
    background: #14877f;
}

/* Disabilita frecce se non ci sono abbastanza slide */
.gallery-swiper .swiper-button-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Stili per le righe di immagini */
.image-row {
    display: flex;
    justify-content: space-around;
    margin: 8px 0;
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 18px;
}

.image-wrapper:last-child {
    margin-right: 0;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-overlay {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    align-items: top;
    justify-content: top;
    font-size: 15px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 4px;
    z-index: 10;
}

.image-title {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align:center;
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
    z-index: 1;
    pointer-events: none;
    font-family: Rockwell Nova
}

.image-wrapper:hover .image-overlay {
    opacity: 1;
}

/* Mobile/tablet < 1200px: slide con aspect-ratio 3/4 → proporzioni verticali garantite */
@media (max-width: 1199px) {

    /* Gallery: altezza automatica */
    .gallery-swiper {
        height: auto !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* Wrapper allineato al top */
    .gallery-swiper .swiper-wrapper {
        align-items: flex-start !important;
    }

    /* Slide: aspect-ratio 3/4 → proporzione verticale garantita indipendentemente dal viewport */
    .gallery-swiper .swiper-slide {
        overflow: hidden !important;
        height: auto !important;
        aspect-ratio: 3 / 4 !important;
    }

    /* Immagini: cover riempie la slide rispettando il rapporto 3/4 della slide */
    .gallery-swiper .swiper-slide img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    /* Frecce: ridimensionate su mobile */
    .gallery-swiper .swiper-button-next,
    .gallery-swiper .swiper-button-prev {
        width: 36px !important;
        height: 36px !important;
    }

    .gallery-swiper .swiper-button-next:after,
    .gallery-swiper .swiper-button-prev:after {
        font-size: 14px !important;
    }

    /* Caption: posizionata da JS con bottom:16px */
    .gallery-swiper .slide-caption-giostra {
        position: absolute;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        width: 88%;
        background: rgba(18, 116, 127, 0.92);
        color: white;
        padding: 12px 13px 16px 13px;
        border-radius: 5px;
        text-align: center;
        z-index: 5;
        white-space: normal;
        overflow: hidden;
        word-wrap: break-word;
        box-sizing: border-box;
        max-height: 40%;
    }
}
