/* Grant Funder Intelligence — annual-report styling.
   Tokens are the spec's; do not invent colours. */
:root {
  --ink: #16202A;
  --muted: #5B6B78;
  --paper: #FBF9F5;
  --surface: #FFFFFF;
  --line: #E3DED4;
  --primary: #12405C;
  --accent: #B08A2E;
  --positive: #2F6B4F;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--sans);
  font-feature-settings: "tnum";
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* header */
.site-head {
  background: var(--primary);
  border-bottom: 3px solid var(--accent);
}
.headrow { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 14px 24px; flex-wrap: wrap; }
.brand { color: var(--surface); font-family: var(--serif); font-size: 20px; text-decoration: none; letter-spacing: .2px; }
.brand em { font-style: normal; color: #E7C568; }
.site-head nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-head nav a { color: #D8E2EA; text-decoration: none; font-size: 15px; padding: 2px 0; border-bottom: 2px solid transparent; }
.site-head nav a:hover { color: #fff; border-color: var(--accent); }
body[data-page="overview"] nav a[href="/"],
body[data-page="funders"] nav a[href="/funders"],
body[data-page="grants"] nav a[href="/grants"],
body[data-page="prospect"] nav a[href="/prospect-pack"],
body[data-page="method"] nav a[href="/method"] { color: #fff; border-color: var(--accent); }

main { padding: 40px 24px 64px; }

h1, h2, h3 { font-family: var(--serif); color: var(--primary); line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 34px; letter-spacing: -.01em; }
h2 { font-size: 24px; margin-top: 8px; }
h3 { font-size: 19px; }
p { margin: 0 0 14px; }
a { color: var(--primary); }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.kicker { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.lede { font-size: 19px; max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }
.breadcrumb { font-size: 14px; }

/* hero */
.hero { padding: 8px 0 20px; max-width: 70ch; }
.hero h1 { font-size: 44px; margin: 6px 0 14px; max-width: 26ch; text-wrap: balance; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 26px 0 34px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--primary); padding: 18px 20px 16px; box-shadow: 0 1px 2px rgba(22,32,42,.04); }
.stat-num { display: block; font-family: var(--serif); font-size: 34px; line-height: 1.1; color: var(--primary); font-variant-numeric: tabular-nums; }
.stat-num.accent { color: var(--accent); }
.stat-cap { display: block; color: var(--muted); font-size: 14px; margin-top: 6px; }

/* cards */
.cards3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 0 0 34px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); padding: 20px 22px 16px; text-decoration: none; box-shadow: 0 1px 2px rgba(22,32,42,.04); }
.card:hover { border-color: var(--accent); }
.card h3 { margin-bottom: 6px; }
.card p { color: var(--muted); font-size: 15px; }
.card-go { color: var(--accent); font-weight: 600; font-size: 15px; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); padding: 22px 26px; margin: 0 0 24px; box-shadow: 0 1px 2px rgba(22,32,42,.04); }
.panel.quiet { background: transparent; box-shadow: none; border-style: dashed; }

/* horizontal bars */
.hbar { display: grid; grid-template-columns: 280px 1fr 110px; gap: 12px; align-items: center; margin: 8px 0; }
.hbar-label { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-val { font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.hbar-rect { fill: var(--primary); }
.hbar:nth-child(2) .hbar-rect, .hbar:nth-child(3) .hbar-rect { fill: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 4px 12px; font-size: 14px; border-radius: 999px; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.flag { border-color: var(--accent); color: var(--accent); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); padding: 14px 16px; margin: 18px 0; }
.filters input[type="search"], .filters input[type="number"] {
  font: inherit; font-size: 15px; line-height: 1.4; padding: 8px 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 3px; appearance: textfield; -moz-appearance: textfield; }
.filters input[type="search"] { flex: 1 1 260px; }
.filters input[type="number"] { flex: 0 0 auto; width: 120px; }
.f-item { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.f-check { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); white-space: nowrap; }
.filters select { font: inherit; font-size: 15px; padding: 7px 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 3px; }
.btn { font: inherit; font-size: 15px; padding: 8px 16px; border-radius: 3px; cursor: pointer; border: 1px solid var(--primary); background: var(--primary); color: #fff; }
.btn.ghost { background: transparent; color: var(--primary); }

/* tables */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(22,32,42,.04); }
.data-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.data-table th, .data-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table thead th { position: sticky; top: 0; background: var(--surface); font-family: var(--sans); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 2px solid var(--primary); cursor: pointer; user-select: none; }
.data-table thead th[data-sort]:hover { color: var(--primary); }
.data-table .num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: #F6F2EA; }
.data-table td.tl a { text-decoration: none; }
td.purpose, .purpose { color: var(--muted); font-size: 14px; }
.src { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge.matched { color: var(--positive); border-color: var(--positive); }
.badge.unresolved { color: var(--muted); }

.empty { padding: 30px 0; color: var(--muted); text-align: center; border: 1px dashed var(--line); background: var(--surface); }
.placeholder { border: 1px dashed var(--accent); padding: 12px 16px; color: var(--muted); background: #FCF8EE; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0; }
.pager button { font: inherit; font-size: 14px; min-width: 38px; padding: 6px 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; border-radius: 3px; }
.pager button[aria-current="page"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager button:hover { border-color: var(--accent); }

/* prospect pack tiers */
.md { max-width: 80ch; }
.md h2 { margin-top: 28px; }
.md table { margin: 14px 0; }
.tier { border-left: 4px solid var(--accent); background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 18px 2px; margin: 16px 0; box-shadow: 0 1px 2px rgba(22,32,42,.04); }
.tier1 { border-left-color: var(--accent); }
.tier2 { border-left-color: var(--primary); }
.tier3 { border-left-color: var(--muted); }
.tier.drop { border-left-color: var(--line); color: var(--muted); background: transparent; box-shadow: none; }

.limits li { margin-bottom: 14px; }

/* footer */
.site-foot { border-top: 1px solid var(--line); background: var(--surface); margin-top: 40px; }
.site-foot p { color: var(--muted); font-size: 13px; padding: 20px 0; }

/* filter drawer on small screens */
.filter-toggle { display: none; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cards3 { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 150px 1fr 90px; }
  .hero h1 { font-size: 34px; }
  h1 { font-size: 28px; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  main { padding: 24px 16px 48px; }
  .headrow { padding: 12px 16px; }
  .site-head nav { gap: 12px; font-size: 14px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-num { font-size: 26px; }

  /* filters collapse into a drawer */
  .filter-toggle { display: inline-block; width: 100%; margin: 14px 0 0; }
  .filters { display: none; }
  .filters.open { display: flex; flex-direction: column; align-items: stretch; }
  .filters.open input[type="search"] { flex: 0 0 auto; width: auto; min-height: 0; height: 2.6em; }
  .filters.open .f-item, .filters.open .f-check { font-size: 15px; }
  .filters.open input[type="number"] { flex: 1; width: auto; }

  /* tables become stacked rows with labels */
  .table-scroll { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .data-table, .data-table thead, .data-table tbody, .data-table tr, .data-table th, .data-table td { display: block; }
  .data-table thead { display: none; }
  .data-table tr { background: var(--surface); border: 1px solid var(--line); margin-bottom: 10px; padding: 6px 0; box-shadow: 0 1px 2px rgba(22,32,42,.04); }
  .data-table td { border: 0; padding: 4px 14px; }
  .data-table td.num { text-align: left; }
  .data-table td::before { content: attr(data-label); display: inline-block; min-width: 90px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .data-table td:first-child { font-weight: 600; font-size: 16px; padding-top: 10px; }
  .data-table td:first-child::before { display: none; }
  .hbar { grid-template-columns: 1fr; }
  .hbar-label { white-space: normal; }
  .hero h1 { font-size: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
