/*
 * Shared language layer for the RTC mockups.
 * Sites define their Latin font roles on :root only:
 *   --ff-display  --ff-hand  --ff-body  --ff-pixel  --ff-serif  --ff-mono
 * and use them everywhere. The rules below swap the roles for scripts that the
 * Latin fonts cannot draw. html[lang] (0,1,1) outranks :root (0,1,0).
 */

html[lang="tr"] {
  --ff-hand: "Caveat Brush", "Caveat", "Comic Sans MS", cursive;
}

html[lang="ru"] {
  --ff-display: "Oswald", "Rubik", Impact, "Arial Narrow", sans-serif;
  --ff-hand: "Caveat", "Comic Sans MS", cursive;
  --ff-body: "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --ff-pixel: "Press Start 2P", "Courier New", monospace;
  --ff-serif: "Cormorant Garamond", "Playfair Display", Georgia, serif;
}

html[lang="zh-Hans"] {
  --ff-display: "ZCOOL KuaiLe", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ff-hand: "ZCOOL KuaiLe", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ff-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ff-pixel: "ZCOOL QingKe HuangYou", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --ff-serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
}

html[lang="ja"] {
  --ff-display: "Dela Gothic One", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  --ff-hand: "Yomogi", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  --ff-body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --ff-pixel: "DotGothic16", "Noto Sans JP", monospace;
  --ff-serif: "Shippori Mincho", "Noto Serif JP", "Yu Mincho", serif;
}

html[lang="ko"] {
  --ff-display: "Black Han Sans", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --ff-hand: "Gaegu", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --ff-body: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --ff-pixel: "Do Hyeon", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --ff-serif: "Nanum Myeongjo", "Noto Serif KR", serif;
}

/* CJK: no faux tracking or forced caps, natural line breaking. */
html:is([lang="zh-Hans"], [lang="ja"], [lang="ko"]) :is(h1, h2, h3, h4, .i18n-display) {
  letter-spacing: 0;
  text-transform: none;
}
html:is([lang="zh-Hans"], [lang="ja"]) {
  line-break: strict;
}
html[lang="ko"] :is(h1, h2, h3, h4, p, li, .i18n-display) {
  word-break: keep-all;
}

/* Long German / Russian / Turkish compounds must wrap instead of overflowing. */
html:is([lang="de"], [lang="ru"], [lang="tr"], [lang="pt"], [lang="fr"], [lang="es"]) :is(h1, h2, h3, .i18n-display) {
  overflow-wrap: anywhere;
  hyphens: auto;
}

/* While a non-English dictionary loads, hide strings that are about to change. */
html.rtc-i18n-loading :is([data-i18n], [data-i18n-html]) {
  visibility: hidden;
}

/* "Also available in…" chip. Sites may restyle; these are safe defaults. */
.rtc-lang-suggest {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 14px;
  border: 2px solid #000;
  border-radius: 999px;
  background: #fff7e6;
  color: #111;
  font: 600 14px/1.2 var(--ff-body, system-ui, sans-serif);
  box-shadow: 4px 4px 0 #000;
  transform: translate(-50%, 140%);
  transition: transform 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.rtc-lang-suggest.is-in {
  transform: translate(-50%, 0);
}
.rtc-lang-suggest__go {
  padding: 6px 12px;
  border: 2px solid #000;
  border-radius: 999px;
  background: #fc5c04;
  color: #000;
  font: inherit;
  cursor: pointer;
}
.rtc-lang-suggest__close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .rtc-lang-suggest {
    transition: none;
  }
}
