/* Before-and-after slider mechanics; each look sets the --compare-* colours and the type. */

.compare-note {
  max-width: 64ch;
  margin-bottom: 28px;
  padding: 16px 20px;
  border-left: 3px solid var(--compare-accent, currentColor);
  font-size: 1rem;
  line-height: 1.55;
}

.compare-list {
  display: grid;
  gap: clamp(32px, 5vw, 56px);
}

@media (min-width: 900px) {
  .compare-list-many {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

.compare-figure {
  display: grid;
  justify-items: center;
  gap: 14px;
}

/* Sized by the before photo's width attribute, so the box is never wider than either file. */
.compare {
  --pos: 50%;

  position: relative;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--compare-radius, 0);
  background: var(--compare-ground, #222);
  cursor: ew-resize;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y pinch-zoom;
}

/* The range is invisible, so its keyboard ring goes on the photo. */
.compare:focus-within {
  outline: 2px solid var(--compare-focus, currentColor);
  outline-offset: 3px;
}

.compare img {
  display: block;
  pointer-events: none;
}

/* Fits between the sticky header and the phone call bar; a taller photo is cropped, not shrunk. */
.compare-base {
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - var(--header-h, 0px) - var(--callbar-h, 0px) - 32px);
  object-fit: cover;
}

@supports (height: 100svh) {
  .compare-base {
    max-height: calc(100svh - var(--header-h, 0px) - var(--callbar-h, 0px) - 32px);
  }
}

.compare-after {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--pos));
}

.compare-after img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare-tag {
  position: absolute;
  bottom: 14px;
  padding: 6px 11px;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
}

.compare-tag-before {
  left: 14px;
}

.compare-tag-after {
  right: 14px;
}

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--compare-line, #fff);
  pointer-events: none;
}

.compare-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--compare-grip, #fff);
  box-shadow: var(--compare-grip-shadow, 0 6px 24px rgb(0 0 0 / 0.35));
  transform: translate(-50%, -50%);
}

.compare-grip::before,
.compare-grip::after {
  content: "";
  position: absolute;
  top: 18px;
  border-block: 6px solid transparent;
}

.compare-grip::before {
  left: 11px;
  border-right: 8px solid var(--compare-arrow, #000);
}

.compare-grip::after {
  right: 11px;
  border-left: 8px solid var(--compare-arrow, #000);
}

/* Pointer events go to the photo; the range is there for the keyboard and screen readers. */
.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.compare-cap,
.compare-credit {
  font-size: 0.875rem;
  line-height: 1.5;
}

.compare-cap {
  max-width: 60ch;
  text-align: center;
}

.compare-credit {
  margin-top: 16px;
}

@media print {
  .compare-handle,
  .compare-range {
    display: none;
  }
}
