/* ═══════════════════════════════════════════════════════════════════════════
   Calculator Suite — /calculators.html hub + /calculators/*.html
   Mobile-first; uses site.css theme variables (--primary, --secondary, …).
   Charts are pure DOM/CSS bars — no libraries, no canvas.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Shared card frame ── */
.calc-frame {
  background: #fff;
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 12px;
  padding: 20px;
  margin: 24px 0;
  box-shadow: 0 2px 12px rgba(31, 41, 51, 0.06);
}

.calc-inputs {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}
@media (min-width: 720px) {
  .calc-inputs.calc-inputs-2col {
    grid-template-columns: 1fr 1fr;
  }
}

.calc-inputs label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}
.calc-inputs input[type='number'],
.calc-inputs select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--dark, #1f2933);
}
.calc-inputs input[type='range'] {
  display: block;
  width: 100%;
  margin-top: 10px;
  accent-color: var(--primary, #1565c0);
}
.calc-hint {
  display: block;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted, #6b7280);
  margin-top: 4px;
}

.calc-fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
}
.calc-fieldset legend {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.calc-radio-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.calc-radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

/* ── Figure citation chips ── */
.fig-chip {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  font-size: 0.75rem;
  color: var(--muted, #6b7280);
  background: var(--light, #f6f8fb);
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 6px;
  white-space: nowrap;
  vertical-align: middle;
}
.fig-chip a {
  color: var(--primary, #1565c0);
  text-decoration: underline;
}

.calc-figures-error {
  background: #fdf3f3;
  border: 1px solid #ecc8c8;
  border-radius: 8px;
  color: var(--error, #b91c1c);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.95rem;
}

/* ── Results panel ── */
.calc-results {
  background: var(--light, #f6f8fb);
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 10px;
  padding: 18px;
  margin-top: 12px;
}
.calc-results .calc-kpi {
  font-weight: 800;
  color: var(--primary-dark, #0d47a1);
  font-variant-numeric: tabular-nums;
}
.calc-result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border, #d9e1ec);
}
.calc-result-row:last-of-type {
  border-bottom: 0;
}
.calc-verdict {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border, #d9e1ec);
  font-weight: 600;
}
.calc-verdict-ok {
  border-color: #bfdcc0;
  background: #f2f9f2;
  color: var(--success, #2e7d32);
}
.calc-verdict-warn {
  border-color: #ecc8c8;
  background: #fdf3f3;
  color: var(--error, #b91c1c);
}

/* ── Generic horizontal bar chart ── */
.calc-bar-chart {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}
.calc-bar-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
@media (min-width: 600px) {
  .calc-bar-row {
    grid-template-columns: 200px 1fr auto;
    align-items: center;
    gap: 12px;
  }
}
.calc-bar-label {
  font-size: 0.9rem;
  font-weight: 600;
}
.calc-bar-track {
  background: var(--light, #f6f8fb);
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 999px;
  height: 22px;
  overflow: hidden;
}
.calc-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--primary, #1565c0);
  transition: width 0.6s ease;
}
.calc-bar-fill.calc-bar-alt {
  background: var(--secondary, #d6a21e);
}
.calc-bar-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}
.ltc-row-active .calc-bar-label {
  color: var(--primary-dark, #0d47a1);
}
.ltc-row-active .calc-bar-fill {
  background: var(--primary-dark, #0d47a1);
}

/* ── IRMAA income track ── */
.irmaa-track-wrap {
  margin: 28px 0 8px;
}
.irmaa-track {
  position: relative;
  height: 26px;
  border-radius: 999px;
  background: var(--light, #f6f8fb);
  border: 1px solid var(--border, #d9e1ec);
}
.irmaa-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2e7d32, #d6a21e 85%);
  transition: width 0.6s ease;
}
.irmaa-dot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-dark, #0d47a1);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  transition: left 0.4s ease;
  z-index: 2;
}
.irmaa-cliff {
  position: absolute;
  top: -8px;
  bottom: -8px;
  width: 3px;
  background: var(--error, #b91c1c);
  transform: translateX(-50%);
  z-index: 1;
}
.irmaa-cliff::after {
  content: '⚠';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
}
.irmaa-cliff-label {
  margin-top: 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--error, #b91c1c);
}

/* ── DIME stacked bar ── */
.dime-stack {
  display: flex;
  height: 34px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border, #d9e1ec);
  background: var(--light, #f6f8fb);
  margin: 16px 0 8px;
}
.dime-seg {
  height: 100%;
  width: 0;
  transition: width 0.6s ease;
}
.dime-seg-d { background: #1565c0; }
.dime-seg-i { background: #2e7d32; }
.dime-seg-m { background: #d6a21e; }
.dime-seg-e { background: #7b1fa2; }

.dime-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.dime-legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

/* ── Email-my-results form ── */
.calc-email-form {
  margin-top: 20px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 10px;
}
.calc-email-form h3 {
  margin-bottom: 8px;
}
.calc-email-fields {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}
@media (min-width: 600px) {
  .calc-email-fields {
    grid-template-columns: 1fr 1.4fr auto;
    align-items: end;
  }
}
.calc-email-form input[type='text'],
.calc-email-form input[type='email'] {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 8px;
  font-size: 1rem;
}
.calc-consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--muted, #6b7280);
  margin: 10px 0;
}
.calc-consent input {
  margin-top: 3px;
  flex: none;
}
.calc-email-status {
  min-height: 1.4em;
  margin-top: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.calc-email-ok { color: var(--success, #2e7d32); }
.calc-email-err { color: var(--error, #b91c1c); }

/* ── Disclaimer block ── */
.calc-disclaimer {
  font-size: 0.85rem;
  color: var(--muted, #6b7280);
  border-left: 3px solid var(--secondary, #d6a21e);
  padding: 10px 14px;
  background: var(--light, #f6f8fb);
  border-radius: 0 8px 8px 0;
  margin: 24px 0;
}

/* ── Hub cards ── */
.calc-hub-grid {
  display: grid;
  gap: 20px;
  margin: 24px 0;
}
@media (min-width: 720px) {
  .calc-hub-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.calc-hub-card {
  display: block;
  background: #fff;
  border: 1px solid var(--border, #d9e1ec);
  border-radius: 12px;
  padding: 22px;
  color: var(--dark, #1f2933);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.calc-hub-card:hover,
.calc-hub-card:focus-visible {
  box-shadow: 0 6px 24px rgba(21, 101, 192, 0.14);
  transform: translateY(-2px);
}
.calc-hub-card .calc-hub-icon {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 8px;
}
.calc-hub-card h3 {
  color: var(--primary-dark, #0d47a1);
  margin-bottom: 6px;
}
.calc-hub-card p {
  font-size: 0.95rem;
  color: var(--muted, #6b7280);
}

/* ── Reduced motion: everything static ── */
@media (prefers-reduced-motion: reduce) {
  .calc-bar-fill,
  .irmaa-fill,
  .irmaa-dot,
  .dime-seg,
  .calc-hub-card {
    transition: none !important;
  }
  .calc-hub-card:hover {
    transform: none;
  }
}
