/* ==========================================================================
   ZHTA — language switcher
   Deliberately a separate stylesheet: nothing here redefines an existing class,
   so the rest of the design system is untouched. Every rule is scoped under
   .lang-switch / .lang-row / .lang-inline.
   ========================================================================== */

/* A returning visitor with a saved language would otherwise see one frame of
   English before the swap. The engine adds this class before the body exists
   and always removes it again — including on a failed dictionary load, where a
   timeout in the script reveals the page regardless. With JS off the class is
   never added, so the English copy is simply shown. */
html.i18n-pending body{opacity:0}

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

.lang-btn{
  display:flex;align-items:center;gap:7px;height:38px;padding:0 11px 0 13px;
  border:1px solid var(--line);border-radius:100px;background:none;cursor:pointer;
  font-family:inherit;font-size:12px;font-weight:700;letter-spacing:.1em;color:var(--ink-2);
  transition:border-color .25s var(--ease),color .25s var(--ease),background .25s var(--ease);
}
.lang-btn:hover,.lang-switch.open .lang-btn{border-color:var(--red);color:var(--red)}
.lang-btn:focus-visible{outline:2px solid var(--red);outline-offset:2px}
.lang-btn svg{width:15px;height:15px;flex:none}
.lang-btn .lang-caret{width:10px;height:10px;opacity:.66;transition:transform .25s var(--ease)}
.lang-switch.open .lang-caret{transform:rotate(180deg)}

/* While a dictionary is being fetched the button dims and stops accepting
   clicks — on a slow link that can take a few seconds, and a control that
   looks dead is worse than one that looks busy. */
.lang-switch.busy .lang-btn{pointer-events:none;cursor:progress}
.lang-switch.busy .lang-cur{opacity:.45;transition:opacity .2s var(--ease)}
.lang-switch.busy .lang-btn svg:first-child{animation:langSpin 1.1s linear infinite}
@keyframes langSpin{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){
  .lang-switch.busy .lang-btn svg:first-child{animation:none;opacity:.5}
}

.lang-menu{
  position:absolute;top:calc(100% + 9px);right:0;z-index:120;
  min-width:172px;margin:0;padding:6px;list-style:none;
  background:#fff;border:1px solid var(--line);border-radius:16px;
  box-shadow:0 18px 44px rgba(28,16,8,.16);
  opacity:0;visibility:hidden;transform:translateY(-7px);
  transition:opacity .2s var(--ease),transform .24s var(--ease),visibility .2s;
}
.lang-switch.open .lang-menu{opacity:1;visibility:visible;transform:none}
.lang-menu li{margin:0}
.lang-menu button{
  display:flex;width:100%;align-items:center;justify-content:space-between;gap:12px;
  padding:9px 11px;border:0;border-radius:10px;background:none;cursor:pointer;
  font-family:inherit;font-size:13px;font-weight:600;letter-spacing:0;color:var(--ink);
  text-align:left;white-space:nowrap;transition:background .16s var(--ease),color .16s var(--ease);
}
.lang-menu button:hover{background:var(--soft)}
.lang-menu button[aria-selected="true"]{color:var(--red)}
.lang-menu .tick{width:12px;height:12px;flex:none;opacity:0}
.lang-menu button[aria-selected="true"] .tick{opacity:1}
.lang-menu .tick path{stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}

/* the label that sits inside the burger menu on narrow screens */
.lang-row{display:none}
.lang-row .lang-chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.lang-row button{
  height:36px;padding:0 14px;border:1px solid var(--line-2);border-radius:100px;background:none;
  font-family:inherit;font-size:12.5px;font-weight:700;letter-spacing:.04em;color:var(--ink-2);
  cursor:pointer;transition:.2s var(--ease);
}
.lang-row button:hover{border-color:var(--red);color:var(--red)}
.lang-row button[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:#fff}

/* pages that carry no site header (full-screen demo pages, 404) get this instead */
.lang-inline{display:inline-flex;margin-bottom:18px}

@media(max-width:1180px){
  .lang-switch{display:none}
  .lang-row{display:block;width:100%;margin-top:26px;padding-top:20px;border-top:1px solid var(--line)}
  .lang-row .lang-row-t{font-size:11px;font-weight:800;letter-spacing:.16em;text-transform:uppercase;color:var(--muted-2)}
}

/* LTR languages only for now. This block is what keeps a future RTL dictionary
   (Arabic, Hebrew) from breaking the layout the moment it is added. */
html[dir="rtl"] .lang-menu{right:auto;left:0}

/* ---------- long-label languages ----------
 * Cyrillic nav labels run roughly 20–25 % wider than English at the same size,
 * which pushed the contact button past the right edge of a 1440 px header.
 * The pill nav tightens instead: same height, same colour, same rhythm, the
 * header cluster stays where the design put it. */
html[lang="ru"] .nav a{padding:0 11px;font-size:12px}
/* Spanish sits between the two: it fits the viewport at 1440 but pushes the
   contact button 23 px out of the white pill, so the same tightening applies */
html[lang="es"] .nav a{padding:0 11px}
@media(max-width:1360px){
  html[lang="ru"] .nav a{padding:0 9px;font-size:11.5px}
}
/* the narrowest desktop band, just above the burger breakpoint */
@media(max-width:1300px){
  html[lang="es"] .nav a,html[lang="ru"] .nav a{padding:0 7px;font-size:11.5px;letter-spacing:-.01em}
}
