/* 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.
   1.6.1: the --fs-* tokens are at the end of this file ("Type scale"): they follow the reader's text size.
   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 */

  --lh-en: 1.6; --lh-ur: 2.1; --lh-ar: 1.9; --lh-ur-tight: 1.8;
  --lh-ur-ui: 2;
  --lh-urdu: var(--lh-ur); --lh-arabic: var(--lh-ar);

  /* ─── Chrome type (1.6.1): the shared header and footer, and any site chrome. FIXED: never multiplied by the
     text-size factors, so the header, the A− A A+ control and the footer never move when the reader resizes text. ─── */
  --fs-chrome-ur: 17px;     /* Urdu nav labels, footer text, the «رنگ» label */
  --fs-chrome-en: 14px;     /* English nav labels, footer text */
  --fs-chrome-en-s: 12px;   /* English nav labels on phones */

  /* ─── 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 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. 1.6.1: the font sizes (--fs-ctl-*, --fs-excerpt-*) are in "Type scale". ─── */
: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) */
  --lh-ctl-ur: 2;
  --lh-excerpt-ur: 2.1;
}

/* ─── Caption / status text (1.3.1): .qc-caption, the meta and status lines under a control or a card (sizes
   --fs-caption-ur / --fs-caption-en: "Type scale"). ─── */
:root {
  --lh-caption-ur: 1.9;
  --lh-caption-en: 1.6;
}

/* ─── Text size (1.6.0; 1.6.1: all content): 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:
     --text-scale-ur  Nastaliq (Urdu): smaller steps, the face is already large with a 2.1 leading
     --text-scale     Latin (English) and Amiri (Arabic, Persian)
   Keep the steps in step with header.js (MIN, MAX, PCT) and head-early.html. Step 1 is at least +10 % for both. ─── */
: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; } }  /* print ignores the choice */

/* ─── Fixed chrome (1.6.1): the shared header and footer, and any element a site marks .qc-fixed-size (its audio
   player bar, a reader toolbar, a composer) keep the default size at every step. The factors are 1 there, and the
   type tokens below are declared again on those elements, so they compute at 1 for the whole subtree (a custom
   property is computed where it is declared: resetting the factors alone would not reach the tokens). ─── */
.qc-fixed-size, .qc-header, .qc-footer { --text-scale: 1; --text-scale-ur: 1; }

/* ─── Type scale (1.6.1: every content size follows the text size) ───
   Every --fs-* token below is a CONTENT size and multiplies by its factor: Nastaliq (--fs-ur-*, --fs-urdu, the Urdu
   control / excerpt / caption sizes) by --text-scale-ur, Latin and Amiri by --text-scale. So headings, page titles,
   card and list titles, descriptions, chips, intros, metadata lines, search results and reading text all grow with
   A+. Chrome uses --fs-chrome-* (fixed, in :root above) or sits inside .qc-fixed-size.
   Site CSS: never multiply a token again (calc(var(--fs-lead) * var(--text-scale)) is now DOUBLE); write a literal
   size as calc(<px> * var(--text-scale-ur)) for Nastaliq or calc(<px> * var(--text-scale)) for Latin / Amiri
   (`python check.py --text-scale PATH` lists what to convert). A site that redefines a token writes it the same way.
   Values are at step 0. Latin: 1.2 ratio, 16 px base. Nastaliq needs ~1.3× the size and ~2× the leading. */
:root, .qc-fixed-size, .qc-header, .qc-footer {
  /* Latin */
  --fs-caption: calc(12px * var(--text-scale));  --fs-small: calc(14px * var(--text-scale));
  --fs-body: calc(16px * var(--text-scale));     --fs-lead: calc(19px * var(--text-scale));
  --fs-h3: calc(20px * var(--text-scale));       --fs-h2: calc(24px * var(--text-scale));
  --fs-h1: calc(32px * var(--text-scale));       --fs-display: calc(40px * var(--text-scale));
  --fs-xs: calc(11px * var(--text-scale)); --fs-s: var(--fs-caption); --fs-m: var(--fs-small);  /* transcript and book columns */
  /* Urdu (Nastaliq) */
  --fs-ur-caption: calc(15px * var(--text-scale-ur)); --fs-ur-small: calc(17px * var(--text-scale-ur));
  --fs-ur-body: calc(21px * var(--text-scale-ur));    --fs-ur-lead: calc(24px * var(--text-scale-ur));
  --fs-ur-h3: calc(24px * var(--text-scale-ur));      --fs-ur-h2: calc(30px * var(--text-scale-ur));
  --fs-ur-h1: calc(40px * var(--text-scale-ur));      --fs-ur-display: calc(52px * var(--text-scale-ur));
  /* 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-urdu. */
  --fs-ur-ui: var(--fs-ur-small);
  /* reading text: Urdu prose, Arabic, Persian, translations, Latin blocks */
  --fs-ur-body-phone: calc(19px * var(--text-scale-ur));  /* 1.1.1: Urdu reading text on phones (<= 720 px) → --fs-urdu */
  --fs-urdu: var(--fs-ur-body);
  --fs-arabic: calc(22px * var(--text-scale));
  --fs-persian: calc(20px * var(--text-scale));
  --fs-trans: calc(15px * var(--text-scale));
  --fs-latin-block: calc(15px * var(--text-scale));
  /* titles in cards and list rows (1.6.0 twins of --fs-ur-body / --fs-arabic; 1.6.1: they scale too) */
  --fs-ur-title-s: calc(21px * var(--text-scale-ur)); --fs-ar-title: calc(22px * var(--text-scale));
  /* generic controls (1.3.0, decision 06; components.css "Generic controls"). Typed English stays >= 16 px at every
     step (iOS zooms into a smaller input). Control HEIGHTS (--ctl-h) stay fixed: they are minimums. */
  --fs-ctl-ur: var(--fs-ur-small);      /* 17 px: Urdu text in every control */
  --fs-ctl-en: max(16px, calc(16px * var(--text-scale)));  /* English typed text */
  --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 */
  --fs-excerpt-ar: calc(19px * var(--text-scale));  /* 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 */
  --fs-caption-ur: var(--fs-ur-caption); /* 15 px */
  --fs-caption-en: var(--fs-caption);    /* 12 px */
}
@media (max-width: 720px) { :root, .qc-fixed-size, .qc-header, .qc-footer { --fs-urdu: var(--fs-ur-body-phone); } }
