/* ASAVEXA "Ledger Paper" visual system (Stage 3).
   One identity for every screen: editorial paper tones, aligned financial figures, rules instead of boxes, and the proof of each figure
   shown beside it in the margin. This file only ADDS tokens and components; it does not restyle existing pages.
   Prefix map:  .fig = a figure   .pm = the margin mark   .pr = the Proof Rail   .stmt = a statement table   .ledger = the page frame.
   Meaning is never carried by colour alone: every state is also a different shape and is spelled out in words. */

/* The one font that could be self-hosted (open licence, see src/fonts/Fraunces-OFL.txt). Weight 600 is what the headings already use.
   Inter and IBM Plex Mono are NOT bundled: the UI and code fonts stay as the system fonts named in design-system.css. */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/fraunces-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Only one upright face exists, so never fake an italic or a bold from it. */
h1, h2, h3, .brand, .rc-title, .pr-title, .fig-xl .fig-amount { font-synthesis: none; }

/* ---- Tokens ------------------------------------------------------------------------------------------------------- */
:root {
  --ledger-paper: #fbf8f1;        /* warm paper, the same tone the landing hero already uses */
  --ledger-rule: #d9d3c4;         /* a ruled line on that paper */
  --ledger-margin: var(--gold-500);
  --t-small: 12.5px; --t-body: 14px; --t-lead: 16px; --t-h3: 16px; --t-h2: 20px; --t-h1: 28px;
  --t-fig-md: 14px; --t-fig-lg: 20px; --t-fig-xl: clamp(28px, 4vw, 40px);
  --mark-pass: var(--status-pass); --mark-warn: var(--status-warn); --mark-fail: var(--status-fail);   /* the existing state colours, re-tuned for dark below */
  --mark-size: 28px;              /* WCAG 2.2 AA asks for at least 24px; this is larger */
  /* The default accent is the ASAVEXA teal. A workspace sets data-sector="..." on its frame to change only this pair. */
  --accent-l: #0b5c56; --accent-d: #5fd3bf;
}
:root, [data-sector] { --accent: var(--accent-l); --on-accent: #ffffff; }
:root[data-theme="dark"] { --ledger-paper: #151b23; --ledger-rule: #2c3542; --mark-pass: #4ec9a0; --mark-warn: #e0b45a; --mark-fail: #f08a82; }
:root[data-theme="dark"], :root[data-theme="dark"] [data-sector] { --accent: var(--accent-d); --on-accent: #10151c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ledger-paper: #151b23; --ledger-rule: #2c3542; --mark-pass: #4ec9a0; --mark-warn: #e0b45a; --mark-fail: #f08a82; }
  :root:not([data-theme="light"]), :root:not([data-theme="light"]) [data-sector] { --accent: var(--accent-d); --on-accent: #10151c; }
}

/* Sector accents: colour is only a "where am I" cue. Each pair is measured by tests/ledger-contrast.test.js (text on paper at 4.5:1 or more). */
[data-sector="accounting"]   { --accent-l: #0b5c56; --accent-d: #5fd3bf; }
[data-sector="procurement"]  { --accent-l: #1f5f8b; --accent-d: #8ec0e6; }
[data-sector="health"]       { --accent-l: #0e6169; --accent-d: #6fd0d8; }
[data-sector="school"]       { --accent-l: #5a4b9b; --accent-d: #b9aef0; }
[data-sector="university"]   { --accent-l: #1f3f7a; --accent-d: #9bb7ec; }
[data-sector="church"]       { --accent-l: #86394d; --accent-d: #f0a9ba; }
[data-sector="ngo"]          { --accent-l: #386a2a; --accent-d: #9fd68c; }
[data-sector="government"]   { --accent-l: #3b4a5f; --accent-d: #b4c3d9; }

/* ---- Numbers: always aligned ------------------------------------------------------------------------------------- */
.num { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum" 1, "lnum" 1; white-space: nowrap; }
.num.neg { color: var(--mark-fail); }   /* the light red on paper, a lighter red on the dark theme */
.num.is-invalid { color: var(--ink-500); }
td.num, th.num { text-align: right; }

/* ---- A figure and its margin mark --------------------------------------------------------------------------------- */
.fig { display: inline-flex; align-items: baseline; gap: 6px; }
.fig-cur { font-size: 0.72em; letter-spacing: 0.06em; color: var(--ink-500); font-weight: 600; }
.fig-md .fig-amount { font-size: var(--t-fig-md); }
.fig-lg .fig-amount { font-size: var(--t-fig-lg); font-weight: 600; }
.fig-xl .fig-amount { font-family: var(--font-display); font-size: var(--t-fig-xl); font-weight: 600; line-height: 1.1; }

.pm {
  align-self: center; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: var(--mark-size); height: var(--mark-size); padding: 0 6px; margin-left: 2px;
  background: transparent; border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  color: var(--ink-700); font: inherit; font-size: 11.5px; font-weight: 700; line-height: 1;
}
.pm:hover { background: var(--paper-100); border-color: var(--line); }
.pm[aria-expanded="true"] { background: var(--paper-100); border-color: var(--accent); }   /* open: the frame changes, the state colour of the glyph must not */
.pm:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pm-glyph { display: block; }
.pm-ring, .pr-ring { fill: none; stroke: currentColor; stroke-width: 1.8; }
.pm-fill, .pr-fill { fill: currentColor; }
.pm-half, .pr-half { fill: currentColor; stroke: none; }
.pm-dash, .pr-dash { stroke-dasharray: 3 2.4; }
.pm-dots, .pr-dots { stroke-dasharray: 0.1 3.2; stroke-linecap: round; stroke-width: 2.2; }
.pm-complete .pm-glyph { color: var(--mark-pass); }
.pm-partial  .pm-glyph { color: var(--mark-warn); }
.pm-none     .pm-glyph { color: var(--mark-fail); }
.pm-unknown  .pm-glyph { color: var(--ink-500); }
.pm-n { font-variant-numeric: tabular-nums; }

/* ---- The Proof Rail ----------------------------------------------------------------------------------------------- */
.pr { background: var(--ledger-paper); border: 1px solid var(--ledger-rule); border-left: 3px solid var(--ledger-margin); border-radius: var(--radius-sm); padding: var(--space-4) var(--space-4) var(--space-3); }
.pr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.pr-title { font-size: var(--t-h3); margin: 0; }
.pr-subject { font-weight: 600; }
.pr-sample { display: inline-block; margin-top: 4px; padding: 1px 8px; border: 1px solid var(--ink-500); border-radius: 999px; font-size: 11.5px; color: var(--ink-700); }
.pr-close { background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink-700); padding: 4px 10px; min-height: 28px; font: inherit; font-size: var(--t-small); cursor: pointer; }
.pr-close:hover { border-color: var(--ink-300); }
.pr-summary { margin: var(--space-2) 0 var(--space-3); font-size: var(--t-small); color: var(--ink-700); }
.pr-steps { list-style: none; margin: 0; padding: 0; position: relative; }
.pr-steps::before { content: ""; position: absolute; left: 9px; top: 12px; bottom: 12px; width: 2px; background: var(--ledger-rule); }
.pr-step { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: var(--space-3); padding: var(--space-2) 0; align-items: start; }
.pr-bead { display: block; position: relative; z-index: 1; background: var(--ledger-paper); border-radius: 50%; color: var(--ink-500); }
.pr-tick { stroke: var(--ledger-paper); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pr-q { fill: currentColor; font-size: 11px; font-weight: 700; font-family: var(--font-ui); }
.pr-step.is-linked .pr-bead { color: var(--mark-pass); }
.pr-step.is-pending .pr-bead { color: var(--mark-warn); }
.pr-step.is-missing .pr-bead { color: var(--mark-fail); }
.pr-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-2); min-width: 0; }
.pr-label { font-size: var(--t-body); }
.pr-state { font-size: var(--t-small); color: var(--ink-700); }
.pr-what, .pr-link { flex-basis: 100%; font-size: var(--t-small); overflow-wrap: anywhere; }
.pr-link { color: var(--accent); }
.pr-meta { flex-basis: 100%; font-size: var(--t-small); color: var(--ink-500); }
.pr-step.is-missing .pr-state { font-weight: 600; }

/* ---- A statement table: rules, not boxes -------------------------------------------------------------------------- */
.stmt { width: 100%; border-collapse: collapse; font-size: var(--t-body); }
.stmt caption { text-align: left; font-family: var(--font-display); font-weight: 600; font-size: var(--t-h2); padding-bottom: var(--space-2); color: var(--ink-900); }
.stmt th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-500); padding: var(--space-2) var(--space-3); border-bottom: 2px solid var(--ink-900); }
.stmt th.num { text-align: right; }
.stmt tbody th[scope="row"] { border-bottom: 1px solid var(--ledger-rule); vertical-align: baseline; }
.stmt td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--ledger-rule); vertical-align: baseline; }
.stmt tr.total td { border-top: 2px solid var(--ink-900); border-bottom: 3px double var(--ink-900); font-weight: 600; }
.stmt tr.sub td { color: var(--ink-700); padding-left: calc(var(--space-3) + 16px); }
.stmt .kind { display: inline-block; margin-left: var(--space-2); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-500); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
.stmt-scroll { overflow-x: auto; }

/* ---- The page frame: the statement, and the proof in the margin ---------------------------------------------------- */
.ledger { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-6); align-items: start; background: var(--ledger-paper); padding: var(--space-5); border: 1px solid var(--ledger-rule); border-radius: var(--radius-md); }
.ledger-main, .ledger-margin { min-width: 0; }   /* lets a wide table scroll inside its own box instead of stretching the page */
.ledger-margin { position: sticky; top: var(--space-4); }
.ledger-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin: 0 0 var(--space-2); }
@media (max-width: 900px) {
  .ledger { grid-template-columns: minmax(0, 1fr); padding: var(--space-4); gap: var(--space-4); }
  .ledger-margin { position: static; }
}

/* ---- Motion and forced colours ------------------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) { .pm { transition: none; } }
@media (forced-colors: active) {
  .pm, .pr, .pr-close { border-color: CanvasText; }
  .pm[aria-expanded="true"] { border-color: Highlight; }
  .pr-steps::before { background: CanvasText; }
  .pm-ring, .pr-ring { stroke: CanvasText; }
  .pm-fill, .pr-fill, .pm-half, .pr-half { fill: CanvasText; }
}

/* ---- The shell, in the sector's accent (Stage 4). Only the "where am I" cue changes; wording and shape carry the meaning. ---- */
.app-shell .nav-link.active { box-shadow: inset 3px 0 0 var(--accent-d); }
.hm .ledger-eyebrow { margin-bottom: var(--space-1); }
.hm-attention { border-left: 3px solid var(--accent); }
.hm-attn-item { border-bottom: 1px solid var(--ledger-rule); }
.card + .pr, .pr + .card { margin-top: var(--space-4); }   /* a proof panel between cards on a report page */
