/*
 * MIRCO DEX V5 — design tokens (the shared vocabulary of BRIEF_DEX5, "Design-system contract").
 *
 * ```text
 * ONE SOURCE OF COLOUR. dex.css's legacy names (--bg, --ink, --accent ...) ALIAS THESE.
 * A BUY IS NOT THE BRAND COLOUR. THE ACCENT IS MIRCO TEAL; BUY AND SELL ARE SEMANTIC.
 * EVERY NUMBER IS TABULAR.
 * ```
 *
 * The identity is MIRCO's own, derived from what the branding already publishes:
 *   - the MTU mark (deploy/app/branding/static/mtu.svg): disc #0f6e78, ring #7fd8e0, white glyph;
 *   - the network mark (mirco-network.png): a monochrome black/white symbol;
 *   - dex.css's accepted white/light family with a faint teal bias (--teal600 #0b7f8a, --teal700 #085f68).
 * So: neutrals biased toward teal, a single teal accent, monochrome brand ink. Nothing here is borrowed
 * from another venue's palette.
 *
 * Light is the default. Dark arrives through `[data-theme="dark"]` on <html>, or through the OS preference
 * when no explicit choice is stamped (`[data-theme="light"]` pins light). RTL arrives through `dir`; these
 * tokens have no direction, and the components use logical properties only.
 *
 * Contrast (WCAG 2.1, measured against --dx-surface): text >= 15:1, text-dim >= 4.6:1, buy/sell/accent >= 4.5:1
 * in both themes, so a coloured number is still readable text.
 */

:root {
  /* ---- colour --------------------------------------------------------- */
  --dx-bg: #f4f7f8;
  --dx-surface: #ffffff;
  --dx-surface-2: #f6f9fa;
  --dx-surface-3: #eaf0f2; /* hover, pressed, the selected row */
  --dx-border: #dbe2e6;
  --dx-border-soft: #e8edf0;
  --dx-text: #0f1619;
  --dx-text-dim: #5a666e;
  --dx-text-faint: #8b969d;
  --dx-accent: #0b7f8a;
  --dx-accent-strong: #085f68;
  --dx-accent-soft: #e4f4f6;
  --dx-on-accent: #ffffff;
  --dx-buy: #0d7a50;
  --dx-buy-soft: #e5f4ed;
  --dx-sell: #b42f2f;
  --dx-sell-soft: #fbeaea;
  --dx-warn: #8a5f12;
  --dx-warn-soft: #fcf4e2;
  --dx-danger: #b42f2f;
  --dx-danger-soft: #fbeaea;
  --dx-focus: #0b7f8a;
  --dx-overlay: rgba(10, 18, 22, 0.42);
  --dx-brand-ring: #7fd8e0;

  /* ---- type ----------------------------------------------------------- */
  --dx-font: "Inter var", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic",
    "Segoe UI Arabic", sans-serif;
  --dx-mono: ui-monospace, "Cascadia Mono", "SF Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --dx-fs-xs: 11px;
  --dx-fs-sm: 12px;
  --dx-fs-md: 13px;
  --dx-fs-lg: 15px;
  --dx-fs-xl: 20px;
  --dx-fw-regular: 400;
  --dx-fw-medium: 500;
  --dx-fw-strong: 600;
  --dx-fw-heavy: 700;
  --dx-lh: 1.45;
  --dx-lh-tight: 1.2;

  /* ---- space (4/8/12/16/24/32) --------------------------------------- */
  --dx-sp-1: 4px;
  --dx-sp-2: 8px;
  --dx-sp-3: 12px;
  --dx-sp-4: 16px;
  --dx-sp-5: 24px;
  --dx-sp-6: 32px;

  /* ---- radius / shadow ------------------------------------------------ */
  --dx-radius-s: 4px;
  --dx-radius-m: 6px;
  --dx-radius-l: 10px;
  --dx-shadow-1: 0 1px 2px rgba(15, 22, 25, 0.06), 0 1px 1px rgba(15, 22, 25, 0.04);
  --dx-shadow-2: 0 10px 28px rgba(15, 22, 25, 0.14), 0 2px 6px rgba(15, 22, 25, 0.08);

  /* ---- heights -------------------------------------------------------- */
  --dx-row-h: 20px; /* one order-book level */
  --dx-input-h: 34px;
  --dx-tap: 32px; /* the smallest hit target on desktop */
  --dx-tap-touch: 44px; /* and on a touch screen */
  --dx-topbar-h: 48px;

  /* ---- motion --------------------------------------------------------- */
  --dx-ease: cubic-bezier(0.2, 0, 0, 1);
  --dx-dur: 120ms;

  /* ---- desktop terminal layout (dex5-desktop.css reads these; prefs.js stores the viewer's) ---- */
  --dx-book-w: 300px;
  --dx-ticket-w: 312px;
  --dx-bottom-h: 260px;

  color-scheme: light;
}

/* Dark: the same tokens, a deep ink with the same teal bias. Used when the viewer chose it ... */
:root[data-theme="dark"] {
  --dx-bg: #0a0f12;
  --dx-surface: #10171b;
  --dx-surface-2: #141c21;
  --dx-surface-3: #1b252b;
  --dx-border: #222d34;
  --dx-border-soft: #1a232a;
  --dx-text: #e7edf0;
  --dx-text-dim: #95a2aa;
  --dx-text-faint: #69767e;
  --dx-accent: #3fb6c0;
  --dx-accent-strong: #7fd8e0;
  --dx-accent-soft: #0f2a2e;
  --dx-on-accent: #04191c;
  --dx-buy: #3ecf8e;
  --dx-buy-soft: #0d261e;
  --dx-sell: #f2726a;
  --dx-sell-soft: #2b1513;
  --dx-warn: #e3b558;
  --dx-warn-soft: #2a2212;
  --dx-danger: #f2726a;
  --dx-danger-soft: #2b1513;
  --dx-focus: #7fd8e0;
  --dx-overlay: rgba(0, 0, 0, 0.6);
  --dx-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --dx-shadow-2: 0 12px 32px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ... or when the OS prefers it and the viewer stamped no choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --dx-bg: #0a0f12;
    --dx-surface: #10171b;
    --dx-surface-2: #141c21;
    --dx-surface-3: #1b252b;
    --dx-border: #222d34;
    --dx-border-soft: #1a232a;
    --dx-text: #e7edf0;
    --dx-text-dim: #95a2aa;
    --dx-text-faint: #69767e;
    --dx-accent: #3fb6c0;
    --dx-accent-strong: #7fd8e0;
    --dx-accent-soft: #0f2a2e;
    --dx-on-accent: #04191c;
    --dx-buy: #3ecf8e;
    --dx-buy-soft: #0d261e;
    --dx-sell: #f2726a;
    --dx-sell-soft: #2b1513;
    --dx-warn: #e3b558;
    --dx-warn-soft: #2a2212;
    --dx-danger: #f2726a;
    --dx-danger-soft: #2b1513;
    --dx-focus: #7fd8e0;
    --dx-overlay: rgba(0, 0, 0, 0.6);
    --dx-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --dx-shadow-2: 0 12px 32px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

/* A touch screen gets touch-sized targets without a separate token set. */
@media (pointer: coarse) {
  :root {
    --dx-tap: 44px;
    --dx-input-h: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dx-dur: 0ms;
  }
}
