/*
 * compare-slider.css — before / after image comparison slider
 * Requires CompareSlider.js.
 *
 * All visual state flows through --compare-slider-pos (0–100) set by JS.
 * :focus-within links keyboard focus on the injected input to the handle.
 */

@property --compare-slider-pos {
  syntax: "<number>";
  inherits: true;
  initial-value: 50;
}

.compare-slider {
  position: relative;
  display: block;
  overflow: hidden;
  cursor: col-resize;
  user-select: none;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.compare-slider__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
}

.compare-slider__after {
  clip-path: inset(0 0 0 calc(var(--compare-slider-pos) * 1%));
}

.compare-slider::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 calc(var(--compare-slider-pos) * 1%);
  transform: translateX(-50%);
  width: 2px;
  background: #fff;
  z-index: 2;
  pointer-events: none;
}

.compare-slider__handle {
  position: absolute;
  top: 50%;
  left: calc(var(--compare-slider-pos, 50) * 1%);
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M3 10h14M3 10l4-4M3 10l4 4M17 10l-4-4M17 10l-4 4' stroke='%23111' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C%2Fsvg%3E")
    center / 20px no-repeat,
    #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 5;
  pointer-events: none;
  transition: box-shadow 0.15s, transform 0.15s;
}

.compare-slider:focus-within .compare-slider__handle {
  box-shadow: 0 0 0 3px #6c63ff, 0 2px 10px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%) scale(1.08);
}

.compare-slider__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: col-resize;
  z-index: 4;
  margin: 0;
  appearance: none;
}
