/* ════════════════════════════════════════════════════════════════ */
/* BEFORE/AFTER SLIDER STYLES - FULLY RESPONSIVE & FIXED          */
/* ════════════════════════════════════════════════════════════════ */

.before-after-section {
    width: min(1200px, 94%);
    margin: 60px auto 80px;
    text-align: center;
}

.before-after-header {
    margin-bottom: 30px;
    padding: 0 10px;
}

.before-after-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f200ff, #800080);
    color: #fff;
    padding: 10px 22px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 14px;
}

.before-after-header h2 {
    margin: 0 0 10px;
    font-size: clamp(22px, 5vw, 52px);
    color: #111;
    line-height: 1.1;
}

.before-after-header p {
    color: #666;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    font-weight: 400;
    margin: 0;
    line-height: 1.4;
}

/* ═══════ Container slider ═══════ */
.before-after-slider {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    /* aspect-ratio rimosso - usiamo padding-bottom trick per mantenere proporzioni */
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    /* Altezza fissa basata sulle proporzioni delle immagini */
    height: auto;
}

.before-after-slider.ba-loaded {
    opacity: 1;
    transform: translateY(0);
}

/* ═══════ Wrapper immagini - mantiene aspect ratio ═══════ */
.ba-images-wrapper {
    position: relative;
    width: 100%;
    /* Aspect ratio 3:2 per le immagini della moto */
    padding-bottom: 66.67%;
    background: #fff;
}

.before-after-slider .ba-images {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.before-after-slider .ba-images img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* object-fit: contain per vedere l'intera moto con sfondo bianco */
    object-fit: contain;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
    background: #fff;
}

.before-after-slider .ba-before {
    z-index: 2;
    clip-path: inset(0 50% 0 0);
    will-change: clip-path;
}

.before-after-slider .ba-after {
    z-index: 1;
}

/* ═══════ Maniglia - posizionata rispetto al wrapper ═══════ */
.before-after-slider .ba-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 44px;
    height: 100%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    pointer-events: auto;
}

.ba-handle-line {
    flex: 1;
    width: 3px;
    background: linear-gradient(to bottom,
    transparent 0%,
    rgba(255,255,255,0.95) 5%,
    rgba(255,255,255,0.95) 95%,
    transparent 100%
    );
}

.ba-handle-circle {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #f200ff, #800080);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 4px 20px rgba(242, 0, 255, 0.5),
    0 0 0 4px rgba(255,255,255,0.3);
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    /* Assicura che sia sempre visibile e centrata */
    position: relative;
    z-index: 11;
}

.ba-handle-circle:hover,
.ba-handle-circle:active {
    transform: scale(1.12);
    box-shadow: 0 6px 30px rgba(242, 0, 255, 0.7),
    0 0 0 6px rgba(255,255,255,0.4);
}

.ba-handle-circle i {
    color: #fff;
    font-size: 12px;
    pointer-events: none;
}

/* ═══════ Label ═══════ */
.ba-label {
    position: absolute;
    top: 16px;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    border-radius: 4px;
    z-index: 5;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
}

.ba-label-before {
    left: 16px;
}

.ba-label-after {
    right: 16px;
}

/* ════════════════════════════════════════════════════════════════ */
/* RESPONSIVE - TABLET (max 1024px)                               */
/* ════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .before-after-section {
        margin: 50px auto 70px;
    }

    .before-after-slider {
        border-radius: 14px;
    }

    .ba-handle-circle {
        width: 46px;
        height: 46px;
    }
}

/* ════════════════════════════════════════════════════════════════ */
/* RESPONSIVE - MOBILE (max 768px)                                */
/* ════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .before-after-section {
        width: 96%;
        margin: 35px auto 50px;
    }

    .before-after-header {
        margin-bottom: 20px;
    }

    .before-after-badge {
        padding: 8px 16px;
        font-size: 11px;
    }

    .before-after-slider {
        border-radius: 12px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    }

    .ba-images-wrapper {
        padding-bottom: 75%; /* Leggermente più alto su mobile */
    }

    .before-after-slider .ba-handle {
        width: 40px;
    }

    .ba-handle-line {
        width: 2px;
    }

    .ba-handle-circle {
        width: 42px;
        height: 42px;
        gap: 3px;
        box-shadow: 0 3px 15px rgba(242, 0, 255, 0.5),
        0 0 0 3px rgba(255,255,255,0.3);
    }

    .ba-handle-circle i {
        font-size: 10px;
    }

    .ba-label {
        font-size: 9px;
        padding: 5px 10px;
        top: 10px;
        letter-spacing: 1px;
    }

    .ba-label-before {
        left: 10px;
    }

    .ba-label-after {
        right: 10px;
    }
}

/* ════════════════════════════════════════════════════════════════ */
/* RESPONSIVE - SMALL MOBILE (max 480px)                          */
/* ════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .before-after-section {
        width: 95%;
        margin: 25px auto 40px;
    }

    .before-after-header {
        margin-bottom: 16px;
    }

    .before-after-badge {
        padding: 6px 12px;
        font-size: 10px;
        margin-bottom: 8px;
    }

    .before-after-header h2 {
        font-size: clamp(18px, 6vw, 26px);
    }

    .before-after-header p {
        font-size: 0.75rem;
    }

    .before-after-slider {
        border-radius: 10px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    }

    .ba-images-wrapper {
        padding-bottom: 80%; /* Più alto per vedere meglio la moto */
    }

    .before-after-slider .ba-handle {
        width: 36px;
    }

    .ba-handle-circle {
        width: 38px;
        height: 38px;
        gap: 2px;
        box-shadow: 0 2px 12px rgba(242, 0, 255, 0.5),
        0 0 0 2px rgba(255,255,255,0.3);
    }

    .ba-handle-circle i {
        font-size: 9px;
    }

    .ba-label {
        font-size: 8px;
        padding: 4px 8px;
        top: 8px;
        border-radius: 3px;
    }

    .ba-label-before {
        left: 8px;
    }

    .ba-label-after {
        right: 8px;
    }
}

/* ════════════════════════════════════════════════════════════════ */
/* RESPONSIVE - EXTRA SMALL (max 360px)                           */
/* ════════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
    .before-after-slider {
        border-radius: 8px;
    }

    .ba-images-wrapper {
        padding-bottom: 85%;
    }

    .before-after-slider .ba-handle {
        width: 32px;
    }

    .ba-handle-circle {
        width: 34px;
        height: 34px;
    }

    .ba-handle-circle i {
        font-size: 8px;
    }

    .ba-label {
        font-size: 7px;
        padding: 3px 6px;
        top: 6px;
    }

    .ba-label-before {
        left: 6px;
    }

    .ba-label-after {
        right: 6px;
    }
}

/* ════════════════════════════════════════════════════════════════ */
/* LANDSCAPE ORIENTATION FIX                                      */
/* ════════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .ba-images-wrapper {
        padding-bottom: 45%;
    }

    .ba-handle-circle {
        width: 40px;
        height: 40px;
    }
}