/* Odysseus — the language switcher.
 *
 * Its own file because it is the ONE component that appears on both kinds of
 * page this site has: the assembled pages, which load /css/shared.css, and the
 * whole pages (home, changelog, security), which carry their own design tokens
 * in an inline <style> and load no shared stylesheet at all. Putting these
 * rules in shared.css would have styled half the site; copying them into three
 * inline <style> blocks would have been three copies to drift apart.
 *
 * Every value is a token with a literal fallback, so the file is correct in
 * both hosts: the tokens resolve on pages that define them, and the fallbacks
 * carry the pages that do not.
 *
 * No JavaScript is involved anywhere below. The menu variant is a <details>
 * element, which opens on click and on Enter/Space in every browser with
 * scripting switched off. That is deliberate: this control exists for readers
 * on networks where the reason the fonts are self-hosted is that Google's hosts
 * do not answer, and a switcher that needs a script to navigate is a switcher
 * that fails for exactly them.
 */

.lang-switch ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lang-switch a,
.lang-switch .lang-current {
  font-size: var(--text-xs, 0.75rem);
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.lang-switch a {
  color: var(--color-muted, #6b6b85);
  transition: color 0.15s;
}

.lang-switch a:hover,
.lang-switch a:focus-visible {
  color: var(--color-text, #e8e8f0);
}

/* The language you are already in. A <span>, not a link — see build-pages.sh. */
.lang-switch .lang-current {
  color: var(--color-text, #e8e8f0);
  font-weight: 600;
}

.lang-switch-globe {
  flex: none;
  color: var(--color-muted, #6b6b85);
}

/* ─── list variant: the footer, and the mobile menu ─── */

.lang-switch-list {
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
}

.lang-switch-list ul {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3, 0.75rem);
}

/* ─── menu variant: the navigation bar ─── */

.lang-switch-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.lang-switch-menu summary {
  display: flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  border: 1px solid var(--color-border, #1e1e32);
  border-radius: var(--radius-md, 8px);
  background: transparent;
  color: var(--color-muted, #6b6b85);
  font-size: var(--text-xs, 0.75rem);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

/* Safari draws its own disclosure triangle through a pseudo-element that
   `list-style: none` alone does not remove. */
.lang-switch-menu summary::-webkit-details-marker { display: none; }

.lang-switch-menu summary:hover,
.lang-switch-menu details[open] > summary {
  color: var(--color-text, #e8e8f0);
  border-color: var(--color-muted, #6b6b85);
}

.lang-switch-menu .lang-switch-label { font-weight: 500; }

.lang-switch-menu ul {
  position: absolute;
  top: calc(100% + 0.375rem);
  inset-inline-end: 0;
  z-index: 60;
  min-width: 10rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: var(--space-2, 0.5rem);
  border: 1px solid var(--color-border, #1e1e32);
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface, #0f0f1a);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.lang-switch-menu li { display: block; }

.lang-switch-menu a,
.lang-switch-menu .lang-current {
  display: block;
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-sm, 4px);
  font-size: var(--text-sm, 0.875rem);
}

.lang-switch-menu a:hover,
.lang-switch-menu a:focus-visible {
  background: var(--color-surface-2, #151525);
}

.lang-switch-menu .lang-current { background: var(--color-surface-2, #151525); }

/* A keyboard user must be able to see where they are. The site's own focus
   styles do not reach a control that did not exist when they were written. */
.lang-switch a:focus-visible,
.lang-switch-menu summary:focus-visible {
  outline: 2px solid var(--color-accent, #3b82f6);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .lang-switch a,
  .lang-switch-menu summary { transition: none; }
}
