/* finance.of.fail: municipal paperwork, kid-sized.
   Forms are boxed fields on white sheets; status is a rubber stamp. */

@font-face {
  font-family: "Atkinson Next";
  src: url("fonts/atkinson-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 500 900;
  font-stretch: 100% 125%;
  font-display: swap;
}

:root {
  --paper: #F2F4F7;
  --sheet: #FFFFFF;
  --ink: #1B2A4A;
  --ink-2: #56627A;
  --rule: #C9D0DC;
  --stamp: #C62F2F;
  --money: #1F7A4D;
  --canary: #F5D547;
  --canary-wash: #FDF6D3;
  --civic: #2F5BD3;
  --civic-dark: #22449F;
  --body: "Atkinson Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --head: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --r: 6px;
  --nav-h: 68px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 18px/1.5 var(--body);
  font-variant-numeric: tabular-nums;
}
body.kid { padding-bottom: calc(var(--nav-h) + 24px); }

a { color: var(--civic); text-underline-offset: 3px; }
a:hover { color: var(--civic-dark); }

:focus-visible { outline: 3px solid var(--civic); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3 {
  font-family: var(--head);
  font-stretch: 125%;
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 .5em;
  letter-spacing: -.005em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; max-width: 68ch; }
:is(h1, h2, h3):first-child { margin-top: 0; }
small, .quiet { color: var(--ink-2); font-size: .85rem; }

.wrap { max-width: 760px; margin: 0 auto; padding: 20px 18px; }
.wrap.wide { max-width: 1040px; }

/* ---------------------------------------------------------------- header */
.masthead {
  background: var(--ink);
  color: #fff;
}
.masthead .wrap {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding-top: 12px; padding-bottom: 12px;
}
.wordmark {
  font-family: var(--head); font-stretch: 125%; font-weight: 900;
  font-size: 1.05rem; color: #fff; text-decoration: none; margin-right: auto;
}
.wordmark span { color: var(--canary); }
.passbook { display: flex; gap: 8px; }
.passbook a {
  display: block; color: #fff; text-decoration: none;
  border: 1.5px solid rgba(255,255,255,.35); border-radius: var(--r);
  padding: 4px 12px; line-height: 1.2; min-width: 110px;
}
.passbook small { color: rgba(255,255,255,.75); font-size: .75rem; display: block; }
.passbook strong { font-size: 1.1rem; }
.passbook .amt.neg { color: #FFB4B4; }

.adminnav { display: flex; gap: 4px 16px; flex-wrap: wrap; font-size: .95rem; }
.adminnav a { color: #fff; text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.adminnav a[aria-current] { border-bottom-color: var(--canary); }
.scope-note {
  background: var(--canary-wash); border-bottom: 1px solid var(--canary);
  font-size: .9rem;
}
.scope-note .wrap { padding-top: 8px; padding-bottom: 8px; }

/* ---------------------------------------------------------------- kid tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--sheet); border-top: 2px solid var(--ink);
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: var(--nav-h);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--ink-2); font-size: .8rem; gap: 2px;
}
.tabbar a .ic { font-size: 1.5rem; line-height: 1; }
.tabbar a[aria-current] { color: var(--ink); font-weight: 700; background: var(--canary-wash); box-shadow: inset 0 3px 0 var(--canary); }

/* ---------------------------------------------------------------- sheets & forms */
.sheet {
  background: var(--sheet);
  border: 1.5px solid var(--ink);
  border-radius: var(--r);
  padding: 18px 20px;
  margin: 0 0 18px;
  position: relative;
}
.sheet > :last-child { margin-bottom: 0; }
.sheet-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-bottom: 1.5px solid var(--ink); margin: -18px -20px 16px; padding: 12px 20px;
}
.sheet-head h2, .sheet-head h1 { margin: 0; }
.form-no { font-size: .8rem; color: var(--ink-2); white-space: nowrap; }

.field { margin: 0 0 14px; }
.field > label, .field > .label { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=email],
input[type=date], input[type=tel], select, textarea {
  font: inherit; color: var(--ink);
  width: 100%; min-height: 48px; padding: 8px 12px;
  background: #fff; border: 1.5px solid var(--rule); border-radius: 4px;
}
input:focus, select:focus, textarea:focus { border-color: var(--civic); outline: none; box-shadow: 0 0 0 3px rgba(47,91,211,.2); }
textarea { min-height: 110px; resize: vertical; }
input.pin { max-width: 9ch; letter-spacing: .4em; font-size: 1.3rem; text-align: center; }
input.short { max-width: 10ch; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--civic); }

.btn {
  font: 700 1rem/1 var(--body);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 2px solid var(--civic); border-radius: var(--r);
  background: var(--civic); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--civic-dark); border-color: var(--civic-dark); color: #fff; }
.btn.quiet { background: transparent; color: var(--civic); }
.btn.quiet:hover { background: rgba(47,91,211,.08); }
.btn.danger { background: transparent; color: var(--stamp); border-color: var(--stamp); }
.btn.danger:hover { background: rgba(198,47,47,.08); }
.btn.onink { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.btn.onink:hover { background: rgba(255,255,255,.12); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn.big { min-height: 60px; font-size: 1.15rem; padding: 0 28px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
form.inline { display: inline; }

/* The signature block at the bottom of every form that needs a PIN. */
.sign {
  border-top: 1.5px dashed var(--ink); margin: 20px -20px -18px; padding: 16px 20px;
  background: #F7F9FC; border-radius: 0 0 var(--r) var(--r);
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
}
.sign .field { margin: 0; }
.sign p { margin: 0; flex: 1 1 220px; font-size: .9rem; color: var(--ink-2); }

/* Segmented choices (radio pills), big enough for fingers. */
.choices { display: inline-flex; border: 1.5px solid var(--rule); border-radius: 999px; overflow: hidden; }
.choices label { position: relative; }
.choices input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choices span {
  display: flex; align-items: center; justify-content: center;
  min-width: 52px; min-height: 46px; padding: 0 14px; font-weight: 700;
  border-left: 1.5px solid var(--rule); color: var(--ink-2);
}
.choices label:first-child span { border-left: 0; }
.choices input:checked + span { background: var(--ink); color: #fff; }
.choices input.yes:checked + span { background: var(--money); }
.choices input.no:checked + span { background: var(--stamp); }
.choices input:focus-visible + span { outline: 3px solid var(--civic); outline-offset: -3px; }

/* ---------------------------------------------------------------- chart */
.chart { width: 100%; border-collapse: collapse; }
.chart th { text-align: left; font-size: .85rem; color: var(--ink-2); font-weight: 400; padding: 0 8px 8px; }
.chart td { border-top: 1px solid var(--rule); padding: 10px 8px; vertical-align: middle; }
.chart tr.break td { background: #F5F7FA; }
.chart .seg strong { display: block; }
.chart .seg small { display: block; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.total {
  border: 1.5px solid var(--rule); border-radius: var(--r); padding: 10px 14px;
}
.total strong { font-size: 1.4rem; }
.total.met { border-color: var(--money); background: #EAF5EF; }

/* ---------------------------------------------------------------- ledgers & tables */
table.ledger { width: 100%; border-collapse: collapse; font-size: .95rem; }
.ledger th { text-align: left; font-weight: 400; color: var(--ink-2); font-size: .8rem; padding: 6px 8px; border-bottom: 1.5px solid var(--ink); }
.ledger td { padding: 9px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger td.n, .ledger th.n { text-align: right; white-space: nowrap; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger tfoot td { border-top: 1.5px solid var(--ink); font-weight: 700; }
.amt { white-space: nowrap; }
.amt.neg { color: var(--stamp); }
.amt.pos { color: var(--money); }
.scroll-x { overflow-x: auto; }

/* ---------------------------------------------------------------- stamps */
.stamp {
  display: inline-block;
  font-family: var(--head); font-stretch: 125%; font-weight: 900;
  font-size: .95rem; letter-spacing: .06em; line-height: 1;
  color: var(--stamp); border: 3px double currentColor; border-radius: 4px;
  padding: 6px 10px 5px; transform: rotate(-4deg);
  opacity: .9; white-space: nowrap; background: rgba(255,255,255,.4);
}
.stamp.blue { color: var(--civic); }
.stamp.green { color: var(--money); }
.stamp.ink { color: var(--ink-2); }
.stamp.big { font-size: 1.6rem; padding: 8px 14px 7px; border-width: 5px; }
.sheet > .stamp.corner {
  position: absolute; top: 74px; right: 22px; transform: rotate(6deg);
  font-size: 1.5rem; padding: 8px 14px 7px; border-width: 5px;
}
@media (prefers-reduced-motion: no-preference) {
  .stamp.fresh { animation: thunk .28s cubic-bezier(.2,1.6,.4,1) both; }
}
@keyframes thunk {
  from { transform: rotate(6deg) scale(1.9); opacity: 0; }
  to { transform: rotate(6deg) scale(1); opacity: .9; }
}

/* ---------------------------------------------------------------- pay stub (carbon copy) */
.stub {
  background: var(--canary-wash);
  border: 1.5px solid var(--ink);
  border-radius: 0 0 var(--r) var(--r);
  padding: 22px 20px 18px; margin: 0 0 18px; position: relative;
}
.stub::before { /* perforated tear edge */
  content: ""; position: absolute; left: -1.5px; right: -1.5px; top: -8px; height: 8px;
  background: radial-gradient(circle at 6px 8px, var(--paper) 4px, transparent 4.5px) 0 0 / 12px 8px repeat-x,
              var(--canary-wash);
  border-left: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink);
}
.stub-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1.5px solid var(--ink); padding-bottom: 10px; margin-bottom: 10px; }
.stub .ledger td { border-bottom-color: #E7D98F; }
.stub-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stub-sum div { background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; padding: 8px 12px; }
.stub-sum small { display: block; }
.stub-sum strong { font-size: 1.3rem; }
.stub-sum .net { background: var(--ink); color: #fff; }
.stub-sum .net small { color: rgba(255,255,255,.75); }

/* ---------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--rule); padding: 12px 0; display: flex; gap: 14px; align-items: center; }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .emoji { font-size: 1.9rem; width: 2.2rem; text-align: center; flex: none; }

.notice {
  border-left: 5px solid var(--canary); background: var(--sheet);
  padding: 10px 14px; margin: 0 0 10px; display: flex; gap: 12px; align-items: center;
  border-radius: 0 var(--r) var(--r) 0;
}
.notice p { margin: 0; flex: 1; }
.flash {
  background: var(--ink); color: #fff; border-radius: var(--r);
  padding: 12px 16px; margin: 0 0 16px;
}
.error {
  border: 2px solid var(--stamp); color: var(--stamp); background: #FCEDED;
  border-radius: var(--r); padding: 12px 16px; margin: 0 0 16px; font-weight: 700;
}

/* ---------------------------------------------------------------- home */
.today-card { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.big-amt { font-family: var(--head); font-stretch: 125%; font-weight: 900; font-size: 2.6rem; line-height: 1; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
.dl dt { color: var(--ink-2); }
.dl dd { margin: 0; text-align: right; }

/* Reading timer */
.timer { text-align: center; padding: 10px 0 4px; }
.timer .clock { font-family: var(--head); font-stretch: 125%; font-weight: 900; font-size: 4rem; line-height: 1; }
progress.meter {
  -webkit-appearance: none; appearance: none; display: block; width: 100%;
  height: 16px; margin: 12px 0 6px; border: 1.5px solid var(--ink);
  border-radius: 999px; overflow: hidden; background: #E3E7EE; color: var(--money);
}
progress.meter::-webkit-progress-bar { background: #E3E7EE; }
progress.meter::-webkit-progress-value { background: var(--money); }
progress.meter::-moz-progress-bar { background: var(--money); }

/* Store: price tag */
.tag {
  font-weight: 800; white-space: nowrap; background: var(--canary); color: var(--ink);
  padding: 4px 10px 4px 16px; border-radius: 3px;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%);
}
details.buy > summary { list-style: none; cursor: pointer; }
details.buy > summary::-webkit-details-marker { display: none; }
details.buy[open] > summary .btn { background: transparent; color: var(--civic); }
.buy-panel { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }

/* Ballot */
.option { display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--rule); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.option input { width: 22px; height: 22px; accent-color: var(--ink); }
.option:has(input:checked) { border-color: var(--ink); background: #F5F7FA; }
.option .grow { flex: 1; }
.argument { white-space: pre-wrap; border-left: 4px solid var(--rule); padding-left: 14px; }
.houses { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.house { border: 1.5px solid var(--rule); border-radius: var(--r); padding: 10px 14px; }

.constitution h1 { font-size: 1.5rem; }
.constitution li { margin-bottom: .6em; }

.photo-thumb { max-width: 100%; border: 1.5px solid var(--ink); border-radius: 4px; }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; border: 1.5px solid var(--ink); }
code.secret { font-size: 1rem; word-break: break-all; background: #fff; padding: 2px 6px; border: 1px solid var(--rule); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.kv:last-child { border-bottom: 0; }

@media (max-width: 640px) {
  body { font-size: 17px; }
  h1 { font-size: 1.45rem; }
  .grid2, .houses, .totals { grid-template-columns: 1fr; }
  .stub-sum { grid-template-columns: 1fr 1fr; }
  .stub-sum .net { grid-column: span 2; }
  .passbook a { min-width: 0; }
  .wordmark { width: 100%; }
}

@media print {
  .masthead, .tabbar, .actions, .sign, form { display: none !important; }
  body { background: #fff; padding: 0; }
}
