/* ===========================================================================
   JPMate — language menu in the site nav (built by js/i18n.js).
   A quiet pill (globe, the language's own name, chevron) opens a small list:
   each language in its own script, its code on the right, a tick on the
   current one. Shares its motion with the form dropdowns (css/forms.css):
   the panel fades in fast and evenly and slides 6px. Rows don't fade on
   their own, so the text is at full ink as soon as the panel is.
   =========================================================================== */

.langmenu {
  --lm-ease: cubic-bezier(.22, .8, .24, 1);
  /* Legal and contact pages (legal.css tokens). */
  --lm-panel: linear-gradient(var(--card), var(--card)), var(--bg);
  --lm-ink: var(--tx); --lm-muted: var(--tx3); --lm-line: var(--hair2);
  --lm-accent: var(--act); --lm-wash: var(--act-soft);
  --lm-chip: var(--chip-bg); --lm-chip-line: transparent; --lm-chip-hover: var(--act-soft);
  --lm-shadow: 0 22px 44px -20px rgba(15, 40, 52, .32), 0 3px 10px rgba(15, 40, 52, .06);
  position: relative; flex: none; display: inline-flex; align-items: center;
}
/* Homepage (home.css tokens). */
.homepage .langmenu {
  --lm-panel: var(--site-surface); --lm-ink: var(--site-ink); --lm-muted: var(--site-muted);
  --lm-line: var(--site-line); --lm-accent: var(--site-accent); --lm-wash: var(--site-soft);
  --lm-chip: transparent; --lm-chip-line: var(--site-line); --lm-chip-hover: var(--site-soft);
  --lm-shadow: 0 22px 44px -22px #1d3a3f66, 0 3px 10px #1d3a3f12;
}
:root[data-theme="dark"] .langmenu { --lm-shadow: 0 24px 48px -18px #000c, 0 2px 8px #0006; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .langmenu { --lm-shadow: 0 24px 48px -18px #000c, 0 2px 8px #0006; }
}

/* ---- the button (scoped: the homepage sizes every button and svg) ---- */
.langmenu .lm-button {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; margin: 0; padding: 0 12px 0 11px;
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1; letter-spacing: 0; white-space: nowrap;
  color: var(--lm-ink); background: var(--lm-chip); border: 1px solid var(--lm-chip-line); border-radius: 999px;
  cursor: pointer; -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .25s var(--lm-ease), border-color .25s var(--lm-ease), color .25s var(--lm-ease);
}
.lm-button:hover, .langmenu.open .lm-button { background: var(--lm-chip-hover); }
.homepage .lm-button:hover, .homepage .langmenu.open .lm-button { border-color: var(--lm-muted); }
.langmenu :is(.lm-globe, .lm-chevron) { flex: none; fill: none; stroke: var(--lm-muted); stroke-linecap: round; stroke-linejoin: round; }
.langmenu .lm-globe { width: 15px; height: 15px; stroke-width: 1.25; transition: stroke .25s var(--lm-ease); }
.langmenu .lm-chevron { width: 10px; height: 7px; stroke-width: 1.5; transition: transform .45s var(--lm-ease), stroke .25s var(--lm-ease); }
.langmenu.open .lm-chevron { transform: rotate(180deg); stroke: var(--lm-accent); }
.langmenu.open .lm-globe, .lm-button:hover .lm-globe { stroke: var(--lm-accent); }
.lm-label { display: inline-flex; align-items: center; }
.lm-short { display: none; }
.lm-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- the list ---- */
.lm-list {
  position: absolute; z-index: 60; top: calc(100% + 10px); right: 0;
  min-width: 232px; max-height: min(430px, calc(100vh - 120px)); overflow-y: auto; overscroll-behavior: contain;
  margin: 0; padding: 6px; list-style: none; text-align: left;
  background: var(--lm-panel); border: 1px solid var(--lm-line); border-radius: 16px; box-shadow: var(--lm-shadow);
  opacity: 0; transform: translateY(-6px);
  visibility: hidden; pointer-events: none;
  transition: opacity .16s linear, transform .28s var(--lm-ease), visibility 0s .28s;
}
.langmenu.lm-left .lm-list { right: auto; left: 0; }
.langmenu.open .lm-list { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.lm-list li { margin: 0; padding: 0; }
.lm-option {
  position: relative; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; color: var(--lm-ink); text-decoration: none;
  font-size: 14px; font-weight: 400; line-height: 1.35; white-space: nowrap;
  transition: background-color .22s var(--lm-ease);
}
.lm-option::before {
  content: ""; position: absolute; top: 9px; bottom: 9px; left: 1px; width: 2px; border-radius: 2px;
  background: var(--lm-accent); transform: scaleY(0); transition: transform .3s var(--lm-ease);
}
.lm-option:hover, .lm-option:focus-visible { background: var(--lm-wash); color: var(--lm-ink); text-decoration: none; outline: none; }
.lm-option:hover::before, .lm-option:focus-visible::before { transform: scaleY(1); }
.lm-mark {
  width: 12px; height: 12px; background: var(--lm-accent);
  clip-path: polygon(12% 50%, 0 64%, 40% 100%, 100% 22%, 87% 9%, 40% 72%);
  transform: scale(0); transition: transform .35s var(--lm-ease);
}
.lm-option[aria-current="true"] .lm-mark { transform: scale(1); }
.lm-option[aria-current="true"] .lm-name { font-weight: 600; }
.lm-code { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; color: var(--lm-muted); }
.lm-option[aria-current="true"] .lm-code { color: var(--lm-accent); }

/* ---- legal and contact pages: the menu sits with the theme toggle ---- */
body:not(.homepage) .nav .bar > .langmenu { margin-left: auto; margin-right: 4px; }
body:not(.homepage) .nav .bar > .langmenu ~ .btn-cta { margin-left: 8px; }

/* ---- phones ---- */
@media (max-width: 560px) {
  .langmenu .lm-button { height: 34px; padding: 0 10px 0 10px; gap: 6px; font-size: 12.5px; }
  body:not(.homepage) .nav .bar > .langmenu { margin-right: 2px; }
}
@media (max-width: 400px) {
  .lm-short { display: inline; }
  .lm-label.has-short .lm-long { display: none; }
  .lm-list { min-width: 216px; }
}

@media (prefers-reduced-motion: reduce) {
  .lm-button, .lm-globe, .lm-chevron, .lm-list, .lm-option, .lm-option::before, .lm-mark { transition: none; }
}
