/* Styles are scoped to .image-compare so they do not affect the Hugo theme. */
.image-compare {
  --compare-bg: #17232c;
  --compare-border: #344651;
  --compare-muted: #c2c2c1;
  --compare-accent: #727272;
  --compare-position: 50%;
  --compare-opacity: .5;
  margin: 1.75rem 0;
  color: inherit;
}

.image-compare,
.image-compare * {
  box-sizing: border-box;
}

.image-compare__stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--compare-ratio, 4 / 3);
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--compare-border);
  border-radius: 12px;
  background: #101820;
  touch-action: pan-y;
}

.image-compare__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.image-compare__image--old {
  z-index: 0;
}

.image-compare__image--new {
  z-index: 1;
  opacity: var(--compare-opacity);
  clip-path: inset(0 0 0 0);
}

.image-compare.is-wipe .image-compare__image--new {
  opacity: 1;
  clip-path: inset(0 0 0 var(--compare-position));
}

.image-compare__label {
  position: absolute;
  z-index: 3;
  top: 12px;
  max-width: 45%;
  padding: .35rem .65rem;
  overflow: hidden;
  border-radius: 6px;
  background: rgb(16 24 32 / 82%);
  color: var(--compare-muted);
  font-size: .82rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.image-compare__label--old { left: 12px; }
.image-compare__label--new { right: 12px; }

.image-compare__divider {
  display: none;
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: var(--compare-position);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 35%);
  transform: translateX(-1px);
  pointer-events: none;
}

.image-compare.is-wipe .image-compare__divider { display: block; }

.image-compare__handle {
  display: none;
  position: absolute;
  z-index: 4;
  top: 50%;
  left: var(--compare-position);
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 2px solid #17232c;
  border-radius: 50%;
  background: #fff;
  color: #17232c;
  box-shadow: 0 2px 12px rgb(0 0 0 / 45%);
  font-size: 1.2rem;
  font-weight: 700;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.image-compare.is-wipe .image-compare__handle { display: flex; }

.image-compare__controls {
  margin-top: .8rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--compare-border);
  border-radius: 10px;
/*  background: var(--compare-bg); */
  color: var(--compare-muted);
}

.image-compare__control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .45rem;
}

.image-compare__range-label { font-weight: 600; }
.image-compare__value {
  color: var(--compare-accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.image-compare__range {
  display: block;
  width: 100%;
  margin: .4rem 0 .1rem;
  accent-color: var(--compare-accent);
  cursor: pointer;
}

.image-compare__endpoints {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--compare-muted);
  font-size: .82rem;
}

.image-compare__mode {
  display: flex;
  width: fit-content;
  gap: .25rem;
  margin-top: .9rem;
  padding: .25rem;
  border: 1px solid var(--compare-border);
  border-radius: 9px;
  background: rgb(0 0 0 / 18%);
}

.image-compare__mode-button {
  padding: .45rem .8rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--compare-muted);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}

.image-compare__mode-button[aria-pressed="true"] {
  background: var(--compare-accent);
  color: #fff;
}

.image-compare__mode-button:focus-visible,
.image-compare__range:focus-visible {
  outline: 2px solid var(--compare-accent);
  outline-offset: 3px;
}

.image-compare__caption {
  margin-top: .5rem;
  color: var(--compare-muted);
  font-size: .9rem;
}

@media (max-width: 600px) {
  .image-compare__label { top: 8px; font-size: .72rem; }
  .image-compare__label--old { left: 8px; }
  .image-compare__label--new { right: 8px; }
  .image-compare__controls { padding: .85rem; }
  .image-compare__mode { width: 100%; }
  .image-compare__mode-button { flex: 1; padding-inline: .35rem; }
}
