/*
 * "Reken uit wat je bespaart": de stapel.
 *
 * Draait op de 7 SEO-pagina's met de calculator (js/savings-calculator.js).
 * Links zet je aan wat je nu los betaalt, rechts staan twee torens op
 * dezelfde schaal: elk los abonnement is een blok in de linker toren, de
 * rechter toren is het ene blok van MyCompanyDesk. Het hoogteverschil is wat
 * je per maand bespaart, en dat staat als stippelvlak boven het MCD-blok.
 *
 * Alles is gescoped onder .landing-savings-calc: de home gebruikt dezelfde
 * .landing-savings-*-klassen voor zijn vaste kaart en blijft ongemoeid.
 * Hoogtes rekenen in CSS uit --v (bedrag) en --max (schaal), zodat de pagina
 * zonder JS al de juiste stand laat zien en er na het laden niets verspringt.
 */

.landing-savings-calc {
  --sv-track: 300px;
  --sv-gap: 3px;
  --sv-c0: #4f46e5;
  --sv-c1: #0284c7;
  --sv-c2: #f59e0b;
  --sv-c3: #db2777;
  --sv-c4: #0d9488;
  --sv-c5: #ea580c;
  --sv-c6: #dc2626;
  --sv-c7: #475569;
  --sv-ink2: #1f2937;
  max-width: 1040px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 24px;
  align-items: stretch;
}

[data-theme="dark"] .landing-savings-calc {
  --sv-c0: #6366f1;
  --sv-c1: #0ea5e9;
  --sv-c2: #fbbf24;
  --sv-c3: #ec4899;
  --sv-c4: #14b8a6;
  --sv-c5: #f97316;
  --sv-c6: #ef4444;
  --sv-c7: #64748b;
}

.landing-savings-calc #savings-tools li:nth-child(1),
.landing-savings-calc [data-savings-block="0"] { --c: var(--sv-c0); }
.landing-savings-calc #savings-tools li:nth-child(2),
.landing-savings-calc [data-savings-block="1"] { --c: var(--sv-c1); }
.landing-savings-calc #savings-tools li:nth-child(3),
.landing-savings-calc [data-savings-block="2"] { --c: var(--sv-c2); --ink: var(--sv-ink2); }
.landing-savings-calc #savings-tools li:nth-child(4),
.landing-savings-calc [data-savings-block="3"] { --c: var(--sv-c3); }
.landing-savings-calc #savings-tools li:nth-child(5),
.landing-savings-calc [data-savings-block="4"] { --c: var(--sv-c4); }
.landing-savings-calc #savings-tools li:nth-child(6),
.landing-savings-calc [data-savings-block="5"] { --c: var(--sv-c5); }
.landing-savings-calc #savings-tools li:nth-child(7),
.landing-savings-calc [data-savings-block="6"] { --c: var(--sv-c6); }
.landing-savings-calc #savings-tools li:nth-child(8),
.landing-savings-calc [data-savings-block="7"] { --c: var(--sv-c7); }

/* ---------- links: de lijst ---------- */

.landing-savings-calc .landing-savings-col {
  padding: 26px;
}

.landing-savings-calc .landing-savings-label {
  margin-bottom: 6px;
}

.landing-savings-hint {
  margin: 0 0 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--landing-text-muted);
}

.landing-savings-calc .landing-savings-list {
  gap: 4px;
  margin-bottom: 12px;
}

.landing-savings-calc .landing-savings-list li {
  display: block;
  font-size: 0.95rem;
}

.landing-savings-calc .landing-savings-tool {
  gap: 12px;
  min-height: 50px;
  padding: 4px 6px 4px 8px;
  border-radius: 12px;
  transition: background-color 0.2s ease;
}

@media (hover: hover) {
  .landing-savings-calc .landing-savings-tool:hover {
    background: var(--landing-bg-subtle-hover);
  }
}

/* De checkbox wordt een schakelaar in de kleur van zijn blok. Het blijft een
   echte checkbox: spatie schakelt, en de hele regel is het label. */
.landing-savings-calc .landing-savings-tool input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--landing-text-faint) 38%, transparent);
  transition: background-color 0.2s ease;
}

.landing-savings-calc .landing-savings-tool input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s var(--landing-transition);
}

.landing-savings-calc .landing-savings-tool input[type="checkbox"]:checked {
  background: var(--c);
}

.landing-savings-calc .landing-savings-tool input[type="checkbox"]:checked::before {
  transform: translateX(16px);
}

.landing-savings-calc .landing-savings-tool input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--landing-accent);
  outline-offset: 2px;
}

/* Uit is gewoon uit: gedimd, niet doorgestreept (doorgestreept las als "al
   geschrapt"). */
.landing-savings-calc .landing-savings-tool input[type="checkbox"]:not(:checked) ~ .landing-savings-tool-name {
  color: var(--landing-text-muted);
  text-decoration: none;
}

.landing-savings-calc .landing-savings-tool input[type="checkbox"]:checked ~ .landing-savings-tool-name {
  color: var(--landing-text);
  font-weight: 600;
}

.landing-savings-calc .landing-savings-tool-input {
  width: 4.8rem;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.landing-savings-calc .landing-savings-tool input[type="checkbox"]:not(:checked) ~ .landing-savings-tool-price .landing-savings-tool-input {
  border-style: dashed;
  color: var(--landing-text-muted);
}

.landing-savings-calc .landing-savings-tool input[type="checkbox"]:checked ~ .landing-savings-tool-price .landing-savings-tool-input {
  border-color: color-mix(in srgb, var(--c) 45%, var(--landing-border));
}

.landing-savings-calc .landing-savings-total {
  flex-wrap: wrap;
  row-gap: 2px;
  padding: 14px 8px 0;
  font-variant-numeric: tabular-nums;
}

/* Alleen op de telefoon: daar staan de torens boven de lijst, dus de
   totaalregel plakt onderin beeld en zegt meteen wat het scheelt. */
.landing-savings-total-save {
  display: none;
  flex-basis: 100%;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--landing-accent-2);
}

.landing-savings-total-save[data-off] {
  visibility: hidden;
}

/* ---------- rechts: de twee torens ---------- */

.landing-savings-calc .landing-savings-col-mcd {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  text-align: left;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--landing-accent) 6%, var(--landing-bg-card)),
    var(--landing-bg-card) 70%
  );
}

.landing-savings-col-mcd > .landing-savings-label {
  margin: 0 0 4px;
}

.landing-savings-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 14px;
  padding: 6px 4px 0;
}

.landing-savings-tower {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Naam staat in de DOM boven de toren (schermlezer leest eerst wat het is),
   maar staat in beeld eronder, op de "vloer". */
.landing-savings-tower-name {
  order: 2;
  margin: 0;
  padding-top: 10px;
  border-top: 2px solid var(--landing-border-hover);
  min-height: 52px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--landing-text-muted);
  text-align: center;
}

.landing-savings-tower-mcd .landing-savings-tower-name {
  color: var(--landing-text);
}

.landing-savings-calc .landing-savings-tower-name .landing-savings-label {
  display: block;
  margin: 0;
  font-size: 0.72rem;
  color: var(--landing-text-muted);
}

/* De oude planknop was een keuzepil zonder keuze. Het is nu gewoon de naam
   van het abonnement; data-price blijft erop staan als bron van de prijs. */
.landing-savings-calc .landing-savings-plan {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.landing-savings-calc .landing-savings-plan-btn,
.landing-savings-calc .landing-savings-plan-btn.active {
  display: inline;
  padding: 0;
  background: none;
  box-shadow: none;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--landing-text);
  cursor: default;
}

.landing-savings-track {
  order: 1;
  position: relative;
  height: var(--sv-track);
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
}

.landing-savings-block {
  box-sizing: border-box;
  --h: calc(var(--v, 0) / var(--max) * var(--sv-track));
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: var(--h);
  min-height: 0;
  padding: 0 10px;
  overflow: hidden;
  border-radius: 10px;
  /* Een doorzichtige rand boven elk blok scheidt de blokken, zodat het leest
     als een stapel losse dingen en niet als één balk. */
  border-top: var(--sv-gap) solid transparent;
  background: var(--c);
  background-clip: padding-box;
  color: var(--ink, #fff);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  transition:
    height 0.45s cubic-bezier(0.34, 1.3, 0.64, 1),
    opacity 0.3s ease;
}

.landing-savings-block[data-off] {
  opacity: 0;
}

/* Een blok dat te dun is voor tekst laat alleen zijn kleur zien; de lijst
   ernaast is dan de legenda. */
.landing-savings-block.is-thin > * {
  opacity: 0;
}

.landing-savings-block > * {
  transition: opacity 0.2s ease;
}

.landing-savings-block-name {
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.landing-savings-block-amt {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.landing-savings-block-mcd {
  justify-content: center;
  background: var(--landing-btn-primary-gradient);
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--landing-accent) 70%, transparent);
  color: #fff;
}

/* Het bedrag rijdt bovenop de toren mee. */
.landing-savings-cap,
.landing-savings-calc .landing-savings-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--v, 0) / var(--max) * var(--sv-track) + 6px);
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  color: var(--landing-text);
  font-variant-numeric: tabular-nums;
  transition: bottom 0.45s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.landing-savings-calc .landing-savings-mcd-value {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.landing-savings-calc .landing-savings-mcd-value .landing-savings-per {
  color: rgba(255, 255, 255, 0.82);
}

/* Wat je niet meer betaalt: het stuk van de linker toren dat rechts niet
   bestaat, als stippelvlak boven het MCD-blok. */
.landing-savings-ghost {
  box-sizing: border-box;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--lo) / var(--max) * var(--sv-track));
  height: calc((var(--hi) - var(--lo)) / var(--max) * var(--sv-track));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border: 2px dashed color-mix(in srgb, var(--landing-accent-2) 70%, transparent);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: repeating-linear-gradient(
    -45deg,
    color-mix(in srgb, var(--landing-accent-2) 10%, transparent) 0 8px,
    transparent 8px 16px
  );
  color: var(--landing-accent-2);
  text-align: center;
  overflow: hidden;
  transition:
    bottom 0.45s cubic-bezier(0.34, 1.3, 0.64, 1),
    height 0.45s cubic-bezier(0.34, 1.3, 0.64, 1),
    opacity 0.3s ease;
}

.landing-savings-ghost[data-off] {
  opacity: 0;
}

.landing-savings-ghost-text {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
}

.landing-savings-ghost-text [data-savings-ghost] {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.landing-savings-ghost.is-thin .landing-savings-ghost-text {
  opacity: 0;
}


.landing-savings-calc .landing-savings-stage .landing-savings-vs {
  align-self: center;
  padding: 0 0 52px;
}

/* ---------- de uitkomst ---------- */

.landing-savings-result {
  margin: 22px 0 0;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--landing-accent-2) 30%, var(--landing-border));
  background: color-mix(in srgb, var(--landing-accent-2) 7%, var(--landing-bg-card));
}

/* Gereserveerd voor twee regels, zodat wisselen tussen uitkomst, "los
   goedkoper" en de lege stand de kaart niet laat verspringen. */
.landing-savings-result strong {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.32em;
  min-height: 2.9rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--landing-text);
}

.landing-savings-result strong[hidden] {
  display: none;
}

.landing-savings-calc ~ * .landing-savings-amount,
.landing-savings-result .landing-savings-amount {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--landing-accent-2);
  font-variant-numeric: tabular-nums;
}

.landing-savings-plan-note {
  margin: 10px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--landing-text-muted);
}

.landing-savings-plan-note a {
  display: inline-block;
  padding: 3px 0;
  color: var(--landing-accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.landing-savings-calc .landing-savings-mcd-note {
  margin-top: 14px;
}

/* ---------- onder de calculator: bron en uitleg, rustig ---------- */

.landing-savings-foot {
  max-width: 1040px;
  margin: 0 auto 36px;
  padding: 4px 8px 0;
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--landing-text-muted);
}

.landing-savings-foot > span {
  display: inline;
}

.landing-savings-foot > span + span::before {
  content: " ";
}

/* ---------- intro: de stapel bouwt zich op als hij in beeld komt ---------- */

.landing-savings-calc.is-pre .landing-savings-block,
.landing-savings-calc.is-pre .landing-savings-ghost {
  height: 0;
  opacity: 0;
}

.landing-savings-calc.is-pre .landing-savings-cap {
  bottom: 6px;
  opacity: 0;
}

.landing-savings-calc.is-intro .landing-savings-block {
  transition-delay: calc(var(--i, 0) * 140ms);
}

.landing-savings-calc.is-pre .landing-savings-block-mcd {
  opacity: 0;
}

.landing-savings-calc.is-intro .landing-savings-block-mcd {
  transition-delay: 760ms;
}

.landing-savings-calc.is-intro .landing-savings-ghost {
  transition-delay: 1050ms;
}

.landing-savings-calc.is-intro .landing-savings-cap {
  transition:
    bottom 0.85s cubic-bezier(0.45, 0, 0.25, 1),
    opacity 0.4s ease;
}

.landing-savings-result strong {
  transition: opacity 0.35s ease;
}

/* Tijdens de opbouw staat er nog geen bedrag: geen "€ 0" laten zien. */
.landing-savings-calc.is-pre .landing-savings-result strong,
.landing-savings-calc.is-intro:not(.is-counting) .landing-savings-result strong {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .landing-savings-calc *,
  .landing-savings-calc *::before {
    transition: none !important;
  }
}

/* ---------- telefoon ---------- */

@media (max-width: 860px) {
  .landing-savings-calc {
    --sv-track: 230px;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  /* Op de telefoon eerst de torens: dat is wat je moet zien. */
  .landing-savings-calc .landing-savings-col-mcd {
    order: -1;
  }

  .landing-savings-calc .landing-savings-col {
    padding: 20px 16px;
  }

  .landing-savings-stage {
    grid-template-columns: minmax(0, 1.3fr) auto minmax(0, 1fr);
    gap: 8px;
  }

  .landing-savings-block {
    gap: 4px;
    padding: 0 7px;
    font-size: 0.7rem;
  }

  .landing-savings-calc .landing-savings-total {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 0 -16px -20px;
    padding: 12px 24px 14px;
    border-radius: 0 0 20px 20px;
    background: var(--landing-bg-section);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .landing-savings-total-save {
    display: block;
  }

  .landing-savings-result .landing-savings-amount {
    font-size: 2rem;
  }

  .landing-savings-result #savings-result > span:first-child {
    flex-basis: 100%;
    margin-bottom: 4px;
  }

  .landing-savings-result strong {
    min-height: 4.4rem;
  }
}
