/**
 * Shared RTL layout system for Arabic (dir="rtl").
 * Loaded globally alongside each page's own CSS. Relies mostly on the
 * cascading effect of `direction: rtl` (flex/grid content order and default
 * text-align flip automatically for most existing layouts without needing
 * per-property overrides), plus a few explicit fixes for things direction
 * alone doesn't handle: iconography that implies a direction, and the
 * Arabic web font.
 */

/* Self-hosted Cairo (Arabic + Latin + Latin-Ext, variable weight 200-1000).
   Every page also loads Cairo from Google Fonts via <link>, but ad-blockers,
   privacy extensions, and some regional networks block fonts.gstatic.com —
   the font-family then silently falls back to Segoe UI/Tahoma with no error.
   These local @font-face rules guarantee Cairo renders even when that
   external request is blocked (same-origin src, no third-party dependency). */
@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("../assets/fonts/cairo/cairo-arabic.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, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("../assets/fonts/cairo/cairo-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("../assets/fonts/cairo/cairo-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

[dir="rtl"] body {
    direction: rtl;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select,
[dir="rtl"] button {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

/* Headings across the site use a decorative Latin serif (literal
   'Playfair Display' or the --font-heading variable) which has no Arabic
   glyphs and silently falls back to the browser default font. Force Cairo
   on every heading-level element/class so titles actually render in the
   Arabic typeface instead of a fallback.

   Almost every page also redeclares --font-heading itself inside its own
   <style> block (e.g. `:root { --font-heading: 'Playfair Display', serif; }`),
   which loads AFTER this shared stylesheet. Since :root and [dir="rtl"] tie
   on specificity, source order decides the winner — and the later,
   page-local declaration always wins, silently undoing this override for
   any element that reads the variable via var(--font-heading) with a class
   name our wildcard selectors below don't happen to match (e.g.
   .offer-card__name). !important on the custom property itself is the only
   way to make this win unconditionally regardless of how many pages
   redeclare it or what they name their heading classes. */
[dir="rtl"] {
    --font-heading: 'Cairo', 'Segoe UI', Tahoma, sans-serif !important;
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] [class*="title"],
[dir="rtl"] [class*="heading"],
[dir="rtl"] [class*="Title"],
[dir="rtl"] [class*="Heading"] {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif !important;
}

/* Body text has the exact same problem as headings: many pages hardcode a
   literal font-family (usually 'Poppins', sometimes 'Playfair Display')
   directly on dozens of differently-named classes (.pv-footer-description,
   .pv-copyright, .cmethod__value, etc.) with no shared naming convention to
   select on. Enumerating each one is a losing battle — this is the same bug
   as the headings above, just on body text instead of titles. Rather than
   keep discovering one hardcoded class at a time, force Cairo on every
   element under [dir="rtl"], excluding icon fonts (Font Awesome <i>/<span>
   glyphs are specific codepoints in a symbol font — forcing Cairo on them
   would render boxes instead of icons) and inline SVGs (icons drawn as
   paths, not text, so font-family is irrelevant but harmless to skip). */
[dir="rtl"] *:not(i):not(svg):not(svg *):not([class*="fa-"]):not([class^="fa "]):not([class$=" fa"]) {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif !important;
}

/* Directional icons (arrows, chevrons that imply "forward"/"next" in LTR)
   — add class="rtl-flip" to any <svg>/<i> that should mirror in Arabic. */
[dir="rtl"] .rtl-flip {
    transform: scaleX(-1);
}

/* Numbers, prices, and codes should stay LTR even inside an RTL page
   (e.g. phone numbers, prices like "12.50 OMR", order numbers). */
[dir="rtl"] .ltr-content {
    direction: ltr;
    display: inline-block;
    unicode-bidi: isolate;
}
