:root {
  color-scheme: dark;
  background: #11120c;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #11120c;
}

main,
.comparison {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
}

.image-stage {
  position: relative;
  width: min(100vw, 75dvh);
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #25241a;
  box-shadow: 0 0 80px rgb(0 0 0 / 44%);
  isolation: isolate;
  touch-action: none;
  user-select: none;
}

.comparison-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.comparison-image--after {
  z-index: 1;
  clip-path: inset(0 48% 0 0);
}

.divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52%;
  z-index: 2;
  width: 2px;
  transform: translateX(-50%);
  background: rgb(255 251 238 / 88%);
  box-shadow: 0 0 0 1px rgb(22 22 14 / 14%);
  pointer-events: none;
}

.divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 1px solid rgb(38 36 23 / 16%);
  border-radius: 50%;
  background: #f4edda;
  box-shadow: 0 5px 20px rgb(0 0 0 / 28%);
  color: #353426;
  transition: transform 160ms var(--ease-out);
}

.divider-handle svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.comparison-control {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: ew-resize;
  opacity: 0;
}

.image-stage:has(.comparison-control:active) .divider-handle {
  transform: translate(-50%, -50%) scale(0.95);
}

.comparison-control:focus-visible {
  outline: none;
}

.image-stage:has(.comparison-control:focus-visible) {
  box-shadow:
    inset 0 0 0 3px #e8cf8f,
    0 0 80px rgb(0 0 0 / 44%);
}

@media (prefers-reduced-motion: reduce) {
  .divider-handle {
    transition-duration: 0ms;
  }
}
