/* =====================================================================
   Usine — Before/After comparison slider
   Activated ONLY on a bloc_gallery_01 whose heading contains "avant" +
   "après" AND that has exactly 2 images. Every other gallery / page is
   untouched (JS opt-in, no markup change elsewhere).
   ===================================================================== */

.usine-ba {
  position: relative;
  width: 100%;
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  background: transparent;
  --usine-ba-pos: 50%;
}

.usine-ba__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}

/* Base layer = "après" (revealed on the right). Its image establishes the
   natural height of the whole comparison box. */
.usine-ba__base {
  position: relative;
  z-index: 1;
}

.usine-ba__base .usine-ba__img {
  height: auto;
}

/* Top layer = "avant" (revealed on the left), clipped at the divider */
.usine-ba__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  clip-path: inset(0 calc(100% - var(--usine-ba-pos)) 0 0);
  will-change: clip-path;
}

.usine-ba__overlay .usine-ba__img {
  position: absolute;
  inset: 0;
}

/* Divider line + handle */
.usine-ba__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--usine-ba-pos);
  z-index: 3;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}

.usine-ba__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5c4429;
  pointer-events: none;
}

.usine-ba__handle svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* Labels */
.usine-ba__label {
  position: absolute;
  bottom: 14px;
  z-index: 3;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.usine-ba__label--before { left: 14px; }
.usine-ba__label--after { right: 14px; }

.usine-ba:focus-visible {
  outline: 3px solid #5c4429;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .usine-ba__handle { width: 38px; height: 38px; }
  .usine-ba__label { font-size: 0.68rem; padding: 4px 9px; }
}
