/* One column, works on a phone. Looks like a printed civic guide: serif headings, plain sans text,
   paper and ink colors, maroon accent, thin rules instead of floating boxes. Colors live in variables for dark mode. */

/* Fonts are served from our own site (no Google requests). Both are free (SIL Open Font License). */
@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("fonts/public-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f6f3ec;          /* paper */
  --card: #fffdf8;        /* inputs */
  --text: #1f1d19;        /* ink */
  --muted: #625d53;
  --line: #d9d3c5;
  --strong-line: #1f1d19;
  --accent: #7d1f2c;      /* maroon */
  --accent-text: #ffffff;
  --button: #7d1f2c;      /* filled buttons */
  --note: #7a5a12;        /* dark gold, for "only funds groups it knows" */
  --highlight: #ebe4d3;
  --error: #a3271d;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1916;
    --card: #23221e;
    --text: #ece8de;
    --muted: #a8a294;
    --line: #3a3832;
    --strong-line: #ece8de;
    --accent: #dc5a52;      /* red, light enough to read as text on dark */
    --accent-text: #ffffff;
    --button: #9e2a33;      /* dark red button, white text */
    --note: #d9bb6e;
    --highlight: #2c2a24;
    --error: #f08a80;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* keep "hidden" working even on flex/grid elements */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main, header, footer, .masthead { max-width: 700px; margin: 0 auto; padding: 0 16px; }

/* Site name and links across the top of every page */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-top: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--strong-line);
  max-width: calc(700px - 32px);
  padding-left: 0;
  padding-right: 0;
}
@media (max-width: 732px) { .masthead { margin: 0 16px; } }
.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.masthead nav { display: flex; gap: 18px; font-size: 0.92rem; }
.masthead nav a { color: var(--muted); text-decoration: none; }
.masthead nav a:hover, .masthead nav a[aria-current] { color: var(--text); text-decoration: underline; }

header { padding-top: 36px; }
h1, h2, h3 { font-family: var(--serif); letter-spacing: -0.01em; }
h1 { font-size: 2.3rem; line-height: 1.12; font-weight: 600; margin: 0 0 12px; }
h2 { font-size: 1.4rem; font-weight: 600; margin: 40px 0 12px; }
a { color: var(--accent); text-underline-offset: 2px; }
.subline { color: var(--muted); margin: 0 0 28px; font-size: 1.05rem; }

/* Form */
label { display: block; font-weight: 600; margin: 22px 0 6px; font-size: 0.95rem; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.88rem; }
textarea, input, select {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border: 1px solid var(--muted);
  border-radius: 3px;
  background: var(--card);
  color: var(--text);
}
/* Dropdowns: our own look instead of the browser's (Safari draws a grey gradient and ignores padding) */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238a8478' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
textarea:focus, input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { min-height: 112px; resize: vertical; }
button {
  font: inherit;
  font-weight: 600;
  padding: 12px 22px;
  border: 1px solid var(--button);
  border-radius: 3px;
  background: var(--button);
  color: var(--accent-text);
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
#find { margin-top: 26px; font-size: 1.05rem; padding: 13px 30px; }
button:disabled { opacity: 0.6; cursor: wait; }
.error { color: var(--error); margin-top: 12px; }

#ein-box { margin-bottom: 4px; }
#ein-box summary { cursor: pointer; color: var(--accent); font-size: 0.95rem; }
.ein-row { display: flex; gap: 8px; }
.ein-row input { flex: 1; }
#ein-message { margin: 8px 0 0; }

/* Results */
.summary { font-family: var(--serif); font-size: 1.25rem; line-height: 1.35; }
.filters {
  display: grid;
  gap: 4px 16px;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 2px 0 14px;
}
.filters label { margin-top: 12px; font-size: 0.9rem; }
.filters .check { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-weight: 400; }
.filters .check input { width: auto; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }
.actions button { padding: 8px 16px; font-size: 0.92rem; }

/* One funder: a numbered entry between thin rules */
.card {
  position: relative;
  padding: 22px 0 18px 52px;
  border-bottom: 1px solid var(--line);
}
.card .rank {
  position: absolute;
  left: 0;
  top: 22px;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.card h3 { margin: 0; font-size: 1.3rem; line-height: 1.25; font-weight: 600; }
.card .where { color: var(--muted); margin: 2px 0 8px; font-size: 0.95rem; }
.card .near { margin: 0 0 4px; font-size: 0.9rem; color: var(--accent); }
.tag { display: block; color: var(--note); font-size: 0.9rem; margin-bottom: 4px; }
.tag::before { content: "▲ "; font-size: 0.7em; vertical-align: 0.15em; }
.stats {
  display: flex;
  gap: 8px 28px;
  flex-wrap: wrap;
  margin: 12px 0 10px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums lining-nums;
}
.stats div span {
  display: block;
  font-family: var(--sans);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.card .why { margin: 6px 0 12px; padding: 8px 12px; background: var(--highlight); border-radius: 2px; }
.ai-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}
.card > p:not([class]) { margin: 12px 0 0; font-size: 0.9rem; color: var(--muted); }
.evidence { list-style: none; padding: 0; margin: 4px 0 8px; }
.evidence li { padding: 7px 0; border-bottom: 1px dotted var(--line); font-size: 0.93rem; }
.evidence li:last-child { border-bottom: 0; }
.evidence .purpose { color: var(--muted); }
.card .links { font-size: 0.92rem; margin: 6px 0 0; }

.loading { display: flex; gap: 12px; align-items: center; color: var(--muted); margin: 24px 0; }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tables (data brief). The wrapper scrolls sideways on narrow phones instead of the page. */
.table-wrap { overflow-x: auto; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  border-top: 2px solid var(--strong-line);
  border-bottom: 2px solid var(--strong-line);
}
th, td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

#funded-box { margin-top: 28px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#funded-box summary { cursor: pointer; }
#funded-box button { margin-top: 16px; }

footer {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 48px;
  padding-top: 16px;
  padding-bottom: 40px;
  border-top: 1px solid var(--line);
  max-width: calc(700px - 32px);
  padding-left: 0;
  padding-right: 0;
}
@media (max-width: 732px) { footer { margin-left: 16px; margin-right: 16px; } }
.disclaimer { color: var(--muted); font-size: 0.92rem; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  h1 { font-size: 1.85rem; }
  .filters { grid-template-columns: 1fr; }
  .card { padding-left: 0; }
  .card .rank { position: static; display: block; font-size: 1rem; margin-bottom: 2px; }
  #find { width: 100%; }
}

/* People who turn off animations in their phone/computer settings: no spinning, no smooth scroll */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  html { scroll-behavior: auto; }
}
