/* The language menu, and the type adjustments other scripts need.
   Colours come from the page: --text, --line, and --menu-bg. */

.i18n-pending body { visibility: hidden; }

.lang { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: inherit;
  font: inherit; font-size: 13px; font-weight: 600; letter-spacing: .04em; cursor: pointer;
}
.lang-btn::after { content: ""; width: 6px; height: 6px; margin: -3px 0 0 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); opacity: .7; }
.lang-btn:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.flag { width: 20px; height: 15px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); flex: none; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 200px; padding: 6px;
  border-radius: 14px; background: var(--menu-bg, #fff); color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgb(0 0 0 / 22%);
}
.lang-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 9px;
  background: transparent; color: inherit; font: inherit; font-size: 15px; text-align: left; cursor: pointer;
}
.lang-menu button:hover, .lang-menu button:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); outline: none; }
.lang-menu button[aria-checked="true"] { font-weight: 700; }
.lang-menu button[aria-checked="true"]::after { content: ""; margin-left: auto; width: 6px; height: 11px; border-right: 2px solid #DA1B2B; border-bottom: 2px solid #DA1B2B; transform: rotate(45deg) translate(-2px, -2px); }
@media (max-width: 520px) { .lang-btn .code { display: none; } .lang-btn { padding: 0 10px; } }

/* Thai and Lao stack vowels and tone marks above and below the line, so
   display type set tight for English would clip them. Scripts without
   capitals or word spaces are not tracked in either. */
:root:is([lang="th"], [lang="lo"]) :is(h1, h2, h3, .mega, .big) { line-height: 1.32 !important; }
:root:is([lang="th"], [lang="lo"], [lang="zh"], [lang="ko"]) :is(h1, h2, h3, h4, .mega, .big) { letter-spacing: 0 !important; }
:root:is([lang="zh"], [lang="ko"]) :is(h1, h2, .mega, .big) { line-height: 1.15 !important; }
/* Vietnamese stacks accents above capitals (Ắ, Ẻ); give them room. */
:root[lang="vi"] :is(h1, h2, .mega, .big) { line-height: 1.12 !important; }
:root[lang="vi"] .mega .line { padding-top: .12em; }
/* Korean breaks between words, not inside them. */
:root[lang="ko"] body { word-break: keep-all; }
