/* ============================================================
   Before / After image slider
   Drag the handle to wipe between the two images.
   Markup: see /includes/before-after.php
   ============================================================ */

.ba-slider {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 24px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    cursor: ew-resize;
    line-height: 0;
    background: #0c0c0c;
}

/* both images stack; the "after" (full) is the base layer */
.ba-slider img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* the "before" image sits on top and gets clipped by the handle position */
.ba-before {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* clipped from the right; --pos is updated by JS (0–100) */
    clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0);
}

/* keep the before image at the slider's full width so it doesn't squash */
.ba-before img {
    position: absolute;
    inset: 0;
    width: var(--ba-width, 100%);
    max-width: none;
}

/* corner labels */
.ba-label {
    position: absolute;
    bottom: 16px;
    z-index: 4;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(12, 12, 12, 0.65);
    backdrop-filter: blur(4px);
    line-height: 1;
}

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

.ba-label.after {
    right: 16px;
    color: #0c0c0c;
    background: var(--primary--color, #62c2ae);
}

/* the draggable handle / divider line */
.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--pos, 50%);
    width: 3px;
    margin-left: -1.5px;
    background: #fff;
    z-index: 5;
    pointer-events: none;
}

.ba-handle::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* the two arrows inside the knob */
.ba-handle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 12px;
    z-index: 1;
    background-image:
        linear-gradient(45deg, transparent 50%, #0c0c0c 50%),
        linear-gradient(-45deg, transparent 50%, #0c0c0c 50%);
    /* fallback look; we draw chevrons via CSS borders below instead */
    background: none;
}

/* chevrons drawn with bordered triangles for crispness */
.ba-handle .ba-arrows {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 2;
    pointer-events: none;
}

.ba-handle .ba-arrows i {
    width: 8px;
    height: 8px;
    border: solid #0c0c0c;
    border-width: 0 2px 2px 0;
    display: inline-block;
}

.ba-handle .ba-arrows i.left {
    transform: rotate(135deg);
}

.ba-handle .ba-arrows i.right {
    transform: rotate(-45deg);
}

/* aspect-ratio helpers so sliders keep a consistent shape */
.ba-slider.ba-16x9 {
    aspect-ratio: 16 / 9;
}

.ba-slider.ba-4x3 {
    aspect-ratio: 4 / 3;
}

@media (max-width: 575px) {
    .ba-slider {
        border-radius: 16px;
    }

    .ba-handle::before {
        width: 38px;
        height: 38px;
    }
}
