/* =========================================================
   MyLavida – Before / After comparison slider (single product)
   Sits right before the order form. Does not touch the gallery,
   price, offers or the order button.

   The compare box is forced to direction:ltr so that, in RTL pages too,
   Before is physically on the LEFT and After on the RIGHT (as the divider logic assumes).
   Section title and the rest of the page keep the site's own direction.
========================================================= */

.mlv-ba,
.mlv-ba * {
  box-sizing: border-box;
}

.mlv-ba {
  max-width: 980px;
  margin: 32px auto;
  padding: 0 16px;
}

.mlv-ba__title {
  margin: 0 0 16px;
  color: var(--dark, #0f172a);
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}

/* ---------- Compare box ---------- */
.mlv-ba .mlv-ba__compare {
  --mlv-pos: 50%;
  position: relative;
  direction: ltr;
  /* Ratio comes from the Before image; never taller than 80% of the viewport on wide screens */
  width: min(100%, calc(80vh * var(--mlv-ba-r, 1)), 760px);
  aspect-ratio: var(--mlv-ba-r, 1);
  margin: 0 auto;
  overflow: hidden;
  background: #f3fbf7;
  border: 1px solid var(--border, #dbeee7);
  border-radius: var(--radius, 18px);
  box-shadow: 0 10px 30px rgba(31, 191, 117, .08);
  touch-action: pan-y; /* vertical swipes scroll the page; horizontal ones drag the divider */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mlv-ba .mlv-ba__compare.is-ready {
  cursor: ew-resize;
}

/* Both layers occupy exactly the same box (cover = no stretching or distortion) */
.mlv-ba .mlv-ba__compare .mlv-ba__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* Before = top layer, visible from the left edge up to the divider */
.mlv-ba .mlv-ba__compare .mlv-ba__img--before {
  clip-path: inset(0 calc(100% - var(--mlv-pos)) 0 0);
}

/* ---------- Labels ---------- */
.mlv-ba__tag {
  position: absolute;
  top: 12px;
  z-index: 2;
  padding: 6px 14px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  background: rgba(15, 23, 42, .72);
  border-radius: 999px;
  pointer-events: none;
}

.mlv-ba__tag--before {
  left: 12px;
}

.mlv-ba__tag--after {
  right: 12px;
  background: rgba(15, 148, 96, .92);
}

/* ---------- Divider + handle ---------- */
.mlv-ba__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--mlv-pos);
  z-index: 3;
  width: 0;
  pointer-events: none;
}

.mlv-ba__divider::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .22);
}

.mlv-ba__handle {
  position: absolute;
  top: 50%;
  left: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  color: #0f9460;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .12), 0 6px 16px rgba(15, 23, 42, .25);
}

/* Without JS the split stays static at 50%, so don't show a control that can't move */
.mlv-ba__compare:not(.is-ready) .mlv-ba__handle {
  display: none;
}

.mlv-ba__compare.is-dragging .mlv-ba__handle {
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .12), 0 0 0 5px rgba(31, 191, 117, .3), 0 6px 16px rgba(15, 23, 42, .25);
}

/* ---------- Native range control: transparent full-container drag surface ----------
   The invisible native range receives mouse, touch and keyboard input. Keeping it
   over the entire comparison area avoids fragile custom pointer-capture handling.
*/
.mlv-ba .mlv-ba__range {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: auto;
  cursor: ew-resize;
  background: transparent;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
  touch-action: pan-y;
}

/* Make the native track span the container so clicking/dragging anywhere works. */
.mlv-ba .mlv-ba__range::-webkit-slider-runnable-track {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
}

.mlv-ba .mlv-ba__range::-webkit-slider-thumb {
  width: 1px;
  height: 100%;
  margin: 0;
  background: transparent;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
}

.mlv-ba .mlv-ba__range::-moz-range-track {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
}

.mlv-ba .mlv-ba__range::-moz-range-thumb {
  width: 1px;
  height: 100%;
  background: transparent;
  border: 0;
}

.mlv-ba__range:focus-visible ~ .mlv-ba__divider .mlv-ba__handle {
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .12), 0 0 0 5px rgba(31, 191, 117, .45), 0 6px 16px rgba(15, 23, 42, .25);
}

/* ---------- Phones ---------- */
@media (max-width: 520px) {
  .mlv-ba {
    margin: 24px auto;
    padding: 0 12px;
  }

  .mlv-ba__tag {
    top: 8px;
    padding: 5px 11px;
    font-size: 13px;
  }

  .mlv-ba__tag--before {
    left: 8px;
  }

  .mlv-ba__tag--after {
    right: 8px;
  }

  .mlv-ba__handle {
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
  }
}
