/* ==========================================================================
   Right-to-left

   Loaded only when MSM_Tools_I18n::direction() is rtl, so the 142KB of Arabic
   webfont never reaches an English or German page.

   The layout itself is not corrected here. Every direction-dependent property
   in the theme uses logical values (padding-inline-start, inset-inline-end,
   text-align: start), so the layout mirrors on its own from the dir attribute.
   What remains in this file is the font, the typographic adjustments Naskh
   needs, and the small number of surfaces that must stay left to right
   whatever the page direction.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Font (vendored, no CDN)

   Noto Naskh Arabic, subsetted to Arabic plus Latin, because the interface
   mixes English product names, code and Latin numerals into Urdu prose
   constantly and a fallback font for those would be visibly mismatched.
   -------------------------------------------------------------------------- */
@font-face {
	font-family: 'Noto Naskh Arabic';
	font-style: normal;
	font-display: swap;
	font-weight: 400;
	src: url('../fonts/noto-naskh-arabic-regular.woff2') format('woff2');
}

@font-face {
	font-family: 'Noto Naskh Arabic';
	font-style: normal;
	font-display: swap;
	font-weight: 700;
	src: url('../fonts/noto-naskh-arabic-bold.woff2') format('woff2');
}

[dir="rtl"] {
	--msm-font-display: 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;
	--msm-font-body: 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;
}

/* --------------------------------------------------------------------------
   Typography

   Arabic script sits on a lower baseline and carries marks above and below,
   so the line heights tuned for Latin crowd it. Letterforms also carry more
   weight per glyph, so display sizes are eased back slightly.
   -------------------------------------------------------------------------- */
[dir="rtl"] body {
	line-height: 1.9;
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4 {
	line-height: 1.55;
	letter-spacing: 0;
}

[dir="rtl"] p,
[dir="rtl"] li {
	line-height: 1.95;
}

/* Naskh has no condensed or tracked-out forms; negative tracking that flatters
   Latin display type damages Arabic joins. */
[dir="rtl"] .gradient-text,
[dir="rtl"] .hero h1,
[dir="rtl"] .section-header h2 {
	letter-spacing: 0;
}

/* --------------------------------------------------------------------------
   Left-to-right islands

   The reason this file matters more here than on a normal site. Around 180
   tools emit hashes, JSON, CSS, regular expressions, cron strings and URLs,
   none of which is Urdu and none of which survives being laid out right to
   left. Bidirectional reordering does not just move these visually — it
   changes where a reader believes a character sits, so a copied hash looks
   correct and is not.
   -------------------------------------------------------------------------- */
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] kbd,
[dir="rtl"] samp,
[dir="rtl"] .result-box pre,
[dir="rtl"] .msm-ai-md pre,
[dir="rtl"] .msm-ai-md code,
[dir="rtl"] .msm-table td code,
[dir="rtl"] .msm-list code {
	direction: ltr;
	text-align: left;
	unicode-bidi: isolate;
}

/* Fields that take technical input: a URL, a hex colour, a regular
   expression or a snippet of code is never Urdu. */
[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="number"],
[dir="rtl"] .form-group input[data-ltr],
[dir="rtl"] .form-group textarea[data-ltr] {
	direction: ltr;
	text-align: left;
}

/* Monospace stays monospace: the Latin stack is kept rather than inherited. */
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] kbd,
[dir="rtl"] samp {
	font-family: var(--msm-font-mono);
}

/* --------------------------------------------------------------------------
   Numerals

   Latin digits throughout. Pakistani users read both, but a tool that reports
   a byte count or a hash length in Eastern Arabic-Indic digits beside output
   that uses Latin ones is harder to read than either alone.
   -------------------------------------------------------------------------- */
[dir="rtl"] .msm-stat-value,
[dir="rtl"] .home-stat-value,
[dir="rtl"] .msm-ad-label,
[dir="rtl"] time {
	font-feature-settings: normal;
}
