/* ============================================================================
   FinanceCalc — calculator presentation layer  (assets/tools.css)
   Load AFTER site.css. Uses the existing brand tokens so light/dark both work.

   Direction: editorial finance meets a professional terminal. A serif display
   face carries the headline figures (characterful, and free — no webfont, so
   the "nothing leaves your device" promise stays literally true), while every
   number is set in tabular figures so columns line up and digits don't jitter
   as live results update.
   ========================================================================== */

:root {
  --disp: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
  --radius: 14px;
  --radius-sm: 9px;
  --ok-bg: rgba(34, 197, 94, .10);
  --warn-bg: rgba(245, 158, 11, .12);
  --bad-bg: rgba(239, 68, 68, .10);
  --accent-bg: rgba(79, 140, 255, .10);
}

/* Tabular figures for anything numeric — the single biggest readability win
   on a page whose numbers change as you type. */
.num, .res .big, .sched td, .stattable td, .cmprow .v, .kv .v,
input[type=number], .herofig, .inlinenum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv01" 1;
}

/* ------------------------------------------------------------------ hero -- */

/* The answer-first hero: the verdict is the first thing on the page and it
   updates live. This is the anti-pattern to the incumbent's "press Calculate,
   scroll down, find the number". */
.answer {
  background: linear-gradient(160deg, var(--tldr-a), var(--tldr-b));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 20px;
  margin: 18px 0 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.answer::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 100% 0%, rgba(79,140,255,.14), transparent 60%);
  pointer-events: none;
}
.answer .kick {
  font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 8px;
}
.answer .line {
  font-size: 17.5px; line-height: 1.55; color: var(--text); max-width: 74ch;
}
.answer .line b { color: var(--accent); font-weight: 800; }
.answer .line em { font-style: normal; color: var(--accent2); font-weight: 700; }
.answer .line s { text-decoration: none; color: var(--bad); font-weight: 700; }

/* the headline figure */
.herofig {
  font-family: var(--disp);
  font-size: clamp(34px, 7vw, 52px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--text);
  display: block;
  margin: 2px 0 4px;
}
.herofig.g { color: var(--accent2); }
.herofig.b { color: var(--bad); }
.herofig.w { color: var(--warn); }
.herosub { color: var(--muted); font-size: 12.5px; }

/* --------------------------------------------------------- stat cards ----- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.res.stat { padding: 13px 14px 12px; }
.res.stat .big {
  font-family: var(--disp);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* --------------------------------------------------------------- inputs --- */

/* A two-column control row: label + value read-out, then a full-width slider */
.slider-row { margin-bottom: 13px; }
.slider-row .top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 5px;
}
.slider-row label { font-size: 12.5px; color: var(--text); font-weight: 600; }
.slider-row .hint { font-size: 11px; color: var(--muted); font-weight: 400; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: grab; margin: 0;
}
input[type=range]:active { cursor: grabbing; }
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 999px;
  background: var(--panel3); border: 1px solid var(--line);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; margin-top: -7px;
  border-radius: 50%; background: var(--accent);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
  transition: transform .12s ease;
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.14); }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-bg); }
input[type=range]::-moz-range-track { height: 5px; border-radius: 999px; background: var(--panel3); border: 1px solid var(--line); }
input[type=range]::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); }

/* keyboard users must always see focus */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

/* money/number field with a leading unit mark */
.field .unitwrap { position: relative; }
.field .unitwrap .u {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 13px; pointer-events: none;
}
.field .unitwrap input { padding-left: 24px; }
.field .unitwrap.pct input { padding-left: 10px; padding-right: 24px; }
.field .unitwrap.pct .u { left: auto; right: 10px; }

/* segmented control (monthly/annual, method A/B, etc.) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel3); gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 13px; border-radius: 999px; cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }

.ghostbtn {
  border: 1px solid var(--line); background: var(--panel3); color: var(--text);
  font: inherit; font-size: 12px; font-weight: 600; padding: 5px 12px;
  border-radius: 999px; cursor: pointer; transition: all .15s ease;
}
.ghostbtn:hover { border-color: var(--accent); color: var(--accent); }

/* --------------------------------------------------------------- charts --- */
.chartgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 820px) { .chartgrid { grid-template-columns: 1fr; } }
.chart .h { font-size: 12.5px; font-weight: 700; color: var(--text); margin: 2px 4px 8px; }
.chart .h span { font-weight: 400; color: var(--muted); }

/* ------------------------------------------------------- schedule table --- */
.tablebar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.tablewrap { max-height: 430px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.sched { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.sched th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel2); color: var(--muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--line);
}
table.sched th:first-child, table.sched td:first-child { text-align: left; }
table.sched td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); color: var(--text); }
table.sched tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel2) 45%, transparent); }
table.sched tbody tr:hover { background: var(--accent-bg); }
table.sched td.neg { color: var(--bad); }
table.sched td.pos { color: var(--accent2); }

/* plain two-column data table (CPI history, reference tables) */
table.ref { width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0; }
table.ref th { background: var(--panel2); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 8px 11px; border-bottom: 1px solid var(--line); }
table.ref td { padding: 7px 11px; border-bottom: 1px solid var(--line); }
table.ref td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.ref tbody tr:hover { background: var(--accent-bg); }
.tablemax { max-height: 400px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* ----------------------------------------------------------- comparison --- */
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
@media (max-width: 700px) { .cmp { grid-template-columns: 1fr; } }
.cmp .side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.cmp .side.win { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2) inset, var(--shadow); }
.cmp .side h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cmp .badge { font-size: 9.5px; font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: var(--accent2); color: #052; text-transform: uppercase; }
.cmprow { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dotted var(--line); font-size: 13px; }
.cmprow:last-child { border-bottom: 0; }
.cmprow .k { color: var(--muted); }
.cmprow .v { font-weight: 700; color: var(--text); }

/* --------------------------------------------------------- explainer ------ */
.method { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 14px 16px; margin: 14px 0; }
.method h3 { font-size: 13px; margin-bottom: 7px; }
.method p, .method li { font-size: 13px; color: var(--muted); line-height: 1.62; }
.method ul { margin: 7px 0 0 18px; }
.method .fml { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--panel3); border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; margin: 8px 0; color: var(--text); overflow-x: auto; }

.callout { border-radius: var(--radius-sm); padding: 12px 15px; margin: 13px 0; font-size: 13.3px; line-height: 1.6; border: 1px solid var(--line); }
.callout.info { background: var(--accent-bg); border-left: 3px solid var(--accent); }
.callout.good { background: var(--ok-bg); border-left: 3px solid var(--accent2); }
.callout.warn { background: var(--warn-bg); border-left: 3px solid var(--warn); }
.callout b { color: var(--text); }
.warnbox { background: var(--warn-bg); border: 1px solid var(--warn); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text); }

.editorial p { margin-bottom: 11px; }
.editorial h2 { font-size: 17px; margin: 26px 0 9px; letter-spacing: -.01em; }
.editorial h3 { font-size: 14.5px; margin: 20px 0 7px; }
.editorial ul, .editorial ol { margin: 8px 0 13px 20px; }
.editorial li { margin-bottom: 6px; line-height: 1.6; }
.editorial code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--panel3); padding: 1.5px 5px; border-radius: 5px; }

/* hero section for a tool page */
.thero { padding: 6px 0 2px; }
.thero h1 { font-size: clamp(23px, 4.4vw, 31px); letter-spacing: -.022em; line-height: 1.18; margin-bottom: 8px; }
.thero .lede { color: var(--muted); font-size: 14.5px; line-height: 1.6; max-width: 76ch; }
.byline { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: 11.5px; margin-top: 11px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; background: var(--panel3); font-size: 11px; }

/* related-tools strip */
.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 12px 0; }
.related a {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; text-decoration: none; color: var(--text); transition: all .15s ease;
}
.related a:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.related .t { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.related .d { font-size: 11.5px; color: var(--muted); line-height: 1.45; }

/* --------------------------------------------------------- county search -- */
/* A typeahead over 3,208 counties. Arrow keys move, Enter picks, Escape closes. */
.csearch { position: relative; }
.csearch input { padding-right: 30px; }
.csearch .clr {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 5px; border-radius: 4px;
}
.csearch .clr:hover { color: var(--text); background: var(--panel3); }
.csearch .list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  max-height: 268px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0,0,0,.20); display: none;
}
.csearch .list.open { display: block; }
.csearch .opt {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 7px 11px; cursor: pointer; font-size: 12.5px; border-bottom: 1px solid var(--line);
}
.csearch .opt:last-child { border-bottom: 0; }
.csearch .opt:hover, .csearch .opt.active { background: var(--accent-bg); }
.csearch .opt .nm { color: var(--text); }
.csearch .opt .nm b { color: var(--accent); font-weight: 700; }
.csearch .opt .mx { color: var(--muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.csearch .empty { padding: 9px 11px; font-size: 12.5px; color: var(--muted); }
.csearch .hit { padding: 6px 11px 2px; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

/* ------------------------------------------------------- motion / reveal -- */
[data-reveal] { opacity: 0; transform: translateY(9px); transition: opacity .5s ease, transform .5s ease; }
[data-reveal].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1 !important; transform: none !important; transition: none !important; }
  input[type=range]::-webkit-slider-thumb { transition: none; }
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

/* number change flash — a quiet cue that a live value moved */
@keyframes figflash { from { color: var(--accent); } to { color: inherit; } }
.flash { animation: figflash .5s ease; }

/* visible only to screen readers */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------- print ------ */
@media print {
  .topbar, .nav, .share, .ad-slot, .affiliate, .related, .footer .no-print, .seg, .ghostbtn, input[type=range] { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .answer { background: #fff; border: 1px solid #999; }
  .answer::after { display: none; }
  .chartbox { break-inside: avoid; border: 1px solid #ccc; }
  .tablewrap { max-height: none; overflow: visible; }
  table.sched { font-size: 9.5pt; }
  table.sched th { position: static; }
  a { color: #000; text-decoration: none; }
  .tablewrap::after { content: "Full schedule printed above."; font-size: 9pt; color: #666; }
}

@media (max-width: 620px) {
  .answer { padding: 18px 16px 16px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .res.stat .big { font-size: 22px; }
  .chart { height: 260px; }
}

