/*
------------------------
Vorher / Nachher (Bricks-Element)
Nutzt ausschließlich Tokens aus tokens-and-classes.css.
------------------------
*/
.vorher-nachher {
  --vn-pos: 50%;
  width: 100%;
}

.vorher-nachher__buehne {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 2;
  background-color: var(--color-neutral-100);
  user-select: none;
  -webkit-user-select: none;
}

.vorher-nachher__buehne--4-3 { aspect-ratio: 4 / 3; }
.vorher-nachher__buehne--16-9 { aspect-ratio: 16 / 9; }
.vorher-nachher__buehne--1-1 { aspect-ratio: 1 / 1; }

/* Ziehen auf dem Bild erst, wenn JS aktiv ist */
.vorher-nachher.is-interaktiv .vorher-nachher__buehne {
  cursor: ew-resize;
  touch-action: pan-y;
}

/* Verkettet, damit „main img:hover“ (Zoom) und „img { height: auto }“ aus der style.css nicht greifen */
.vorher-nachher .vorher-nachher__bild {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  transform: none;
  transition: none;
  pointer-events: none;
}

.vorher-nachher .vorher-nachher__bild--vorher {
  clip-path: inset(0 calc(100% - var(--vn-pos)) 0 0);
}

.vorher-nachher__linie {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--vn-pos);
  width: 3px;
  background-color: var(--white);
  transform: translateX(-50%);
  pointer-events: none;
}

.vorher-nachher__label {
  position: absolute;
  top: var(--space-s);
  padding: 0.25em 0.75em;
  border-radius: 2rem;
  color: var(--white);
  font-size: var(--text-s);
  font-weight: var(--font-weight-bold);
  line-height: 1.5;
  pointer-events: none;
  transition: opacity var(--transition-duration) ease;
}

.vorher-nachher__label--vorher {
  left: var(--space-s);
  background-color: rgb(0 0 0 / 0.55);
}

/* Dummy: #41bcc9 (--color-primary). Weiß darauf hat nur 2,3:1 → WCAG-AA-Abweichung, daher --color-secondary #025f87 (7:1). */
.vorher-nachher__label--nachher {
  right: var(--space-s);
  background-color: var(--color-secondary);
}

/* Label ausblenden, wenn das zugehörige Bild fast ganz verdeckt ist */
.vorher-nachher.is-vorher-verdeckt .vorher-nachher__label--vorher,
.vorher-nachher.is-nachher-verdeckt .vorher-nachher__label--nachher {
  opacity: 0;
}

.vorher-nachher__regler {
  width: 100%;
  margin: var(--space-s) 0 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.vorher-nachher__regler:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 4px;
}

.vorher-nachher__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .vorher-nachher__label {
    transition: none;
  }
}
