/* ============================================================================
 * i18n-fonts.css — script coverage for the nine translated locales.
 * ----------------------------------------------------------------------------
 * DM Sans (the site's base face) ships LATIN + LATIN-EXT ONLY. Measured against the
 * site catalogs, that leaves:
 *
 *   zh-Hans  1099 codepoints uncovered   -> Noto Sans SC
 *   zh-Hant  1116                        -> Noto Sans TC
 *   ko        642                        -> Noto Sans KR
 *   ru         79 (Cyrillic)             -> Noto Sans
 *   bn         71 (Bengali)              -> Noto Sans Bengali
 *   every locale, incl. ENGLISH: 8       -> arrows/math/geometric, notably U+2192 →
 *                                           ("Calculate my AWW →"). Pre-existing gap.
 *
 * WHY CDN AND NOT SELF-HOSTED, unlike the app: the app is a Capacitor bundle that must
 * render offline with no network, so it self-hosts subsets. This site already loads DM
 * Sans from the Google Fonts CDN on every page — adding the Noto faces from the same
 * origin is consistent with that, costs the repo nothing, and lets Google serve
 * unicode-range-split subsets that are finer-grained than anything hand-built here.
 * If the site ever needs to be CDN-independent, self-hosting is the change to make, and
 * only these @font-face sources move.
 *
 * Applied per <html lang>, so it needs no per-component CSS: the locale page sets
 * lang="zh-Hans" and the token below re-points --font for that document only.
 * ========================================================================== */

/* The base stack, with a symbol-capable fallback ahead of system-ui so the arrow and
   the fraction glyphs resolve from a known face rather than whatever the OS supplies.
   Applies to English too — this is where the pre-existing U+2192 gap gets closed. */
:root {
  --font-i18n-fallback: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font: 'DM Sans', var(--font-i18n-fallback);
}

html:lang(zh-Hans) {
  --font: 'DM Sans', 'Noto Sans SC', var(--font-i18n-fallback), 'PingFang SC', 'Microsoft YaHei';
}
html:lang(zh-Hant) {
  --font: 'DM Sans', 'Noto Sans TC', var(--font-i18n-fallback), 'PingFang TC', 'Microsoft JhengHei';
}
html:lang(ko) {
  --font: 'DM Sans', 'Noto Sans KR', var(--font-i18n-fallback), 'Apple SD Gothic Neo', 'Malgun Gothic';
}
html:lang(bn) {
  --font: 'DM Sans', 'Noto Sans Bengali', var(--font-i18n-fallback), 'Kohinoor Bangla';
}
html:lang(ru) {
  /* DM Sans has NO Cyrillic — verified on the app project, where Russian was silently
     rendering from OS fonts. Noto Sans carries the full Cyrillic block. */
  --font: 'Noto Sans', 'DM Sans', system-ui, -apple-system, sans-serif;
}

/* Redefining --font is not enough on its own. This site is not consistently tokenised:
   several pages (and some inline <style> blocks in the calculators) hardcode
   `font-family: 'DM Sans', system-ui, …` instead of using var(--font). Those rules would
   otherwise win and the CJK/Cyrillic/Bengali text would render from OS fallbacks.
   The locale-qualified selectors below are more specific than a bare `body` or `h1`, and
   the stylesheet is injected last in <head>, so they win on both counts.
   `code`/`pre`/`.mono` are deliberately excluded — those stay monospace. */
html:lang(zh-Hans), html:lang(zh-Hant), html:lang(ko), html:lang(bn), html:lang(ru) {
  font-family: var(--font);
}
html:lang(zh-Hans) body, html:lang(zh-Hant) body, html:lang(ko) body,
html:lang(bn) body, html:lang(ru) body,
html:lang(zh-Hans) :is(h1,h2,h3,h4,h5,h6,p,li,a,span,label,button,input,select,textarea,th,td,summary,figcaption,legend),
html:lang(zh-Hant) :is(h1,h2,h3,h4,h5,h6,p,li,a,span,label,button,input,select,textarea,th,td,summary,figcaption,legend),
html:lang(ko)      :is(h1,h2,h3,h4,h5,h6,p,li,a,span,label,button,input,select,textarea,th,td,summary,figcaption,legend),
html:lang(bn)      :is(h1,h2,h3,h4,h5,h6,p,li,a,span,label,button,input,select,textarea,th,td,summary,figcaption,legend),
html:lang(ru)      :is(h1,h2,h3,h4,h5,h6,p,li,a,span,label,button,input,select,textarea,th,td,summary,figcaption,legend) {
  font-family: var(--font);
}
html:lang(zh-Hans) :is(code,pre,.mono), html:lang(zh-Hant) :is(code,pre,.mono),
html:lang(ko) :is(code,pre,.mono), html:lang(bn) :is(code,pre,.mono),
html:lang(ru) :is(code,pre,.mono) {
  font-family: var(--mono, ui-monospace, monospace);
}

/* Bengali and Korean line boxes are taller than Latin at the same font-size; without
   this, headings clip against tight line-heights tuned for DM Sans. */
html:lang(bn) body, html:lang(ko) body { line-height: 1.6; }
