/* Masterpiece BI — design tokens. The ONLY place a raw colour, size or duration may live;
   every other stylesheet and every module reads these names. docs/DESIGN_SYSTEM.md explains
   each decision; the short version is below.

   Provenance: values marked [site] were measured from https://www.mpinv.ae on 2026-09-25
   (computed styles, not guesses). Values marked [derived] extend the site's palette where a
   data product needs a step the marketing site never shows (e.g. a warning colour, an
   eight-colour chart palette). Nothing here is decoration: if a token has no user, delete it. */

/* Brand face. Garbata (Zetafonts) is the website's typeface; its Bold cut carries page titles,
   panel titles and KPI values. Self-hosted in public/fonts (the same Bold Latin file mpinv.ae
   serves; licence confirmed for bi.mpinv.cloud by the user 2026-09-26). If it ever fails to load,
   every Garbata use falls back to the text face at the same weight, designed to look right alone.
   Garbata has NO tabular figures (measured: '1' is 55% the width of '0'), so it is never used
   where numbers must align in columns — only for single values and titles. */
@font-face {
  font-family: 'Garbata';
  src: url('/assets/fonts/Garbata-Bold-Latin.woff2') format('woff2');
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ── Colour primitives ─────────────────────────────────────────────── */
  --ink-950: #0B0909;   /* [site] --primaryColor: text, primary buttons, dark bands */
  --ink-800: #2C2925;   /* [site] dark body text */
  --stone-700: #3D382F; /* [site] strong secondary text */
  --stone-600: #5F594F; /* [site] helper / sub text — 6.9:1 on white */
  --stone-500: #6C665D; /* [site] muted text — 5.6:1 on white */
  --stone-400: #8A8377; /* [derived] placeholders, disabled — never for text a reader needs */
  --stone-300: #B5AC9C; /* [derived] decorative only */
  --line-400: #D9D2C3;  /* [site] chip border */
  --line-300: #E6DFD2;  /* [site] table rule, card border */
  --line-200: #EFE9DF;  /* [derived] row rule */
  --sand-100: #F3EEE5;  /* [site] sand band */
  --paper-100: #F7F5F0; /* [derived] app canvas — between the site's #F7F4ED and #F7F7F5 */
  --paper-50: #FBFAF7;  /* [site] page background */
  --white: #FFFFFF;

  --gold-700: #765C1F;  /* [site] bronze — gold as TEXT on light (6.3:1) */
  --gold-600: #A8843E;  /* [site] deep gold — gold as a mark on light (3.3:1, passes non-text) */
  --gold-500: #C5A55A;  /* [site] brand gold — fills that carry ink text */
  --gold-300: #D7BD79;  /* [site] light gold — gold on the dark sidebar */
  --gold-100: #F6EAD0;  /* [site] permit-chip tint */

  --green-700: #1C6B47; /* [site] positive figures on the Investor Zone tables */
  --green-100: #E4F0E9;
  --red-700: #A3392B;   /* [site] negative figures */
  --red-100: #F6E4E0;
  --amber-700: #8F5E0A; /* [derived] warning text (5.6:1) — the site has no warning state */
  --amber-100: #F6ECD8;
  --navy-900: #0E1620;  /* [site] Investor Zone ink */
  --navy-600: #2E4A62;  /* [derived] info / "active" data */
  --navy-100: #E6ECF1;
  --slate-600: #56616D; /* [site] "Not published" — not-applicable values */

  /* ── Semantic roles (components use THESE, never the primitives) ───── */
  --bg-canvas: var(--paper-100);
  --bg-surface: var(--white);
  --bg-subtle: var(--sand-100);      /* table heads, selected rows, quiet fills */
  --bg-hover: #FAF7F1;               /* [site] row / item hover */
  --text-strong: var(--ink-950);
  --text: var(--ink-800);
  --text-muted: var(--stone-600);
  --text-subtle: var(--stone-500);
  --text-disabled: var(--stone-400);
  --text-inverse: var(--white);
  --text-accent: var(--gold-700);
  --text-na: var(--slate-600);
  --border: var(--line-300);
  --border-strong: var(--line-400);
  --border-soft: var(--line-200);
  --focus-ring: var(--ink-950);      /* 19:1 — gold rings measured 2.2:1 and fail */
  --accent: var(--gold-500);
  --accent-mark: var(--gold-600);
  --accent-soft: var(--gold-100);

  --positive: var(--green-700);  --positive-bg: var(--green-100);
  --negative: var(--red-700);    --negative-bg: var(--red-100);
  --warning: var(--amber-700);   --warning-bg: var(--amber-100);
  --info: var(--navy-600);       --info-bg: var(--navy-100);
  --neutral: var(--stone-600);   --neutral-bg: var(--sand-100);

  /* Sidebar — the site's ink band, gold only for "you are here". */
  --nav-bg: var(--ink-950);
  --nav-text: #D8D2C6;
  --nav-text-muted: #8C857A;
  --nav-hover: rgba(255, 255, 255, .06);
  --nav-active-bg: rgba(215, 189, 121, .12);
  --nav-indicator: var(--gold-300);
  --nav-line: rgba(255, 255, 255, .08);

  /* ── Data colours ──────────────────────────────────────────────────── */
  /* Categorical: assigned by IDENTITY (BI.colorFor), never by rank — a source must keep its
     colour when a filter reorders the list. Ordered so neighbours differ in lightness, not
     just hue (colour-vision safe); past eight, fold the tail into "Other". */
  --chart-1: #A8843E; /* gold */
  --chart-2: #2E4A62; /* navy */
  --chart-3: #CFB27A; /* sand */
  --chart-4: #7C8896; /* slate */
  --chart-5: #3F7D60; /* green */
  --chart-6: #B0644C; /* clay */
  --chart-7: #765C1F; /* bronze */
  --chart-8: #9C9384; /* stone */
  /* Sand (2.0:1) and stone sit below 3:1 on white on purpose — at 3:1 sand is indistinguishable
     from gold. So no chart may rely on them alone: bars print their values, stacks separate
     segments with a white hairline, and every series is named in text. */
  /* Identities that must read the same on every page (Unit and Publishing had PF/Bayut swapped). */
  --portal-pf: var(--chart-6);     /* Property Finder — clay, after its red mark */
  --portal-bayut: var(--chart-5);  /* Bayut — green, after its own */
  --portal-pf-ink: #8E4B37;        /* PF as TEXT (6.5:1 on white) — the fill is 4.4:1, too light for small text */
  --portal-bayut-ink: #2F6A4F;     /* Bayut as TEXT (6.4:1) */
  --dept-sales: var(--chart-2);    /* navy */
  --dept-listing: var(--chart-1);  /* gold */
  /* Sequential (heatmaps, budget bands): paper → bronze, one hue. */
  --seq-1: #F6EFDF; --seq-2: #EAD9AE; --seq-3: #D7BD79; --seq-4: #B8964C; --seq-5: #8E6F2C; --seq-6: #5C4816;
  /* Lead buckets — semantic, so they never double as categorical colours. */
  --bucket-raw: #9C9384;
  --bucket-pre: #CFB27A;
  --bucket-active: #2E4A62;
  --bucket-won: #3F7D60;
  --bucket-lost: #B5503E;
  --chart-grid: rgba(11, 9, 9, .06);
  --chart-axis: var(--stone-500);

  /* ── Typography ────────────────────────────────────────────────────── */
  --font-brand: 'Garbata', 'Source Sans 3', system-ui, sans-serif;
  --font-text: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* Every token below is size / line-height. Seven sizes replace the 25 in use today. */
  --fs-display: 26px; --lh-display: 32px; /* page title — Garbata */
  --fs-kpi: 28px;     --lh-kpi: 32px;     /* KPI value — Garbata */
  --fs-title: 16px;   --lh-title: 22px;   /* panel / section title — Garbata */
  --fs-body: 14px;    --lh-body: 20px;    /* text, controls */
  --fs-table: 13px;   --lh-table: 18px;   /* table cells */
  --fs-label: 12px;   --lh-label: 16px;   /* labels, table heads, captions */
  --fs-micro: 11px;   --lh-micro: 14px;   /* badges, chart axes */
  --fw-regular: 400; --fw-semibold: 600; --fw-bold: 700;

  /* ── Space, shape, depth, motion ───────────────────────────────────── */
  --sp-0-5: 2px; --sp-1: 4px; --sp-1-5: 6px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --r-xs: 2px;    /* chart bars, meters */
  --r-sm: 4px;    /* [site] buttons, inputs, badges, tooltips */
  --r-md: 8px;    /* panels, popovers, dialogs */
  --r-pill: 999px;/* [site] filter chips, segmented controls, avatars */
  /* Panels carry structure with a hairline, not a shadow (the site almost never shadows). */
  --shadow-1: 0 1px 2px rgba(20, 16, 11, .05);     /* [site] sticky bars, raised hover */
  --shadow-2: 0 8px 24px rgba(11, 9, 9, .10);      /* dropdowns, popovers */
  --shadow-3: 0 28px 70px rgba(11, 9, 9, .32);     /* [site] dialogs, drawers */
  --z-sticky: 50; --z-nav: 100; --z-drop: 200; --z-overlay: 900; --z-modal: 1000; --z-toast: 1100;
  --dur-fast: 120ms; --dur-base: 180ms; --ease: cubic-bezier(.2, 0, 0, 1);

  /* ── Layout ────────────────────────────────────────────────────────── */
  --nav-w: 232px; --nav-w-rail: 64px; --topbar-h: 56px;
  --page-pad: 24px; --gap: 16px;
  --control-h: 32px; --row-h: 36px;
}

@media (max-width: 767px) {
  :root { --page-pad: 16px; --gap: 12px; --fs-display: 22px; --lh-display: 28px; --fs-kpi: 24px; --lh-kpi: 28px; }
}

/* ── Base ─────────────────────────────────────────────────────────── */
body {
  font: var(--fw-regular) var(--fs-body)/var(--lh-body) var(--font-text);
  color: var(--text);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums; /* aligned figures everywhere text-face numbers appear */
}
/* One focus ring for the whole app: visible, 3:1+, keyboard-only. */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ── Legacy aliases ─────────────────────────────────────────────────────
   The names app.html used to define, still read by module code. Each maps onto a token, so
   unmigrated code already wears the new palette. Delete a line when its last reader migrates
   (Phase 5); nothing new may use them. */
:root {
  --gold: var(--accent-mark);
  --green: var(--positive);
  --red: var(--negative);
  --blue: var(--info);
  --orange: var(--warning);
  --mint: var(--chart-5);
  --purple: var(--chart-6);
  --sky: var(--chart-4);
  --bg: var(--bg-canvas);
  --ink: var(--text-strong);
  --muted: var(--text-muted);
  --line: var(--border);
  --font-body: var(--font-text);
  --font-serif: var(--font-brand);
  --font-mono: var(--font-text); /* numbers were set in DM Mono; the text face's tabular figures replace it */
}
