/* NoProfits Grant Flow Network — site layer over the shared noprofits theme.
   noprofits-theme.css (loaded first) owns the palette, fonts, and chrome tokens;
   this file only maps the app's own token names onto the theme and re-skins the
   three-pane tool. Dark mode is inherited: every app token below resolves to a
   theme token that already flips under [data-theme="dark"], so there is no
   separate dark block here. */

:root {
  /* --accent is intentionally NOT redefined — it inherits the theme's sky
     accent so focus nodes / primary buttons track the rest of the suite. */
  --bg: var(--cream);            /* app page base (mostly covered by panels) */
  --panel: var(--offwhite);      /* rails, inspector, toolbar, statusbar */
  --canvas: var(--sky-tint);     /* graph area — a cool wash, distinct from cream panels */
  --fg: var(--text);
  --fg-soft: var(--slate);
  --fg-faint: var(--faint);
  --line: var(--border);
  --line2: var(--border-strong);
  --rule: var(--border-strong);  /* input / search-field border */
  --accent-text: var(--accent-deep);
  --chip-bg: var(--sky-tint);
  --alert: var(--req);           /* taxpayer/govt register — terracotta, AA in both themes */
  --alert-bg: color-mix(in srgb, var(--terracotta) 18%, var(--offwhite));

  /* graph renderer role colors — single source of truth for flow-graph.js.
     getComputedStyle substitutes these var() refs to concrete colors, which the
     renderer needs because SVG fill/stroke attributes can't take var(). */
  --grantee: var(--sky-soft);        /* recipient node fill (pale sky / deep sky in dark) */
  --grantee-stroke: var(--sky-mid);  /* recipient node stroke */
  --edge: var(--border-strong);      /* flow edges — quiet neutral register */
  /* Edge amount pills: high-contrast ink chip with near-white text (~14:1) so
     $X.YM figures read at a glance over any edge, in both themes. */
  --edge-label-bg: var(--ink);
  --edge-label-fg: #F4F1EA;
  /* Node name labels: full-strength text + a canvas-colored halo painted
     behind the glyphs (paint-order:stroke) so names stay crisp crossing edges. */
  --node-label: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--fg);
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
* { transition: background-color .28s ease, border-color .28s ease, color .18s ease; }
a { text-decoration: none; color: inherit; }
input[type=range] { accent-color: var(--accent); width: 100%; }
input[type=checkbox] { accent-color: var(--accent); }
::selection { background: var(--sky-soft); }

/* font helpers */
.mono { font-family: 'JetBrains Mono', monospace; }
.lbl  { font-family: 'Hanken Grotesk', sans-serif; font-weight: 700; text-transform: uppercase;
        font-size: 12px; letter-spacing: 0.08em; color: var(--accent-text); }

/* ---------- masthead (np-header chrome over the app's flex shell) ---------- */
header.masthead {
  flex-shrink: 0; height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: var(--header-veil);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); }
.mast-right { display: flex; align-items: center; gap: 16px; }
.impact { display: flex; align-items: center; gap: 8px; background: var(--alert-bg);
  border: 1px solid var(--alert); border-radius: 999px; padding: 4px 12px; }
.impact .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--alert); }
.impact .k { font-family: 'Hanken Grotesk', sans-serif; font-weight: 700; text-transform: uppercase;
  font-size: 11px; letter-spacing: .08em; color: var(--alert); }
.impact .v { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 12px; color: var(--fg); }
.src { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--fg-faint); letter-spacing: .04em;
  border-left: 1px solid var(--line2); padding-left: 14px; }
.theme-btn { width: 36px; height: 36px; border: 1px solid var(--line2); border-radius: 10px;
  background: var(--white); color: var(--fg); cursor: pointer; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0; flex: none; }

/* ---------- workspace ---------- */
.workspace { flex: 1; display: grid; grid-template-columns: 300px 1fr 348px; min-height: 0; }
aside.rail { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
aside.inspector { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; }
.section { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.section .hdr { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section .hdr .sq { width: 9px; height: 9px; border-radius: 3px; background: var(--accent); display: inline-block; }
.section .hdr .t { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700;
  font-size: 15px; letter-spacing: -0.01em; color: var(--fg); }

.searchbox { display: flex; align-items: center; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--white); overflow: hidden; }
.searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(47, 125, 163, 0.16); }
.searchbox .ic { display: flex; align-items: center; padding: 0 11px; color: var(--fg-faint); }
.searchbox input { flex: 1; border: none; outline: none; background: transparent; color: var(--fg);
  font-family: inherit; font-size: 16px; padding: 11px 4px; min-width: 0; }
.match-list { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line2); border-radius: 10px;
  max-height: 140px; overflow-y: auto; background: var(--white); }
.match-list li { padding: 8px 11px; font-size: 13px; color: var(--fg); cursor: pointer; border-bottom: 1px solid var(--line); }
.match-list li:last-child { border-bottom: none; }
.match-list li:hover { background: var(--chip-bg); }

.row-between { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.val { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px; color: var(--accent-text); }
.range-ends { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--fg-faint); margin-top: 4px; }
.years { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.years label { font-size: 13px; color: var(--fg); display: flex; align-items: center; gap: 6px; }

.seg { display: flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; text-align: center; font-family: 'Hanken Grotesk', sans-serif; font-weight: 600;
  font-size: 13px; padding: 9px 0; cursor: pointer; background: transparent; color: var(--fg-soft); border: none; }
.seg button.on { background: var(--accent); color: var(--on-accent); }

/* primary action — the theme's np-btn-primary voice */
.btn-accent { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--on-accent); font-family: inherit; font-weight: 600;
  font-size: 16px; padding: 13px 18px; min-height: 48px; cursor: pointer; border: none; border-radius: 12px;
  box-shadow: 0 8px 20px -8px rgba(20, 63, 51, 0.55); }
.btn-accent:disabled { opacity: .5; cursor: default; box-shadow: none; }
/* secondary action — the theme's np-btn-secondary voice */
.btn-ghost { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--white); border: 1px solid var(--line2); color: var(--fg); font-family: inherit;
  font-weight: 600; font-size: 15px; padding: 12px; min-height: 44px; cursor: pointer; border-radius: 12px; }
.btn-ghost:disabled { opacity: .5; cursor: default; }

.legend { display: flex; flex-direction: column; gap: 10px; }
.legend .item { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--fg-soft); }
.legend .swatch { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; }
.legend .ringsw { width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--alert); flex-shrink: 0; }

/* ---------- canvas ---------- */
section.canvas { background: var(--canvas); display: flex; flex-direction: column; min-width: 0; position: relative; }
.toolbar { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.toolbar .focus-chip { font-family: 'Hanken Grotesk', sans-serif; font-weight: 600; font-size: 12.5px;
  color: var(--on-accent); background: var(--accent); padding: 5px 12px; border-radius: 999px; }
.tool-btns { display: flex; align-items: center; gap: 6px; }
.tool-btns .tb { height: 34px; min-width: 34px; border: 1px solid var(--line2); border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 12px; color: var(--fg-soft);
  cursor: pointer; background: var(--white); font-family: 'Hanken Grotesk', sans-serif; font-weight: 600; font-size: 13px; }
.tool-btns .tb:hover { color: var(--fg); border-color: var(--accent); }
.tool-btns .tb.mono { font-family: 'JetBrains Mono', monospace; font-size: 16px; }
#network { flex: 1; min-height: 0; width: 100%; display: block; }
.statusbar { flex-shrink: 0; display: flex; align-items: center; gap: 22px; padding: 10px 18px;
  border-top: 1px solid var(--line); background: var(--panel); font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--fg-faint); letter-spacing: .02em; }
.statusbar b { color: var(--fg-soft); font-weight: 600; }
.statusbar .impact-count { margin-left: auto; color: var(--alert); }

.canvas-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 12px; pointer-events: none; padding: 0 40px; }
.canvas-hint h1 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 38px;
  line-height: 1.05; letter-spacing: -0.02em; color: var(--fg); margin: 0; text-wrap: balance; }
.canvas-hint p { font-family: 'Hanken Grotesk', sans-serif; font-size: 16px; color: var(--fg-soft);
  margin: 0; max-width: 520px; line-height: 1.55; }

/* ---------- inspector ---------- */
.insp-head { padding: 22px 22px 18px; border-bottom: 1px solid var(--line); }
.role-chip { font-family: 'Hanken Grotesk', sans-serif; font-weight: 700; text-transform: uppercase;
  font-size: 11px; letter-spacing: .08em; color: var(--accent-text); background: var(--chip-bg);
  padding: 4px 10px; display: inline-block; border-radius: 999px; margin-bottom: 11px; }
.insp-name { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 26px; line-height: 1.08;
  letter-spacing: -0.02em; color: var(--fg); margin: 0; }
.insp-sub { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--fg-faint); margin-top: 8px; word-break: break-all; }
.insp-sub.insp-match { color: var(--alert); margin-top: 5px; }
.alert-box { margin: 18px 22px 0; background: var(--alert-bg); border-left: 3px solid var(--alert);
  border-radius: 0 12px 12px 0; padding: 13px 15px; }
.alert-box .ah { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.alert-box .ah .sq { width: 8px; height: 8px; border-radius: 2px; background: var(--alert); display: inline-block; }
.alert-box .ah .t { font-family: 'Hanken Grotesk', sans-serif; font-weight: 700; text-transform: uppercase;
  font-size: 11.5px; letter-spacing: .06em; color: var(--alert); }
.alert-box .body { font-size: 13px; line-height: 1.5; color: var(--fg-soft); }
.stats { padding: 14px 22px 4px; }
.stat { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: none; }
.stat .k { font-size: 13px; color: var(--fg-soft); }
.stat .k .field { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--fg-faint); }
.stat .v { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 14px; color: var(--fg); }
.flow-group { padding: 14px 22px 4px; }
.flow-group .gh { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.flow-group .gh .t { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 14px; color: var(--fg); }
.flow-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.flow-row .n { font-size: 13px; color: var(--fg); cursor: pointer; display: flex; align-items: center; gap: 7px; }
.flow-row .n .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.flow-row .n:hover { color: var(--accent); }
.flow-row .a { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--fg); white-space: nowrap; }
.insp-actions { padding: 16px 22px 26px; display: flex; flex-direction: column; gap: 9px; }
.insp-empty { padding: 40px 22px; color: var(--fg-faint); font-size: 13px; text-align: center; }

/* ---------- narrow viewports: stack the three panes so the tool stays usable
   and never forces horizontal scroll (the graph keeps a workable height). ---- */
@media (max-width: 860px) {
  body { overflow: auto; }
  .workspace { display: flex; flex-direction: column; min-height: 0; }
  aside.rail { border-right: none; border-bottom: 1px solid var(--line); }
  aside.inspector { border-left: none; border-top: 1px solid var(--line); }
  section.canvas { min-height: 60vh; }
  header.masthead { padding: 0 16px; }
  .src { display: none; }
}
