/* ============================================================
   SLIDER WTHC — Frontend v5.2
   ============================================================ */

.swthc {
    --slider-height: 70vh;
    --slider-overlay: rgba(0,0,0,0.38);
    --slider-title-size: clamp(1.6rem, 4vw, 3.2rem);
    --slider-title-color: #fff;
    --slider-body-size: 1.1rem;
    --slider-text-maxwidth: 600px;
    --slider-text-minheight: 160px;
    --slider-btn1-bg: #fff;
    --slider-btn1-color: #111;
    --slider-btn2-bg: transparent;
    --slider-btn2-color: #fff;
    --slider-btn-radius: 999px;
    /* mobile overrides (impostabili via PHP) */
    --slider-mob-title-size: clamp(1.3rem, 5.5vw, 2rem);
    --slider-mob-body-size: 0.95rem;
    --slider-mob-text-maxwidth: 100%;
    --slider-mob-text-minheight: 80px;
    --swthc-trans: 0.75s;
    --swthc-ease: cubic-bezier(0.4,0,0.2,1);
}

/* Break out of WP container */
.swthc {
    position: relative;
    width: 100vw;
    left: 50%;
    margin-left: -50vw;
    height: var(--slider-height);
    min-height: 240px;
    overflow: hidden;
    background: #111;
    contain: layout style;
}

.swthc__track {
    position: relative;
    width: 100%;
    height: 100%;
    /* Il track è il contesto per tutte le slide */
}

/* ============================================================
   SLIDE BASE
   ============================================================ */
.swthc__slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* z-index base: tutte le slide "sotto" */
    z-index: 0;
    /* Visibilità: di default nascosta via opacity/transform */
}

/* ============================================================
   ANIMAZIONE: FADE
   ============================================================ */
.animation-fade .swthc__slide {
    opacity: 0;
    transition: opacity var(--swthc-trans) var(--swthc-ease);
}
.animation-fade .swthc__slide.is-active {
    opacity: 1;
    z-index: 2;
}
.animation-fade .swthc__slide.is-out {
    opacity: 0;
    z-index: 1;   /* sopra le inattive, sotto l'attiva */
    transition: opacity var(--swthc-trans) var(--swthc-ease);
}

/* ============================================================
   ANIMAZIONE: SLIDE
   FIX NERO: le slide inattive stanno FUORI dallo schermo con
   translateX, non con opacity:0 — così non c'è mai il buco nero.
   La slide entrante arriva da destra (o sinistra), quella uscente
   va a sinistra. Entrambe usano z-index:1 durante la transizione.
   ============================================================ */
.animation-slide .swthc__slide {
    /* default: tutte le slide pronte fuori dallo schermo (a destra) */
    transform: translateX(100%);
    transition: transform var(--swthc-trans) var(--swthc-ease);
    z-index: 0;
}
.animation-slide .swthc__slide.is-active {
    transform: translateX(0);
    z-index: 2;
}
.animation-slide .swthc__slide.is-out {
    transform: translateX(-100%);
    z-index: 1;
    transition: transform var(--swthc-trans) var(--swthc-ease);
}
/* Prev direction: slide entrante arriva da sinistra */
.animation-slide .swthc__slide.from-prev {
    transform: translateX(-100%);
}

/* ============================================================
   ANIMAZIONE: ZOOM
   ============================================================ */
.animation-zoom .swthc__slide {
    opacity: 0;
    transform: scale(1.12);
    transition: opacity var(--swthc-trans) var(--swthc-ease),
                transform var(--swthc-trans) var(--swthc-ease);
    z-index: 0;
}
.animation-zoom .swthc__slide.is-active {
    opacity: 1;
    transform: scale(1);
    z-index: 2;
}
.animation-zoom .swthc__slide.is-out {
    opacity: 0;
    transform: scale(0.92);
    z-index: 1;
}

/* ============================================================
   MEDIA
   ============================================================ */
.swthc__media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Ken Burns: reset immediato sulle slide inattive */
.swthc__slide:not(.is-active):not(.is-out) .swthc__media {
    transform: scale(1) translate(0,0) !important;
    transition: none !important;
}

.kb-zoomin  .swthc__slide            .swthc__media { transform: scale(1);    transition: transform 9s ease-out; }
.kb-zoomin  .swthc__slide.is-active  .swthc__media { transform: scale(1.07); }
.kb-zoomout .swthc__slide            .swthc__media { transform: scale(1.08); transition: transform 9s ease-out; }
.kb-zoomout .swthc__slide.is-active  .swthc__media { transform: scale(1); }
.kb-pan     .swthc__slide            .swthc__media { transform: translateX(0);   transition: transform 12s linear; }
.kb-pan     .swthc__slide.is-active  .swthc__media { transform: translateX(-4%); }
.kb-none    .swthc__media { transition: none !important; }

/* ============================================================
   OVERLAY
   ============================================================ */
.swthc__overlay {
    position: absolute;
    inset: 0;
    background: var(--slider-overlay);
    display: flex;
    align-items: flex-end;
    z-index: 3;   /* sopra la media */
    pointer-events: none;
}
.swthc__overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
        rgba(0,0,0,.6)  0%,
        rgba(0,0,0,.1) 50%,
        transparent    100%);
    pointer-events: none;
}

/* ============================================================
   INNER — contenitore testo+CTA
   ============================================================ */
.swthc__inner {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(20px,4vw,56px) clamp(20px,5vw,72px);
    pointer-events: auto;
    color: #fff;
    /* layout default: colonna (below) */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
}

/* Blocco testo: larghezza e altezza minima configurabili */
.swthc__text-block {
    max-width: var(--slider-text-maxwidth);
    min-height: var(--slider-text-minheight);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* ---- Layout BELOW (default) ---- */
.swthc__inner.cta-below {
    flex-direction: column;
    align-items: flex-start;
}

/* ---- Layout RIGHT ---- */
.swthc__inner.cta-right {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 40px;
}
.swthc__inner.cta-right .swthc__text-block {
    flex: 1 1 auto;
    min-width: 0;
}
.swthc__inner.cta-right .swthc__cta {
    flex-shrink: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-bottom: 8px;
}
.swthc__inner.cta-right .swthc-btn {
    min-width: 160px;
    text-align: center;
}

/* ---- Layout CENTER ---- */
.swthc__inner.cta-center {
    flex-direction: column;
    align-items: flex-start;
    /* i pulsanti vengono posizionati in assoluto */
}
.swthc__inner.cta-center .swthc__cta {
    position: absolute;
    bottom: clamp(24px,4vw,48px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    flex-direction: row;
    justify-content: center;
    gap: 14px;
}

/* ============================================================
   TESTI
   ============================================================ */
.swthc__title {
    margin: 0 0 10px;
    font-size: var(--slider-title-size);
    color: var(--slider-title-color);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.swthc__body {
    font-size: var(--slider-body-size);
    line-height: 1.6;
    text-shadow: 0 1px 4px rgba(0,0,0,.35);
    opacity: .92;
}
.swthc__body p:first-child { margin-top: 0; }
.swthc__body p:last-child  { margin-bottom: 0; }

/* ============================================================
   CTA
   ============================================================ */
.swthc__cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.swthc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 30px;
    border-radius: var(--slider-btn-radius);
    font-size: clamp(.85rem, 1.5vw, 1rem);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    transition: filter .2s ease, transform .15s ease, box-shadow .2s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}
.swthc-btn:focus-visible { outline: 3px solid rgba(255,255,255,.8); outline-offset: 3px; }

.swthc-btn--1 {
    background: var(--slider-btn1-bg);
    color: var(--slider-btn1-color);
    border: 2px solid var(--slider-btn1-bg);
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.swthc-btn--1:hover { filter: brightness(.9); transform: translateY(-2px); }

.swthc-btn--2 {
    background: var(--slider-btn2-bg);
    color: var(--slider-btn2-color);
    border: 2px solid var(--slider-btn2-color);
}
.swthc-btn--2:hover { filter: brightness(1.15); transform: translateY(-2px); }

/* ============================================================
   FRECCE
   ============================================================ */
.swthc__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px; height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    color: #fff;
    transition: background .2s, transform .2s;
    -webkit-tap-highlight-color: transparent;
}
.swthc__arrow svg { width: 20px; height: 20px; flex-shrink: 0; }
.swthc__arrow--prev { left: clamp(12px,3vw,28px); }
.swthc__arrow--next { right: clamp(12px,3vw,28px); }
.swthc__arrow:hover { background: rgba(255,255,255,.34); transform: translateY(-50%) scale(1.08); }
.swthc__arrow:focus-visible { outline: 3px solid rgba(255,255,255,.8); outline-offset: 2px; }
@media (hover:none) and (pointer:coarse) and (max-width:480px) { .swthc__arrow { display: none; } }

/* ============================================================
   DOTS
   ============================================================ */
.swthc__dots {
    position: absolute;
    bottom: clamp(14px,3vw,22px);
    left: 50%; transform: translateX(-50%);
    z-index: 10;
    display: flex; gap: 7px; align-items: center;
}
.swthc__dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.7);
    background: transparent;
    cursor: pointer; padding: 0;
    transition: background .25s, border-color .25s, width .3s;
    -webkit-tap-highlight-color: transparent; flex-shrink: 0;
}
.swthc__dot:hover { background: rgba(255,255,255,.5); }
.swthc__dot.is-active { background: #fff; border-color: #fff; width: 26px; border-radius: 999px; }
.swthc__dot:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: 3px; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.swthc__progress {
    position: absolute; bottom: 0; left: 0;
    width: 100%; height: 3px;
    background: rgba(255,255,255,.2);
    z-index: 10; overflow: hidden;
}
.swthc__progress-bar {
    height: 100%; width: 0%;
    background: rgba(255,255,255,.75);
    transition: width linear;
    will-change: width;
}

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */
@media (max-width: 768px) {

    /* Testo: override con variabili mobile */
    .swthc__title {
        font-size: var(--slider-mob-title-size);
    }
    .swthc__body {
        font-size: var(--slider-mob-body-size);
    }
    .swthc__text-block {
        max-width: var(--slider-mob-text-maxwidth);
        min-height: var(--slider-mob-text-minheight);
    }

    /* Layout: tutto colonna su mobile */
    .swthc__inner.cta-right {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .swthc__inner.cta-right .swthc__cta {
        flex-direction: row;
        flex-wrap: wrap;
        padding-bottom: 0;
    }
    .swthc__inner.cta-right .swthc-btn {
        min-width: 0;
    }
    .swthc__inner.cta-center .swthc__cta {
        position: static;
        transform: none;
        width: auto;
        flex-wrap: wrap;
    }

    /* Bottoni: non a piena larghezza su mobile (brutto) */
    .swthc-btn {
        padding: 11px 22px;
        font-size: .9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .swthc__slide, .swthc__media, .swthc-btn, .swthc__arrow, .swthc__dot {
        transition-duration: .01ms !important;
    }
    .kb-zoomin .swthc__slide.is-active .swthc__media,
    .kb-zoomout .swthc__slide .swthc__media,
    .kb-pan .swthc__slide.is-active .swthc__media { transform: none !important; }
}
