/* =====================================================================================================================
   BILINGUAL UI — the EN / 中文 switch
   Injected by js/i18n.js as <button id="lang-toggle"> in the top-right corner. Deliberately a sibling of the existing HUD
   glass: same 1px hairline, same Rajdhani/Orbitron micro-lettering, same cyan accent, same "instrument" pill as #modes.
   Loaded after app.css / beyond.css so it can nudge panels that already live in that corner instead of covering them.
   ===================================================================================================================== */

#lang-toggle {
  position: fixed;
  z-index: 75;                                      /* above the loaders (50/60), so the UI can be switched even mid-load */
  top: max(18px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  margin: 0;
  border: 1px solid var(--cyan-line, var(--line, rgba(160, 210, 255, .22)));
  border-radius: 999px;
  background: var(--glass-strong, rgba(6, 14, 26, .62));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .03), 0 8px 26px rgba(0, 0, 0, .45);
  cursor: pointer;
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .25s, box-shadow .25s, opacity .4s;
}
#lang-toggle:hover { border-color: var(--cyan-dim, rgba(127, 220, 255, .55)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), 0 8px 26px rgba(0, 0, 0, .45), 0 0 18px rgba(127, 220, 255, .12); }
#lang-toggle:focus-visible { outline: 1px solid var(--cyan, var(--ice, #9fd8ff)); outline-offset: 3px; }

#lang-toggle i {
  font-style: normal;
  padding: 6px 10px;
  border-radius: 999px;
  font: 600 9.5px/1 var(--display, 'Rajdhani', sans-serif);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-dim, rgba(220, 239, 255, .58));
  transition: color .25s, background .25s, box-shadow .25s;
  white-space: nowrap;
}
#lang-toggle i[data-l="zh"] { letter-spacing: .08em; font-family: 'Rajdhani', 'PingFang SC', 'Microsoft YaHei', sans-serif; }
#lang-toggle i.on {
  color: #03151f;
  background: var(--cyan, var(--ice, #9fd8ff));
  box-shadow: 0 0 14px rgba(127, 220, 255, .45);
}
#lang-toggle:hover i:not(.on) { color: var(--text, #dcefff); }

/* ---------- Part I (/earth/index.html): the orbital-position panel owns this corner ---------- */
body.part1 #orbit-panel { top: calc(max(22px, env(safe-area-inset-top)) + 46px); }

/* ---------- Part II (/earth/beyond.html): film mode docks the modes pill in this corner ---------- */
body.part2.cinematic #modes { right: calc(max(22px, env(safe-area-inset-right)) + 108px); }
body.part2.free #data { right: calc(max(22px, env(safe-area-inset-right)) + 108px); }

@media (max-width: 1100px) {
  #lang-toggle { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
  #lang-toggle i { padding: 6px 8px; letter-spacing: .12em; }
  body.part1 #orbit-panel { top: calc(max(16px, env(safe-area-inset-top)) + 46px); }
}

@media (max-width: 760px) {
  #lang-toggle { top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
  #lang-toggle i { padding: 5px 7px; font-size: 9px; }
  /* the modes pill is centred on small screens — dock it left of the switch */
  body.part2.cinematic #modes, body.part2:not(.free) #modes { right: auto; left: max(12px, env(safe-area-inset-left)); transform: none; }
  body.part2 .mb { padding: 0 12px; letter-spacing: .14em; }
  body.part2.free #data { right: max(12px, env(safe-area-inset-right)); }
}

@media (max-width: 520px) {
  /* Part I stacks its HUD toggles in this corner too: drop them below the switch */
  body.part1 #hud-toggle-wrap { top: calc(max(18px, env(safe-area-inset-top)) + 42px); }
}
