/* Calculator pages. Layered on compare.css, which supplies the site tokens,
   nav, footer, tables, FAQ and CTA styling. Nothing here redefines a token:
   the calculators are part of the site, not a separate design.

   The one addition is tabular figures. Every number that recalculates uses
   font-variant-numeric: tabular-nums so digits keep a fixed width and the
   hero figure does not jitter sideways as the visitor types. Inter ships the
   tnum feature, so this costs no extra font request. */

.calculator {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  margin: 8px 0 28px;
}

@media (max-width: 820px) {
  .calculator { grid-template-columns: 1fr; gap: 20px; }
}

/* ---------------------------------- form --------------------------------- */

.calc-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 15px;
  position: sticky;
  top: 76px;
}

@media (max-width: 820px) {
  .calc-form { position: static; }
}

.field > label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 5px;
}

.field-input { position: relative; display: flex; align-items: center; }

.field-input .affix {
  position: absolute;
  left: 11px;
  color: var(--text-3);
  font-size: 14.5px;
  pointer-events: none;
}

.field-input.has-affix input { padding-left: 28px; }

.calc-form input,
.calc-form select {
  width: 100%;
  font: inherit;
  font-size: 15.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg-raise);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.calc-form select { padding-right: 30px; }

/* A visible focus ring, not the removed-outline pattern. Keyboard users have
   to be able to see where they are. */
.calc-form input:focus-visible,
.calc-form select:focus-visible,
.calc-form button:focus-visible,
.calculator a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.field-help {
  margin: 5px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-3);
}

.calc-reset { margin: 4px 0 0; }
.calc-reset .btn { width: 100%; padding: 8px 14px; font-size: 14px; }

/* --------------------------------- results ------------------------------- */

.results {
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-left: 4px solid var(--profit);
  border-radius: var(--radius);
  padding: 26px 24px;
}

.hero-label {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

/* The largest, most confident element on the page. Everything else stays
   quiet on purpose. */
.hero-value {
  margin: 2px 0 0;
  font-size: clamp(44px, 8vw, 72px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

@keyframes result-change {
  from { opacity: 0.55; transform: translateY(-3px); }
  to   { opacity: 1;    transform: none; }
}

.hero-value.is-changed { animation: result-change 180ms ease-out; }

@media (prefers-reduced-motion: reduce) {
  .hero-value.is-changed { animation: none; }
}

.interpretation {
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  max-width: 60ch;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 22px;
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.result dt {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.35;
}

.result-help {
  display: block;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.result dd {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}

/* ----------------------------------- CTA --------------------------------- */

/* Immediately below the result, and deliberately quieter than the number
   above it. The answer comes first; the pitch follows. */
.tool-cta {
  background: var(--accent-soft);
  border: 1px solid rgba(91, 103, 241, 0.28);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 0;
}

.tool-cta .cta-line { margin: 0 0 14px; max-width: 68ch; font-size: 15.5px; }
.tool-cta p:last-child { margin-bottom: 0; }
.tool-cta .trust-line { margin-top: 10px; }

/* ------------------------------ page sections ---------------------------- */

.tool-hero { padding-top: 34px; margin-bottom: 18px; }
.tool-hero h1 { max-width: 20ch; }

.calculator + .tool-cta { margin-bottom: 34px; }

.sec > p { max-width: 72ch; }

.formula {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.formula code {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
}

.variables {
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr;
  gap: 9px 20px;
  margin: 0;
  max-width: 860px;
  font-size: 14.5px;
}

.variables dt { font-weight: 600; }
.variables dd { margin: 0; color: var(--text-2); }

@media (max-width: 560px) {
  .variables { grid-template-columns: 1fr; gap: 2px; }
  .variables dd { margin-bottom: 10px; }
}

.example-table { min-width: 420px; }
.example-table .num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.example-table .note { color: var(--text-3); font-size: 13px; }
.example-table tr:nth-last-child(-n + 2) th,
.example-table tr:nth-last-child(-n + 2) td { font-weight: 700; }

.example-conclusion {
  margin-top: 16px;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  color: var(--text);
  max-width: 72ch;
}

.last-updated {
  font-size: 13px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 34px;
}

/* Screen-reader-only, for the form heading that would otherwise be visual
   noise but is needed to keep the heading outline sensible. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Down to 360px: the form and results stack, nothing overflows, and the hero
   number scales with the viewport rather than being clipped. */
@media (max-width: 400px) {
  .results { padding: 20px 16px; }
  .calc-form { padding: 16px; }
  .result-grid { grid-template-columns: 1fr 1fr; }
}
