/*
 * Snack Break Games shared localization styles. The build links this before a game's own stylesheet (docs/i18n/GAME-RUNTIME.md).
 * Phase 1: no font files for Japanese, Korean, Chinese, Arabic, Urdu, Hindi, Bengali or Thai; the page's lang attribute makes the
 * browser pick the system font of the right script, and these stacks name the Windows, Apple and Noto faces explicitly.
 * English is the unstyled default: nothing here applies to it.
 */

/* Joined and caseless scripts: letter-spacing breaks Arabic joining and there are no capitals to force. */
:lang(ar), :lang(ur), :lang(hi), :lang(bn), :lang(th), :lang(xx-rtl) {
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* Line breaking. Chinese and Japanese may break between most characters but never before closing marks (kinsoku). */
:lang(ja), :lang(zh) { line-break: strict; word-break: normal; }
:lang(ko) { word-break: keep-all; }
:root:not(:lang(en)) body { overflow-wrap: break-word; }

/* Marks above and below the line (Thai, Devanagari, Bengali, Arabic) need more room than Latin text. */
:where(:lang(th), :lang(hi), :lang(bn), :lang(ar), :lang(ur)) body { line-height: 1.5; }

/* Per-script font stacks. Put var(--sbg-font-fallback, sans-serif) at the end of a game's own font stacks. */
:root { --sbg-font-fallback: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; }
:root:lang(ru), :root:lang(uk) { --sbg-font-fallback: "Segoe UI", system-ui, Roboto, Arial, "Noto Sans", sans-serif; }
:root:lang(ja) { --sbg-font-fallback: "Yu Gothic UI", "Yu Gothic", Meiryo, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; }
:root:lang(ko) { --sbg-font-fallback: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; }
:root:lang(zh-Hans) { --sbg-font-fallback: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif; }
:root:lang(zh-Hant) { --sbg-font-fallback: "Microsoft JhengHei UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif; }
:root:lang(ar) { --sbg-font-fallback: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", Arial, sans-serif; }
:root:lang(ur), :root:lang(xx-rtl) { --sbg-font-fallback: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", Arial, sans-serif; }
:root:lang(hi) { --sbg-font-fallback: "Nirmala UI", Mangal, "Kohinoor Devanagari", "Noto Sans Devanagari", system-ui, sans-serif; }
:root:lang(bn) { --sbg-font-fallback: "Nirmala UI", Vrinda, "Kohinoor Bangla", "Noto Sans Bengali", system-ui, sans-serif; }
:root:lang(th) { --sbg-font-fallback: "Leelawadee UI", Tahoma, Thonburi, "Noto Sans Thai", system-ui, sans-serif; }

/* Shared widgets: the language select and the demo bar. */
.sbg-lang { font: inherit; font-family: var(--sbg-font-fallback, system-ui, sans-serif); max-width: 100%; }
[dir=rtl] .sbg-lang { text-align: right; }

/* Right-to-left helpers. Text and menus mirror; boards, timelines, grids, scores and key names do not (docs/i18n/GAME-RUNTIME.md). */
[dir=rtl] .sbg-flip { transform: scaleX(-1); }
.sbg-keep-ltr { direction: ltr; unicode-bidi: isolate; }
[dir=rtl] kbd, [dir=rtl] code { direction: ltr; unicode-bidi: isolate; }
