/*
 * tokens.css — the ONLY file in this repository that holds a colour literal.
 *
 * Plan 2 Task 1 (`docs/tasks/2026-09-19-ui-redesign-plan-2-foundation.md`), spec
 * `docs/specs/02-ui-redesign.md` §9.1. Every theme block below was cut out of
 * `core/static/core/site.css` (now retired) so that colour has one home.
 * The legacy `--color-*` alias layer that `site.css` read went with it.
 *
 * ── the founding rule ──────────────────────────────────────────────────────────
 *
 * **`--money: var(--text);` in every single theme block.** Money is never a colour
 * (`docs/design/05-concept.md`). It is not an alias of convenience and it is not a
 * default waiting to be overridden — `tests/test_tokens_css.py` asserts it by theme
 * key, so a future theme that tries to tint a figure green fails the gate by name.
 *
 * ── one spelling ───────────────────────────────────────────────────────────────
 *
 * Each theme block declares the semantic names session 1 drew against (`--surface`,
 * `--text`, …) and nothing else. The legacy `--color-*` aliases `site.css` once read
 * were deleted with it (Plan 4 Run 2, Task 11); `tests/test_tokens_css.py` fails if
 * one comes back. `--surface` is the page ground and `--surface-raised` the card.
 *
 * ── what varies per theme, and what does not ───────────────────────────────────
 *
 * The bare `:root` carries only what every theme agrees on: spacing, the type
 * scale, line heights, the tap-target floor, and motion. Colour, font, radius and
 * heading tokens are deliberately given NO bare-`:root` fallback, exactly as the
 * old stylesheet reasoned: one authoritative definition per theme beats a fifth,
 * semi-duplicate "default" copy that can silently drift.
 *
 * `--font-sans` is per theme, from `core.themes.Theme.font_family`, and
 * `tests/test_themes_registry.py`'s
 * `test_every_theme_blocks_font_sans_matches_the_registrys_font_family` fails by
 * theme key the moment the two disagree. Session 1 declared it once in the shared
 * `:root`; the registry is the older source of truth and wins (Plan 2, C4).
 */

/* ── theme-agnostic ──────────────────────────────────────────────────────────── */

:root {
  /*
   * Spacing stays in `rem`, not session 1's `px`. The two agree exactly at a 16px
   * root (0.25rem = 4px, 2.5rem = 40px, and so on), but the app's bare-element rules
   * have always scaled with the browser's own font size, and
   * switching them to `px` here would quietly take that away from a person who
   * enlarges their text. `--space-0` and `--space-6` are session 1's new steps,
   * written in the same idiom.
   */
  --space-0: 0.125rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;

  /*
   * A tap target is a physical size, not a typographic one — `px` on purpose, so it
   * does not shrink on a phone whose owner has set a smaller root font.
   */
  --tap-min: 44px;

  /* Type scale — root 16px, nothing off this list, no fluid type (session 1 §2). */
  --text-2xs: 0.75rem;    /* 12 — meta, timestamps, the small unit word */
  --text-xs: 0.8125rem;   /* 13 — captions, badges, help */
  --text-sm: 0.875rem;    /* 14 — table cells, labels, secondary body */
  --text-base: 1rem;      /* 16 — body and EVERY form input */
  --text-md: 1.125rem;    /* 18 — h3, Mini App primary button */
  --text-lg: 1.375rem;    /* 22 — h2, Mini App page title */
  --text-xl: 1.75rem;     /* 28 — h1 */
  --text-2xl: 2rem;       /* 32 — confirm hero at 390 */
  --text-3xl: 2.75rem;    /* 44 — confirm hero at >=900 */
  --text-4xl: 3.5rem;     /* 56 — Plan 4: the money screen's lead figure at 390 */
  --text-5xl: 6.25rem;    /* 100 — Plan 4: the money screen's lead figure at >=900 */
  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-normal: 1.55;

  /*
   * Motion — every duration collapses to 0 under reduced motion, here, once, so no
   * component has to remember its own `@media` guard.
   */
  --dur-80: 80ms;
  --dur-120: 120ms;
  --dur-160: 160ms;
  --dur-200: 200ms;
  --dur-320: 320ms;
  --dur-pulse: 1600ms;
  --dur-grow: 700ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-decel: cubic-bezier(0, 0, 0, 1);
  --ease-stamp: cubic-bezier(0.3, 1.6, 0.5, 1);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-80: 0ms;
    --dur-120: 0ms;
    --dur-160: 0ms;
    --dur-200: 0ms;
    --dur-320: 0ms;
    --dur-pulse: 0ms;
    --dur-grow: 0ms;
  }
}

/* ── lojuvard: everyone's look outside Telegram (core.themes.FALLBACK_THEME) ────
 *
 * Plan 4 Task 1, decision `0007` §2. "Lojuvard" is Uzbek for the deep lapis blue: a
 * generic name for a palette, never a school's name. It replaced `naqd`, `kassa`,
 * `signal` and `chaqmoq`; migration `core/migrations/0018` moved every stored row.
 * Values are `docs/design/16-familiar-frame/tokens.css` section 2, literal for literal
 * (`tests/test_tokens_css.py` pins the theme-agnostic half; the contrast pairs are
 * `tests/test_theme_contrast.py`).
 *
 * `--gold` is the Kirim ring only (2.6:1 on white) and `--faint` is for chevrons and
 * icons on white only (3.08:1). Neither is ever text. Danger, success and warning are
 * carried over from the retired `naqd` as status colours, never money colours.
 */
:root[data-ui-theme="lojuvard"] {
  /* the semantic set every theme block declares (tests/test_themes_registry.py) */
  --surface:          #f2f4f8; /* page */
  --surface-raised:   #ffffff; /* panels, slips, white cards, header at >=900, tab bar */
  --text:             #0b1630; /* ink */
  --text-muted:       #5b6580; /* soft: 5.27:1 on page, 5.80:1 on white */
  --border:           #e5e8ef; /* line */
  --accent:           #1a3566; /* navy: the filled button */
  --accent-contrast:  #ffffff; /* 12.03:1 on navy */
  --link:             #1b2f61; /* navy-2: 11.73:1 on page */
  --danger:           #b02318; /* carried from naqd: status, never money (0007) */
  --danger-surface:   #fce3e0;
  --success:          #03713d;
  --success-surface:  #d7f5e3;
  --warning:          #8a5c00;
  --warning-surface:  #f8eed4;
  --money:            var(--text);
  --header-bg:        #ffffff;
  --header-text:      #0b1630;
  --header-text-muted:#5b6580;
  --header-accent:    #1a3566;


  /* Plan 4's brand set: added to EVERY theme block, telegram included */
  --brand:            #1a3566; /* navy: the cash-box card, the active tab, the filled rule */
  --brand-2:          #1b2f61; /* navy-2 */
  --brand-contrast:   #ffffff; /* text on navy */
  --brand-contrast-muted: #a9b3cc; /* secondary text on navy: 5.73:1 */
  --brand-wash:       rgba(255, 255, 255, 0.14); /* the pill on a navy card */
  --gold:             #c79532; /* the Kirim ring only: 2.6:1 on white, NEVER text */
  --gold-soft:        #f3e9d2; /* the Kirim fill */
  --gold-deep:        #7d5714; /* the Kirim glyph: 5.36:1 on gold-soft */
  --chip:             #eceff5; /* avatar, icon discs, active top-menu item, rule track */
  --dot:              #cdd3df; /* card dots, slip edges: decoration only */
  --faint:            #8a93a8; /* chevrons and icons on WHITE only: 3.08:1, NEVER text */
  --bar:              #1a3566; /* the statement's filled rule */
  --bar-light:        #93a1c4; /* a staff member's rule */
  --stamp:            #2c3d94; /* stamp ink and the Tasdiqlash outline: 9.54:1 on white */
  --focus-wash:       #dfe5f3; /* the lit line on the money screen */
  --shadow-slip:      rgba(11, 22, 48, 0.16); /* the slip's two-layer shadow, ink at 16 % */
  --radius-hero:      22px;    /* balance cards */

  --font-sans: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --radius-card: 18px;
  --heading-weight: 700;
  --heading-letter-spacing: -0.01em;
}

/* ── telegram: applied by itself inside the Mini App (0007 §2) ──────────────────
 *
 * Telegram supplies eight values through `--tg-theme-*` on its own webview. They map
 * as session 1 drew them:
 *
 *   --surface         <- secondary_bg_color  (Telegram's page ground; bg_color is
 *                                             the CARD colour on iOS/Android)
 *   --surface-raised  <- bg_color
 *   --text            <- text_color
 *   --text-muted      <- hint_color
 *   --link            <- link_color
 *   --accent          <- button_color
 *   --accent-contrast <- button_text_color
 *   --danger          <- destructive_text_color
 *
 * Everything else has no Telegram equivalent and is held at lojuvard's literal: the
 * borders, status colours, `--header-*` and the whole brand set. Navy stays navy
 * inside Telegram; whether that reads on a person's DARK Telegram theme needs a real
 * phone (`0007`, "What this decision does not settle").
 *
 * The surface script in `base.html` sets `data-ui-theme="telegram"` itself once the
 * launch is confirmed; nobody picks it. Outside Telegram every `var(--tg-theme-*, …)`
 * falls through to its lojuvard fallback, the designed degradation.
 *
 * `--money` is `var(--text)` here too. No `--tg-theme-*` value may go near it.
 */
:root[data-ui-theme="telegram"] {
  --surface:          var(--tg-theme-secondary-bg-color, #f2f4f8);
  --surface-raised:   var(--tg-theme-bg-color, #ffffff);
  --text:             var(--tg-theme-text-color, #0b1630);
  --text-muted:       var(--tg-theme-hint-color, #5b6580);
  --border:           #e5e8ef;
  --accent:           var(--tg-theme-button-color, #1a3566);
  --accent-contrast:  var(--tg-theme-button-text-color, #ffffff);
  --link:             var(--tg-theme-link-color, #1b2f61);
  --danger:           var(--tg-theme-destructive-text-color, #b02318);
  --danger-surface:   #fce3e0;
  --success:          #03713d;
  --success-surface:  #d7f5e3;
  --warning:          #8a5c00;
  --warning-surface:  #f8eed4;
  --money:            var(--text);
  --header-bg:        var(--tg-theme-bg-color, #ffffff);
  --header-text:      var(--tg-theme-text-color, #0b1630);
  --header-text-muted:var(--tg-theme-hint-color, #5b6580);
  --header-accent:    #1a3566;


  --brand:            #1a3566;
  --brand-2:          #1b2f61;
  --brand-contrast:   #ffffff;
  --brand-contrast-muted: #a9b3cc;
  --brand-wash:       rgba(255, 255, 255, 0.14);
  --gold:             #c79532;
  --gold-soft:        #f3e9d2;
  --gold-deep:        #7d5714;
  --chip:             #eceff5;
  --dot:              #cdd3df;
  --faint:            #8a93a8;
  --bar:              #1a3566;
  --bar-light:        #93a1c4;
  --stamp:            #2c3d94;
  --focus-wash:       #dfe5f3;
  --shadow-slip:      rgba(11, 22, 48, 0.16);
  --radius-hero:      22px;

  --font-sans: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --radius-card: 18px;
  --heading-weight: 700;
  --heading-letter-spacing: -0.01em;
}

/* ── paper — the receipt is the one screen meant for it (Plan 3C Task 2) ─────────
 *
 * Taken from session 4's addition to this file (`docs/design/session-4/tokens.css`,
 * after session 1's prefix), adapted in two ways:
 *
 * 1. **The selector.** Session 4 drew against session 1's `:root, [data-theme=…]`
 *    shape. This product's themes are `:root[data-ui-theme="<key>"]`, specificity
 *    (0,2,0); a bare `:root` here (0,1,0) would lose to every one of them and the
 *    paper would print in the theme's greys. `:root[data-ui-theme]` is the same
 *    (0,2,0) and sits AFTER the last theme block, so source order wins — for all
 *    every theme without naming it, including one added later.
 * 2. **No `[data-theme="print"]` screen twin.** Session 4 needed it to review a print
 *    preview inside a canvas. The product has no such axis; the PDF is the review.
 *
 * `--text` (and therefore `--money`, which is `var(--text)`), `--text-muted` and
 * `--border` become true black: a grey label dithers on a cheap office laser and
 * every label on the receipt is load-bearing. Never hard-code black in a component.
 * `--surface*` go white so a dark or tinted theme does not print a ground.
 *
 * `.no-print` is a RULE, not a token — the first one in this file, and a documented
 * exception: it has to fire for print whichever stylesheet loaded. It is the only
 * `.no-print` rule in the repository. No `@page` rule exists anywhere (A4 is a call,
 * not a fact; the plan does not authorize one).
 */
@media print {
  :root,
  :root[data-ui-theme] {
    color-scheme: light;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --text: #000000;
    --text-muted: #000000;
    --border: #000000;
    --money: var(--text);
  }
  .no-print {
    display: none !important;
  }
}
