/* Loaded on every page by tools/build_i18n.py.
   The language switcher, the "read this in your language" banner, and the
   fallback fonts for the scripts the Latin web fonts do not cover. */

.lang-switch {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 14px;
}
.lang-switch a {
  color: var(--ink-muted);
  text-decoration: none;
  padding: 6px 0;
}
.lang-switch a:hover,
.lang-switch a:focus-visible,
.lang-switch a[aria-current] {
  color: var(--ink);
}
.lang-switch a[aria-current] {
  font-weight: 600;
}

.lang-banner {
  position: fixed;
  z-index: 60;
  inset-inline: 16px;
  /* Top, so it never covers the cookie banner or the mobile download bar. */
  top: calc(16px + env(safe-area-inset-top, 0px));
  max-width: 520px;
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--paper-raised, #fff);
  color: var(--ink, #16140f);
  border: 1px solid var(--line-strong, #847d6b);
  border-radius: 12px;
  font: 15px/1.4 var(--font-sans, system-ui, sans-serif);
}
.lang-banner p {
  margin: 0;
  flex: 1 1 200px;
}
.lang-banner a,
.lang-banner button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.lang-banner a {
  background: var(--trace-action, #c8f03c);
  color: var(--on-trace-action, #16140f);
  text-decoration: none;
}
.lang-banner button {
  background: transparent;
  color: var(--ink-muted, #5f5a4e);
  border: 1px solid var(--line, #d9d3c4);
}
.lang-banner a:focus-visible,
.lang-banner button:focus-visible,
.lang-switch a:focus-visible {
  outline: 2px solid var(--ember-ink, #ae3303);
  outline-offset: 2px;
}

/* The web fonts are Latin only. These scripts use the system fonts. */
:lang(zh) {
  --font-sans: "Instrument Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
:lang(ja) {
  --font-sans: "Instrument Sans", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}
:lang(ko) {
  --font-sans: "Instrument Sans", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  word-break: keep-all;
}
:lang(he) {
  --font-sans: "Instrument Sans", "Arial Hebrew", "Segoe UI", "Noto Sans Hebrew", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Arial Hebrew", "Segoe UI", "Noto Sans Hebrew", system-ui, sans-serif;
}
/* Negative letter spacing breaks up CJK and Hebrew glyphs. */
:lang(zh) h1, :lang(zh) h2, :lang(zh) h3,
:lang(ja) h1, :lang(ja) h2, :lang(ja) h3,
:lang(ko) h1, :lang(ko) h2, :lang(ko) h3,
:lang(he) h1, :lang(he) h2, :lang(he) h3 {
  letter-spacing: 0 !important; /* beats the inline style on the hero h1 */
}
:lang(zh) body, :lang(ja) body {
  line-break: strict;
}

/* Right to left. Keys, code and version numbers stay left to right. */
[dir="rtl"] code,
[dir="rtl"] kbd,
[dir="rtl"] .mono {
  direction: ltr;
  unicode-bidi: isolate;
}
