/* =========================================
   Before/After Slider (Überblend-Bild)
   ========================================= */

/* Container */
.ba-slider {
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    cursor: col-resize;
    line-height: 0;
    border-radius: 8px;
}

/* ---- Bilder ---- */
.ba-img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

/* Vorher-Ebene (obere Schicht, geclippt) */
.ba-before {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 1;
}

.ba-img--before {
    display: block;
    width: auto;
    min-width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Vertikaler Modus: Vorher-Bild Breite fixieren */
.ba-slider[data-direction="vertical"] .ba-before {
    right: 0;
    bottom: auto;
    width: 100%;
}

.ba-slider[data-direction="vertical"] .ba-img--before {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 100%;
    object-fit: cover;
}

/* ---- Handle (Regler) ---- */
.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: col-resize;
}

.ba-handle__line {
    flex: 1;
    width: 3px;
    background: var(--ba-handle-color, #e67e22);
    pointer-events: none;
}

.ba-handle__grip {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ba-handle-color, #e67e22);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ba-handle__grip svg {
    pointer-events: none;
    flex-shrink: 0;
}

/* Hover / Active */
.ba-handle:hover .ba-handle__grip,
.ba-handle:focus-visible .ba-handle__grip {
    transform: scale(1.1);
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.4);
}

.ba-slider.ba-dragging .ba-handle__grip {
    transform: scale(1.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

/* Focus-Visible Ring */
.ba-handle:focus-visible {
    outline: none;
}

.ba-handle:focus-visible .ba-handle__grip {
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.4), 0 3px 16px rgba(0, 0, 0, 0.4);
}

/* ---- Handle-Varianten ---- */

/* Nur Linie */
.ba-slider[data-handle-style="line"] .ba-handle__grip {
    display: none;
}

.ba-slider[data-handle-style="line"] .ba-handle__line {
    width: 4px;
}

/* Pill */
.ba-slider[data-handle-style="pill"] .ba-handle__grip {
    border-radius: 24px;
    width: 36px;
    height: 64px;
    flex-direction: column;
    gap: 2px;
}

.ba-slider[data-handle-style="pill"] .ba-handle__grip svg {
    transform: rotate(90deg);
    width: 16px;
    height: 16px;
}

/* ---- Vertikaler Modus ---- */
.ba-slider[data-direction="vertical"] {
    cursor: row-resize;
}

.ba-slider[data-direction="vertical"] .ba-handle {
    top: auto;
    bottom: auto;
    left: 0;
    right: 0;
    width: auto;
    height: 4px;
    flex-direction: row;
    transform: translateY(-50%);
    cursor: row-resize;
}

.ba-slider[data-direction="vertical"] .ba-handle__line {
    width: auto;
    height: 3px;
    flex: 1;
}

.ba-slider[data-direction="vertical"] .ba-handle__grip svg {
    transform: rotate(90deg);
}

/* ---- Labels ---- */
.ba-label {
    position: absolute;
    bottom: 16px;
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 6px;
    pointer-events: none;
    z-index: 2;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.25s ease;
}

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

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

/* Vertikale Labels */
.ba-slider[data-direction="vertical"] .ba-label--before {
    left: 16px;
    top: 16px;
    bottom: auto;
}

.ba-slider[data-direction="vertical"] .ba-label--after {
    right: 16px;
    bottom: 16px;
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 1024px) {
    .ba-handle__grip {
        width: 44px;
        height: 44px;
    }

    .ba-handle__grip svg {
        width: 18px;
        height: 18px;
    }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 767.98px) {
    .ba-slider {
        border-radius: 6px;
    }

    .ba-handle__grip {
        width: 40px;
        height: 40px;
    }

    .ba-handle__grip svg {
        width: 16px;
        height: 16px;
    }

    .ba-slider[data-handle-style="pill"] .ba-handle__grip {
        width: 32px;
        height: 56px;
    }

    .ba-label {
        font-size: 0.75rem;
        padding: 4px 10px;
        bottom: 10px;
    }

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

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

    .ba-slider[data-direction="vertical"] .ba-label--before {
        left: 10px;
        top: 10px;
    }

    .ba-slider[data-direction="vertical"] .ba-label--after {
        right: 10px;
        bottom: 10px;
    }
}
