/* Pyrix web · the language panel (public/js/i18n.js) and the keys that open it: the site's top bar and footer, the
   dashboard's account menu and More sheet. Loaded on every page (site and dashboard), so it carries its own copy of the
   DESIGN.md tokens it uses. Floating glass like the dashboard's popovers; a bottom sheet on phones. */
.lp,
.lang-ask,
.lang-key,
.lang-row,
.lang-foot {
  --lp-text: #f2f4f7;
  --lp-text-2: #a4a9b4;
  --lp-text-3: #767d8a;
  --lp-edge: rgba(255, 255, 255, 0.075);
  --lp-edge-2: rgba(255, 255, 255, 0.13);
  --lp-edge-hi: rgba(255, 255, 255, 0.22);
  --lp-blue-2: #60a5fa;
  --lp-blue-ink: #93c5fd;
  --lp-wash: rgba(59, 130, 246, 0.1);
  --lp-line: rgba(59, 130, 246, 0.55);
  --lp-hover: #0c0c0f;
  --lp-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- the site's top bar key: globe + code, a softkey like the nav (site.css .sk) ---------- */
.site .lang-key { gap: 7px; padding: 0 10px; }
.site .lang-key .lang-globe { width: 15px; height: 15px; color: var(--lp-text-3); transition: color 110ms; }
.site .lang-key:hover .lang-globe,
.site .lang-key[aria-expanded="true"] .lang-globe { color: var(--lp-blue-2); }
.site .lang-key[aria-expanded="true"] { color: #fff; border-color: var(--lp-line); background: var(--lp-wash); }
.site .lang-code { font-variant-numeric: tabular-nums; min-width: 2ch; }

/* ---------- the footer: the current language, beside the copyright ---------- */
.site .lang-foot {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  margin-left: auto;
  border: 1px solid var(--lp-edge-2);
  border-radius: 3px;
  background: transparent;
  color: var(--lp-text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: color 110ms, border-color 110ms;
}
.site .foot-legal { align-items: center; }
.site .lang-foot .lang-globe { width: 14px; height: 14px; color: var(--lp-text-3); }
.site .lang-foot:hover,
.site .lang-foot[aria-expanded="true"] { color: #fff; border-color: var(--lp-edge-hi); }

/* ---------- the dashboard's account menu / More sheet row (dashboard.css .d-pop-row) ---------- */
.lang-row { cursor: pointer; }
.lang-row .lang-now { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-row .lang-chev { width: 13px; height: 13px; margin-left: -4px; }

/* ---------- the panel ---------- */
.lp {
  position: fixed;
  inset: auto;
  top: var(--lp-top, auto);
  bottom: var(--lp-bottom, auto);
  left: var(--lp-left, auto);
  z-index: 90;
  box-sizing: border-box;
  width: 320px;
  max-height: min(620px, calc(100dvh - 16px));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--lp-edge-2);
  border-radius: 4px;
  background: rgba(5, 5, 6, 0.96);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 48px -12px rgba(0, 0, 0, 0.85);
  color: var(--lp-text);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-transform: none;
}
.lp:popover-open { display: flex; flex-direction: column; animation: lp-in 180ms var(--lp-ease); }
.lp::backdrop { background: transparent; }
@keyframes lp-in {
  from { opacity: 0; transform: translateY(4px); }
}
.lp[aria-busy="true"] .lp-list { opacity: 0.6; transition: opacity 160ms; pointer-events: none; }

.lp-h {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--lp-edge);
}
.lp-back {
  display: none;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: -8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--lp-text-2);
  cursor: pointer;
  transition: color 110ms, border-color 110ms;
}
.lp-back .ico { width: 16px; height: 16px; }
.lp-back:hover { color: #fff; border-color: var(--lp-edge-2); }
.lp-sub .lp-back { display: grid; }
.lp-t {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lp-t1 { color: var(--lp-text); }
.lp-t2 { color: var(--lp-text-3); }
.lp-t2::before { content: "· "; }

.lp-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
.lp-row {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--lp-text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 110ms, color 110ms, border-color 110ms;
}
.lp-row:hover { background: var(--lp-hover); color: #fff; }
.lp-row:focus-visible { outline: 1.5px solid var(--lp-blue-2); outline-offset: 2px; }
.lp .lp-row .lp-tick { flex: none; width: 15px; height: 15px; color: var(--lp-blue-2); visibility: hidden; }
.lp-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-n[dir="rtl"] { text-align: left; unicode-bidi: plaintext; }
.lp-e { flex: none; max-width: 48%; overflow: hidden; color: var(--lp-text-3); font-size: 0.75rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.lp-row[aria-checked="true"] { border-color: var(--lp-line); background: var(--lp-wash); color: #fff; }
.lp .lp-row[aria-checked="true"] .lp-tick { visibility: visible; color: var(--lp-blue-2); }
.lp-row[aria-checked="true"] .lp-e { color: var(--lp-text-2); }

/* phones: a bottom sheet, 44px rows, a scrim behind */
.lp.lp-sheet {
  top: auto;
  bottom: 0;
  left: 0;
  right: 0;
  width: auto;
  max-height: 86dvh;
  border-width: 1px 0 0;
  border-radius: 4px 4px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.lp.lp-sheet:popover-open { animation: lp-up 220ms var(--lp-ease); }
.lp.lp-sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.lp.lp-sheet .lp-h { height: 52px; }
.lp.lp-sheet .lp-row { height: 44px; font-size: 0.875rem; }
@keyframes lp-up {
  from { transform: translateY(24px); opacity: 0; }
}
@media (pointer: coarse) {
  .lp-row { height: 44px; }
  .lp-back { width: 44px; height: 44px; }
}

/* ---------- the first-visit question ---------- */
.lang-ask {
  position: fixed;
  inset: auto;
  top: var(--lp-top, auto);
  left: var(--lp-left, auto);
  z-index: 85;
  box-sizing: border-box;
  width: max-content;
  max-width: min(320px, calc(100vw - 16px));
  margin: 0;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--lp-edge-2);
  border-radius: 4px;
  background: rgba(5, 5, 6, 0.96);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 48px -12px rgba(0, 0, 0, 0.85);
  color: var(--lp-text);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-transform: none;
}
.lang-ask:popover-open { animation: lp-in 220ms var(--lp-ease); }
.lang-ask-top { top: calc(56px + 8px); left: 8px; right: 8px; max-width: none; width: auto; }
.lang-ask-low { bottom: calc(92px + env(safe-area-inset-bottom)); left: 8px; right: 8px; max-width: none; width: auto; }
@media (min-width: 761px) {
  .lang-ask-low { left: auto; right: 20px; bottom: 20px; width: max-content; max-width: 320px; }
}
.lang-ask-q { margin: 0 0 10px; font-size: 0.875rem; font-weight: 600; line-height: 1.4; }
.lang-ask-k { display: flex; gap: 8px; }
.lang-ask-k button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--lp-edge-2);
  border-radius: 4px;
  background: transparent;
  color: var(--lp-text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 110ms, border-color 110ms, background-color 110ms;
}
.lang-ask-k .lang-ask-yes { border-color: var(--lp-line); background: var(--lp-wash); color: #fff; }
.lang-ask-k .lang-ask-yes:hover { border-color: #3b82f6; }
.lang-ask-k .lang-ask-no:hover { color: #fff; border-color: var(--lp-edge-hi); }
.lang-ask-k button:focus-visible,
.lang-foot:focus-visible,
.lp-back:focus-visible { outline: 1.5px solid var(--lp-blue-2); outline-offset: 2px; }
@media (pointer: coarse) {
  .lang-ask-k button { height: 44px; padding: 0 16px; }
}

/* ---------- the switch: a short cross-fade into the same page in the new language (i18n.js skips every other) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 180ms; animation-timing-function: var(--lp-ease, ease-out); }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .lp:popover-open,
  .lp.lp-sheet:popover-open,
  .lang-ask:popover-open { animation: none; }
}

/* ---------- right to left (Arabic; ui audit 2026-11-27) ----------
   server/i18n.js puts dir="rtl" on <html> for Arabic: flex and grid rows mirror by themselves (the rail goes right,
   rows read right to left). What must not mirror or flip is set here. */
/* code, keys and the loader line read left to right */
[dir="rtl"] :is(code, kbd, pre, .sc-code, .ov-loader) { direction: ltr; unicode-bidi: isolate; }
/* the Live View's map: its canvas labels ("200 m") and the readouts over it ("60 fps", "184 m") stay left to right */
[dir="rtl"] :is(canvas, .rd2-hud, .rd2-tape, .hud) { direction: ltr; }
/* text that stays English (the changelog's entries): read left to right, so its full stops end the line, but placed
   on the right like the page around it (:where = no specificity: an alignment a page sets wins) */
:where([dir="rtl"] [translate="no"], [dir="rtl"] [translate="no"] p) { unicode-bidi: plaintext; text-align: right; }
/* the rail's active mark sits on the rail's inner edge (dashboard.css .d-ind::before is placed with left) */
[dir="rtl"] .d-ind::before { left: auto; right: -13px; }
/* the search key reads "Ctrl K", not "K Ctrl" */
[dir="rtl"] .d-search kbd:not([data-mod]) { order: 1; }
[dir="rtl"] .d-search kbd[data-mod] { order: 2; }
/* Servers search: the "/" key on the field's end side */
[dir="rtl"] .sv-kbd { right: auto; left: 10px; }
[dir="rtl"] .sv-search input { padding-right: 12px; padding-left: 40px; }
