/* Post 101 finances.
   The site's own palette and faces (see src/styles/global.css): awning
   blue and its gold lettering, the brick behind it. Money in is awning
   blue, money out is brick — the building's colours, not a traffic light. */

@font-face {
  font-family: "Big Shoulders Display";
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/big-shoulders-display-var.woff2") format("woff2-variations");
}
@font-face {
  font-family: "Public Sans";
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/public-sans-var.woff2") format("woff2-variations");
}

:root {
  --awning: #2850a0;
  --awning-dk: #17356e;
  --gold: #e3b93c;
  --gold-lt: #f2d268;
  --brick: #8a4f4f;
  --ink: #0f1420;
  --slate: #5a6474;
  --paper: #eceef2;
  --sheet: #ffffff;
  --rule: #d3d7df;
  --in: #2850a0;
  --out: #8a4f4f;
  --warn-bg: #fff4d6;
  --warn-ink: #5c4400;
  --focus: #e3b93c;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --body: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --col: 680px;
  --tabs-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --awning: #2d5ab4;
    --awning-dk: #10264f;
    --ink: #e8ebf1;
    --slate: #a2abba;
    --paper: #0d121c;
    --sheet: #161d2a;
    --rule: #2a3344;
    --in: #8fb0ee;
    --out: #e0a3a3;
    --brick: #b86f6f;
    --warn-bg: #3a2f10;
    --warn-ink: #f2d268;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
}

main { max-width: var(--col); margin: 0 auto; outline: none; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; letter-spacing: 0.01em; }

a { color: var(--awning); }
@media (prefers-color-scheme: dark) { a { color: var(--in); } }

.num, .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.in { color: var(--in); }
.out { color: var(--out); }
.muted { color: var(--slate); }
.small { font-size: 0.875rem; }

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

.loading, .empty { padding: 48px 20px; text-align: center; color: var(--slate); }

/* ---------- page header ---------- */

.head { padding: 20px 20px 12px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.head .sub { color: var(--slate); font-size: 0.9rem; margin-top: 2px; }

/* ---------- the awning ---------- */

.awning {
  background: var(--awning);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 20px 44px;
  position: relative;
  /* The scalloped edge of the storefront awning. */
  -webkit-mask: radial-gradient(22px at 50% 100%, #0000 98%, #000) 50% calc(100% + 11px) / 44px 100% repeat-x,
                linear-gradient(#000 0 0) top / 100% calc(100% - 11px) no-repeat;
          mask: radial-gradient(22px at 50% 100%, #0000 98%, #000) 50% calc(100% + 11px) / 44px 100% repeat-x,
                linear-gradient(#000 0 0) top / 100% calc(100% - 11px) no-repeat;
}
.awning-wrap { max-width: var(--col); margin: 0 auto; }
.awning .post { font-weight: 600; font-size: 0.95rem; opacity: 0.85; }
.awning .total {
  font-family: var(--display);
  font-weight: 800;
  color: var(--gold);
  font-size: clamp(3.4rem, 17vw, 5.4rem);
  line-height: 0.95;
  margin: 10px 0 4px;
  font-variant-numeric: tabular-nums;
}
.awning .total-label { opacity: 0.85; }
.awning .accounts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 14px; font-size: 0.95rem; }
.awning .accounts b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- actions ---------- */

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 16px 8px; }
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px;
  border: 1.5px solid var(--rule); border-radius: 10px;
  background: var(--sheet); color: var(--ink);
  font: 600 1rem/1.2 var(--body); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--awning); }
.btn.primary { background: var(--awning); border-color: var(--awning); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.danger { color: var(--out); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.linkish { background: none; border: 0; padding: 0; color: var(--awning); font: inherit; text-decoration: underline; cursor: pointer; }

.snap-hero {
  margin: 8px 16px 4px; width: calc(100% - 32px);
  min-height: 64px; font-size: 1.15rem;
}

/* ---------- lists (ledger lines, not cards) ---------- */

.section { margin-top: 22px; }
.section > h2, .section > .section-head { padding: 0 20px 8px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }

.rows { list-style: none; margin: 0; padding: 0; background: var(--sheet); border-block: 1px solid var(--rule); }
@media (min-width: 720px) { .rows { border: 1px solid var(--rule); border-radius: 10px; } }
.rows > li + li { border-top: 1px solid var(--rule); }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline;
  padding: 12px 20px; color: inherit; text-decoration: none;
}
a.row:hover { background: color-mix(in srgb, var(--awning) 6%, transparent); }
.row .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .what { grid-column: 1; color: var(--slate); font-size: 0.875rem; }
.row .amt { font-weight: 600; }
.row .when { color: var(--slate); font-size: 0.875rem; text-align: right; }
.row.voided .who, .row.voided .amt { text-decoration: line-through; color: var(--slate); }
.day { padding: 14px 20px 6px; font-weight: 600; font-size: 0.875rem; color: var(--slate); }

.row.thumbrow { grid-template-columns: 56px 1fr auto; }
.thumb { grid-row: span 2; width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--paper); border: 1px solid var(--rule); display: grid; place-items: center; font-size: 0.75rem; color: var(--slate); }

.callout {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 14px 16px 0; padding: 14px 16px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-ink); text-decoration: none; font-weight: 600;
}
.note { margin: 12px 16px; padding: 12px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 0.95rem; }
.note.ok { background: color-mix(in srgb, var(--awning) 12%, var(--sheet)); color: var(--ink); }

.month-sum { display: grid; grid-template-columns: 1fr 1fr; background: var(--sheet); border-block: 1px solid var(--rule); }
@media (min-width: 720px) { .month-sum { border: 1px solid var(--rule); border-radius: 10px; } }
.month-sum > div { padding: 14px 20px; }
.month-sum > div + div { border-left: 1px solid var(--rule); }
.month-sum .big { font-family: var(--display); font-weight: 700; font-size: 1.9rem; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */

form.entry, .panel { background: var(--sheet); border-block: 1px solid var(--rule); padding: 18px 20px; }
@media (min-width: 720px) { form.entry, .panel { border: 1px solid var(--rule); border-radius: 10px; } }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span, .field > label { font-weight: 600; font-size: 0.95rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--sheet);
  border: 1.5px solid var(--rule); border-radius: 8px;
  padding: 11px 12px; min-height: 48px; width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--awning); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--awning) 25%, transparent); }
input.money { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.15rem; }
input[aria-invalid="true"] { border-color: var(--out); }

.kind { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--rule); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.kind label { position: relative; text-align: center; padding: 11px 6px; font-weight: 600; cursor: pointer; }
.kind label + label { border-left: 1.5px solid var(--rule); }
.kind input { position: absolute; opacity: 0; inset: 0; min-height: 0; }
.kind label:has(input:checked) { background: var(--awning); color: #fff; }
.kind label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }

.line { border-top: 1px dashed var(--rule); padding-top: 14px; margin-top: 4px; }
.line-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }
.split-sum { display: flex; justify-content: space-between; padding: 10px 0 16px; font-weight: 600; border-top: 1px solid var(--rule); }
.form-actions { display: grid; gap: 10px; margin-top: 8px; }
.form-error { color: var(--out); font-weight: 600; margin: 0 0 12px; }

.receipt-view { display: block; margin: 0 16px 14px; border-radius: 10px; overflow: hidden; border: 1px solid var(--rule); background: var(--sheet); }
.receipt-view img { display: block; width: 100%; max-height: 52vh; object-fit: contain; background: #fff; }
.receipt-view .pdf { padding: 18px; font-weight: 600; }
details.items { margin: 0 0 16px; }
details.items summary { cursor: pointer; font-weight: 600; color: var(--awning); }
details.items table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.9rem; }
details.items td { padding: 4px 0; border-bottom: 1px solid var(--rule); }
details.items td:last-child { text-align: right; }

/* ---------- detail ---------- */

.facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.facts dt { color: var(--slate); }
.facts dd { margin: 0; }
.history { list-style: none; padding: 0; margin: 12px 0 0; font-size: 0.9rem; color: var(--slate); }
.history li { padding: 4px 0; }

/* ---------- month picker ---------- */

.picker { display: flex; align-items: center; gap: 6px; }
.picker .btn { min-height: 40px; width: 40px; padding: 0; font-size: 1.2rem; }
.picker b { min-width: 9.5em; text-align: center; font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 0 16px 12px; }
.toolbar input[type="search"] { flex: 1 1 200px; min-height: 42px; }

/* ---------- report ---------- */

.report { background: var(--sheet); border-block: 1px solid var(--rule); padding: 22px 20px; }
@media (min-width: 720px) { .report { border: 1px solid var(--rule); border-radius: 10px; } }
.report header { border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 8px; }
.report header p { margin: 4px 0 0; color: var(--slate); }
.report table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.report th, .report td { padding: 7px 0; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.report td + td, .report th + th { text-align: right; padding-left: 14px; white-space: nowrap; }
/* Multi-column tables scroll inside themselves on a phone rather than
   pushing the page sideways. */
.report .wide { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.report .wide table { min-width: 460px; font-size: 0.925rem; }
.report th { font-size: 0.875rem; color: var(--slate); font-weight: 600; }
.report tr.total td { font-weight: 700; border-bottom: 2px solid var(--ink); }
.report tr.grand td { font-family: var(--display); font-size: 1.35rem; font-weight: 700; border-bottom: 0; }
.report h3 { margin: 22px 0 4px; }
.report .form990 { color: var(--slate); font-size: 0.8rem; }
.signoff { margin-top: 26px; font-size: 0.9rem; color: var(--slate); }

/* ---------- tabs ---------- */

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr; align-items: center;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  padding-inline: max(0px, calc((100vw - var(--col)) / 2));
  background: var(--sheet); border-top: 1px solid var(--rule);
}
.tabs a { display: grid; place-items: center; height: 100%; color: var(--slate); text-decoration: none; font-weight: 600; font-size: 0.9rem; position: relative; }
.tabs a[aria-current="page"] { color: var(--awning); box-shadow: inset 0 3px 0 var(--awning); }
@media (prefers-color-scheme: dark) { .tabs a[aria-current="page"] { color: var(--in); box-shadow: inset 0 3px 0 var(--in); } }
.tabs .badge { position: absolute; top: 9px; right: calc(50% - 32px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brick); color: #fff; font-size: 0.75rem; display: grid; place-items: center; }
.snap {
  justify-self: center; width: 68px; height: 68px; margin-top: -26px;
  border-radius: 50%; border: 4px solid var(--paper);
  background: var(--gold); color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.snap svg { width: 30px; height: 30px; }
.snap:active { transform: scale(0.96); }

/* ---------- overlays ---------- */

.busy { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgb(15 20 32 / 0.55); }
.busy-card { background: var(--sheet); padding: 22px 26px; border-radius: 12px; display: flex; gap: 14px; align-items: center; font-weight: 600; max-width: 86vw; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--rule); border-top-color: var(--awning); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  z-index: 20; background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 10px; font-weight: 600;
  max-width: calc(100vw - 32px);
}
.dropping::after { content: "Drop receipts to add them"; position: fixed; inset: 12px; z-index: 40; border: 3px dashed var(--awning); border-radius: 16px; background: rgb(236 238 242 / 0.9); display: grid; place-items: center; font: 700 1.6rem var(--display); color: var(--awning); }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .snap:active { transform: none; }
}

/* ---------- print: the monthly report on paper ---------- */

@media print {
  :root { --ink: #000; --paper: #fff; --sheet: #fff; --rule: #bbb; --slate: #444; }
  body { padding: 0; background: #fff; font-size: 11pt; }
  .tabs, .noprint, .toast, .busy { display: none !important; }
  main { max-width: none; }
  .report { border: 0; padding: 0; }
}
