/* Loabi — Thaana / Dhivehi RTL scaffolding
 *
 * USAGE
 *   1. Link this sheet: <link rel="stylesheet" href="styles/thaana.css">
 *   2. Set dir="rtl" lang="dv" on <html>.
 *   3. Wrap any embedded LTR content (numbers, URLs, Latin words) in:
 *        <span class="ltr" dir="ltr">...</span>
 *   4. For bold/prominent Dhivehi, headings automatically use MV MAG Round
 *      at weight 700. For extra weight use .thaana-heavy (weight 800).
 *      For decorative/calligraphic text use .thaana-calligraphy.
 *
 * FONTS (all Unicode-correct, verified by cmap+outline inspection)
 *   Body        : MV Faseyha → Faruma → Noto Sans Thaana (Google fallback)
 *   Display/bold: MV MAG Round 700 (Bold) and 800 (XBold) — real weights,
 *                 no synthesis. Replaces MV Aammu FK / MV Waheed which have
 *                 glyphs mapped at non-Thaana codepoints and render garbage.
 *   Calligraphy : Mv Sehga Old — Unicode-correct script face.
 *
 * FONT FILES — call use_kit_asset for each before linking this sheet
 *   (no path arg — manifest paths are already correct):
 *   use_kit_asset("mv-faseyha.woff2")
 *   use_kit_asset("faruma.woff2")
 *   use_kit_asset("mv-mag-round-bold.woff2")
 *   use_kit_asset("mv-mag-round-xbold.woff2")
 *   use_kit_asset("mv-sehga-old.woff2")
 */

/* ── Body fonts ────────────────────────────────────────────────────────── */

/* MV Faseyha — primary body face (clean, ideal for long reading). */
@font-face {
  font-family: "MV Faseyha";
  src: local("MV Faseyha"),
       local("mv-faseyha"),
       url("../fonts/mv-faseyha.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0780-07BF, U+25CC;
}

/* Faruma — secondary body face; Unicode-correct, widely tested. */
@font-face {
  font-family: "Faruma";
  src: local("Faruma"),
       url("../fonts/faruma.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0780-07BF, U+25CC;
}

/* ── Display / bold fonts ───────────────────────────────────────────────── */

/* MV MAG Round Bold — weight 700, for headings and bold emphasis. */
@font-face {
  font-family: "MV MAG Round";
  src: url("../fonts/mv-mag-round-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0780-07BF, U+25CC, U+0020-007E;
}

/* MV MAG Round XBold — weight 800, for extra-heavy display headlines. */
@font-face {
  font-family: "MV MAG Round";
  src: url("../fonts/mv-mag-round-xbold.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0780-07BF, U+25CC, U+0020-007E;
}

/* ── Calligraphy font ───────────────────────────────────────────────────── */

/* Mv Sehga Old — Unicode-correct calligraphic/script face. */
@font-face {
  font-family: "Mv Sehga Old";
  src: url("../fonts/mv-sehga-old.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0780-07BF, U+25CC, U+0020-007E;
}

/* ── CSS custom properties ─────────────────────────────────────────────── */
:root {
  /* Body: MV Faseyha → Faruma. Both Unicode-correct woff2 files from the kit. */
  --loabi-font-thaana: "MV Faseyha", "Faruma", sans-serif;

  /* Display/bold: MV MAG Round has real weight variants (700 Bold, 800 XBold).
     Set font-weight:700 or 800 to select the appropriate weight file. */
  --loabi-font-thaana-display: "MV MAG Round", "MV Faseyha", sans-serif;

  /* Calligraphy/decorative: use for pull-quotes, headings, hero text. */
  --loabi-font-thaana-calligraphy: "Mv Sehga Old", "MV MAG Round", sans-serif;
}

/* ── RTL document root ─────────────────────────────────────────────────── */
[dir="rtl"] {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: start;
  font-family: var(--loabi-font-thaana);
  line-height: 1.8;
  /* Hard stops — !important so template-level styles can't override them.
     letter-spacing breaks Thaana glyph joins; text-transform corrupts
     Unicode codepoints; font-synthesis creates fake-bold stroke distortion. */
  letter-spacing: 0 !important;
  text-transform: none !important;
  font-synthesis: none !important;
}

/* Guard: keep the body Thaana even if page CSS sets a Latin body font.
   `[dir="rtl"] body` (specificity 0,1,1) outranks a bare `body{}` (0,0,1)
   regardless of load order, so a stray `body{font-family:Inter}` in the
   generated stylesheet no longer forces Dhivehi to fall back to the OS
   default Thaana font (MV Boli on Windows). Not !important — a deliberate
   higher-specificity choice can still win. Scope Latin faces to .ltr runs. */
[dir="rtl"] body {
  font-family: var(--loabi-font-thaana);
}

/* ── Inline / block Dhivehi inside an LTR page ─────────────────────────── */
.thaana {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: start;
  font-family: var(--loabi-font-thaana);
  line-height: 1.8;
  letter-spacing: 0 !important;
  text-transform: none !important;
  font-synthesis: none !important;
}

/* ── Display / heading Dhivehi ─────────────────────────────────────────── */
/* MV MAG Round 700 — a real weight file, not synthesised bold. */
.thaana-display,
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3,
[dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6,
.thaana h1, .thaana h2, .thaana h3,
.thaana h4, .thaana h5, .thaana h6 {
  font-family: var(--loabi-font-thaana-display);
  font-weight: 700 !important;
  line-height: 1.55;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* .thaana-heavy — MV MAG Round XBold for extra-large hero headlines. */
.thaana-heavy {
  font-family: var(--loabi-font-thaana-display);
  font-weight: 800 !important;
  line-height: 1.4;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* ── Bold / emphasis ────────────────────────────────────────────────────── */
.thaana-bold,
[dir="rtl"] strong,
[dir="rtl"] b,
.thaana strong,
.thaana b {
  font-family: var(--loabi-font-thaana-display);
  font-weight: 700 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* ── Calligraphy / decorative ───────────────────────────────────────────── */
/* Use for pull-quotes, hero section labels, decorative headings.
   Mv Sehga Old is Unicode-correct (verified cmap inspection). */
.thaana-calligraphy {
  font-family: var(--loabi-font-thaana-calligraphy);
  font-weight: 400 !important;
  line-height: 1.8;
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* ── LTR isolation for Latin/numbers inside RTL ─────────────────────────── */
/* Wrap numbers, URLs, Latin names in: <span class="ltr" dir="ltr">...</span> */
.thaana .ltr,
[dir="rtl"] .ltr {
  direction: ltr;
  unicode-bidi: isolate;
  /* No display:inline-block — that incorrectly creates a new stacking context */
}
