/* Dig Deep — Grants Intelligence Hub
   Aesthetic: civic-infrastructure field journal. Warm paper ground, deep teal/slate ink,
   a characterful serif for display + a clean grotesque for data. Color-coded status. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,900&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper:        #f4f0e6;
  --paper-2:      #ebe5d6;
  --ink:          #16302f;   /* deep teal-slate */
  --ink-soft:     #43605d;
  --line:         #c9bfa8;
  --accent:       #0d6e64;   /* water teal */
  --accent-deep:  #084b44;
  --gold:         #b0792a;

  /* canonical status colors */
  --st-open:       #1f7a4d;
  --st-closed:     #a13a2e;
  --st-upcoming:   #2c5d99;
  --st-suspended:  #b0792a;
  --st-unverified: #7d7866;

  --shadow: 0 1px 0 #fff8, 0 2px 14px -6px #16302f44;
  --radius: 3px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #ffffff66, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 27px, #16302f08 27px 28px),
    var(--paper);
  line-height: 1.5;
}

a { color: var(--accent-deep); }

/* ---- Masthead ---- */
.masthead {
  border-bottom: 2px solid var(--ink);
  padding: 22px 28px 16px;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  background: linear-gradient(180deg, #fffefb55, transparent);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand .mark {
  font-family: 'Fraunces', serif; font-weight: 900; font-size: 2.1rem;
  letter-spacing: -.02em; line-height: .9; color: var(--ink);
}
.brand .mark em { color: var(--accent); font-style: normal; }
.brand .sub {
  font-family: 'IBM Plex Mono', monospace; font-size: .68rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-soft);
  border-left: 1px solid var(--line); padding-left: 12px;
}
.masthead nav { display: flex; gap: 6px; }
.masthead nav a {
  font-family: 'IBM Plex Mono', monospace; font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; text-decoration: none; color: var(--ink);
  padding: 7px 13px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff7; transition: all .15s;
}
.masthead nav a:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.masthead nav a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.wrap { padding: 22px 28px 64px; max-width: 1280px; margin: 0 auto; }

/* ---- Controls / filters ---- */
.controls {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px;
  margin-bottom: 18px; align-items: end;
}
/* Search spans the full width on its own row. */
.search-row { margin-bottom: 12px; }
.search-row .field { width: 100%; }
/* Filters sit in one row under the search, wrapping to a second row if needed. Each box is sized
   to fit its widest option's full text (incl. when the dropdown is open) rather than a fixed grid
   column. */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px 14px;
  margin-bottom: 18px; align-items: end;
}
/* Each filter is wide enough to show its longest option's full text (no clipping in the closed box),
   with a comfortable minimum. The row wraps to a second line if the filters don't all fit. */
.filters .field { flex: 0 0 auto; min-width: 160px; }
.filters select { width: 100%; }
/* Filters whose options run longer than the default (funder type "Local/Tribal", full state names)
   get extra room so the selected value is never cut off. */
.filters .field:has(#funderType),
.filters .field:has(#location) { min-width: 185px; }
.field label {
  display: block; font-family: 'IBM Plex Mono', monospace; font-size: .62rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 4px;
}
input, select, textarea {
  width: 100%; font-family: inherit; font-size: .92rem; color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #0d6e6422;
}
.toggle { display: flex; align-items: center; gap: 7px; padding-bottom: 9px; }
.toggle input { width: auto; }

.count {
  font-family: 'IBM Plex Mono', monospace; font-size: .74rem; letter-spacing: .06em;
  color: var(--ink-soft); margin: 4px 2px 14px;
}
.count b { color: var(--ink); }

/* ---- Status chip ---- */
.chip {
  display: inline-block; font-family: 'IBM Plex Mono', monospace; font-size: .66rem;
  font-weight: 500; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--chip, #777); padding: 3px 8px; border-radius: 2px; white-space: nowrap;
}

/* ---- Grant cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card {
  background: linear-gradient(180deg, #fffefb, #fcfaf3);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 9px; position: relative;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px -10px #16302f55; }
.card.featured { border-left: 3px solid var(--gold); }
.card .top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.card h3 {
  margin: 0; font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.06rem;
  letter-spacing: -.01em; line-height: 1.2;
}
.card .agency { font-size: .8rem; color: var(--ink-soft); }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .76rem; color: var(--ink-soft); margin-top: 2px; }
.card .meta b { color: var(--ink); font-weight: 500; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.card .tag {
  font-family: 'IBM Plex Mono', monospace; font-size: .6rem; letter-spacing: .04em;
  color: var(--accent-deep); background: #0d6e6414; border: 1px solid #0d6e6433;
  padding: 1px 6px; border-radius: 10px;
}
.card .actions { margin-top: auto; padding-top: 8px; display: flex; gap: 8px; border-top: 1px dotted var(--line); }
.card .actions a { font-family: 'IBM Plex Mono', monospace; font-size: .68rem; letter-spacing: .04em; text-decoration: none; }
.fund-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: .58rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 2px;
}

/* ---- Entry form ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; max-width: 920px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { font-family: 'IBM Plex Mono', monospace; font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); display: block; margin-bottom: 5px; }
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; align-items: center; }
.btn {
  font-family: 'IBM Plex Mono', monospace; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  padding: 11px 20px; border-radius: var(--radius); cursor: pointer; transition: all .15s;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { background: transparent; color: var(--st-closed); border-color: var(--st-closed); }
.btn.danger:hover { background: var(--st-closed); color: #fff; }

/* ---- Auth bar ---- */
.authbar { margin-bottom: 18px; }
.authbar > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(180deg, #fffefb, #fcfaf3); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; }
.auth-note { font-size: .88rem; color: var(--ink-soft); }
.auth-note b { color: var(--ink); }
.authbar input { max-width: 280px; }

/* ---- States ---- */
.state { padding: 48px 20px; text-align: center; color: var(--ink-soft); font-family: 'IBM Plex Mono', monospace; font-size: .82rem; }
.banner {
  border: 1px solid; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
  font-size: .88rem; display: none;
}
.banner.show { display: block; }
.banner.err { border-color: var(--st-closed); background: #a13a2e12; color: #6e251c; }
.banner.ok  { border-color: var(--st-open);   background: #1f7a4d12; color: #16302f; }

@media (max-width: 760px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .filters .field { flex: 1 1 100%; min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .brand .mark { font-size: 1.6rem; }
}

/* ── Candidate Review Queue (review.html) ───────────────────────────────── */
.review-tally { display: flex; gap: 10px; margin: 2px 2px 14px; flex-wrap: wrap; }
.review-tally .t {
  font-size: .76rem; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fffdf8; color: var(--ink-soft);
}
.review-tally .t b { color: var(--ink); font-size: .9rem; }
.review-tally .t.pending  { border-left: 3px solid var(--accent); }
.review-tally .t.approved { border-left: 3px solid var(--st-open); }
.review-tally .t.rejected { border-left: 3px solid var(--st-closed); }

.card.cand .fitwrap { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.fitscore { font-family: 'IBM Plex Mono', monospace; font-size: 1.35rem; font-weight: 600; color: var(--ink); line-height: 1; }
.fitscore small { font-size: .7rem; color: var(--ink-soft); font-weight: 400; }
.fitchip {
  font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; color: #fff;
}
.fit-strong   { background: var(--st-open); }
.fit-possible { background: var(--accent); }
.fit-weak     { background: var(--st-unverified); }
.fit-none     { background: #b8b1a0; }

.card.cand .summary { font-size: .85rem; color: var(--ink-soft); margin: 8px 0 2px; line-height: 1.45; }
.card.cand .src  { font-family: 'IBM Plex Mono', monospace; font-size: .7rem; color: var(--ink-soft); }
.card.cand .conf { font-size: .7rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); }
.conf-high   { color: var(--st-open); border-color: var(--st-open); }
.conf-medium { color: var(--gold); border-color: var(--gold); }
.conf-low    { color: var(--st-closed); border-color: var(--st-closed); }
.meta-note   { font-family: 'IBM Plex Mono', monospace; font-size: .72rem; color: var(--accent-deep); }

/* fit breakdown (the transparency disclosure) */
.fitbreak { margin: 8px 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fffdf8; }
.fitbreak > summary {
  cursor: pointer; padding: 6px 10px; font-size: .76rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-soft); user-select: none;
}
.fitbreak[open] > summary { border-bottom: 1px solid var(--line); }
.fb-row { padding: 7px 10px; border-bottom: 1px dashed var(--line); }
.fb-row:last-child { border-bottom: none; }
.fb-head { display: flex; justify-content: space-between; font-size: .78rem; }
.fb-name { text-transform: capitalize; font-weight: 600; color: var(--ink); }
.fb-pts  { font-family: 'IBM Plex Mono', monospace; color: var(--ink-soft); }
.fb-bar  { height: 5px; background: var(--paper-2); border-radius: 999px; margin: 4px 0; overflow: hidden; }
.fb-bar > span { display: block; height: 100%; background: var(--accent); }
.fb-why  { font-size: .74rem; color: var(--ink-soft); }
.fb-penalty { padding: 6px 10px; font-size: .74rem; color: var(--st-closed); background: #a13a2e11; }

/* match verdict controls */
.verdict { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; flex-wrap: wrap; }
.verdict .vlabel { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.vbtn {
  font-family: inherit; font-size: .76rem; padding: 3px 9px; cursor: pointer;
  background: #fffdf8; color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
}
.vbtn:hover:not(:disabled) { border-color: var(--accent); }
.vbtn:disabled { opacity: .5; cursor: not-allowed; }
.vbtn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.vbadge { font-size: .68rem; text-transform: uppercase; padding: 1px 7px; border-radius: 999px; color: #fff; }
.vbadge.v-good { background: var(--st-open); }
.vbadge.v-bad  { background: var(--st-closed); }
.vbadge.v-unsure { background: var(--st-unverified); }

/* row actions */
.card.cand .actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.btn.approve { background: var(--st-open); color: #fff; border-color: var(--st-open); }
.btn.approve:hover:not(:disabled) { background: #155f3b; }
.state-tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.state-tag.approved { color: var(--st-open); border-color: var(--st-open); }
.state-tag.rejected { color: var(--st-closed); border-color: var(--st-closed); }

/* ── Funder origin banner (top of each grant/candidate card) ─────────────── */
/* Full-width green header naming where the grant's funding comes from
   ("Federal", "State - Oregon", …). White uppercase letters; sits flush at the
   card's top edge, just taller than the text. */
.funder-banner {
  margin: -16px -16px 12px;            /* pull to the card edges (card has ~16px padding) */
  padding: 6px 14px;
  background: var(--accent);           /* water teal — matches the theme */
  color: #fff;
  font-size: .72rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  border-radius: var(--radius) var(--radius) 0 0;   /* round only the top to match the card */
}
/* Subtle per-type shade so origin reads fast, all in the green/teal family. */
.funder-banner.funderfederal    { background: var(--accent-deep); }   /* deep teal */
.funder-banner.funderstate      { background: var(--accent); }        /* water teal */
.funder-banner.funderlocaltribal{ background: #2f7d54; }              /* green */
.funder-banner.funderprivate    { background: var(--gold); }          /* gold accent */
.funder-banner.funderunverified { background: var(--st-unverified); } /* muted */
/* Featured browse cards keep their gold left-rule; let the banner round flush over it. */
.card.featured .funder-banner { border-top-left-radius: 0; }

/* Expandable summary: first paragraph stays in view (cards keep a uniform collapsed height); the
   rest opens behind an arrow, same disclosure idiom as "Why this score". */
.summary-wrap { margin: 8px 0 2px; }
.summary { font-size: .85rem; color: var(--ink-soft); line-height: 1.45; margin: 0 0 4px; }
.summary-more > summary {
  cursor: pointer; list-style: none; user-select: none;
  font-family: 'IBM Plex Mono', monospace; font-size: .68rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-deep);
}
.summary-more > summary::-webkit-details-marker { display: none; }
.summary-more > summary::before { content: "▸ "; }       /* collapsed arrow */
.summary-more[open] > summary::before { content: "▾ "; }  /* expanded arrow */
.summary-more[open] > summary { margin-bottom: 4px; }
.summary-rest { margin: 0; }

/* Green "Source" button — opens the original posting. Same green family as the funder banner;
   sits on its own line (on review cards, just above the "Why this score" box). */
.source-btn {
  display: inline-block; margin: 8px 0; padding: 5px 12px;
  background: var(--accent); color: #fff !important; text-decoration: none;
  font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  border-radius: var(--radius); border: none;
}
.source-btn:hover { background: var(--accent-deep); }
