/*
 * Self-hosted RTL script webfonts — Arabic + Hebrew.
 *
 * WHY THIS FILE IS SEPARATE FROM THE GLOBAL BUNDLE:
 * The marketing/admin UI font is `@fontsource-variable/inter`, imported once
 * in src/main.tsx and applied to every page via theme.ts. Inter's self-hosted
 * subsets cover latin/latin-ext/cyrillic/greek/vietnamese only (see
 * node_modules/@fontsource-variable/inter/unicode.json) — NO Arabic and NO
 * Hebrew glyphs are shipped, so `ar`/`he` marketing pages fall back to
 * whatever system font the visitor's OS/browser happens to have. This file
 * fixes that by self-hosting IBM Plex Sans Arabic + IBM Plex Sans Hebrew
 * (same family as each other, metrics-compatible pairing) and is linked ONLY
 * from the prerendered `ar`/`he` HTML files (see scripts/prerender.mjs) — it
 * must NEVER be referenced from index.html or any Latin-locale page, per the
 * "marketing must never pay a render-blocking Google Fonts cost" rule (see
 * the comment in index.html). These are self-hosted static files served from
 * the same origin — no external Google Fonts CDN request, no render-blocking
 * cross-origin connection — and this stylesheet only loads on the ~2 of 8
 * locales that need it.
 *
 * Only 3 static weights per family (400/600/700) are shipped — enough to
 * cover body copy (400), Mantine's headings weight (650, rounds to the
 * nearest available weight — 600 or 700 — via standard CSS font matching),
 * and emphasized/bold inline text (700). This is a small slice of each
 * @fontsource package (which ships 9 weights x multiple unicode subsets);
 * only the arabic/hebrew subset files at these 3 weights were copied into
 * public/fonts/ to keep the repo lean.
 */

/* ---- IBM Plex Sans Arabic (ar) ---- */

@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ibm-plex-sans-arabic-400.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/ibm-plex-sans-arabic-600.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ibm-plex-sans-arabic-700.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* ---- IBM Plex Sans Hebrew (he) ---- */

@font-face {
  font-family: 'IBM Plex Sans Hebrew';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ibm-plex-sans-hebrew-400.woff2') format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

@font-face {
  font-family: 'IBM Plex Sans Hebrew';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/ibm-plex-sans-hebrew-600.woff2') format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

@font-face {
  font-family: 'IBM Plex Sans Hebrew';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ibm-plex-sans-hebrew-700.woff2') format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

/*
 * Body/heading font stack per RTL locale. The RTL script family goes FIRST
 * so its glyphs win for Arabic/Hebrew runs; "Inter Variable" + the rest of
 * the existing theme.ts stack stay right after so Latin glyphs inside mixed
 * text (numbers, brand names, embedded English) keep rendering in Inter —
 * this file only ADDS script coverage, it never removes the Latin stack.
 *
 * IMPORTANT: this overrides the `--mantine-font-family` /
 * `--mantine-font-family-headings` CSS custom properties, NOT a plain
 * `font-family` on `body`. Every Mantine component (Title, Text, Button, …)
 * sets `font-family: var(--mantine-font-family[-headings])` directly on
 * itself (see @mantine/core/styles.css) rather than inheriting from an
 * ancestor, so a `body { font-family }` rule alone would silently miss all
 * Mantine-rendered text — which is nearly every marketing page. Mantine's
 * own theme override ships as an inline `<style data-mantine-styles="true">`
 * block scoped to plain `:root` (specificity 0,1,0); the `:lang()` pseudo
 * class below raises our selector to (0,2,0), so it always wins the cascade
 * regardless of DOM order, and the plain `body` rule stays as a fallback
 * for non-Mantine elements. Selector matches the prerendered
 * `<html lang="ar" dir="rtl">` root (see scripts/prerender.mjs htmlLangDir)
 * and is scoped narrowly by :lang() so it can never leak onto a Latin-locale
 * page even if this stylesheet were ever loaded there by mistake.
 */
:root:lang(ar) {
  --mantine-font-family:
    'IBM Plex Sans Arabic', 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mantine-font-family-headings:
    'IBM Plex Sans Arabic', 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
}
:root:lang(ar) body {
  font-family:
    'IBM Plex Sans Arabic',
    'Inter Variable',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
}

:root:lang(he) {
  --mantine-font-family:
    'IBM Plex Sans Hebrew', 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mantine-font-family-headings:
    'IBM Plex Sans Hebrew', 'Inter Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
}
:root:lang(he) body {
  font-family:
    'IBM Plex Sans Hebrew',
    'Inter Variable',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
}
