/* =========================================================
   EXTRA MORTGAGE PAYMENT CALCULATOR
   ---------------------------------------------------------
   Loaded ONLY by /extra-mortgage-payment-calculator/.
   Every selector is prefixed .xp- so it cannot affect the mortgage
   calculator or any other page. Uses existing design tokens only —
   no new colours, radii or fonts are introduced.
   ========================================================= */

/* ---------- Biweekly mode switch ---------- */
.xp-mode {
  margin-top: 4px;
  padding: 13px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 9px;
}
/* NOTE ON SPECIFICITY: calculator.css sets `.field label { display:block }`
   at 0,0,1,1, which outranks a bare `.xp-switch` at 0,0,1,0. That silently
   killed the flex layout, leaving the track span inline so its width and
   height were ignored and the switch rendered as a 0x0 invisible box.
   Every rule below is scoped under .xp-mode so it outranks that rule. */
.xp-mode .xp-switch {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  cursor: pointer;
  margin-bottom: 0;
}
.xp-mode .xp-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.xp-mode .xp-track {
  display: block;
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--gray-400);
  transition: background .18s;
  margin-top: 1px;
}
.xp-mode .xp-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}
.xp-mode .xp-switch input:checked + .xp-track { background: var(--lime-dark); }
.xp-mode .xp-switch input:checked + .xp-track::after { transform: translateX(18px); }
.xp-mode .xp-switch input:focus-visible + .xp-track {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.xp-mode .xp-switch-txt { display: block; min-width: 0; }
.xp-switch-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}
.xp-switch-sub {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--gray-600);
  line-height: 1.5;
}

/* ---------- Headline result ---------- */
.xp-headline {
  text-align: center;
  font-size: clamp(1.6rem, 3.4vw, 2.15rem);
  font-weight: 800;
  color: var(--lime-dark);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 4px;
}
.xp-head-sub {
  text-align: center;
  font-size: 13px;
  color: #2f6b4d;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ---------- Three key stats ---------- */
.xp-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}
@media (max-width: 520px) { .xp-stats { grid-template-columns: 1fr; } }
.xp-stat {
  background: #fff;
  border: 1px solid #cfeadd;
  border-radius: 9px;
  padding: 11px 10px;
  text-align: center;
}
.xp-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.xp-stat-value {
  display: block;
  font-size: 15.5px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* ---------- With / without comparison ---------- */
.xp-compare { margin-top: 2px; }
.xp-crow {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #dcefe6;
  font-size: 13px;
  align-items: baseline;
}
.xp-crow:last-child { border-bottom: none; }
.xp-crow .xp-ch {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--gray-500);
}
.xp-crow span:first-child { color: var(--gray-700); font-weight: 500; }
.xp-crow strong { color: var(--navy); font-weight: 700; text-align: right; }
.xp-crow .xp-good { color: var(--lime-dark); }
.xp-crow span:nth-child(2),
.xp-crow strong:nth-child(2) { text-align: right; }
.xp-crow > *:nth-child(2),
.xp-crow > *:nth-child(3) { text-align: right; }

/* ---------- Balance chart ---------- */
.xp-chart-wrap {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 10px 8px;
  margin: 4px 0 10px;
}
/* min-height matches the SVG height so the card does not collapse
   (and then jump) before the chart is drawn. */
.xp-chart { width: 100%; min-height: 260px; }
.xp-chart svg { display: block; width: 100%; height: auto; }
.xp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  padding: 6px 2px 2px;
}
.xp-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--gray-600);
}
.xp-swatch { width: 16px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.xp-swatch.sw-base { background: #dd6229; }
.xp-swatch.sw-fast { background: #2bb673; }
