/* Before/after comparison slider ([data-ba]). Shared byte-identical DK <-> EN;
   behaviour lives in /assets/js/before-after.js.

   Both layers are stacked; the BEFORE layer sits on top and is clipped to the
   left of --ba-pos, so the AFTER layer shows through on the right. Either
   layer may hold an <img> or a <video> -- both are object-fit: cover, so the
   two media must share the same aspect ratio (3:4 here) to line up.

   Touch: the frame is touch-action: pan-y pinch-zoom, so a vertical swipe
   still scrolls the page (and pinch-zoom still works) while a horizontal
   swipe drags the divider. The knob itself is touch-action: none so grabbing
   it never scrolls; it sits low in the frame (off the speaker, in the thumb
   zone) and is clamped 24px inside the edges so it is never clipped at 0/100%
   and never competes with the iOS edge-swipe back gesture. */

.ba-section { overflow: hidden; }
.ba-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
  gap: 4rem; align-items: center;
}
.ba-copy p { color: color-mix(in srgb, var(--white) 62%, transparent); font-size: 1.05rem; line-height: 1.6; max-width: 34ch; }
.ba-hint {
  display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 1.4rem;
  font-family: var(--font-b); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--purple);
}
.ba-hint svg { width: 18px; height: 18px; flex: none; }
/* Width follows the viewport height too, so the whole 3:4 frame fits between
   the nav and the sticky buy bar on short phones and landscape screens. */
.ba-media { width: 100%; margin: 0 auto; max-width: min(460px, max(280px, calc((100vh - 140px) * 0.75))); }
@supports (height: 100svh) {
  .ba-media { max-width: min(460px, max(280px, calc((100svh - 140px) * 0.75))); }
}

.ba {
  --ba-pos: 50%;
  position: relative; width: 100%; aspect-ratio: 3 / 4; overflow: hidden;
  border-radius: 14px; background: var(--bg2);
  border: 1px solid color-mix(in srgb, var(--purple) 18%, transparent);
  isolation: isolate; cursor: ew-resize;
  touch-action: pan-y pinch-zoom;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.ba-layer { position: absolute; inset: 0; }
.ba-layer img, .ba-layer video {
  display: block; width: 100%; height: 100%; object-fit: cover;
  pointer-events: none; -webkit-user-drag: none;
}
.ba-before {
  z-index: 1;
  -webkit-clip-path: inset(0 calc(100% - var(--ba-pos)) 0 0);
          clip-path: inset(0 calc(100% - var(--ba-pos)) 0 0);
}

.ba-label {
  position: absolute; top: 14px; z-index: 2; pointer-events: none;
  padding: 0.3rem 0.75rem 0.2rem; border-radius: 999px;
  font-family: var(--font-h); font-size: 1.1rem; letter-spacing: 0.08em; line-height: 1.1;
  color: var(--white); background: rgba(7,6,15,0.62);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: opacity 0.2s ease;
}
.ba-label--before { left: 14px; }
.ba-label--after { right: 14px; }
.ba.is-before-hidden .ba-label--before,
.ba.is-after-hidden .ba-label--after { opacity: 0; }

/* Divider line: full height, never intercepts input. */
.ba-line {
  position: absolute; top: 0; bottom: 0; left: var(--ba-pos); z-index: 3;
  width: 2px; margin-left: -1px; pointer-events: none;
  background: var(--white); box-shadow: 0 0 12px rgba(168,85,247,0.8);
}
/* Knob: 48px touch target on the line, clamped inside the frame. */
.ba-knob {
  position: absolute; top: 80%; left: clamp(24px, var(--ba-pos), calc(100% - 24px)); z-index: 4;
  width: 48px; height: 48px; margin: -24px 0 0 -24px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; cursor: ew-resize; touch-action: none;
  color: var(--bg); background: var(--white);
  box-shadow: 0 0 0 4px rgba(168,85,247,0.35), 0 4px 18px rgba(0,0,0,0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ba-knob svg { width: 26px; height: 26px; pointer-events: none; }
@media (hover: hover) { .ba-knob:hover { transform: scale(1.06); } }
.ba.is-dragging .ba-knob { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(168,85,247,0.5), 0 4px 18px rgba(0,0,0,0.5); }
.ba-knob:focus { outline: none; }
.ba-knob:focus-visible { outline: 2px solid var(--purple); outline-offset: 4px; }

@media (max-width: 900px) {
  .ba-grid { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .ba-copy { text-align: center; }
  .ba-copy p { margin: 0 auto; }
}
@media (max-width: 550px) {
  .ba { border-radius: 12px; }
  .ba-label { top: 10px; font-size: 1rem; }
  .ba-label--before { left: 10px; }
  .ba-label--after { right: 10px; }
}
