/*
 * Before/after comparison slider. Behaviour: assets/js/before-after.js.
 * --ba-pos is where the photos split: BEFORE shows to the left of it, AFTER to the right.
 */
.ba {
    --ba-pos: 50%;
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 1rem;
    background: #e5e7eb;
    box-shadow: 0 24px 48px -18px rgba(15, 23, 42, .45);
    isolation: isolate;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ba.ba-ready {
    cursor: ew-resize;
    touch-action: pan-y;           /* vertical swipes still scroll the page on phones */
}

.ba-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
}

.ba-before {
    position: absolute;
    inset: 0;
    z-index: 1;
    clip-path: inset(0 calc(100% - var(--ba-pos)) 0 0);
}

/* "Before" / "After" labels */
.ba-tag {
    position: absolute;
    top: .85rem;
    padding: .3rem .7rem;
    border-radius: 9999px;
    font: 800 .7rem/1 'Inter', ui-sans-serif, system-ui, sans-serif;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
    pointer-events: none;
}
.ba-tag-before { left: .85rem; background: rgba(17, 24, 39, .78); }
.ba-tag-after  { right: .85rem; background: #2563eb; }

/* Divider line + round knob */
.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--ba-pos);
    z-index: 2;
    width: 0;
    pointer-events: none;
}
.ba-handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1.5px;
    width: 3px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .12), 0 0 14px rgba(0, 0, 0, .35);
}
.ba-knob {
    position: absolute;
    top: 50%;
    left: 0;
    width: 3.25rem;
    height: 3.25rem;
    transform: translate(-50%, -50%);
    border-radius: 9999px;
    background: #fff;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    font-size: .95rem;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .38);
    transition: transform .15s ease;
}
.ba.is-dragging .ba-knob { transform: translate(-50%, -50%) scale(1.08); }

/* Pulsing ring that invites a drag; stops once the visitor has used the slider */
.ba-ready:not(.is-touched) .ba-knob::after {
    content: '';
    position: absolute;
    inset: -7px;
    border-radius: inherit;
    border: 2px solid rgba(255, 255, 255, .95);
    animation: ba-pulse 1.8s ease-out 4;
}
@keyframes ba-pulse {
    from { opacity: .95; transform: scale(.9); }
    to   { opacity: 0;   transform: scale(1.35); }
}

/* "Drag to compare" pill, hidden after first use */
.ba-hint {
    position: absolute;
    left: 50%;
    bottom: .85rem;
    z-index: 3;
    transform: translateX(-50%);
    padding: .4rem .8rem;
    border-radius: 9999px;
    background: rgba(17, 24, 39, .72);
    color: #fff;
    font: 600 .75rem/1 'Inter', ui-sans-serif, system-ui, sans-serif;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity .3s ease;
}
.ba.is-touched .ba-hint { opacity: 0; }

/* The real (visually hidden) range input: keyboard + screen-reader control */
.ba-range {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}
/* Focus ring on the knob for keyboard users (hidden while dragging with a mouse/finger) */
.ba:not(.is-pointer) .ba-range:focus-visible ~ .ba-handle .ba-knob {
    outline: 3px solid #1d4ed8;
    outline-offset: 3px;
}

/* Without JavaScript: a static 50/50 split, no handle to drag */
.ba:not(.ba-ready) .ba-handle,
.ba:not(.ba-ready) .ba-range,
.ba:not(.ba-ready) .ba-hint { display: none; }

@media (prefers-reduced-motion: reduce) {
    .ba-knob, .ba-hint { transition: none; }
    .ba-ready:not(.is-touched) .ba-knob::after { animation: none; display: none; }
}
