/* ============================================================
   Before & After Slider — Elementor Widget
   Version: 1.0.0
   ============================================================ */

/* ── Reset & Base ──────────────────────────────────────────── */
.ba-slider-wrapper {
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
}

.ba-slider-container {
  position: relative;
  width: 100%;
  height: 450px;
  overflow: hidden;
  cursor: col-resize;
  touch-action: pan-y;
  background: #111;
  border-radius: 4px;
}

.ba-slider-container.ba-vertical {
  cursor: row-resize;
  touch-action: pan-x;
}

/* ── Images ────────────────────────────────────────────────── */
.ba-image {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.ba-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  transition: none;
}

/* BEFORE: full width, clipped by the slider handle */
.ba-image-before {
  z-index: 1;
  clip-path: inset(0 50% 0 0);   /* horizontal default */
  will-change: clip-path;
  transition: clip-path 0s;
}

/* AFTER: sits behind */
.ba-image-after {
  z-index: 0;
}

/* Vertical orientation */
.ba-vertical .ba-image-before {
  clip-path: inset(0 0 50% 0);
}

/* ── Labels ────────────────────────────────────────────────── */
.ba-label {
  position: absolute;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(0,0,0,.55);
  color: #fff;
  border-radius: 3px;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.25s;
}

.ba-label-before {
  top: 14px;
  left: 14px;
}

.ba-label-after {
  top: 14px;
  right: 14px;
}

/* Vertical label positions */
.ba-vertical .ba-label-before {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.ba-vertical .ba-label-after {
  bottom: 14px;
  top: auto;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

/* ── Divider & Handle ──────────────────────────────────────── */
.ba-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 20;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  will-change: left;
  pointer-events: none;
}

.ba-vertical .ba-divider {
  left: 0;
  right: 0;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  flex-direction: row;
  height: 0;
  width: 100%;
  align-items: center;
  justify-content: center;
  will-change: top;
}

.ba-divider-line {
  width: 3px;
  height: 100%;
  background: #fff;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(0,0,0,.4);
}

.ba-vertical .ba-divider-line {
  width: 100%;
  height: 3px;
}

/* Handle */
.ba-handle {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 14px rgba(0,0,0,.35), 0 0 0 3px rgba(255,255,255,.25);
  pointer-events: all;
  cursor: grab;
  transition: transform 0.15s cubic-bezier(.34,1.56,.64,1), box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.ba-handle:active,
.ba-handle:focus-visible {
  transform: scale(1.15);
  box-shadow: 0 4px 20px rgba(0,0,0,.5), 0 0 0 4px rgba(255,255,255,.4);
  cursor: grabbing;
}

.ba-handle-arrows {
  width: 28px;
  height: 14px;
  color: #333;
  flex-shrink: 0;
}

.ba-vertical .ba-handle-arrows {
  transform: rotate(90deg);
}

/* Circle handle variant */
.ba-handle-circle {
  display: block;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
}

/* Lines handle variant */
.ba-handle-lines {
  display: flex;
  gap: 3px;
  align-items: center;
}

.ba-handle-lines span {
  display: block;
  width: 3px;
  height: 18px;
  background: currentColor;
  border-radius: 2px;
}

/* ── Smooth drag transition ────────────────────────────────── */
.ba-slider-container.ba-smooth .ba-image-before,
.ba-slider-container.ba-smooth .ba-divider {
  transition: clip-path 0.05s linear, left 0.05s linear, top 0.05s linear;
}

/* ══════════════════════════════════════════════════════════════
   ENTRANCE ANIMATIONS
   ══════════════════════════════════════════════════════════════ */

/* Common: start invisible */
.ba-anim-fade-up,
.ba-anim-fade-in,
.ba-anim-slide-left,
.ba-anim-slide-right,
.ba-anim-zoom-in,
.ba-anim-flip,
.ba-anim-bounce,
.ba-anim-reveal {
  opacity: 0;
}

/* — Fade Up — */
.ba-anim-fade-up {
  transform: translateY(40px);
}
.ba-anim-fade-up.ba-animated {
  animation: ba-fadeUp var(--ba-dur, 800ms) cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes ba-fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* — Fade In — */
.ba-anim-fade-in.ba-animated {
  animation: ba-fadeIn var(--ba-dur, 800ms) ease forwards;
}
@keyframes ba-fadeIn {
  to { opacity: 1; }
}

/* — Slide Left — */
.ba-anim-slide-left {
  transform: translateX(-60px);
}
.ba-anim-slide-left.ba-animated {
  animation: ba-slideLeft var(--ba-dur, 800ms) cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes ba-slideLeft {
  to { opacity: 1; transform: translateX(0); }
}

/* — Slide Right — */
.ba-anim-slide-right {
  transform: translateX(60px);
}
.ba-anim-slide-right.ba-animated {
  animation: ba-slideRight var(--ba-dur, 800ms) cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes ba-slideRight {
  to { opacity: 1; transform: translateX(0); }
}

/* — Zoom In — */
.ba-anim-zoom-in {
  transform: scale(0.85);
}
.ba-anim-zoom-in.ba-animated {
  animation: ba-zoomIn var(--ba-dur, 800ms) cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes ba-zoomIn {
  to { opacity: 1; transform: scale(1); }
}

/* — Flip 3D — */
.ba-anim-flip {
  transform: perspective(800px) rotateY(30deg);
}
.ba-anim-flip.ba-animated {
  animation: ba-flip var(--ba-dur, 800ms) cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes ba-flip {
  to { opacity: 1; transform: perspective(800px) rotateY(0deg); }
}

/* — Bounce — */
.ba-anim-bounce {
  transform: scale(0.7);
}
.ba-anim-bounce.ba-animated {
  animation: ba-bounce var(--ba-dur, 800ms) cubic-bezier(.34,1.8,.64,1) forwards;
}
@keyframes ba-bounce {
  to { opacity: 1; transform: scale(1); }
}

/* — Reveal Cortina — */
.ba-anim-reveal {
  clip-path: inset(0 100% 0 0);
  opacity: 1;
}
.ba-anim-reveal.ba-animated {
  animation: ba-reveal var(--ba-dur, 800ms) cubic-bezier(.77,0,.18,1) forwards;
}
@keyframes ba-reveal {
  to { clip-path: inset(0 0% 0 0); }
}

/* ══════════════════════════════════════════════════════════════
   AUTO-PLAY SWEEP animation
   ══════════════════════════════════════════════════════════════ */
.ba-slider-container.ba-autoplay-active .ba-image-before {
  animation: ba-autoPlayH 3s ease-in-out infinite alternate;
}
.ba-vertical.ba-autoplay-active .ba-image-before {
  animation: ba-autoPlayV 3s ease-in-out infinite alternate;
}
@keyframes ba-autoPlayH {
  0%   { clip-path: inset(0 80% 0 0); }
  100% { clip-path: inset(0 10% 0 0); }
}
@keyframes ba-autoPlayV {
  0%   { clip-path: inset(0 0 80% 0); }
  100% { clip-path: inset(0 0 10% 0); }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATIONS
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .ba-slider-container {
    height: 260px !important;
    cursor: default;
  }

  .ba-handle {
    width: 44px;
    height: 44px;
    /* Larger touch area with pseudo-element */
  }

  .ba-handle::before {
    content: '';
    position: absolute;
    inset: -14px;
    border-radius: 50%;
  }

  .ba-handle-arrows {
    width: 22px;
    height: 12px;
  }

  .ba-label {
    font-size: 11px;
    padding: 4px 10px;
  }

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

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

@media (max-width: 480px) {
  .ba-slider-container {
    height: 210px !important;
  }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .ba-anim-fade-up,
  .ba-anim-fade-in,
  .ba-anim-slide-left,
  .ba-anim-slide-right,
  .ba-anim-zoom-in,
  .ba-anim-flip,
  .ba-anim-bounce {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .ba-anim-reveal {
    clip-path: none;
    animation: none;
  }
}
