/* =========================================================================
   blocade-proto.css — Civic-Ledger prototype component layer (additive)

   Ports the reusable component primitives from the design prototype
   (`Blocade app design/assets/blocade.css`) into the live app so prototype
   markup renders with full fidelity.

   Two parts:
   1. GLOBAL token aliases — map the prototype's short token names
      (--r, --sh-1, --pos, …) onto the live design-system.css tokens. Safe to
      load globally; they only add aliases and resolve through the live tokens
      (so dark mode follows design-system.css automatically).
   2. SCOPED component primitives — every component rule is prefixed with `.bl`
      so it never clobbers Bootstrap or the already-migrated civic screens.
      A ported screen opts in by rendering inside a `.bl` container
      (e.g. `{% block main_class %}bl{% endblock %}`).
   ========================================================================= */

/* ---- 1. Token aliases (global, additive) -------------------------------- */
:root {
  --r-xs: var(--radius-xs);
  --r-sm: var(--radius-sm);
  --r: var(--radius);
  --r-lg: var(--radius-lg);
  --r-xl: var(--radius-xl);
  --r-pill: var(--radius-pill);

  --sh-1: var(--shadow-xs);
  --sh-2: var(--shadow-sm);
  --sh-3: var(--shadow-lg);
  --sh-gold: 0 6px 22px rgba(232, 163, 61, .30);

  --pos: var(--success);
  --pos-soft: var(--success-soft);
  --neg: var(--danger);
  --neg-soft: var(--danger-soft);
  --warn: var(--warning);
  --warn-soft: var(--warning-soft);

  --speed: .18s;
}

/* ---- 2. Component primitives (scoped under .bl) ------------------------- */
.bl { color: var(--ink); font-family: var(--font-sans); }

/* layout container — mirrors the prototype `.content` */
.bl .content { padding: 28px 32px 80px; max-width: 1280px; width: 100%; margin: 0 auto; }
.bl .content.wide { max-width: 1480px; }

/* typography helpers */
.bl .display, .bl .serif { font-family: var(--font-display); }
.bl .mono, .bl .num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; letter-spacing: -.02em; }
.bl .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.bl .muted { color: var(--ink-2); }
.bl .faint { color: var(--ink-3); }
.bl h1, .bl h2, .bl h3, .bl h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; margin: 0; color: var(--ink); }

/* layout helpers */
.bl .row { display: flex; align-items: center; gap: 12px; }
.bl .between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bl .stack { display: flex; flex-direction: column; }
.bl .wrap-gap { display: flex; flex-wrap: wrap; gap: 10px; }
.bl .spacer { flex: 1; }
.bl .grid { display: grid; gap: 16px; }
.bl .cols-2 { grid-template-columns: repeat(2, 1fr); }
.bl .cols-3 { grid-template-columns: repeat(3, 1fr); }
.bl .cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .bl .cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .bl .cols-2, .bl .cols-3, .bl .cols-4 { grid-template-columns: 1fr; } }

/* page head */
.bl .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.bl .page-head .title { font-size: 26px; font-family: var(--font-display); font-weight: 600; letter-spacing: -.025em; color: var(--ink); }
.bl .page-head .sub { color: var(--ink-2); margin-top: 3px; }

/* buttons */
.bl .btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 8px 15px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  transition: all var(--speed) var(--ease); text-decoration: none; line-height: 1.2; white-space: nowrap; }
.bl .btn svg { width: 16px; height: 16px; }
.bl .btn:active { transform: translateY(.5px); }
.bl .btn-primary { background: var(--ink); color: var(--paper); }
.bl .btn-primary:hover { background: color-mix(in srgb, var(--ink) 88%, var(--blue)); color: var(--paper); }
.bl .btn-blue { background: var(--blue); color: #fff; box-shadow: var(--sh-1); }
.bl .btn-blue:hover { background: var(--blue-press); color: #fff; }
.bl .btn-gold { background: var(--gold-bright); color: #1a1305; box-shadow: var(--sh-gold); }
.bl .btn-gold:hover { filter: brightness(1.05); color: #1a1305; }
.bl .btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.bl .btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.bl .btn-sm { padding: 5px 11px; font-size: 12.5px; }
.bl .btn-lg { padding: 12px 22px; font-size: 15px; border-radius: var(--r); }
.bl .btn[disabled], .bl .btn:disabled { opacity: .55; cursor: not-allowed; }

/* cards */
.bl .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.bl .card-pad { padding: 20px 22px; }
.bl .card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.bl .card-head h3 { font-size: 15px; }

/* stat tiles */
.bl .stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--sh-1); position: relative; overflow: hidden; }
.bl .stat .label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; display: flex; align-items: center; gap: 7px; }
.bl .stat .value { font-family: var(--font-mono); font-weight: 600; font-size: 30px; letter-spacing: -.03em; margin-top: 8px; line-height: 1; color: var(--ink); }
.bl .stat .delta { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; margin-top: 8px; display: inline-flex; align-items: center; gap: 5px; }
.bl .delta.up { color: var(--pos); }
.bl .delta.down { color: var(--neg); }
.bl .stat.gold { background: linear-gradient(180deg, var(--gold-soft), var(--surface)); border-color: var(--gold-line); }
.bl .stat.gold .value { color: var(--gold); }

/* pills */
.bl .pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 3px 9px; border-radius: var(--r-pill); letter-spacing: .01em; }
.bl .pill.blue { background: var(--blue-soft); color: var(--blue-ink); }
.bl .pill.gold { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-line); }
.bl .pill.pos { background: var(--pos-soft); color: var(--pos); }
.bl .pill.neg { background: var(--neg-soft); color: var(--neg); }
.bl .pill.warn { background: var(--warn-soft); color: var(--warn); }
.bl .pill.neutral { background: var(--surface-2); color: var(--ink-2); }
.bl .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; flex: none; }

/* tables */
.bl .table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto hidden; box-shadow: var(--sh-1); }
.bl .tbl { width: 100%; border-collapse: collapse; }
.bl .tbl thead th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.bl .tbl tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.bl .tbl tbody tr { transition: background var(--speed) var(--ease); }
.bl .tbl tbody tr:hover { background: var(--surface-2); }
.bl .tbl tbody tr:last-child td { border-bottom: none; }
.bl .tbl .num { text-align: right; }
.bl .tbl a.name { color: var(--ink); font-weight: 600; }
.bl .tbl a.name:hover { color: var(--blue); }
.bl .tbl th.num { text-align: right; }

/* avatar */
.bl .avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; background: linear-gradient(135deg, var(--blue), #5a6cf0); }
.bl .avatar.gold { background: linear-gradient(135deg, var(--gold-bright), #c9821f); color: #2a1d06; }

/* form fields */
.bl .field { width: 100%; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 9px 12px; transition: all var(--speed) var(--ease); }
.bl .field:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.bl .field.mono { font-family: var(--font-mono); }
.bl textarea.field { resize: vertical; min-height: 72px; }
.bl select.field { cursor: pointer; }

/* reveal / pop animation (pure CSS, no JS needed) */
@keyframes bl-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bl-pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.bl .reveal { animation: bl-rise .5s var(--ease) both; }
.bl .reveal:nth-child(1) { animation-delay: .02s; }
.bl .reveal:nth-child(2) { animation-delay: .06s; }
.bl .reveal:nth-child(3) { animation-delay: .10s; }
.bl .reveal:nth-child(4) { animation-delay: .14s; }
.bl .reveal:nth-child(5) { animation-delay: .18s; }
.bl .reveal:nth-child(6) { animation-delay: .22s; }
.bl .pop { animation: bl-pop .4s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { .bl .reveal, .bl .pop { animation: none; } }

/* keep flex/grid children from overflowing */
.bl .content, .bl .grid > *, .bl .stat, .bl .card, .bl .table-wrap, .bl .stack { min-width: 0; }

/* ── wizard stepper (Import, and any multi-step flow) ─────────────────────── */
.bl .steps { display:flex; align-items:center; gap:0; margin-bottom:22px; }
.bl .step { display:flex; align-items:center; gap:10px; flex:1; }
.bl .step .num { width:28px; height:28px; border-radius:50%; flex:none; display:flex; align-items:center; justify-content:center; font-family:var(--font-mono); font-weight:600; font-size:13px; background:var(--surface-2); color:var(--ink-3); border:1px solid var(--line-2); }
.bl .step .st-txt b { font-size:13.5px; font-weight:650; display:block; line-height:1.2; color:var(--ink-2); }
.bl .step .st-txt span { font-size:11.5px; color:var(--ink-3); }
.bl .step.on .num { background:var(--blue); color:#fff; border-color:var(--blue); }
.bl .step.done .num { background:var(--pos-soft); color:var(--pos); border-color:var(--pos); }
.bl .step.on .st-txt b { color:var(--ink); }
.bl .step .bar { flex:1; height:2px; background:var(--line); margin:0 14px; border-radius:2px; }
.bl .step.done .bar { background:var(--pos); }
@media (max-width:680px){ .bl .step .st-txt { display:none; } .bl .step .bar { margin:0 8px; } }

/* ── topbar theme toggle: show one icon per theme (no JS innerHTML) ───────── */
.theme-toggle .th-sun { display: none; }
[data-theme="dark"] .theme-toggle .th-moon { display: none; }
[data-theme="dark"] .theme-toggle .th-sun { display: inline; }
.cmdk-empty { padding: 24px 16px; text-align: center; color: var(--ink-3, #6e6d77); font-size: 13px; }

/* ── Collapsible nav sections (Fundraise / Finance) ─────────────────────────
   The section label is a toggle; its items live in a .nav-group that collapses
   via the grid-rows trick (smooth without measuring heights). Icon-only
   sidebar mode hides headers, so groups stay expanded there. */
.nav-section-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; background: none; border: none; cursor: pointer; text-align: left;
  font-family: inherit; font-size: 10.5px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3); padding: 14px 10px 6px;
}
.nav-section-toggle:hover { color: var(--ink-2); }
.nav-sec-chev { width: 12px; height: 12px; flex: none; opacity: .7; transition: transform .2s var(--ease); }
.nav-section-toggle[aria-expanded="false"] .nav-sec-chev { transform: rotate(-90deg); }
.nav-group { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .22s var(--ease); }
.nav-group.collapsed { grid-template-rows: 0fr; }
.nav-group-inner { overflow: hidden; min-width: 0; display: flex; flex-direction: column; }
.app.nav-collapsed .nav-section-toggle { display: none; }
.app.nav-collapsed .nav-group, .app.nav-collapsed .nav-group.collapsed { grid-template-rows: 1fr; }
