/* ============================================================
   Arabic (RTL) locale overrides. Loaded ONLY on /ar/ pages (base.njk gates it
   on loc.code == 'ar'), so every rule here is AR-only and never touches EN.
   The document is already dir="rtl", so flex/grid layout mirrors automatically;
   this sheet covers what direction-agnostic CSS does NOT: the Arabic typeface and
   the few physical (left/right) properties that don't flip on their own.

   NOTE (deferred): a few inline paddings use physical sides (e.g. the location
   card meta line) — minor, best tuned once the Arabic copy is finalised.
   ============================================================ */

/* ---- Arabic typography guard ----------------------------------------------
   Two EN-design defaults must never reach an Arabic page:
     letter-spacing - tracking disconnects the cursive Arabic script.
     text-transform - uppercasing is a no-op on Arabic (no letter case), but it
       DOES mangle Latin runs that legitimately sit inside Arabic copy: product
       names and acronyms would render FLEETOS instead of FleetOS.
   The few Latin runs lose their tracking too, which is the correct trade on an
   Arabic-first page.

   Selector note: this MUST target descendants, not just <html>. Both properties
   are inherited, but inheritance only supplies a value to an element that has no
   declaration of its own — and this site sets `text-transform:uppercase` /
   `letter-spacing` via INLINE styles on descendants, which are their own
   declarations and would beat a value inherited from <html>. An !important on
   `html[dir="rtl"]` alone only wins against other rules targeting <html>, so it
   would silently do nothing here. Author !important does outrank inline styles,
   hence `... .nlm-page *` + !important. Verified: computed text-transform on the
   previously-uppercased eyebrows is `none`. */
html[lang="ar"] .nlm-page *,
html[dir="rtl"] .nlm-page * {
  text-transform: none !important;
  letter-spacing: normal !important;
}

/* ---- Arabic typeface -------------------------------------------------------
   SINGLE SOURCE OF TRUTH: --font-ar is the only place the Arabic font is named.
   Change it here and every Arabic page restyles — no component, section or page
   hardcodes an Arabic font. (One companion edit: the Google Fonts <link> in
   base.njk must load whatever family this names. Those two lines are the whole
   contract; the comment in base.njk points back here.)

   It is slotted INTO the existing stacks AFTER the Latin brand fonts rather than
   replacing them. That ordering is load-bearing: Latin runs (the `nehlum`
   wordmark, product names like FleetOS, ISO codes, Western digits) keep rendering
   in Sora/Poppins, and only glyphs those fonts lack — i.e. Arabic — fall through.
   Setting `font-family` on html[lang="ar"] instead would override the whole stack
   and render those Latin names in the Arabic face.

   Scaling note: no legacy page declares --nlm-font-*; they only reference it. So
   this :root override already reaches every migrated page — migrated templates
   must never re-declare --nlm-font-* (if a page needs CLS fallback faces, include
   var(--font-ar) in the stack, as #nlm-home does below). ------------------- */
:root {
  --font-ar: 'IBM Plex Sans Arabic';

  --nlm-font-display: 'Sora', var(--font-ar), system-ui, sans-serif;
  --nlm-font-body: 'Poppins', var(--font-ar), system-ui, sans-serif;
  --nlm-font-mono: 'JetBrains Mono', var(--font-ar), ui-monospace, monospace;
}
/* The homepage is the one page that re-declares these vars — its inline head
   <style> carries metric-adjusted fallback faces for the CLS fix and loads after
   this sheet, so re-assert with a matched stack. This is homepage-CLS-specific,
   NOT a pattern to copy onto the other pages. */
#nlm-home {
  --nlm-font-display: 'Sora', 'Sora Fallback', var(--font-ar), system-ui, sans-serif !important;
  --nlm-font-body: 'Poppins', 'Poppins Fallback', var(--font-ar), system-ui, sans-serif !important;
}

/* ---- RTL directional fixes -------------------------------------------------
   The header dropdown panel is absolutely positioned with a physical `left`,
   which does not flip under dir="rtl". Mirror it to the right so the menu opens
   aligned to its trigger in RTL. (The header's own <style> block renders after
   this sheet, so the override needs !important.)

   stylelint physical-property ban disabled here deliberately: the declaration
   being overridden (`.nlm-drop-panel{left:-16px}`) lives in header.njk's inline
   <style>, which this sheet does not control. Cancelling a physical `left`
   REQUIRES a physical `left:auto` — a logical property would not remove it, it
   would apply alongside it and stretch the panel across both edges. The clean
   fix is to make the source declaration logical (inset-inline-start) and delete
   this override entirely; that is a change to shared chrome, tracked as
   follow-up rather than done under a CI-gate task. */
/* stylelint-disable property-disallowed-list -- overriding a physical `left`
   from a sheet we do not control requires a physical `left:auto`; see above. */
.nlm-header-root .nlm-drop-panel {
  left: auto !important;
  right: -16px !important;
}
/* stylelint-enable property-disallowed-list */
