/* Before/After slider gallery */
.ba-container {
  /* Don't rely on utility classes (Tailwind). Provide the core layout here. */
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: #f3f4f6;
  aspect-ratio: 4 / 3;
  touch-action: none;
  /* Percent (0-100%) of the before image revealed */
  --ba-pos: 50%;
}

/* Fallback for browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 4 / 3) {
  .ba-container {
    height: 0;
    padding-top: 75%; /* 3/4 = 0.75 */
  }
}

.ba-container img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ba-before-wrap {
  position: absolute;
  inset: 0;
  /* Keep the before layer full-width so the image doesn't squish.
     We reveal using clip-path on the image itself. */
  width: 100% !important;
  overflow: visible;
}

/* Reveal before image by clipping it, not scaling it */
.ba-before {
  clip-path: inset(0 calc(100% - var(--ba-pos)) 0 0);
}

.ba-range {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  opacity: 0;
  cursor: ew-resize;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Make sure it still works on mobile where range can be hard to grab */
.ba-container:focus-within {
  outline: 2px solid rgba(0,0,0,0.08);
  outline-offset: 3px;
}

.ba-knob {
  user-select: none;
}

.ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  transform: translateX(-50%);
  pointer-events: none; /* the invisible range captures input */
}

.ba-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 6px rgba(0,0,0,0.25);
}

.ba-knob {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 20px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Space between gallery sliders */
.bg-white {
  margin: .5rem;
}

/* Optional: reduce spacing on mobile */
@media (max-width: 768px) {
  .ba-item {
    margin-bottom: 2rem;
  }
}
