/* Where Taxes Bite — shares the paper and type of the other Money apps.
 * One sequential ramp (paper to the deep green accent) for every measure;
 * copper marks the pinned state and the compare picks. */
:root {
  --paper: #f4f1e8; --card: #fbf9f3; --ink: #1d2420; --ink-2: #4c5650;
  --ink-3: #87908a; --rule: rgba(29,36,32,.18); --rule-soft: rgba(29,36,32,.09);
  --accent: #2f5d46;
  --accent-2: #b0662a;
  --serif: "Fraunces", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --side-w: 330px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-padding-top: calc(var(--appnav-h, 0px) + 20px); }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); max-width: 1680px; margin: 0 auto; }
.side {
  position: sticky; top: var(--appnav-h, 0px);
  height: calc(100vh - var(--appnav-h, 0px)); height: calc(100dvh - var(--appnav-h, 0px));
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  border-right: 1px solid var(--rule-soft);
}
.side-inner { padding: 1.2rem 1.15rem 1.4rem 1.3rem; }
.kicker, .cap-k, .controls legend, .controls label.lab, .card .k, .detail h3, .rank-h {
  font-family: var(--mono); font-size: .66rem; font-weight: 500; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}
h1 {
  font-family: var(--serif); font-weight: 600; font-size: 2.15rem; line-height: 1.05;
  letter-spacing: -.01em; margin: .3rem 0 .6rem; font-variation-settings: "opsz" 96;
}
h1 em { font-style: italic; color: var(--accent); }
.lede { font-size: 15px; color: var(--ink-2); }

/* ---------- measure picker ---------- */
.controls { margin-top: 1rem; display: grid; gap: .8rem; border: 0; }
.controls legend { display: block; margin-bottom: .35rem; }
.measures { display: grid; gap: .3rem; }
.measure {
  display: grid; grid-template-columns: auto 1fr; gap: .1rem .55rem; align-items: start;
  padding: .45rem .55rem; border: 1px solid var(--rule-soft); border-radius: 8px;
  background: var(--card); cursor: pointer;
}
.measure input { margin-top: .3rem; accent-color: var(--accent); }
.measure .t { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.measure .d { grid-column: 2; font-size: .8rem; color: var(--ink-2); line-height: 1.35; }
.measure:has(input:checked) { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.sub { display: grid; gap: .45rem; padding: .1rem 0 .2rem; }
.seg { display: flex; border: 1px solid var(--rule); border-radius: 7px; overflow: hidden; background: var(--card); }
.seg button {
  flex: 1; padding: .34rem .3rem; border: 0; background: none; cursor: pointer;
  font-size: .82rem; line-height: 1.2; border-left: 1px solid var(--rule-soft);
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed=true] { background: var(--accent); color: #fff; }
.money-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.money {
  width: 7.6rem; padding: .3rem .5rem; text-align: right;
  font-family: var(--mono); font-size: .9rem;
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
}
.chip {
  padding: .22rem .55rem; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--card); cursor: pointer; font-size: .8rem; font-family: var(--mono);
}
.chip[aria-pressed=true] { background: var(--accent); color: #fff; border-color: var(--accent); }
.hint { font-size: .78rem; color: var(--ink-3); line-height: 1.4; }
.side-foot { margin-top: 1rem; font-size: .8rem; color: var(--ink-3); }

/* ---------- main stage ---------- */
.main { min-width: 0; }
.stage {
  display: grid; grid-template-columns: minmax(0, 1fr) 270px; grid-template-rows: auto minmax(0, 1fr) auto;
  gap: .4rem 1.1rem;
  height: calc(100vh - var(--appnav-h, 0px)); height: calc(100dvh - var(--appnav-h, 0px));
  min-height: 600px; padding: .9rem 1.2rem .8rem;
}
.stage-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; align-items: baseline; }
.cap-k { color: var(--accent); }
.cap-t { font-size: .88rem; color: var(--ink-2); }
.map-box { position: relative; min-height: 0; }
.map-box svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .78rem; color: var(--ink-2); font-family: var(--mono); align-items: center; }
.legend i { display: inline-block; width: .85rem; height: .85rem; border-radius: 2px; vertical-align: -.12rem; margin-right: .3rem; border: 1px solid var(--rule-soft); }
.legend .none { background: repeating-linear-gradient(45deg, var(--card) 0 3px, #e3e0d5 3px 5px); }

.tile { cursor: pointer; }
.tile rect { stroke: var(--paper); stroke-width: 2; }
.tile text { font-family: var(--mono); pointer-events: none; text-anchor: middle; }
.tile .ab { font-size: 13px; font-weight: 500; }
.tile .val { font-size: 10.5px; }
.tile.dark text { fill: #fff; }
.tile.light text { fill: var(--ink); }
.tile.hover rect, .tile:focus-visible rect { stroke: var(--ink); stroke-width: 2.5; }
.tile.pinned rect { stroke: var(--accent-2); stroke-width: 3.5; }
.tile:focus { outline: none; }
.county { stroke: var(--paper); stroke-width: .25; cursor: pointer; }
.county.hover { stroke: var(--ink); stroke-width: 1.2; }
.county.pinned { stroke: var(--accent-2); stroke-width: 1.8; }
.state-line { fill: none; stroke: var(--paper); stroke-width: 1.1; pointer-events: none; }
.map-msg { font-family: var(--mono); font-size: 13px; fill: var(--ink-3); text-anchor: middle; }

.tip {
  position: absolute; pointer-events: none; z-index: 3; max-width: 240px;
  background: var(--card); border: 1px solid var(--rule); border-radius: 7px;
  padding: .35rem .55rem; font-size: .8rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(29,36,32,.12);
}
.tip b { font-family: var(--mono); font-weight: 500; }

/* ---------- detail card (under the map) ---------- */
.detail {
  border-top: 1px solid var(--rule); padding-top: .5rem; min-height: 7.2rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .35rem 1.2rem;
  font-size: .86rem;
}
.detail .who { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .2rem .8rem; align-items: baseline; }
.detail .who b { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; }
.detail .who .badge { font-family: var(--mono); font-size: .72rem; color: var(--ink-2); }
.detail .who button { margin-left: auto; }
.detail h3 { margin-bottom: .1rem; }
.detail .row { display: flex; justify-content: space-between; gap: .6rem; border-bottom: 1px solid var(--rule-soft); }
.detail .row span:last-child { font-family: var(--mono); font-size: .82rem; white-space: nowrap; }
.detail .row.on span { color: var(--accent); font-weight: 600; }
.detail .fine { font-size: .76rem; color: var(--ink-3); line-height: 1.35; margin-top: .15rem; }
.detail .empty { grid-column: 1 / -1; color: var(--ink-3); font-size: .88rem; }
.btn {
  padding: .25rem .65rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--card);
  cursor: pointer; font-size: .8rem;
}
.btn:hover { border-color: var(--accent); }

/* ---------- ranked list ---------- */
.rank { grid-row: 2 / 4; grid-column: 2; display: flex; flex-direction: column; min-height: 0; }
.rank-h { margin-bottom: .3rem; }
.rank ol { list-style: none; overflow-y: auto; min-height: 0; flex: 1; scrollbar-width: thin; padding-right: 2px; }
.rank li button {
  width: 100%; display: grid; grid-template-columns: 1.6rem 1fr; gap: .05rem .4rem; align-items: center;
  border: 0; background: none; padding: .14rem .2rem; cursor: pointer; text-align: left; border-radius: 4px;
}
.rank li button:hover, .rank li button.hover { background: var(--rule-soft); }
.rank li button.pinned { box-shadow: inset 3px 0 0 var(--accent-2); background: rgba(176,102,42,.08); }
.rank .n { font-family: var(--mono); font-size: .68rem; color: var(--ink-3); text-align: right; }
.rank .nm { font-size: .8rem; display: flex; justify-content: space-between; gap: .4rem; line-height: 1.25; }
.rank .nm b { font-family: var(--mono); font-weight: 500; font-size: .76rem; }
.rank .bar { grid-column: 2; height: 5px; border-radius: 2px; background: var(--accent); min-width: 1px; }

/* ---------- compare ---------- */
.section { padding: 1.6rem 1.5rem 0; max-width: 1100px; }
.section h2 { font-family: var(--serif); font-weight: 600; font-size: 1.45rem; margin-bottom: .5rem; }
.section > p { max-width: 72ch; }
.cmp-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem 1.2rem; margin: .9rem 0; }
.cmp-inputs label.lab { display: block; font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .25rem; }
.cmp-inputs select {
  width: 100%; padding: .3rem .4rem; background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
}
.cmp-inputs .money { width: 100%; }
.cmp-wrap { overflow-x: auto; }
.cmp { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 340px; }
.cmp th, .cmp td { padding: .35rem .5rem; border-bottom: 1px solid var(--rule-soft); text-align: right; vertical-align: top; }
.cmp th:first-child, .cmp td:first-child { text-align: left; padding-left: 0; }
.cmp thead th { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; border-bottom: 1px solid var(--rule); }
.cmp td { font-family: var(--mono); font-size: .86rem; }
.cmp td:first-child { font-family: var(--sans); font-size: .9rem; }
.cmp td .how { display: block; font-family: var(--sans); font-size: .74rem; color: var(--ink-3); }
.cmp tr.total td { font-weight: 600; border-bottom: 1px solid var(--rule); }
.cmp tr.share td { color: var(--accent); font-weight: 600; }
.cmp .lowest { color: var(--accent); }

.prose p, .prose li { max-width: 72ch; }
.prose p + p, .prose ul + p { margin-top: .7rem; }
.prose ul { padding-left: 1.2rem; margin-top: .5rem; }
.prose li { margin-bottom: .45rem; }
.prose code { font-family: var(--mono); font-size: .85em; }
.refs li { font-size: .92rem; }
.changelog { padding-bottom: 3rem; }
.changelog ul { list-style: none; padding: 0; }
.changelog time { font-family: var(--mono); font-size: .8rem; color: var(--ink-3); margin-right: .7rem; }

/* ---------- narrow ---------- */
@media (max-width: 1100px) {
  .stage { grid-template-columns: minmax(0, 1fr) 220px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--rule-soft); }
  .side-inner { padding: 1rem 16px 1.2rem; }
  .stage { display: flex; flex-direction: column; height: auto; min-height: 0; padding: .8rem 16px 0; gap: .6rem; }
  .map-box { height: 72vw; max-height: 520px; min-height: 250px; }
  .rank ol { max-height: 360px; }
  .section { padding: 1.4rem 16px 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .seg button, .chip, .tile rect, .rank .bar { transition: background-color .15s, color .15s, fill .25s, width .25s; }
}
