/* ==========================================================================
   FinBedrock calculators — widget styles (BEM, prefix fbc-).
   Variables are scoped to .fbc-root (never :root) so nothing leaks into the
   theme. Dark palette follows the site's own switch (Kadence colour switch /
   data-theme), like the research pages; prefers-color-scheme alone does not
   flip it, so the widget never turns dark on a white page.
   ========================================================================== */

.fbc-root {
  --fbc-surface: #ffffff;
  --fbc-bg: #f6f8fb;
  --fbc-fg: #14213a;
  --fbc-muted: #5a6578;
  --fbc-line: #dfe4ec;
  --fbc-brand: #1a4fa0;
  --fbc-brand-soft: #e7eef9;
  --fbc-ok: #1d6b3a;
  --fbc-ok-bg: #e7f4ec;
  --fbc-bad: #a3271b;
  --fbc-bad-bg: #fbeaea;
  --fbc-warn-bg: #fff6e0;
  --fbc-focus: #1d4ed8;
  --fbc-radius: 10px;
  color: var(--fbc-fg);
  font-variant-numeric: tabular-nums;
}

.color-switch-dark .fbc-root,
[data-theme="dark"] .fbc-root {
  --fbc-surface: #191d25;
  --fbc-bg: #12151b;
  --fbc-fg: #e8ecf3;
  --fbc-muted: #a3acbb;
  --fbc-line: #2c3340;
  --fbc-brand: #7aa7f0;
  --fbc-brand-soft: #1c2b45;
  --fbc-ok: #7fd49c;
  --fbc-ok-bg: #14301f;
  --fbc-bad: #f29a90;
  --fbc-bad-bg: #3a1a17;
  --fbc-warn-bg: #3a3017;
  --fbc-focus: #9cc0ff;
}

.fbc-calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* --- form ---------------------------------------------------------------- */
.fbc-form {
  background: var(--fbc-surface);
  border: 1px solid var(--fbc-line);
  border-radius: var(--fbc-radius);
  padding: 18px;
}
.fbc-grid { display: grid; gap: 14px; }
.fbc-mode,
.fbc-months { border: 0; margin: 0 0 4px; padding: 0; min-width: 0; }
.fbc-mode { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.fbc-legend { font-weight: 600; font-size: 0.9375rem; margin: 0 0 8px; padding: 0; width: 100%; }
.fbc-months__chips { display: flex; flex-wrap: wrap; gap: 6px; }

.fbc-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--fbc-line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--fbc-surface);
  font-size: 0.9375rem;
  line-height: 1.2;
}
.fbc-chip--small { padding: 6px 11px; font-size: 0.875rem; }
.fbc-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.fbc-chip--on { border-color: var(--fbc-brand); background: var(--fbc-brand-soft); color: var(--fbc-brand); font-weight: 600; }
.fbc-chip:focus-within { outline: 2px solid var(--fbc-focus); outline-offset: 2px; }

.fbc-field { display: grid; gap: 4px; min-width: 0; }
.fbc-field__label { font-weight: 600; font-size: 0.9375rem; }
.fbc-field__control {
  display: flex;
  align-items: center;
  border: 1px solid var(--fbc-line);
  border-radius: 8px;
  background: var(--fbc-surface);
  overflow: hidden;
}
.fbc-field__control:focus-within { outline: 2px solid var(--fbc-focus); outline-offset: 1px; }
.fbc-field--invalid .fbc-field__control { border-color: var(--fbc-bad); }
.fbc-field__affix { padding: 0 10px; color: var(--fbc-muted); white-space: nowrap; }
.fbc-input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  color: var(--fbc-fg) !important;
  padding: 10px 12px !important;
  font-size: 1rem;
  box-shadow: none !important;
  outline: none;
}
.fbc-select { appearance: auto; }
.fbc-field__hint { margin: 0; font-size: 0.8125rem; color: var(--fbc-muted); }
.fbc-field__error { margin: 2px 0 0; font-size: 0.875rem; color: var(--fbc-bad); font-weight: 600; }
.fbc-field__error::before { content: "⚠ "; }
.fbc-apr { display: grid; gap: 10px; }
.fbc-card-note { margin: 0; font-size: 0.875rem; color: var(--fbc-muted); }
.fbc-card-note a { color: var(--fbc-brand); }

/* --- results ------------------------------------------------------------- */
.fbc-results {
  background: var(--fbc-bg);
  border: 1px solid var(--fbc-line);
  border-radius: var(--fbc-radius);
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* a wide table scrolls inside its box, never widens the page */
  gap: 16px;
  min-width: 0;
  transition: opacity .15s;
}
.fbc-results > *,
.fbc-form,
.fbc-grid > * { min-width: 0; }
.fbc-results--busy { opacity: .6; }
.fbc-results__title { font-size: 1.125rem; margin: 0; }
.fbc-h { font-size: 1rem; margin: 0 0 6px; }
.fbc-empty { color: var(--fbc-muted); margin: 0; }
.fbc-problem { color: var(--fbc-bad); font-weight: 600; margin: 0; }

.fbc-headline { background: var(--fbc-surface); border: 1px solid var(--fbc-line); border-radius: 8px; padding: 14px 16px; }
.fbc-headline p { margin: 0; }
.fbc-headline__label { font-size: 0.875rem; color: var(--fbc-muted); }
.fbc-headline__value { font-size: 2.25rem; font-weight: 700; line-height: 1.15; color: var(--fbc-brand); }
.fbc-headline__value span { font-size: 1rem; font-weight: 600; color: var(--fbc-muted); }
.fbc-headline__sub { font-weight: 600; }
.fbc-headline__safe { margin-top: 8px !important; font-size: 0.9375rem; color: var(--fbc-muted); }

.fbc-stake p { margin: 0 0 6px; }
.fbc-stake__value { font-size: 1.375rem; }
.fbc-stake__upper,
.fbc-stake__penny { font-size: 0.9375rem; }
.fbc-stake__upper { color: var(--fbc-muted); }

.fbc-verdict { display: flex; gap: 10px; align-items: flex-start; border-radius: 8px; padding: 12px 14px; }
.fbc-verdict p { margin: 0; }
.fbc-verdict--ok { background: var(--fbc-ok-bg); color: var(--fbc-ok); }
.fbc-verdict--bad { background: var(--fbc-bad-bg); color: var(--fbc-bad); }
.fbc-verdict__icon {
  flex: 0 0 1.6em;
  height: 1.6em;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid currentColor;
}

.fbc-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; background: var(--fbc-surface); }
.fbc-table th,
.fbc-table td { border-bottom: 1px solid var(--fbc-line); padding: 8px 10px; text-align: right; white-space: nowrap; }
.fbc-table th:first-child,
.fbc-table td:first-child { text-align: left; }
.fbc-table thead th { font-weight: 600; color: var(--fbc-muted); white-space: normal; vertical-align: bottom; }
.fbc-table--compare td,
.fbc-table--compare th { white-space: normal; }
.fbc-table__est { color: var(--fbc-muted); }
.fbc-est { font-weight: 400; font-size: 0.8125rem; }

.fbc-warnings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fbc-warnings li { background: var(--fbc-warn-bg); border-radius: 8px; padding: 8px 12px; font-size: 0.9375rem; }

.fbc-schedule { border: 1px solid var(--fbc-line); border-radius: 8px; background: var(--fbc-surface); }
.fbc-schedule summary { cursor: pointer; font-weight: 600; padding: 10px 14px; }
.fbc-schedule summary:focus-visible { outline: 2px solid var(--fbc-focus); outline-offset: 2px; }
.fbc-schedule__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fbc-schedule__scroll:focus-visible { outline: 2px solid var(--fbc-focus); }
.fbc-note { margin: 8px 0 0; font-size: 0.8125rem; color: var(--fbc-muted); }
.fbc-schedule .fbc-note { padding: 0 14px 10px; }
.fbc-assumptions { margin: 0; font-size: 0.8125rem; color: var(--fbc-muted); }
.fbc-assumptions a,
.fbc-noscript a { color: var(--fbc-brand); }

/* Kadence sets a:hover / button:hover colours globally (see picker.css). */
.fbc-root a:hover { color: var(--fbc-brand); }

@media (max-width: 860px) {
  .fbc-calc { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .fbc-form,
  .fbc-results { padding: 14px; }
  .fbc-headline__value { font-size: 1.875rem; }
}
@media (prefers-reduced-motion: reduce) {
  .fbc-results { transition: none; }
}

