/*
 * Right-to-left pages (/ar, /ur): fonts and the few things that must NOT be mirrored.
 * The mirrored layout itself comes from css/rtl/*.css (generated by tools/rtl/gen.js with rtlcss).
 */

/* Interface text: Noto Sans Arabic for Arabic script; Latin falls back to Inter */
html[dir="rtl"] body,
html[dir="rtl"] body *:not(svg):not(svg *) {
    font-family: 'Noto Sans Arabic', 'Inter', system-ui, sans-serif !important;
    letter-spacing: 0 !important;
}

/* Urdu reading text in Nastaliq (headings and controls stay in Naskh-style Noto Sans Arabic) */
html[lang="ur"] body :is(p, li, dd, blockquote, .gr-lead, .h-quran-desc, .h-section-heading-sub, .qs-trans, .q-welcome-subtitle):not(svg *) {
    font-family: 'Noto Nastaliq Urdu', 'Noto Sans Arabic', 'Inter', serif !important;
    line-height: 2.2;
}

/* Qur'anic Arabic keeps its own typeface */
html[dir="rtl"] :is(.qs-name-ar, .qs-basmala, .qs-ar, .qx-ar, .ayah-arabic, .ayah-end-marker, .mushaf-text, .mushaf-ayah, .mushaf-ayah-num,
    .q-bismillah-text, .q-surah-title-ar, .surah-card-ar, .q-src-arabic, .cg-today-ar, .hd-ar, .hd-out-ar, .eid-takbeer, .lp-salam,
    .dn-thanks span, .index-juz-card-ar, .index-bookmark-card-ar, .q-bookmark-item-ar, .h-event-hero-deco) {
    font-family: 'Amiri Quran', 'Amiri', serif !important;
}

/* Uppercase / wide tracking does not exist in Arabic script */
html[dir="rtl"] body * { text-transform: none !important; }

/* Numbers, times, coordinates and Latin codes read left to right inside RTL text */
html[dir="rtl"] :is(input[type="number"], .h-qibla-coords, .q-player-time, .qp-time, .h-qibla-info-value, [id$="-distance"], [id$="-bearing"], code, kbd) {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Compasses show real directions: never mirror them */
html[dir="rtl"] :is(.h-compass, .h-qibla-compass, .qibla-compass, .compass, .qb-compass, .cmp-dial) {
    direction: ltr;
}

/* Direction arrows and chevrons point the other way */
html[dir="rtl"] :is(svg:has(> polyline[points="9 18 15 12 9 6"]), svg:has(> polyline[points="15 18 9 12 15 6"]),
    svg:has(> path[d="M9 18l6-6-6-6"]), svg:has(> path[d="M15 18l-6-6 6-6"]), .qx-sc-go) {
    transform: scaleX(-1);
}
html[dir="rtl"] .qx-sc-go { display: inline-block; }
html[dir="rtl"] .qx-sc:hover .qx-sc-go { transform: scaleX(-1) translateX(3px); }

/* Arabic text blocks the LTR stylesheets already right-align: keep them right-aligned (rtlcss would flip them) */
html[dir="rtl"] :is(.qs-ar, .ayah-arabic, .eid-takbeer, .q-src-arabic) {
    direction: rtl !important;
    text-align: right !important;
}

/* Countdown units written as words (ساعت / دقیقه, گھنٹے / منٹ) need less room than the Latin h / m */
html:is([lang="fa"], [lang="ur"]) :is(.gr-next-unit, .h-hero-unit) { font-size: clamp(18px, 3vw, 34px) !important; }
