/* ---------- language picker ----------
   Bottom-left, opposite the Roll button. Always on the physical left, even in right-to-left languages. */
/* Flags: the "Twemoji Country Flags" @font-face is injected by the inline script in index.html, only on browsers that cannot draw flag emoji.
   Font: Twemoji (CC-BY 4.0) via country-flag-emoji-polyfill. Do not put the @font-face here: browsers fetch it as soon as a matching character is used. */
.lang-picker {
  position: fixed;
  left: 72px;
  bottom: 16px;
  z-index: 10001;
  direction: ltr;
  font: 600 16px/1.2 "Twemoji Country Flags", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  border: 2px solid #000;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font: inherit;
  box-shadow: 3px 3px 0 #000;
  cursor: pointer;
}
.lang-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 #000; }
.lang-btn:focus-visible { outline: 3px solid #4da3ff; outline-offset: 3px; }
.lang-flag:empty { display: none; }
.lang-code { white-space: nowrap; }
.lang-panel {
  position: absolute;
  left: 0;
  bottom: 56px;
  width: min(320px, calc(100vw - 32px));
  max-height: min(60vh, 460px);
  display: flex;
  flex-direction: column;
  border: 2px solid #000;
  border-radius: 14px;
  background: #fff;
  color: #000;
  box-shadow: 4px 4px 0 #000;
  overflow: hidden;
}
.lang-panel[hidden] { display: none; }
.lang-filter {
  flex: none;
  margin: 8px;
  padding: 8px 10px;
  border: 2px solid #000;
  border-radius: 8px;
  font: 500 16px/1.2 system-ui, sans-serif;
  color: #000;
  background: #fff;
}
.lang-list {
  flex: 1;
  margin: 0;
  padding: 0 0 6px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.lang-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 500;
}
.lang-list li:hover, .lang-list li:focus-visible { background: #ffe14d; outline: none; }
.lang-list li[aria-selected="true"] { font-weight: 800; background: #fff6bd; }
.lang-list li.lang-sep { padding: 0; margin: 4px 14px; border-top: 1px solid #bbb; pointer-events: none; }
.lang-list li.lang-none { cursor: default; color: #555; }
.lang-list .lang-f { width: 1.6em; text-align: center; flex: none; }

/* ---------- picker colours per mode ----------
   Every colour is set here explicitly, so no theme's text colour leaks into the panel. */
.lang-picker, :root[data-mode="dark"] .lang-picker {
  --lp-bg: #1c1c1c; --lp-fg: #f2f2f2; --lp-muted: #a8a8a8; --lp-line: #ffe14d; --lp-field: #111;
  --lp-hover: #3a3410; --lp-sel: #2c2810; --lp-sep: #555; --lp-shadow: #000;
}
:root[data-mode="light"] .lang-picker {
  --lp-bg: #fff; --lp-fg: #111; --lp-muted: #555; --lp-line: #000; --lp-field: #fff;
  --lp-hover: #ffe14d; --lp-sel: #fff6bd; --lp-sep: #bbb; --lp-shadow: #000;
}
:root[data-mode="black"] .lang-picker {
  --lp-bg: #000; --lp-fg: #ffe14d; --lp-muted: #b59c2e; --lp-line: #ffe14d; --lp-field: #000;
  --lp-hover: #3a3200; --lp-sel: #241f00; --lp-sep: #6b5c10; --lp-shadow: #ffe14d;
}
.lang-btn { background: var(--lp-bg); color: var(--lp-fg); border-color: var(--lp-line); box-shadow: 3px 3px 0 var(--lp-shadow); }
.lang-btn:hover { box-shadow: 4px 4px 0 var(--lp-shadow); }
.lang-panel { background: var(--lp-bg); color: var(--lp-fg); border-color: var(--lp-line); box-shadow: 4px 4px 0 var(--lp-shadow); }
.lang-filter { background: var(--lp-field); color: var(--lp-fg); border-color: var(--lp-line); }
.lang-filter::placeholder { color: var(--lp-muted); opacity: 1; }
.lang-list { color: var(--lp-fg); }
.lang-list li { color: var(--lp-fg); }
.lang-list li:hover, .lang-list li:focus-visible { background: var(--lp-hover); color: var(--lp-fg); }
.lang-list li[aria-selected="true"] { background: var(--lp-sel); }
.lang-list li.lang-sep { border-top-color: var(--lp-sep); }
.lang-list li.lang-none { color: var(--lp-muted); }
