/*
 * FairOffer design tokens — themes the admin console chooses between (UX/BRAND_AND_DESIGN_SYSTEM.md):
 *   ledger — 0.24.0 default (PRODUCT/POSITIONING.md): warm paper, ink, cobalt actions, a dark hero card,
 *            hairline-ringed cards, IBM Plex type
 *   calm   — warm white, deep green, borderless cards (0.21.0 default)
 *   night  — dark, periwinkle actions, mint figures
 *   indigo — the brand indigo, brighter, with a filled hero card
 *   auto   — ledger on a light device, night on a dark one
 * The theme is <html data-theme>, the Persian font <html data-font> (files in packages/fonts/fa).
 * Latin text is always IBM Plex Sans ('Bankly Latin', the Latin files of IBM Plex Sans Arabic); Persian text uses the
 * console's Persian font — since 0.25.0 Vazirmatn for reading with Estedad for headings and figures (UX/PERSIAN_DESIGN.md).
 * Provenance marks stay: every figure is underlined by how it is known (solid = document, dashed = you told us,
 * dotted = unknown, double = calculated, wavy = synthetic) — never by hue alone — but thinner and quieter.
 * tests/themes.test.ts checks every text / background pair below for WCAG AA contrast in every theme.
 */
:root {
  color-scheme: light;
  /* palette — ledger (default): paper, ink, cobalt; money states carry meaning (received, on the way, at risk, owed) */
  --ink: #0b1220;
  --ink-2: #384152;
  --ink-3: #5b6474;
  --slate-0: #ffffff;
  --slate-1: #f4f3ee;
  --slate-2: #ecebe4;
  --slate-3: #dedcd2;
  --primary: #2a4bdb;
  --on-primary: #ffffff;
  --primary-soft: #e9edfc;
  --verified: #087443;
  --verified-soft: #e3f3ea;
  --stated: #1f5bc4;
  --stated-soft: #e8effb;
  --unknown: #6c3fc4;
  --unknown-soft: #f0eafb;
  --estimate: #8a5000;
  --estimate-soft: #fbefd9;
  --negative: #b42318;
  --negative-soft: #fde9e7;
  --focus: #2a4bdb;
  --outline-strong: #7d8595;

  /* hero card: the one figure a page is about — ink on the ledger theme */
  --hero-bg: #0b1220;
  --hero-ink: #ffffff;
  --hero-muted: #a9b3c6;
  --hero-figure: #8ef0c0;
  /* 0.25.0 Persian design language (UX/PERSIAN_DESIGN.md): service tiles carry colour on Persian pages; the hero gets depth */
  --hero-bg-2: #1d2f7a;
  --scrim: rgb(8 12 24 / 0.45);
  --tile-1-bg: #e6edff;
  --tile-1-ink: #2648d8;
  --tile-2-bg: #efe8ff;
  --tile-2-ink: #6b3fd1;
  --tile-3-bg: #dcf5ef;
  --tile-3-ink: #0b7a66;
  --tile-4-bg: #fff1d6;
  --tile-4-ink: #8f5400;
  --tile-5-bg: #ffe6ec;
  --tile-5-ink: #c02656;
  --tile-6-bg: #e3f6e5;
  --tile-6-ink: #1f7a34;
  --tile-7-bg: #ffe9dc;
  --tile-7-ink: #b0470d;
  --tile-8-bg: #dff3fb;
  --tile-8-ink: #0b6e8f;
  /* money states on the hero card (received, on the way, at risk, owed, missed) — always shown with their words */
  --st-received: #8ef0c0;
  --st-way: #9db0ff;
  --st-risk: #ffc56b;
  --st-owed: #ff9f8f;
  --st-missed: #8590a3;

  /* roles */
  --surface: var(--slate-1);
  --surface-container: var(--slate-0);
  --surface-container-high: var(--slate-2);
  --on-surface: var(--ink);
  --on-surface-variant: var(--ink-2);
  --outline: var(--slate-3);

  /* type: one family for both scripts; numbers in the same family, tabular */
  --font-app: 'Vazirmatn';
  --font-head-fa: 'Estedad';
  --font-ui: 'Bankly Latin', var(--font-app), system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  --font-fa: var(--font-app), 'Noto Sans Arabic', Tahoma, 'DejaVu Sans', sans-serif;
  /* headings and big figures: English stays IBM Plex; Persian uses the display face (Estedad by default) */
  --font-head: 'Bankly Latin', var(--font-head-fa), var(--font-app), system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-figure: var(--font-head);
  /* digits line up in columns in English; Persian digits have no useful tabular forms (equal widths leave gaps) */
  --nums: tabular-nums lining-nums;
  --fs-xs: 0.78rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.3rem;
  --fs-2xl: clamp(1.55rem, 1.25rem + 1.2vw, 2rem);
  --fs-3xl: clamp(2.1rem, 1.6rem + 2.2vw, 3rem);
  --lh-body: 1.65;
  --lh-tight: 1.25;

  /* space (4px grid) */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  /* shape */
  --r-chip: 999px;
  --r-control: 10px;
  --r-btn: 12px;
  --r-panel: 16px;
  --r-sheet: 20px;

  /* elevation: a hairline ring and a breath of shadow — cards sit on the paper like ledger sheets */
  --shadow-card: 0 0 0 1px rgb(11 18 32 / 0.07), 0 1px 2px rgb(11 18 32 / 0.04);
  --shadow-float: 0 16px 40px rgb(11 18 32 / 0.16), 0 0 0 1px rgb(11 18 32 / 0.06);

  /* motion */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --dur-short: 150ms;
  --dur-medium: 280ms;

  --measure: 70ch;

  /* charts (F239): two series colours checked for colour-blind separation (UX/LAYOUT_STANDARD.md, "Charts");
     marks only — text in charts uses the ink tokens */
  --chart-1: #2a4bdb;
  --chart-2: #e2622d;
  --chart-promised: #2a4bdb;
  --chart-received: #0e8a55;
  --chart-grid: var(--slate-2);
  --chart-zero: var(--outline-strong);
  --chart-axis: var(--ink-3);

  /* layout standard (0.23.0, UX/LAYOUT_STANDARD.md): one grid and one rhythm on every page.
     compact < 640 px: 4 columns · medium 640–1023 px: 8 columns · expanded ≥ 1024 px: 12 columns */
  --page-x: 16px;
  --page-top: 16px;
  --page-max: 1200px;
  --gutter: 16px;
  --section-gap: 24px;
  --card-pad: 16px;
  --stack: 12px;
  --tap: 44px;
  --fs-display: clamp(2.25rem, 1.9rem + 1.6vw, 3rem);
}
:lang(fa) {
  --nums: normal;
}
@media (min-width: 640px) {
  :root {
    --page-x: 24px;
    --page-top: 24px;
    --section-gap: 32px;
    --card-pad: 24px;
    --stack: 16px;
  }
}
@media (min-width: 1024px) {
  :root {
    --page-x: 32px;
    --page-top: 32px;
    --gutter: 24px;
  }
}

/* ---------- calm (0.21.0 default) ---------- */
:root[data-theme='calm'] {
  --ink: #101418;
  --ink-2: #3a414b;
  --ink-3: #5b636e;
  --slate-0: #ffffff;
  --slate-1: #f7f7f5;
  --slate-2: #eff0ec;
  --slate-3: #e2e4e0;
  --primary: #0b6b4f;
  --on-primary: #ffffff;
  --primary-soft: #e3f1ea;
  --verified: #1d6f3a;
  --verified-soft: #e4f3e6;
  --stated: #2457c5;
  --stated-soft: #e6eefb;
  --unknown: #6d43b0;
  --unknown-soft: #f0eafa;
  --estimate: #8a5300;
  --estimate-soft: #fcf1dc;
  --negative: #b42318;
  --negative-soft: #fde8e6;
  --focus: #2563eb;
  --outline-strong: #858c95;
  --hero-bg: var(--slate-0);
  --hero-ink: var(--ink);
  --hero-muted: var(--ink-3);
  --hero-figure: var(--primary);
  --st-received: #1d6f3a;
  --st-way: #2457c5;
  --st-risk: #a86500;
  --st-owed: #b42318;
  --st-missed: #858c95;
  --r-control: 12px;
  --r-btn: 14px;
  --r-panel: 20px;
  --r-sheet: 26px;
  --shadow-card: 0 1px 2px rgb(16 20 24 / 0.05), 0 1px 1px rgb(16 20 24 / 0.03);
  --shadow-float: 0 12px 32px rgb(16 20 24 / 0.14), 0 2px 6px rgb(16 20 24 / 0.08);
  --chart-1: #006e4b;
  --chart-2: #eb6834;
  --chart-promised: #2457c5;
  --chart-received: #006e4b;
  --hero-bg-2: var(--hero-bg);
}

/* ---------- night ---------- */
:root[data-theme='night'] {
  color-scheme: dark;
  --ink: #f3f5f8;
  --ink-2: #c9ced6;
  --ink-3: #a1a9b5;
  --slate-0: #161a21;
  --slate-1: #0c0e12;
  --slate-2: #1e232c;
  --slate-3: #2a303b;
  --primary: #9aa8ff;
  --on-primary: #0c0e12;
  --primary-soft: #232a45;
  --verified: #7ee0b5;
  --verified-soft: #12302a;
  --stated: #9cc0ff;
  --stated-soft: #1b2e52;
  --unknown: #c9adf7;
  --unknown-soft: #2e2149;
  --estimate: #f5b451;
  --estimate-soft: #3a2e17;
  --negative: #ffa69b;
  --negative-soft: #4a1714;
  --focus: #aeb9ff;
  --outline-strong: #6b7484;
  --hero-bg: var(--slate-0);
  --hero-ink: var(--ink);
  --hero-muted: var(--ink-3);
  --hero-figure: var(--verified);
  --st-received: #7ee0b5;
  --st-way: #9aa8ff;
  --st-risk: #f5b451;
  --st-owed: #ffa69b;
  --st-missed: #7a8394;
  --shadow-card: 0 0 0 1px rgb(255 255 255 / 0.06);
  --shadow-float: 0 16px 40px rgb(0 0 0 / 0.55), 0 0 0 1px rgb(255 255 255 / 0.08);
  --chart-1: #6f7fe8;
  --chart-2: #d4652f;
  --chart-promised: #6f7fe8;
  --chart-received: #2fa877;
  --hero-bg-2: var(--hero-bg);
  --tile-1-bg: #1c2a57;
  --tile-1-ink: #9db4ff;
  --tile-2-bg: #2c2152;
  --tile-2-ink: #c2a8ff;
  --tile-3-bg: #0f3a33;
  --tile-3-ink: #6fe0c4;
  --tile-4-bg: #3d2e0c;
  --tile-4-ink: #ffcc66;
  --tile-5-bg: #47182a;
  --tile-5-ink: #ff9db7;
  --tile-6-bg: #163a1f;
  --tile-6-ink: #8fe0a0;
  --tile-7-bg: #45230f;
  --tile-7-ink: #ffad7a;
  --tile-8-bg: #0f3442;
  --tile-8-ink: #7fd6f5;
}

/* ---------- indigo ---------- */
:root[data-theme='indigo'] {
  --ink: #14152b;
  --ink-2: #3b3f5c;
  --ink-3: #5a5f7d;
  --slate-0: #ffffff;
  --slate-1: #f3f4fb;
  --slate-2: #ebedf8;
  --slate-3: #dde0f0;
  --primary: #4f46e5;
  --on-primary: #ffffff;
  --primary-soft: #eef0ff;
  --verified: #047857;
  --verified-soft: #e3f5ee;
  --stated: #1d4ed8;
  --stated-soft: #e5edfd;
  --unknown: #7c3aed;
  --unknown-soft: #f1eafe;
  --estimate: #92400e;
  --estimate-soft: #fef3c7;
  --negative: #b91c1c;
  --negative-soft: #fde8e8;
  --focus: #4338ca;
  --outline-strong: #7d82a0;
  --hero-bg: var(--primary);
  --hero-ink: #ffffff;
  --hero-muted: #e0e7ff;
  --hero-figure: #ffffff;
  --st-received: #a7f3d0;
  --st-way: #c7d2fe;
  --st-risk: #fde68a;
  --st-owed: #fecaca;
  --st-missed: #ffffff;
  --r-control: 14px;
  --r-btn: 16px;
  --r-panel: 24px;
  --r-sheet: 30px;
  --shadow-card: 0 1px 3px rgb(20 21 43 / 0.06), 0 1px 2px rgb(20 21 43 / 0.04);
  --chart-1: #4f46e5;
  --chart-2: #eb6834;
  --chart-promised: #4f46e5;
  --chart-received: #047857;
  --hero-bg-2: var(--hero-bg);
}

/* ---------- auto: ledger on a light device, night on a dark one ---------- */
@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    color-scheme: dark;
    --ink: #f3f5f8;
    --ink-2: #c9ced6;
    --ink-3: #a1a9b5;
    --slate-0: #161a21;
    --slate-1: #0c0e12;
    --slate-2: #1e232c;
    --slate-3: #2a303b;
    --primary: #9aa8ff;
    --on-primary: #0c0e12;
    --primary-soft: #232a45;
    --verified: #7ee0b5;
    --verified-soft: #12302a;
    --stated: #9cc0ff;
    --stated-soft: #1b2e52;
    --unknown: #c9adf7;
    --unknown-soft: #2e2149;
    --estimate: #f5b451;
    --estimate-soft: #3a2e17;
    --negative: #ffa69b;
    --negative-soft: #4a1714;
    --focus: #aeb9ff;
    --outline-strong: #6b7484;
    --hero-figure: var(--verified);
    --shadow-card: 0 0 0 1px rgb(255 255 255 / 0.06);
    --shadow-float: 0 16px 40px rgb(0 0 0 / 0.55), 0 0 0 1px rgb(255 255 255 / 0.08);
    --chart-1: #6f7fe8;
    --chart-2: #d4652f;
    --chart-promised: #6f7fe8;
    --chart-received: #2fa877;
    --hero-bg: var(--slate-0);
    --hero-ink: var(--ink);
    --hero-muted: var(--ink-3);
    --st-received: #7ee0b5;
    --st-way: #9aa8ff;
    --st-risk: #f5b451;
    --st-owed: #ffa69b;
    --st-missed: #7a8394;
    --hero-bg-2: var(--hero-bg);
    --tile-1-bg: #1c2a57;
    --tile-1-ink: #9db4ff;
    --tile-2-bg: #2c2152;
    --tile-2-ink: #c2a8ff;
    --tile-3-bg: #0f3a33;
    --tile-3-ink: #6fe0c4;
    --tile-4-bg: #3d2e0c;
    --tile-4-ink: #ffcc66;
    --tile-5-bg: #47182a;
    --tile-5-ink: #ff9db7;
    --tile-6-bg: #163a1f;
    --tile-6-ink: #8fe0a0;
    --tile-7-bg: #45230f;
    --tile-7-ink: #ffad7a;
    --tile-8-bg: #0f3442;
    --tile-8-ink: #7fd6f5;
  }
}

/* ---------- Persian font (packages/fonts/fa; Vazirmatn + Estedad headings by default since 0.25.0) ---------- */
:root[data-font='vazirmatn-estedad'] {
  --font-app: 'Vazirmatn';
  --font-head-fa: 'Estedad';
}
:root[data-font='ibm-plex-sans-arabic'] {
  --font-app: 'IBM Plex Sans Arabic';
  --font-head-fa: 'IBM Plex Sans Arabic';
}
:root[data-font='vazirmatn'] {
  --font-app: 'Vazirmatn';
  --font-head-fa: 'Vazirmatn';
}
:root[data-font='estedad'] {
  --font-app: 'Estedad';
  --font-head-fa: 'Estedad';
}
:root[data-font='shabnam'] {
  --font-app: 'Shabnam';
  --font-head-fa: 'Shabnam';
}
:root[data-font='sahel'] {
  --font-app: 'Sahel';
  --font-head-fa: 'Sahel';
}
:root[data-font='samim'] {
  --font-app: 'Samim';
  --font-head-fa: 'Samim';
}
:root[data-font='noto-sans-arabic'] {
  --font-app: 'Noto Sans Arabic';
  --font-head-fa: 'Noto Sans Arabic';
}
