.calio-image-comparison {
  --calio-comparison-position: 50%;
  --calio-comparison-speed: 180ms;
  --calio-comparison-handle-size: 54px;
  --calio-comparison-divider-width: 3px;
  --calio-comparison-divider-color: #fff;
  --calio-comparison-handle-color: #fff;
  --calio-comparison-handle-icon-color: #0f172a;
  position: relative;
  width: 100%;
  min-height: 220px;
  height: 420px;
  overflow: hidden;
  border-radius: 20px;
  background: #e5e7eb;
  isolation: isolate;
  touch-action: none;
  user-select: none;
}

.calio-image-comparison::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.18);
  mix-blend-mode: multiply;
}

.calio-comparison-stage,
.calio-comparison-image,
.calio-comparison-image img {
  position: absolute;
  inset: 0;
}

.calio-comparison-stage {
  z-index: 1;
}

.calio-comparison-image {
  overflow: hidden;
}

.calio-comparison-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
}

.calio-comparison-before {
  z-index: 1;
}

.calio-comparison-after {
  z-index: 2;
  clip-path: inset(0 0 0 var(--calio-comparison-position));
  transition: clip-path var(--calio-comparison-speed) ease;
  will-change: clip-path;
}

.calio-image-comparison.is-dragging .calio-comparison-after,
.calio-image-comparison.is-dragging .calio-comparison-divider,
.calio-image-comparison.is-dragging .calio-comparison-handle {
  transition-duration: 0ms;
}

.calio-comparison-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--calio-comparison-position);
  z-index: 5;
  width: var(--calio-comparison-divider-width);
  background: var(--calio-comparison-divider-color);
  transform: translateX(-50%);
  transition: left var(--calio-comparison-speed) ease;
  pointer-events: none;
}

.calio-comparison-handle {
  position: absolute;
  top: 50%;
  left: var(--calio-comparison-position);
  z-index: 6;
  width: var(--calio-comparison-handle-size);
  height: var(--calio-comparison-handle-size);
  border-radius: 999px;
  background: var(--calio-comparison-handle-color);
  transform: translate(-50%, -50%);
  transition: left var(--calio-comparison-speed) ease, transform 180ms ease;
  pointer-events: none;
  display: grid;
  place-items: center;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
}

.calio-image-comparison.handle-square .calio-comparison-handle {
  border-radius: 12px;
}

.calio-image-comparison.handle-minimal .calio-comparison-handle {
  width: calc(var(--calio-comparison-handle-size) * 0.56);
  border-radius: 999px;
}

.calio-image-comparison:hover .calio-comparison-handle,
.calio-image-comparison.is-dragging .calio-comparison-handle {
  transform: translate(-50%, -50%) scale(1.04);
}

.calio-comparison-handle-icon {
  position: relative;
  width: 24px;
  height: 14px;
}

.calio-comparison-handle-icon::before,
.calio-comparison-handle-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--calio-comparison-handle-icon-color);
  border-left: 2px solid var(--calio-comparison-handle-icon-color);
}

.calio-comparison-handle-icon::before {
  left: 1px;
  transform: translateY(-50%) rotate(-45deg);
}

.calio-comparison-handle-icon::after {
  right: 1px;
  transform: translateY(-50%) rotate(135deg);
}

.calio-image-comparison.hide-handle-arrows .calio-comparison-handle-icon {
  display: none;
}

.calio-comparison-range {
  position: absolute;
  inset: 0;
  z-index: 7;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  appearance: none;
}

.calio-comparison-range:focus-visible + *,
.calio-image-comparison:focus-within .calio-comparison-handle {
  outline: 3px solid rgba(59, 130, 246, 0.65);
  outline-offset: 4px;
}

.calio-comparison-label {
  position: absolute;
  z-index: 8;
  max-width: min(44%, 220px);
  padding: 8px 13px;
  color: #fff;
  background: rgba(15, 23, 42, 0.78);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.label-position-top .calio-comparison-label {
  top: 18px;
}

.label-position-bottom .calio-comparison-label {
  bottom: 18px;
}

.calio-comparison-label-before {
  left: 18px;
}

.calio-comparison-label-after {
  right: 18px;
}

html[dir='rtl'] .calio-comparison-after,
:dir(rtl) .calio-comparison-after {
  clip-path: inset(0 var(--calio-comparison-position) 0 0);
}

html[dir='rtl'] .calio-comparison-divider,
html[dir='rtl'] .calio-comparison-handle,
:dir(rtl) .calio-comparison-divider,
:dir(rtl) .calio-comparison-handle {
  left: auto;
  right: var(--calio-comparison-position);
}

@media (max-width: 767px) {
  .calio-image-comparison {
    min-height: 180px;
  }

  .calio-comparison-label {
    max-width: 42%;
    padding: 7px 10px;
    font-size: 11px;
  }

  .calio-comparison-label-before {
    left: 12px;
  }

  .calio-comparison-label-after {
    right: 12px;
  }
}
