/* GrantGather — one stylesheet for the whole site.
   Idea: a volunteer's printed grant list, deadlines swiped with a yellow highlighter. */

:root {
  --paper: #ffffff;
  --panel: #f5f7fa;
  --ink: #1d2433;
  --muted: #5b6475;
  --rule: #e1e5ec;
  --link: #1f4fa3;
  --marker: #ffe27a;
  --good: #2f6b4f;
  --maybe: #8a5a00;
  --unlikely: #6b7280;
  --focus: #1f4fa3;
  --danger: #a1262b;
  --radius: 6px;
  --measure: 44rem;
  --font: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #14171c;
    --panel: #1c2027;
    --ink: #e9ecf1;
    --muted: #a3abb9;
    --rule: #2c323c;
    --link: #8fb4ff;
    --marker: rgba(255, 214, 90, 0.34);
    --good: #7fcaa3;
    --maybe: #e7b25a;
    --unlikely: #9aa3b2;
    --focus: #8fb4ff;
    --danger: #ff8a8f;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --paper: #14171c; --panel: #1c2027; --ink: #e9ecf1; --muted: #a3abb9; --rule: #2c323c;
  --link: #8fb4ff; --marker: rgba(255, 214, 90, 0.34); --good: #7fcaa3; --maybe: #e7b25a;
  --unlikely: #9aa3b2; --focus: #8fb4ff; --danger: #ff8a8f; color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 1rem; }
.measure { max-width: var(--measure); }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }

/* Header */
.site-head { border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; flex-wrap: wrap; }
.wordmark { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 0.5rem; }
.wordmark svg { width: 1.6rem; height: 1.6rem; }
.site-nav { display: flex; gap: 1.25rem; font-size: 0.975rem; }
.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current='page'] { text-decoration: underline; }

/* Type scale (perfect fourth-ish) */
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.6em; }
h1 { font-size: clamp(2rem, 1.3rem + 3vw, 3.25rem); font-weight: 800; }
h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.85rem); font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 38rem; }
.small { font-size: 0.9rem; color: var(--muted); }

main { padding: 2.5rem 0 4rem; }
section + section { margin-top: 3.5rem; }

/* The highlighter: used only for deadlines. */
.due {
  font-weight: 700;
  background-image: linear-gradient(100deg, transparent 0.15em, var(--marker) 0.25em, var(--marker) calc(100% - 0.2em), transparent calc(100% - 0.1em));
  background-size: 100% 62%;
  background-position: 0 72%;
  background-repeat: no-repeat;
  padding: 0 0.3em;
  margin: 0 -0.1em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.due.soon { color: var(--danger); }
.closed .due { background-image: none; text-decoration: line-through; font-weight: 400; }

/* Hero */
.hero { padding: 1.5rem 0 0.5rem; }
.hero h1 { max-width: 15em; }
.tally { margin-top: 1.25rem; font-size: 1.05rem; max-width: 38rem; }
.tally strong { font-variant-numeric: tabular-nums; }

/* Signup */
.signup { margin-top: 1.75rem; max-width: 34rem; }
.signup label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.signup .row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.signup input[type='email'] {
  flex: 1 1 15rem; min-width: 0; font: inherit; padding: 0.7rem 0.85rem;
  border: 2px solid var(--ink); border-radius: var(--radius); background: var(--paper); color: var(--ink);
}
.btn {
  font: inherit; font-weight: 700; cursor: pointer; display: inline-block; text-decoration: none;
  padding: 0.7rem 1.15rem; border-radius: var(--radius); border: 2px solid var(--ink);
  background: var(--ink); color: var(--paper);
}
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: transparent; color: var(--ink); }
.signup .note { margin-top: 0.5rem; font-size: 0.9rem; color: var(--muted); }
.signup .msg { margin-top: 0.75rem; font-weight: 700; }
.signup .msg[data-kind='error'] { color: var(--danger); }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

.signup-box { border: 2px solid var(--ink); border-radius: var(--radius); padding: 1.25rem 1.25rem 1rem; margin-top: 3rem; max-width: var(--measure); }
.signup-box h2 { font-size: 1.35rem; margin-bottom: 0.35rem; }
.signup-box .signup { margin-top: 0.75rem; }

/* Grant list: rows, not cards */
.grant-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.grant-list > li { border-bottom: 1px solid var(--rule); padding: 1.1rem 0 1.15rem; }
.grant-list h3 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.grant-list h3 a { color: var(--ink); text-decoration: none; }
.grant-list h3 a:hover { color: var(--link); text-decoration: underline; }
.grant-list .agency { color: var(--muted); font-size: 0.95rem; margin: 0 0 0.45rem; }
.grant-list .blurb { margin: 0.4rem 0 0; max-width: var(--measure); }
.facts-inline { display: flex; flex-wrap: wrap; gap: 0.35rem 1.4rem; font-size: 0.975rem; margin: 0; }
.facts-inline > span { white-space: nowrap; }

.fit { font-weight: 700; }
.fit-good { color: var(--good); }
.fit-maybe { color: var(--maybe); }
.fit-unlikely { color: var(--unlikely); }
.fit::before { content: ''; display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; background: currentColor; margin-right: 0.4em; vertical-align: 0.05em; }

.more { margin-top: 1rem; }

/* Topics */
.topic-list { list-style: none; padding: 0; margin: 0; columns: 2 16rem; column-gap: 2.5rem; }
.topic-list li { break-inside: avoid; padding: 0.4rem 0; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 1rem; }
.topic-list .count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Grant page */
.crumbs { font-size: 0.925rem; color: var(--muted); margin-bottom: 1rem; }
.crumbs a { color: var(--muted); }
.grant-head .agency { color: var(--muted); font-size: 1.05rem; margin-top: -0.2rem; }
.status-banner { border-left: 4px solid var(--danger); background: var(--panel); padding: 0.85rem 1rem; margin: 1rem 0 1.5rem; max-width: var(--measure); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0; margin: 1.75rem 0 2.25rem; border: 1px solid var(--rule); border-radius: var(--radius); }
.facts > div { padding: 0.9rem 1rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin-right: -1px; margin-bottom: -1px; }
.facts dt { font-size: 0.875rem; color: var(--muted); margin-bottom: 0.15rem; }
.facts dd { margin: 0; font-size: 1.1rem; font-weight: 700; }
.facts dd .sub { display: block; font-size: 0.875rem; font-weight: 400; color: var(--muted); }

.plain { max-width: var(--measure); }
.plain .summary { font-size: 1.2rem; line-height: 1.55; }
.plain ul { padding-left: 1.2rem; margin: 0 0 1.25rem; }
.plain li { margin-bottom: 0.3rem; }
.ai-note { font-size: 0.875rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 0.75rem; margin-top: 1.5rem; }
.pending { background: var(--panel); border-radius: var(--radius); padding: 1rem 1.1rem; max-width: var(--measure); }

.official { max-width: var(--measure); }
.official .desc { white-space: pre-line; }
.official details { margin: 0.5rem 0 1.25rem; }
.official summary { cursor: pointer; color: var(--link); font-weight: 700; }
.official dl { display: grid; grid-template-columns: 9rem 1fr; gap: 0.4rem 1rem; margin: 0 0 1.25rem; }
.official dt { color: var(--muted); }
.official dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.25rem 0; }

/* Browse page filters */
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: end; margin: 0 0 1.25rem; padding: 1rem; background: var(--panel); border-radius: var(--radius); }
.filters label { display: flex; flex-direction: column; font-size: 0.9rem; font-weight: 700; gap: 0.25rem; }
.filters input[type='search'], .filters select { font: inherit; font-weight: 400; padding: 0.5rem 0.6rem; border: 1px solid var(--muted); border-radius: var(--radius); background: var(--paper); color: var(--ink); min-width: 13rem; }
.filters .check { flex-direction: row; align-items: center; gap: 0.45rem; font-weight: 400; padding-bottom: 0.55rem; }
.filters .check input { width: 1.1rem; height: 1.1rem; }
.result-count { font-size: 0.95rem; color: var(--muted); margin: 0 0 0.5rem; }

/* Prose pages */
.prose { max-width: var(--measure); }
.prose h2 { margin-top: 2rem; font-size: 1.4rem; }

/* Footer */
.site-foot { border-top: 1px solid var(--rule); padding: 2rem 0 3rem; font-size: 0.9rem; color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: 1rem; }
.site-foot a { color: var(--muted); }
.site-foot p { max-width: var(--measure); }

@media (max-width: 40rem) {
  body { font-size: 1rem; }
  main { padding-top: 1.75rem; }
  .site-nav { gap: 1rem; }
  .official dl { grid-template-columns: 1fr; }
  .official dt { margin-top: 0.4rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero .due { animation: swipe 700ms 250ms ease-out both; }
  @keyframes swipe { from { background-size: 0% 62%; } to { background-size: 100% 62%; } }
}

@media print {
  .site-head nav, .signup, .signup-box, .site-foot nav, .filters { display: none; }
  .due { background: none; text-decoration: underline; }
}

@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/atkinson-hyperlegible-next-latin-800-normal.woff2') format('woff2'); }
