/**
 * i18n-kit core — the parts that are true on every site.
 *
 * Nothing in here names a site's own classes. Two other stylesheets carry that:
 *
 *   assets/generated.css   written by build.py from site.json — per-script font
 *                          stacks and the letter-spacing blanket, both of which
 *                          need the site's own scope selector and brand face
 *   assets/overrides.css   hand-written per site — the typographic corrections
 *                          that only make sense against that site's markup
 *
 * Everything here is themeable through the custom properties at the top of the
 * switcher block, so a site restyles the control by setting four values rather
 * than by overriding a stack of rules.
 */

/* ── the pre-paint hold ───────────────────────────────────────────────────
   Only ever applied for non-default languages, and always removed on a
   timeout, so the worst case is a visitor seeing English rather than a blank
   page. Print is exempt: a print stylesheet that inherits a hidden body
   produces blank paper, and the hold may still be up when the dialog opens. */
html.bik-wait body { visibility: hidden; }
@media print { html.bik-wait body { visibility: visible; } }

/* ── right-to-left ────────────────────────────────────────────────────────
   dir="rtl" on <html> already mirrors text direction, list markers, and any
   layout written with logical properties. What it does NOT mirror is a design
   built on physical left/right, which is most designs. These are the handful
   of resets that are safe to apply blind; anything structural belongs in the
   site's own overrides.css, where it can be checked against real markup. */
html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] .bik-lang { direction: rtl; }
/* Latin fragments inside an RTL line — a URL, an email address, a brand name,
   a date range, a dimension like "9 x 3 x 3 ft" — need an isolation boundary
   or the bidi algorithm reorders their punctuation. Translators mark these in
   the resource files with <bdi>, which needs no styling of its own, but any
   element the site tags this way gets the same treatment. */
html[dir="rtl"] [data-bik-ltr] {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

/* ── the switcher ─────────────────────────────────────────────────────────
   A native <select> rather than a custom menu, on purpose: it is keyboard and
   screen-reader correct for free, it renders as the platform's own picker on a
   phone, and it cannot be the thing that breaks on a device nobody tested.

   Options carry each language's own autonym (Español, 中文, 한국어) and never a
   flag. Flags are countries, not languages, and every choice is wrong for
   somebody — a French flag excludes Senegalese and Haitian readers, a Spanish
   one excludes all of Latin America.

   The markup is identical for every visitor, so it survives a page cache.
   Which option is selected is set client-side from the resolved language,
   because the cached HTML cannot know it. */
.bik-lang {
  --bik-sw-bg: rgba(255, 255, 255, .72);
  --bik-sw-fg: #1a1a1a;
  --bik-sw-border: rgba(120, 120, 120, .35);
  --bik-sw-accent: currentColor;

  position: fixed;
  bottom: var(--bik-sw-bottom, 22px);
  right: var(--bik-sw-right, 22px);
  z-index: 99999;
  height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 100px;
  border: 1px solid var(--bik-sw-border);
  background: var(--bik-sw-bg);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .4);
  transition: background .3s, border-color .3s;
}
html[dir="rtl"] .bik-lang {
  right: auto;
  left: var(--bik-sw-right, 22px);
}

/* Inline placement, for sites that would rather put the control in a footer or
   a nav than float it. Set by adding class bik-lang--inline in site.json. */
.bik-lang--inline {
  position: static;
  display: inline-flex;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.bik-lang select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  outline: 0;
  font: inherit;
  font-size: .78rem;
  line-height: 1;
  letter-spacing: 0;
  color: var(--bik-sw-fg);
  cursor: pointer;
  padding: 0 26px 0 14px;
  height: 32px;
  border-radius: 100px;
  /* The option list is drawn by the OS, which does not inherit the page font.
     Naming the Noto faces here is what stops 中文 and العربية rendering as
     empty boxes in the dropdown on a machine with no system face for them. */
  font-family: inherit, "Noto Sans SC", "Noto Sans JP", "Noto Sans KR",
               "Noto Naskh Arabic", "Noto Sans Devanagari", sans-serif;
}
html[dir="rtl"] .bik-lang select { padding: 0 14px 0 26px; }

.bik-lang::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  pointer-events: none;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  color: var(--bik-sw-fg);
  opacity: .6;
}
html[dir="rtl"] .bik-lang::after { right: auto; left: 12px; }

/* Focus indication, mouse vs keyboard.
   :focus-visible is NOT sufficient to tell these apart on a <select>: browsers
   match it on a plain mouse click too, because the element is keyboard-operable
   once open. Verified in Chromium — clicking the switcher matched both
   :focus-within and :focus-visible, so the accent ring appeared on click and
   then stayed after the menu closed, reading as a stuck highlight rather than
   as focus.

   So the switcher's inline script flags pointer interaction on the wrapper and
   these two rules opt out of the ring for that case only. A keyboard user
   tabbing to the control still gets a real, visible focus ring; a mouse user
   gets nothing, which is what they expect from a picker. Removing focus styling
   outright would have been the easier fix and an accessibility regression. */
.bik-lang:focus-within { border-color: var(--bik-sw-accent); }
.bik-lang select:focus-visible { outline: 2px solid var(--bik-sw-accent); outline-offset: 2px; }

.bik-lang.is-pointer:focus-within { border-color: var(--bik-sw-border); }
.bik-lang.is-pointer select:focus,
.bik-lang.is-pointer select:focus-visible { outline: none; }

.bik-lang option { color: #1a1a1a; background: #fff; }

@media (max-width: 560px) {
  .bik-lang select { font-size: .72rem; padding: 0 24px 0 11px; }
  html[dir="rtl"] .bik-lang select { padding: 0 11px 0 24px; }
}
@media print { .bik-lang { display: none; } }

/* ── controls that were sized for English ─────────────────────────────────
   Generic safety net, scoped by the data-bik-fit attribute the site puts on
   any fixed-size control. German runs ~30% longer than English and will
   overflow a pill that was measured against a six-letter label; letting it
   wrap is always better than letting it spill. */
html:not([lang="en"]) [data-bik-fit] {
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  hyphens: auto;
}
