/* =====================================================================================================
   NeuroShrub KYC — language, script and direction support (KYC-DESIGN 14.4), loaded last. Adapted from NeuroShrub's i18n.css: <html>
   carries lang, dir and data-script; fonts are first-party OFL families (css/fonts/*.css, lib/fontsource) with system fallbacks; CJK
   uses the system fonts. Technical values (ids, e-mails, sizes, dates in ISO form) stay left-to-right on right-to-left pages.
   ===================================================================================================== */

/* ---------- Font stacks per writing system ---------- */
html[data-script="cyrillic"] {
    --ai-font-display: "Exo 2", "Chakra Petch", "Segoe UI", system-ui, sans-serif;
}
html[lang="ar"] {
    --ai-font-body: "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
    --ai-font-display: "Noto Kufi Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
html[lang="fa"] {
    --ai-font-body: "Vazirmatn", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
    --ai-font-display: "Vazirmatn", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
html[lang="ur"] {
    --ai-font-body: "Noto Nastaliq Urdu", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
    --ai-font-display: "Noto Sans Arabic", "Noto Nastaliq Urdu", "Segoe UI", Tahoma, sans-serif;
}
html[data-script="hebrew"] {
    --ai-font-body: "Noto Sans Hebrew", "Segoe UI", Arial, system-ui, sans-serif;
    --ai-font-display: "Rubik", "Noto Sans Hebrew", "Segoe UI", Arial, sans-serif;
}
/* CJK: system fonts only. Each stack names the platform UI font (macOS/iOS, Windows), then the Noto/Source Han CJK families
   that Android, ChromeOS and Linux install under either name, then the generic families. Latin text inside CJK pages uses the
   same fonts (they include Latin glyphs designed to match). */
html[data-script="hans"] {
    --ai-font-body: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "Source Han Sans CN", system-ui, sans-serif;
    --ai-font-display: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
}
html[data-script="hant"] {
    --ai-font-body: "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", "Source Han Sans TC", "Source Han Sans TW", system-ui, sans-serif;
    --ai-font-display: "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", "Source Han Sans TC", system-ui, sans-serif;
}
html[data-script="japanese"] {
    --ai-font-body: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", "Source Han Sans JP", system-ui, sans-serif;
    --ai-font-display: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", "Source Han Sans JP", system-ui, sans-serif;
}
html[data-script="korean"] {
    --ai-font-body: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Noto Sans KR", "Source Han Sans KR", "Nanum Gothic", system-ui, sans-serif;
    --ai-font-display: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Noto Sans KR", "Source Han Sans KR", "Nanum Gothic", system-ui, sans-serif;
}
html[data-script="devanagari"] {
    --ai-font-body: "Noto Sans Devanagari", "Nirmala UI", "Mangal", system-ui, sans-serif;
    --ai-font-display: "Rajdhani", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
}
html[data-script="bengali"] {
    --ai-font-body: "Noto Sans Bengali", "Nirmala UI", "Vrinda", system-ui, sans-serif;
    --ai-font-display: "Noto Sans Bengali", "Nirmala UI", sans-serif;
}
html[data-script="thai"] {
    --ai-font-body: "Noto Sans Thai", "Leelawadee UI", "Tahoma", system-ui, sans-serif;
    --ai-font-display: "Chakra Petch", "Noto Sans Thai", "Leelawadee UI", sans-serif;
}
/* Bootstrap reads its own variables; keep them in step with the theme tokens. */
html:not([data-script="latin"]) {
    --bs-body-font-family: var(--ai-font-body);
    --bs-font-sans-serif: var(--ai-font-body);
}

/* ---------- Case and tracking ----------
   Uppercase labels and wide letter spacing belong to Latin and Cyrillic. Scripts without letter case, and scripts whose
   letters join or stack (Arabic, Devanagari, Bengali, Thai), keep their natural shapes: no tracking, no forced case. */
html:not([data-script="latin"]):not([data-script="cyrillic"]) * {
    letter-spacing: normal !important;
    text-transform: none !important;
}
/* Tiny uppercase labels are sized for Latin capitals; give complex scripts a readable minimum. */
html:not([data-script="latin"]):not([data-script="cyrillic"]) :is(.kyc-steps__label, .kyc-brand__sub, .kyc-muted, .kyc-choice__sides, .small, small) {
    font-size: max(.78rem, 1em);
}
html[data-script="hans"], html[data-script="hant"], html[data-script="japanese"], html[data-script="korean"] {
    line-break: strict;
    word-break: normal;
}
html[data-script="hans"] body, html[data-script="hant"] body, html[data-script="japanese"] body, html[data-script="korean"] body { line-height: 1.7; }
html[data-script="devanagari"] body, html[data-script="bengali"] body, html[data-script="thai"] body { line-height: 1.75; }
html[lang="ur"] body { line-height: 2.05; }
html[lang="ur"] :is(h1, h2, h3, h4, .h1, .h2, .h3, .h4, .display-1, .display-2, .display-3, .display-4) { line-height: 1.75; }
html[data-script="arabic"] :is(h1, h2, h3, h4, .h1, .h2, .h3, .h4), html[data-script="devanagari"] :is(h1, h2, h3, h4) { line-height: 1.45; }

/* The product name is a Latin wordmark in every language. */
.brand-word, [lang="en"].brand-word { font-family: "Chakra Petch", "Segoe UI", system-ui, sans-serif; letter-spacing: .03em !important; }

/* Long words (German, Russian) wrap instead of overflowing panels and buttons. */
.kyc-panel, .btn, .kyc-lang__option, .kyc-choice__label, li, dd { overflow-wrap: break-word; }

/* ---------- Right-to-left ---------- */
[dir="rtl"] :is(code, kbd, samp, pre, .font-monospace, .ltr, input[type="email"], input[type="url"], input[type="number"]) {
    direction: ltr;
    unicode-bidi: isolate;
}
[dir="rtl"] :is(.bi-arrow-right, .bi-arrow-left, .bi-chevron-right, .bi-chevron-left, .bi-box-arrow-right)::before {
    display: inline-block;
    transform: scaleX(-1);
}
[dir="rtl"] .form-select { background-position: left .75rem center; }
