/* The interface in other languages and scripts (see js/i18n.js, which sets <html lang>).
   Map lettering is chosen in Style; this is only the app's own text. */
/* Must not: set sizes or colors; it only picks system fonts for each language's script
   Layer: ui */

/* System fonts that carry each script, so nothing downloads and each language gets its own
   forms of the shared Han characters. */
:root[lang="zh-Hans"] { --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Segoe UI", system-ui, sans-serif; }
:root[lang="zh-Hant"] { --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", "Segoe UI", system-ui, sans-serif; }
:root[lang="ja"] { --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo UI", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", "Segoe UI", system-ui, sans-serif; }
:root[lang="ko"] { --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Noto Sans KR", "Segoe UI", system-ui, sans-serif; }
/* Hindi: the Latin system face first (for digits, keys and names), then a Devanagari face
   each system has: Kohinoor on Apple, Nirmala UI (or older Mangal) on Windows, Noto on
   Android and Linux. */
:root[lang="hi"] { --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Kohinoor Devanagari", "Devanagari Sangam MN", "Nirmala UI", "Mangal", "Noto Sans Devanagari", system-ui, sans-serif; }

/* CJK: no tracking on small caps-style headings (it only spreads the characters apart), and
   a touch more room between lines. Korean breaks between words, as it is written. */
:root:is([lang="zh-Hans"], [lang="zh-Hant"], [lang="ja"], [lang="ko"]) :is(h3, .new-row, .home-sub, .bi-title, .new-tag) { letter-spacing: 0; }
:root:is([lang="zh-Hans"], [lang="zh-Hant"], [lang="ja"], [lang="ko"]) body { line-height: 1.45; }
:root[lang="ko"] body { word-break: keep-all; overflow-wrap: anywhere; }
:root[lang="ja"] body, :root[lang^="zh"] body { line-break: strict; }

/* Devanagari: letters join along the headline, so any tracking pulls the words apart and
   breaks the conjuncts; vowel signs above and below need taller lines. Map lettering (SVG)
   keeps its own spacing, and so do inputs (the digit boxes for sign-in codes). The rules it
   undoes are scattered and some are id-scoped, hence !important (LINT-EXCEPTION). */
:root[lang="hi"] body :not(svg, svg *, input) { letter-spacing: normal !important; }
:root[lang="hi"] body { line-height: 1.5; }

/* Longer words (German, French, Spanish, Portuguese, Italian, Polish, Russian, Indonesian,
   Hindi): let narrow captions break between syllables instead of spilling out of their boxes. */
:root:is([lang="de"], [lang="fr"], [lang="es"], [lang="pt-BR"], [lang="it"], [lang="pl"], [lang="ru"], [lang="id"], [lang="hi"]) :is(button, label, [role="tab"]) { hyphens: auto; overflow-wrap: break-word; }

/* The language menu in dialogs and on the front page. */
.dialog-lang > span { white-space: nowrap; }
dialog .dialog-lang .lang-picker { width: auto; flex: 0 1 auto; margin: 0; }
.menu-lang { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding: 8px 8px 2px; border-top: 1px solid var(--line); color: var(--dim); font-size: var(--font-s); }
#pop-account .menu-lang { margin: 4px 0; padding: 6px 8px; border-bottom: 1px solid var(--line); }
#pop-account .menu-lang .lang-picker { max-width: 60%; }
.dialog-lang { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; color: var(--dim); font-size: var(--font-s); }
.lang-picker { font: inherit; font-size: var(--font-s); padding: 3px 6px; border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--bg-2, transparent); color: inherit; }
footer .lang-picker { margin-left: auto; }

/* Lettering choices are named in the lettering itself; a long translated name wraps rather
   than being cut off. */
:root:not([lang="en"]) .font-choice { white-space: normal; line-height: 1.2; }

/* Tool rail captions: use the button's full width (English captions are short enough for the
   default padding; "Sélection", "Siedlung" or "Fronteira" are not), and if a word still
   doesn't fit, break it with a hyphen onto a second, tighter line. */
:root:not([lang="en"]) #rail button { padding-inline: 1px; }
:root:not([lang="en"]) #rail button span { max-width: 100%; text-align: center; line-height: 1.05; letter-spacing: -.01em; }

/* The World tool's steps (Temperate, Spring...): Indonesian and Hindi name them in two words
   ("Musim semi", "Beriklim sedang"), which wrap onto a second line instead of spilling. The base rule (world.css) is
   id-scoped, so this one has to be too (LINT-EXCEPTION). */
:root:is([lang="id"], [lang="hi"]) #context .world-top .seg.world-steps button { white-space: normal; line-height: 1.1; text-align: center; }
