/* 00-tokens.css — design tokens (colour, type, shape, spacing, elevation, motion); see docs/DESIGN.md.
   Loaded first; every later file builds on these names.

   HOW TO USE (new and touched rules use these names, never raw hex):
   ── Type ──
     --font-ui            the one font (IBM Plex Sans Arabic: fixed-width digits, so amounts line up). Never name a font in a rule.
     Amounts: body sets font-variant-numeric: tabular-nums; wrap an amount in .num (LTR isolate). Never monospace.
   ── Semantic colours (light theme; a dark theme redefines only this block, on :root — the aliases
      below are resolved on :root, so redefining --c-* on an inner element does not reach them) ──
     --c-bg               page background
     --c-surface          cards, sheets, windows
     --c-surface-2        sunken / secondary fills (chips, secondary buttons, table stripes)
     --c-text             main text            --c-text-muted   secondary text (AA on surface and surface-2)
     --c-border           hairlines            --c-border-strong  inputs, dividers that must show
     --c-primary          THE action colour: save buttons, FAB, inline +, links, focus
     --c-primary-hover    --c-primary-soft (tinted background)   --c-on-primary (text on primary)
     --c-danger / --c-danger-soft      destructive actions, money out, errors
     --c-success / --c-success-soft    money in, done
     --c-warning / --c-warning-soft    due soon, attention
     --c-overlay          dim layer behind windows
     --c-primary-line / --c-danger-line / --c-success-line / --c-warning-line
                          tinted borders of a soft box (a -soft fill needs a matching edge; added when the
                          screens moved off raw hex — the gap was ~50 tinted borders with no token)
     (The older --sf-*, --tx-*, --ln*, --brand* and 01-base names --bg-*, --text-*, --border, --*-text
      are aliases of these, so existing rules follow a theme change.)
   ── Shape: one radius scale ──
     --radius-sm 8px (inputs, buttons, chips)  --radius-md 12px (cards, windows)  --radius-lg 16px (sheets, hero cards)
     --radius-pill (badges, round buttons)
   ── Shared components (01-base.css) ──
     .btn + .btn-primary | .btn-secondary | .btn-danger (one each), .btn-full, .btn-sm
     .btn-close (one close button: 44px round ×)   .fab (floating add)   .btn-add (inline round +)
     Windows (.modal-overlay > .modal-card / .modal-card-sm / .modal-content) become bottom sheets under 768px
     (33-sheets.css): grab handle, safe-area padding, the last .btn-primary.btn-full / [type=submit] sticks to the bottom.
   ── Money text (public/app-utils.js) ──
     fmtNum(n, dec) / fmtSigned(n, dec) / fmtMoney(n, dec): "1,234.50 \20C1", real minus kept left in RTL.
     The currency is the official Saudi Riyal sign U+20C1 (below); fmtMoneyText keeps «ر.س» for notifications. */
/* The one UI font, self-hosted (works offline in the installed app; CSP font-src 'self').
   IBM Plex Sans Arabic 400 / 600 / 700, Arabic + Latin subsets, SIL OFL 1.1 (fonts/OFL.txt).
   Its digits are fixed-width (tabular), so amounts line up. The 700 file also serves 800–900
   (the app's heavy weights) so the browser never fakes a bolder face. */
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 400 500; font-display: swap;
    src: url('../fonts/plex-arabic-400.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 400 500; font-display: swap;
    src: url('../fonts/plex-latin-400.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('../fonts/plex-arabic-600.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('../fonts/plex-latin-600.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 700 900; font-display: swap;
    src: url('../fonts/plex-arabic-700.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 700 900; font-display: swap;
    src: url('../fonts/plex-latin-700.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* The official Saudi Riyal sign (U+20C1, SAMA 2025) in the same family, so every text that uses
   the UI font (screens, inputs, charts) draws it. One glyph, built by tools/build-riyal-font.py.
   Declared once per weight range above: a unicode-range face joins only faces with the same weight. */
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 400 500; font-display: block;
    src: url('../fonts/riyal-sign.woff2') format('woff2');
    unicode-range: U+20C1;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 600; font-display: block;
    src: url('../fonts/riyal-sign.woff2') format('woff2');
    unicode-range: U+20C1;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 700 900; font-display: block;
    src: url('../fonts/riyal-sign.woff2') format('woff2');
    unicode-range: U+20C1;
}
:root {
    /* type */
    --font-ui: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* semantic colours */
    --c-bg: #f8fafc;
    --c-surface: #ffffff;
    --c-surface-2: #f1f5f9;
    --c-text: #0f172a;
    --c-text-muted: #5b6b82;      /* 4.95:1 on #f1f5f9 */
    --c-border: #e2e8f0;
    --c-border-strong: #cbd5e1;
    --c-primary: #4f46e5;         /* white text on it: 6.3:1 */
    --c-primary-hover: #4338ca;
    --c-primary-soft: #eef2ff;
    --c-on-primary: #ffffff;
    --c-danger: #b91c1c;          /* 5.9:1 on white */
    --c-danger-soft: #fef2f2;
    --c-success: #047857;         /* 5.0:1 */
    --c-success-soft: #ecfdf5;
    --c-warning: #b45309;         /* 5.0:1 */
    --c-warning-soft: #fef3c7;
    --c-overlay: rgba(15,23,42,.55);
    --c-primary-line: #c7d2fe; --c-danger-line: #fecaca; --c-success-line: #a7f3d0; --c-warning-line: #fde68a;

    /* shape */
    --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-pill: 999px;

    /* aliases kept for existing rules (follow the semantic colours) */
    --sf-page: var(--c-bg); --sf-card: var(--c-surface); --sf-raised: var(--c-surface); --sf-sunken: var(--c-surface-2); --sf-overlay: var(--c-overlay);
    --tx-strong: var(--c-text); --tx-main: #1e293b; --tx-muted: var(--c-text-muted); --tx-faint: #64748b; --tx-inverse: #ffffff;
    --ln: var(--c-border); --ln-strong: var(--c-border-strong);
    --brand: var(--c-primary); --brand-soft: var(--c-primary-soft); --brand-text: var(--c-primary-hover);
    /* money */
    --money-out: var(--c-danger); --money-out-soft: var(--c-danger-soft);
    --money-in: var(--c-success); --money-in-soft: var(--c-success-soft);
    --money-move: #1d4ed8; --money-move-soft: #eff6ff;
    /* amounts in the new interface (body.ui-v2, css/40-v2-base.css; docs/DESIGN.md «Amount colours»):
       an expense is drawn in the text colour with its minus sign; income green, transfers blue,
       red only for over-budget and errors. Classic keeps --money-out red. */
    --amt-expense: var(--c-text); --amt-income: var(--money-in); --amt-transfer: var(--money-move); --amt-over: var(--c-danger);
    /* status */
    --st-ok: var(--c-success); --st-ok-soft: #d1fae5;
    --st-new: #6d28d9; --st-new-soft: #ede9fe;
    --st-warn: var(--c-warning); --st-warn-soft: var(--c-warning-soft);
    --st-bad: var(--c-danger); --st-bad-soft: #fee2e2;
    --st-neutral: #475569; --st-neutral-soft: #e2e8f0;
    /* type scale */
    --fs-xs: .72rem; --fs-sm: .8rem; --fs-md: .9rem; --fs-lg: 1.05rem; --fs-xl: 1.3rem; --fs-2xl: 1.7rem;
    --lh-tight: 1.25; --lh-body: 1.6;
    /* spacing */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
    /* elevation */
    --el-1: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
    --el-2: 0 4px 12px rgba(15,23,42,.08);
    --el-3: 0 12px 32px rgba(15,23,42,.18);
    /* motion */
    /* motion: animate only transform/opacity; press 120ms (buttons scale .97), sheets 280ms, enter from translateY / scale(.95) */
    --mo-fast: 120ms; --mo-base: 200ms; --mo-slow: 280ms; --ease: cubic-bezier(.2,.8,.2,1);
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);   /* the one ease-out curve for new motion */
}

/* Amounts and other numbers: Latin digits, left-to-right inside RTL text, fixed-width digits. */
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

/* Dark mode is scoped on purpose: the app ships one light theme; only the full-screen
   review and bank-SMS surfaces (and the screenshot preview over them) follow the device colour scheme. */
@media (prefers-color-scheme: dark) {
    #bulk-import-modal, #bulk-ai-loader, #bank-sms-screen, #shot-sheet {
        --sf-page: #0b1220; --sf-card: #111a2e; --sf-raised: #16213a; --sf-sunken: #0f172a; --sf-overlay: rgba(2,6,23,.7);
        --tx-strong: #f1f5f9; --tx-main: #e2e8f0; --tx-muted: #a3b1c6; --tx-faint: #8b99b0;
        --ln: #243049; --ln-strong: #334155;
        --brand-soft: #1e1b4b; --brand-text: #a5b4fc;
        --money-out: #f87171; --money-out-soft: #3b1a1a;
        --money-in: #34d399; --money-in-soft: #0d2e26;
        --money-move: #93c5fd; --money-move-soft: #172554;
        --amt-expense: #f1f5f9; --amt-income: #34d399; --amt-transfer: #93c5fd; --amt-over: #f87171;
        --st-ok: #34d399; --st-ok-soft: #0d2e26;
        --st-new: #c4b5fd; --st-new-soft: #2b1d4f;
        --st-warn: #fbbf24; --st-warn-soft: #3b2a0a;
        --st-bad: #f87171; --st-bad-soft: #3b1a1a;
        --st-neutral: #cbd5e1; --st-neutral-soft: #243049;
        --el-1: 0 1px 2px rgba(0,0,0,.4); --el-2: 0 4px 12px rgba(0,0,0,.45); --el-3: 0 12px 32px rgba(0,0,0,.6);
    }
}

@media (prefers-reduced-motion: reduce) {
    :root { --mo-fast: 0ms; --mo-base: 0ms; --mo-slow: 0ms; }
}
