/* Comparateur autonome : le pourcentage pilote la découpe et la barre. */
.image-comparison {
  --position: 50%;
  position: relative;
  width: 100%;
  height: min(65vh, 680px);
  height: min(65svh, 680px);
  overflow: hidden;
  isolation: isolate;
  background: #222;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
  /* Le doigt déplace la barre horizontalement ; le scroll vertical reste libre. */
  touch-action: pan-y;
}
.image-comparison__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}
.image-comparison__after {
  clip-path: inset(0 calc(100% - var(--position)) 0 0);
}
.image-comparison__divider {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: var(--position);
  width: 3px;
  background: #fff;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgb(0 0 0 / 35%);
  pointer-events: none;
}
.image-comparison__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: rgb(0 0 0 / 35%);
  box-shadow: 0 2px 12px rgb(0 0 0 / 25%);
  transform: translate(-50%, -50%);
}
.image-comparison__handle svg { width: 30px; height: 24px; }
.image-comparison:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -6px;
}
@media (max-width: 640px) {
  .image-comparison {
    height: auto;
    aspect-ratio: 4 / 3;
    max-height: 65svh;
  }
  .image-comparison__handle { width: 44px; height: 44px; }
}
