/* Before/After - simple, self-contained slider styling
   My aim here is: looks decent out of the box, no theme dependencies, no plugin.

   IMPORTANT:
   - .ba-before = BEFORE image (base layer)
   - .ba-after  = AFTER image (overlay)
   - We reveal the AFTER overlay from the RIGHT so:
        Left  = Before
        Right = After
*/

.ba-slider{
    position: relative;
    user-select: none;
    width:100%;
    overflow:hidden;
    background:#f5f5f5;
    --ba-pos:50%;
    touch-action: pan-y; /* allow vertical scroll on mobile while still handling horizontal drag */
}

.ba-slider img{
    display:block;
    width:100%;
    height:auto;
}

/* Base image (Before) sets the component height */
.ba-before{
    position: relative;
    z-index: 1;
}

/* After overlay stays full width and is revealed by clip-path */
.ba-after{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;

    /*
        Show AFTER only to the RIGHT of the handle.

        --ba-pos is the divider position measured from the LEFT:
        - 0%   = AFTER fills the whole thing
        - 50%  = AFTER shows on the right half
        - 100% = AFTER hidden (BEFORE only)
    */
    clip-path: inset(0 0 0 var(--ba-pos));
    -webkit-clip-path: inset(0 0 0 var(--ba-pos));
}


/* Handle (button) */
.ba-handle{
    position: absolute;
    top: 0;
    left: var(--ba-pos);
    height: 100%;
    width: 0;
    z-index: 3;

    /* Reset button styling */
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;

    cursor: ew-resize;
}

/* Give the button a minimum hit area without changing visuals */
.ba-handle{
    min-width: 44px; /* WCAG target size friendly */
    transform: translateX(-22px); /* keep the visual line centered at --ba-pos */
}

/* Vertical line */
.ba-handle:before{
    content: "";
    position: absolute;
    top: 0;
    left: 21px; /* center line inside 44px hit area */
    width: 2px;
    height: 100%;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}

/* Knob */
.ba-handle:after{
    content: "";
    position: absolute;
    top: 50%;
    left: 4px; /* centers 36px knob inside 44px */
    width: 36px;
    height: 36px;
    margin-top: -18px;
    border-radius: 999px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    border: 1px solid rgba(0,0,0,0.15);
}

/* Visible focus (WCAG 2.2 focus appearance) */
.ba-handle:focus{
    outline: none;
}

.ba-handle:focus-visible:after{
    box-shadow: 0 0 0 4px rgba(255,255,255,0.95), 0 0 0 7px rgba(13,110,253,0.85), 0 6px 18px rgba(0,0,0,0.25);
}

/* Labels */
.ba-label{
    position: absolute;
    top: 12px;
    z-index: 4;
    font-size: 12px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    pointer-events: none;
}

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

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

@media (prefers-reduced-motion: reduce){
    .ba-slider *{
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}
