/* Language switcher — pinned next to logo in header (same place everywhere) */
.sb-lang {
  display: none !important;
}

/* Reduce EN/RU flash: hide chrome text until first i18n paint */
html.i18n-pending .hdr-right,
html.i18n-pending .sb-tabs,
html.i18n-pending .bonus-head,
html.i18n-pending .lang-switch {
  opacity: 0;
}
html.i18n-ready .hdr-right,
html.i18n-ready .sb-tabs,
html.i18n-ready .bonus-head,
html.i18n-ready .lang-switch {
  opacity: 1;
  transition: opacity 0.12s ease;
}

.lang-switch {
  position: relative;
  z-index: 80;
  font-family: inherit;
  flex-shrink: 0;
  margin-left: 4px;
}

.lang-switch-current {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #213743;
  color: #f7fafc;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: border-color 0.15s, background 0.15s;
}
.lang-switch-current:hover {
  border-color: rgba(20, 117, 225, 0.55);
  background: #2a4554;
}
.lang-switch.open .lang-switch-current {
  border-color: #1475e1;
}
.lang-switch-current svg {
  opacity: 0.7;
  transition: transform 0.2s;
}
.lang-switch.open .lang-switch-current svg {
  transform: rotate(180deg);
}

.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1475e1, #0d5bb8);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.lang-name {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-switch-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  bottom: auto;
  min-width: 200px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 33, 46, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 90;
}
.lang-switch-menu[hidden] {
  display: none !important;
}

.lang-switch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b1bad3;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.lang-switch-item:hover,
.lang-switch-item.active {
  background: rgba(255, 255, 255, 0.06);
  color: #f7fafc;
}
.lang-switch-item.active {
  outline: 1px solid rgba(20, 117, 225, 0.45);
}

/* Fallback if somehow not in header */
body > .lang-switch {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  margin-left: 0;
}

@media (max-width: 720px) {
  .lang-switch-current {
    height: 36px;
    padding: 0 8px;
    gap: 4px;
  }
  .lang-name { display: none; }
  .lang-switch-menu {
    min-width: 180px;
    max-height: min(60vh, 320px);
    overflow-y: auto;
  }
}

@media (max-width: 400px) {
  .hdr-left .lang-switch-current svg { display: none; }
}
