/* ============================================================
   difference — "The Klar Difference" (brief/difference.md)
   Desktop 3446:355 (1440) · Mobile 3446:1403 (375) · no tablet layer (768-1023 = pseudo-tablet).
   Pattern B-edge: .container on the section (gutter = padding-inline), gradient on the section,
   padding-block only. Mobile-first.
   Before/after = drag compare (BA-DF-1): --df-pos 0..100 on .difference__compare, default 50 = Figma.
   ============================================================ */

.difference {
  /* section-scoped fluid tokens — MOBILE (0-767, anchor 375) */
  --df-pad-y: clamp(43px, calc(50px + (var(--max-vw) - 375px) * 0.015), 80px);
  --df-gap: clamp(21px, calc(25px + (var(--max-vw) - 375px) * 0.015), 40px);
  --df-head-gap: clamp(9px, calc(10px + (var(--max-vw) - 375px) * 0.015), 20px);
  --df-row-gap: clamp(17px, calc(20px + (var(--max-vw) - 375px) * 0.015), 20px);
  --df-aside-gap: clamp(17px, calc(20px + (var(--max-vw) - 375px) * 0.015), 40px);
  --df-cards-gap: clamp(9px, calc(10px + (var(--max-vw) - 375px) * 0.015), 20px);
  --df-card-pad: clamp(13px, calc(15px + (var(--max-vw) - 375px) * 0.015), 20px);
  --df-card-gap: clamp(9px, calc(10px + (var(--max-vw) - 375px) * 0.015), 16px);
  --df-radius-img: clamp(5px, calc(6px + (var(--max-vw) - 375px) * 0.015), 12px);
  --df-label-inset: clamp(9px, calc(10px + (var(--max-vw) - 375px) * 0.015), 20px);
  --df-label-pad-y: clamp(2px, calc(2.5px + (var(--max-vw) - 375px) * 0.015), 5px);
  --df-label-pad-x: clamp(4px, calc(5px + (var(--max-vw) - 375px) * 0.015), 10px);
  --df-label-gap: clamp(2px, calc(2.5px + (var(--max-vw) - 375px) * 0.015), 5px);
  --df-dot: clamp(4px, calc(5px + (var(--max-vw) - 375px) * 0.015), 10px);
  --df-blur: clamp(6px, calc(7.5px + (var(--max-vw) - 375px) * 0.015), 15px);
  --df-knob-w: clamp(4px, calc(5px + (var(--max-vw) - 375px) * 0.015), 10px);
  --df-knob-h: clamp(9px, calc(11px + (var(--max-vw) - 375px) * 0.015), 22px);
  --df-knob-r: clamp(2px, calc(2.5px + (var(--max-vw) - 375px) * 0.015), 5px);
  --df-cta-w: 100%;
  --df-divider: 1px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--df-gap);
  padding-block: var(--df-pad-y);
  /* D-DF-2: visible fill stack (gradient over #E6E8D8); mobile angle */
  background: linear-gradient(97.64deg, #EEF0E5 5.51%, #D9E0C7 97.29%), #E6E8D8;
}

/* ---------- Head ---------- */
.difference__head {
  display: flex;
  flex-direction: column;
  gap: var(--df-head-gap);
  width: 100%;
  color: var(--color-heading);
  text-align: center;
}

.difference__title {
  font-family: var(--font-display);
  font-variation-settings: var(--fv-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-heading);
  color: var(--color-heading);
}

.difference__title-line {
  display: block;
  font-family: var(--font-display);
  font-variation-settings: var(--fv-display);
}

.difference__title-line--1 {
  font-size: var(--text-h2);
  font-weight: 600;
}

.difference__title-line--2 {
  font-size: var(--text-title);
  font-weight: 400;
}

.difference__lead {
  font-family: var(--font-body);
  font-size: var(--text-lead);
  font-weight: 400;
  line-height: var(--lh-lead);
  color: var(--color-heading);
}

/* ---------- Body row ---------- */
.difference__body {
  display: flex;
  flex-direction: column;
  gap: var(--df-row-gap);
  width: 100%;
}

/* ---------- Before / After compare ---------- */
.difference__compare {
  --df-pos: 50;
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 670 / 516;
  overflow: hidden;
  border-radius: var(--df-radius-img);
  background: var(--color-white);
  container-type: inline-size;
  cursor: ew-resize;
  touch-action: pan-y;            /* vertical page scroll stays native; horizontal drag → js/difference.js */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* keyboard focus ring on the card (the range itself is invisible);
   .is-pointer = focus handed over by a mouse/touch press (js) → no ring until a key is pressed */
.difference__compare:not(.is-pointer):has(.difference__range:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.difference__img {
  position: absolute;
  top: 0;
  height: 100%;
  max-width: none;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* D-DF-5: Figma x -2 / w 673 of 670 (mobile -1 / 336.5 of 335) */
.difference__img--before {
  left: -0.299%;
  width: 100.448%;
}

/* After layer = node 3446:362 / 3446:1410: from the split to the right edge */
.difference__after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--df-pos) * 1%);
  right: 0;
  overflow: hidden;
  pointer-events: none;
}

/* stays registered with the before image whatever the split */
.difference__img--after {
  left: calc(-1cqw * var(--df-pos) - 0.299cqw);
  width: 100.448cqw;
}

/* D-DF-11: right edge on the split */
.difference__divider {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: calc(var(--df-pos) * 1%);
  width: var(--df-divider);
  background: rgba(255, 255, 255, 0.8);
  transform: translateX(-100%);
  pointer-events: none;
}

/* D-DF-1: handle 3446:353 (desktop) / BA-DF-2 half-size on mobile; centred on the split, y 47.6 % */
.difference__knob {
  position: absolute;
  z-index: 2;
  top: 47.63%;
  left: calc(var(--df-pos) * 1%);
  width: var(--df-knob-w);
  height: var(--df-knob-h);
  border-radius: var(--df-knob-r);
  background: #F9EFEC;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* D-DF-6: glass labels pinned to the card corners */
.difference__label {
  position: absolute;
  z-index: 3;
  top: var(--df-label-inset);
  display: inline-flex;
  align-items: center;
  gap: var(--df-label-gap);
  padding: var(--df-label-pad-y) var(--df-label-pad-x);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.25);
  -webkit-backdrop-filter: blur(var(--df-blur));
  backdrop-filter: blur(var(--df-blur));
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--lh-ui);
  color: var(--color-ink);
  white-space: nowrap;
  pointer-events: none;
}

.difference__label--before { left: var(--df-label-inset); }
.difference__label--after { right: var(--df-label-inset); }

.difference__dot {
  flex: 0 0 auto;
  width: var(--df-dot);
  height: var(--df-dot);
  border-radius: 50%;
  background: var(--color-ink);
}

.difference__label--after .difference__dot { background: var(--color-cream); }

/* Native range = keyboard + a11y surface (arrows ±1, PageUp/PageDown ±10, Home/End).
   Pointer drag is handled on the card by js/difference.js, so the range takes no pointer events. */
.difference__range {
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none;
}

/* ---------- Aside: cards + CTA ---------- */
.difference__aside {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--df-aside-gap);
  width: 100%;
}

.difference__cards {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--df-cards-gap);
  width: 100%;
}

.difference__card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--df-card-gap);
  padding: var(--df-card-pad);
  border: 1px solid rgba(26, 26, 26, 0.1);
  border-radius: var(--radius-card);
}

.difference__card--without { background: rgba(251, 251, 251, 0.6); }
.difference__card--with { background: rgba(255, 255, 255, 0.9); }

.difference__card-title {
  font-family: var(--font-body);
  font-size: var(--text-h4-lg);
  font-weight: 500;
  line-height: var(--lh-ui);
  color: var(--color-ink);
  text-align: left;
}

.difference__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.difference__item {
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.difference__icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.difference__item-text {
  flex: 1 1 0;
  min-width: 0;
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--lh-ui);
  color: var(--color-text);
}

.difference__cta-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: var(--df-cta-w);
}

.difference__cta {
  width: 100%;
}

/* D-DF-8: fixed 254 inner row, centred, content left-aligned inside it */
.difference__guarantee {
  display: flex;
  justify-content: center;
  width: 100%;
}

.difference__guarantee-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  width: 254px;
  max-width: 100%;
}

.difference__guarantee-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.difference__guarantee-text {
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 400;
  line-height: var(--lh-ui);
  color: var(--color-ink);
  white-space: nowrap;
}

/* ============================================================
   PSEUDO-TABLET 768-1023 — split row (desktop-compressed), band tokens
   ============================================================ */
@media (min-width: 768px) {
  .difference {
    --df-pad-y: clamp(55.88px, calc(55.88px + (var(--max-vw) - 768px) * 0.025), 80px);
    --df-gap: clamp(30.88px, calc(30.88px + (var(--max-vw) - 768px) * 0.025), 40px);
    --df-head-gap: clamp(15.88px, calc(15.88px + (var(--max-vw) - 768px) * 0.025), 20px);
    --df-row-gap: clamp(20px, calc(20px + (var(--max-vw) - 768px) * 0.025), 20px);
    --df-aside-gap: clamp(25.88px, calc(25.88px + (var(--max-vw) - 768px) * 0.025), 40px);
    --df-cards-gap: clamp(15.88px, calc(15.88px + (var(--max-vw) - 768px) * 0.025), 20px);
    --df-card-pad: clamp(20px, calc(20px + (var(--max-vw) - 768px) * 0.025), 20px);
    --df-card-gap: clamp(15.88px, calc(15.88px + (var(--max-vw) - 768px) * 0.025), 16px);
    --df-radius-img: clamp(11.88px, calc(11.88px + (var(--max-vw) - 768px) * 0.025), 12px);
    --df-label-inset: clamp(15.88px, calc(15.88px + (var(--max-vw) - 768px) * 0.025), 20px);
    --df-label-pad-y: clamp(5px, calc(5px + (var(--max-vw) - 768px) * 0.025), 5px);
    --df-label-pad-x: clamp(10px, calc(10px + (var(--max-vw) - 768px) * 0.025), 10px);
    --df-label-gap: clamp(5px, calc(5px + (var(--max-vw) - 768px) * 0.025), 5px);
    --df-dot: clamp(10px, calc(10px + (var(--max-vw) - 768px) * 0.025), 10px);
    --df-blur: clamp(13.38px, calc(13.38px + (var(--max-vw) - 768px) * 0.025), 15px);
    --df-knob-w: clamp(10px, calc(10px + (var(--max-vw) - 768px) * 0.025), 10px);
    --df-knob-h: clamp(16.88px, calc(16.88px + (var(--max-vw) - 768px) * 0.025), 22px);
    --df-knob-r: clamp(5px, calc(5px + (var(--max-vw) - 768px) * 0.025), 5px);
    --df-divider: 2px;

    /* D-DF-2: desktop angle (row layout = wide box) */
    background: linear-gradient(121.09deg, #EEF0E5 5.51%, #D9E0C7 97.29%), #E6E8D8;
  }

  /* split row from 768 (page split-row rule); equal heights, the taller column sets the row */
  .difference__body {
    flex-direction: row;
    align-items: stretch;
  }

  .difference__compare {
    flex: 0 0 calc((100% - var(--df-row-gap)) / 2);
    width: auto;
  }

  .difference__aside {
    flex: 1 1 0;
    min-width: 0;
  }

  /* D-DF-4: cards fill the space above the CTA, equal height, content centred.
     Grid 1fr rows keep the two cards equal even when one card's rows wrap (band). */
  .difference__cards {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, 1fr);
    justify-content: stretch;
    align-content: stretch;
    gap: var(--df-cards-gap);
  }
}

/* ============================================================
   DESKTOP 1024+ — scales from --vw-base 1440, capped at 1920
   ============================================================ */
@media (min-width: 1024px) {
  .difference {
    --df-pad-y: clamp(57px, calc(80px * (var(--max-vw) / var(--vw-base))), 107px);
    --df-gap: clamp(28px, calc(40px * (var(--max-vw) / var(--vw-base))), 53px);
    --df-head-gap: clamp(14px, calc(20px * (var(--max-vw) / var(--vw-base))), 27px);
    --df-row-gap: clamp(14px, calc(20px * (var(--max-vw) / var(--vw-base))), 27px);
    --df-aside-gap: clamp(28px, calc(40px * (var(--max-vw) / var(--vw-base))), 53px);
    --df-cards-gap: clamp(14px, calc(20px * (var(--max-vw) / var(--vw-base))), 27px);
    --df-card-pad: clamp(14px, calc(20px * (var(--max-vw) / var(--vw-base))), 27px);
    --df-card-gap: clamp(11px, calc(16px * (var(--max-vw) / var(--vw-base))), 21px);
    --df-radius-img: clamp(9px, calc(12px * (var(--max-vw) / var(--vw-base))), 16px);
    --df-label-inset: clamp(14px, calc(20px * (var(--max-vw) / var(--vw-base))), 27px);
    --df-label-pad-y: clamp(4px, calc(5px * (var(--max-vw) / var(--vw-base))), 7px);
    --df-label-pad-x: clamp(7px, calc(10px * (var(--max-vw) / var(--vw-base))), 13px);
    --df-label-gap: clamp(4px, calc(5px * (var(--max-vw) / var(--vw-base))), 7px);
    --df-dot: clamp(7px, calc(10px * (var(--max-vw) / var(--vw-base))), 13px);
    --df-blur: clamp(11px, calc(15px * (var(--max-vw) / var(--vw-base))), 20px);
    --df-knob-w: clamp(7px, calc(10px * (var(--max-vw) / var(--vw-base))), 13px);
    --df-knob-h: clamp(16px, calc(22px * (var(--max-vw) / var(--vw-base))), 29px);
    --df-knob-r: clamp(4px, calc(5px * (var(--max-vw) / var(--vw-base))), 7px);
    /* D-DF-9: CTA group 420 centred in the 670 aside */
    --df-cta-w: clamp(299px, calc(420px * (var(--max-vw) / var(--vw-base))), 560px);
    /* RESPONSIVE (STEP 3b rule 3): list / refund-row atoms that were flat px in every band.
       M = D (20 / 10 / 5 / 16 / 254 / 6), so the mobile + band values stay; the desktop band
       scales them like plan / clinical / delivery's refund rows (1440 = Figma unchanged).
       The flat 20px icon held every list row at 20 tall while its 14.2px text shrank → 1024/1440 0.752. */
    --df-icon: clamp(14px, calc(20px * (var(--max-vw) / var(--vw-base))), 27px);
    --df-list-gap: clamp(7px, calc(10px * (var(--max-vw) / var(--vw-base))), 13px);
    --df-item-gap: clamp(4px, calc(5px * (var(--max-vw) / var(--vw-base))), 7px);
    --df-cta-gap: clamp(11px, calc(16px * (var(--max-vw) / var(--vw-base))), 21px);
    --df-refund-box: clamp(181px, calc(254px * (var(--max-vw) / var(--vw-base))), 339px);
    --df-refund-gap: clamp(4px, calc(6px * (var(--max-vw) / var(--vw-base))), 8px);
  }

  .difference__list { gap: var(--df-list-gap); }
  .difference__item { gap: var(--df-item-gap); }
  .difference__icon,
  .difference__guarantee-icon {
    width: var(--df-icon);
    height: var(--df-icon);
  }
  .difference__cta-group { gap: var(--df-cta-gap); }
  .difference__guarantee-inner {
    gap: var(--df-refund-gap);
    width: var(--df-refund-box);
  }
}
