/* ===== Before / After video comparison slider ===== */

.section.beforeafter {
  /* padding-block: 6rem 0; */
}

.beforeafter .ba-head {
  margin-bottom: 2.5rem;
}

/* Slider frame */
.ba-slider {
  position: relative;
  width: 100%;
  /* Samakan dengan .wwd__container (var --wwd-max-w = 1300px) */
  max-width: 1300px;
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: #0b0b0b;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  cursor: ew-resize;
}

/* Both videos fill the frame identically */
.ba-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* "Before" video menutupi seluruh slider; bagian kiri diungkap dengan clip-path.
   clip-path di-compositing GPU (tanpa relayout/repaint video) → jauh lebih ringan
   di mobile dibanding menganimasikan width. Digerakkan oleh --ba-pos. */
.ba-before-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  clip-path: inset(0 calc(100% - var(--ba-pos, 50%)) 0 0);
}

.ba-before-wrap .ba-video {
  width: 100%;              /* = lebar penuh slider, tidak gepeng */
  max-width: none;
}

/* Divider handle */
.ba-handle {
  position: absolute;
  top: 0;
  left: var(--ba-pos, 50%);
  transform: translateX(-50%);
  height: 100%;
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: none;     /* dragging handled on the whole slider */
}

.ba-line {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 100%;
  background: #fff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

.ba-grip {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #0b0b0b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}

.ba-grip svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Labels */
.ba-label {
  position: absolute;
  bottom: 16px;
  z-index: 2;
  padding: 6px 12px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  pointer-events: none;
}

.ba-label-before { left: 16px; }
.ba-label-after  { right: 16px; }

/* Hint "drag to compare" di atas grip */
.ba-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  white-space: nowrap;
  padding: 6px 12px;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0b0b0b;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: ba-hint-bob 1.8s ease-in-out infinite;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Caret kecil menunjuk ke grip */
.ba-hint::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}

@keyframes ba-hint-bob {
  0%, 100% { transform: translate(-50%, calc(-50% - 44px)); }
  50%      { transform: translate(-50%, calc(-50% - 50px)); }
}

/* Sembunyikan hint setelah interaksi pertama */
.ba-slider.is-dragged .ba-hint {
  opacity: 0;
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .ba-hint { animation: none; transform: translate(-50%, calc(-50% - 44px)); }
}

@media (max-width: 640px) {
  /* .section.beforeafter { padding-block: 4rem 0; } */
  .ba-slider { aspect-ratio: 4 / 5; }
  .ba-grip { width: 38px; height: 38px; }
}
