/* qamar-common tokens.css — the design tokens of muftiqamar.com AND maktaba.muftiqamar.com: the ONE place for
   colour, type, space, shape and motion. Linked first on every page of both sites, before common.css and the
   site stylesheets, which only consume these. A site never redefines a token here; a new token goes into this file
   (see README.md, "Adding a shared component").

   Palette: Paper Emerald by day, sage by night (chosen 2026-11-27; alternatives: dars static/themes/, review mockups).
   Fonts (work/polish/content/rules.md css-ar-face, ux-research §9):
     --font-ur        Noto Nastaliq Urdu — all Urdu
     --font-ar        Amiri              — all Arabic text: Quran, hadith, duas, Arabic blocks, surah names (user prefers Amiri)
     --font-ar-display Amiri             — large Arabic display titles only (surah titles, basmala)
     --font-en        Source Serif 4     — English
   Type scale (1.2 ratio, 16 px base): --fs-{caption,small,body,lead,h3,h2,h1,display} for Latin; --fs-ur-* for Urdu
   (Nastaliq needs ~1.3× the size and ~2× the leading to read at the same weight). Caption is the minimum anywhere.
   The dark palette applies from the OS preference; header.js forces light/dark by rewriting this media query
   (cookie qamar-scheme, <html data-scheme>). */

:root {
  color-scheme: light dark;

  /* ─── Colour: surfaces and text ─── */
  --bg: #fdfdfa;            /* page (surface-0) */
  --bg-2: #ffffff;          /* raised surface: panels, rails, bars (surface-1) */
  --bg-3: #f3f4ef;          /* subtle fill: hover, chips, buttons, header (surface-2) */
  --fg: #1b211e;            /* text-1 */
  --fg-2: #565c57;          /* text-2: secondary text */
  --muted: var(--fg-2);
  --accent: #0d6647;        /* brand */
  --accent-2: #0a4732;      /* brand-strong: headings, titles, nav labels */
  --on-accent: #ffffff;
  --border: #e2e4dc;        /* line */
  --rule: #ecede6;          /* line-soft: hairlines and dividers */
  --glass: rgba(255, 255, 255, 0.94);
  --focus: var(--accent);

  /* ─── Colour: semantic ─── */
  --green: #1d7550; --yellow: #66665e; --red: #a93527;
  --quran-bg: #ebf5ee; --quran-fg: #154830;
  --hadith-bg: #f0f2f1; --hadith-fg: #3a4744;
  --dua-bg: #f3f4ef;
  --theme-bg: #e8f2f3; --theme-fg: #1f4f55;
  --quote-bg: #f6f7f3; --note-bg: #f0f6f2;
  --ok-bg: #e0f1e6; --warn-bg: #f1f2ee; --danger-bg: #f8e5e1;
  --gap-bg: #f3f4ef; --gap-fg: #4a4b44; --gap-border: #a8aa9f;
  --highlight: #fff4c2;     /* search hits, the paragraph now playing, a contents jump landing */
  --nl-mark: #b4b7ad;
  --cover-ph-bg: #0d6647; --cover-ph-frame: #cfe0d3;  /* cover placeholder: emerald (= --accent) */
  /* Library gold: the ONE sanctioned exception to the green palette. Used only by the Library nav item (.qc-library). */
  --library-gold: #7a5200;          /* text + hover/focus ring on the gold wash */
  --library-gold-bg: #f8edc8;       /* the soft warm wash behind the item */
  --library-gold-ring: #c9a23c;     /* hairline ring */
  --library-gold-glow: rgba(201, 162, 60, 0.40);  /* outer halo */
  --library-gold-sel: #ffe27a;      /* pressed / current page: luminous pale gold (glows brighter, never brown) */
  --library-gold-on-sel: #5c3d00;   /* text on the selected fill (≈7.5:1) */
  --library-gold-sel-ring: #f0b400; /* bright gold edge when selected */
  --library-gold-sel-glow: rgba(255, 196, 0, 0.65);  /* the brighter halo when selected */
  --paper: #fefefc;         /* behind page scans */
  --shadow: 0 1px 2px rgba(30, 40, 30, 0.04), 0 4px 16px rgba(40, 50, 30, 0.06);
  --shadow-hover: 0 4px 12px rgba(30, 40, 30, 0.09);
  --shadow-book: 0 18px 40px rgba(20, 45, 30, 0.16), 0 2px 6px rgba(20, 45, 30, 0.10);

  /* ─── Fonts ─── */
  --font-ur: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif;
  --font-ar: 'Amiri', serif;  /* user 2026-11-29: Amiri everywhere (basmala style), not Noto Naskh (removed 1.4.2) */
  --font-ar-ui: var(--font-ar);
  --font-ar-display: 'Amiri', serif;
  --font-en: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;  /* review builds only */

  /* ─── Type scale ─── */
  --fs-caption: 12px;  --fs-small: 14px;  --fs-body: 16px;  --fs-lead: 19px;
  --fs-h3: 20px;       --fs-h2: 24px;     --fs-h1: 32px;    --fs-display: 40px;
  --fs-ur-caption: 15px; --fs-ur-small: 17px; --fs-ur-body: calc(21px * var(--text-scale-ur)); --fs-ur-lead: 24px;
  --fs-ur-h3: 24px;      --fs-ur-h2: 30px;    --fs-ur-h1: 40px;   --fs-ur-display: 52px;
  --lh-en: 1.6; --lh-ur: 2.1; --lh-ar: 1.9; --lh-ur-tight: 1.8;
  /* Urdu page default (main[lang="ur"]): dars's Urdu UI text — labels, list rows, notes (1.1.0). Urdu reading text
     (prose, a book's page text, search snippets) is --fs-ur-body / --lh-ur. */
  --fs-ur-ui: var(--fs-ur-small); --lh-ur-ui: 2;
  /* used by the transcript and book columns */
  --fs-xs: 11px; --fs-s: var(--fs-caption); --fs-m: var(--fs-small);
  /* 1.6.0: the READING sizes below follow the reader's text size (--text-scale-ur for Nastaliq, --text-scale for
     Latin and Amiri; see "Text size" at the end of this file). UI sizes (labels, controls, header) do not. */
  --fs-trans: calc(15px * var(--text-scale));
  --fs-ur-body-phone: calc(19px * var(--text-scale-ur));  /* 1.1.1: Urdu reading text on phones (<= 720 px), applied to --fs-urdu below */
  --fs-urdu: var(--fs-ur-body); --lh-urdu: var(--lh-ur);
  --fs-arabic: calc(22px * var(--text-scale)); --lh-arabic: var(--lh-ar);
  --fs-persian: calc(20px * var(--text-scale));
  --fs-latin-block: calc(15px * var(--text-scale));
  --fs-ur-title-s: 21px; --fs-ar-title: 22px;  /* 1.6.0: fixed UI twins of --fs-ur-body / --fs-arabic (titles in cards and list rows) */

  /* ─── Space, shape, layout, motion ─── */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --gutter: 16px;                       /* phone side gutter */
  --measure-en: 72ch; --measure-ur: 34em;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 16px; --radius-pill: 999px;
  --sidebar-w: 320px;
  --content-max: 1200px;
  --dur: 150ms;
}

@media (max-width: 720px) { :root { --fs-urdu: var(--fs-ur-body-phone); } }

@media screen and (prefers-color-scheme: dark) {  /* never in print: pale ink on white */
  :root {
    /* sage night */
    --bg: #111513; --bg-2: #181d1a; --bg-3: #212824;
    --fg: #ebedea; --fg-2: #a6aea9;
    --accent: #93b59f; --accent-2: #cfe0d3; --on-accent: #111513;
    --border: #2d3631; --rule: #252d29; --glass: rgba(24, 29, 26, 0.94);
    --green: #6fcf9c; --yellow: #b8b9b2; --red: #ec8874;
    --quran-bg: #162b21; --quran-fg: #bfe5cf;
    --hadith-bg: #1f2523; --hadith-fg: #cfd8d4;
    --dua-bg: #1d2421;
    --theme-bg: #172a2c; --theme-fg: #b4dade;
    --quote-bg: #1a201d; --note-bg: #19241f;
    --ok-bg: #162b21; --warn-bg: #222623; --danger-bg: #37201c;
    --gap-bg: #222623; --gap-fg: #d2d4cc; --gap-border: #6d706a;
    --highlight: #4a3c22;
    --nl-mark: #57605b;
    --cover-ph-bg: #1c4a37; --cover-ph-frame: #7fa28d;  /* deep green */
    --library-gold: #ecc866; --library-gold-bg: #2c2512; --library-gold-ring: #8c7230;
    --library-gold-glow: rgba(236, 200, 102, 0.28); --library-gold-sel: #ffd24d; --library-gold-on-sel: #241800;
    --library-gold-sel-ring: #ffc933; --library-gold-sel-glow: rgba(255, 201, 51, 0.55);
    --paper: #e9ebe6;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 24px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-book: 0 18px 50px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.5);
  }
}

/* ─── Generic controls (1.3.0, decision 06): the sizes of inputs, selects, primary/quiet buttons, suggestion chips,
   excerpts and result cards (components.css, "Generic controls"). dars's scale: Urdu text in a control is the Urdu
   UI size (17 px), controls are at least 44 px tall (touch target), 56 px for the large composer pair. Changing a
   size for both sites = changing it here. ─── */
:root {
  --ctl-h: 44px;                        /* min-height: .qc-input, .qc-select, .btn.primary, .btn.quiet, .chip.suggest */
  --ctl-h-lg: 56px;                     /* .lg: the composer textarea and its send button, a big single action */
  --ctl-pad-x: 14px;                    /* inline padding of inputs, selects, suggestion chips, result cards */
  --ctl-radius: var(--radius-m);        /* inputs, selects, suggestion chips, result cards (buttons stay pills) */
  --fs-ctl-ur: var(--fs-ur-small);      /* 17 px: Urdu text in every control */
  --lh-ctl-ur: 2;
  --fs-ctl-en: var(--fs-body);          /* 16 px: English typed text (>= 16 px also stops iOS zoom-on-focus) */
  --fs-ctl-label-en: var(--fs-small);   /* 14 px, weight 600: English button labels (as .btn) */
  --fs-excerpt-ur: var(--fs-ur-small);  /* 17 px: Urdu search snippets, result-card excerpts */
  --lh-excerpt-ur: 2.1;
  --fs-excerpt-ar: 19px;                /* Arabic in a snippet (Amiri reads smaller than Nastaliq at equal px) */
}

/* ─── Caption / status text (1.3.1): .qc-caption, the meta and status lines under a control or a card. ─── */
:root {
  --fs-caption-ur: var(--fs-ur-caption); /* 15 px: Urdu caption (Nastaliq) */
  --lh-caption-ur: 1.9;
  --fs-caption-en: var(--fs-caption);    /* 12 px: English caption */
  --lh-caption-en: 1.6;
}

/* ─── Text size (1.6.0): the reader's A− / A+ choice (header.html .qc-textsize, header.js, head-early.html). ───
   One step per device, stored in localStorage "qamar-text" (-1 … 3, default 0) and set before first paint as
   <html data-qc-text="N"> by the inline head-early.html script. Each step sets two unitless factors on <html>:
     --text-scale-ur  Nastaliq (Urdu) reading text: smaller steps, the face is already large with a 2.1 leading
     --text-scale     Latin (English) and Amiri (Arabic, Persian) reading text
   The reading tokens above multiply by them (--fs-ur-body, --fs-ur-body-phone → --fs-urdu, --fs-arabic,
   --fs-persian, --fs-trans, --fs-latin-block; .qc-prose English). UI tokens (--fs-ur-small, --fs-body, --fs-ctl-*,
   captions, header) stay fixed so controls and the header never reflow. Site CSS may read the factors for its own
   reading parts: `font-size: calc(21px * var(--text-scale-ur))`, `max-width: calc(34em * var(--text-scale-ur))`, a
   wider scan column `flex-grow: var(--text-scale-ur)`. Set them only on <html> (tokens are computed there).
   Print ignores the choice (the factors are 1 in print). Keep the steps in step with header.js (MIN, MAX, PCT) and head-early.html. */
:root { --text-scale: 1; --text-scale-ur: 1; }
html[data-qc-text="-1"] { --text-scale: 0.9;   --text-scale-ur: 0.92; }
html[data-qc-text="1"]  { --text-scale: 1.125; --text-scale-ur: 1.1; }
html[data-qc-text="2"]  { --text-scale: 1.25;  --text-scale-ur: 1.2; }
html[data-qc-text="3"]  { --text-scale: 1.4;   --text-scale-ur: 1.32; }
@media print { html[data-qc-text] { --text-scale: 1; --text-scale-ur: 1; } }
