/* Language lives after the menu, as a quiet part of the glass navigation. */
.header-shell .header:has(.language-control:not([hidden])) {
  width: 282px;
  gap: 12px;
}

.header .language-control {
  display: flex;
  align-items: center;
  flex: none;
  /* Anchor the panel to the whole capsule, keeping it inside narrow screens. */
  position: static;
  z-index: 2;
}

.header .language-control[hidden],
.language-panel[hidden] { display: none; }

.language-control::before {
  content: '';
  width: 1px;
  height: 16px;
  margin-right: 9px;
  background: linear-gradient(transparent, #c4dfff24, transparent);
}

.language-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 76px;
  min-height: 44px;
  padding: 0;
  color: #aabed7;
  background: transparent;
  border: 0;
  border-radius: 0;
  transition: color .25s ease;
}

.language-code {
  min-width: 33px;
  font: 500 10px 'Manrope', sans-serif;
  letter-spacing: .04em;
  text-align: left;
}

.language-globe {
  width: 13px;
  height: 13px;
  opacity: .75;
  stroke: currentColor;
  stroke-width: 1.3;
}

.language-chevron {
  width: 9px;
  height: 9px;
  opacity: .55;
  stroke: currentColor;
  stroke-width: 1.3;
  transition: transform .3s ease, opacity .3s ease;
}

.language-toggle:hover,
.language-toggle[aria-expanded="true"] { color: #e5f0ff; }
.language-toggle[aria-expanded="true"] .language-chevron { transform: rotate(180deg); opacity: .85; }

/* Mouse focus has no ring. Keyboard focus gets a fine blue light underneath. */
.language-toggle:focus,
.language-option:focus { outline: none; }

.language-toggle::after {
  content: '';
  position: absolute;
  bottom: 7px;
  left: 21px;
  right: 17px;
  height: 1px;
  background: #8cc6ff;
  box-shadow: 0 0 6px #3793ff70;
  opacity: 0;
}

.language-toggle:focus-visible { color: #e5f0ff; }
.language-toggle:focus-visible::after { opacity: 1; }

.language-panel {
  position: absolute;
  top: calc(100% + 13px);
  right: 0;
  z-index: 3;
  width: 252px;
  max-width: calc(100vw - 32px);
  padding: 18px 10px 10px;
  /* Glass surface is shared with .mobile-nav in editorial.css. */
  transform-origin: top right;
  animation: language-appear .25s cubic-bezier(.22, 1, .36, 1) both;
}

.language-heading {
  margin: 0 12px 10px;
  color: #7c94b0;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.language-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 49px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  color: #b9c8d9;
  background: transparent;
  text-align: left;
  transition: background-color .2s ease, color .2s ease;
}

.language-option + .language-option { margin-top: 3px; }
.language-option-code { width: 18px; color: #7088a4; font: 9px monospace; letter-spacing: .04em; }
.language-option-name { font-size: 12px; font-weight: 500; letter-spacing: -.02em; }
.language-region { color: #889bb0; font-size: 11px; }
.language-check { margin-left: auto; width: 14px; height: 14px; stroke: #80bdff; stroke-width: 1.4; opacity: 0; }
.language-option[aria-checked="true"] { color: #e0eeff; background: #3793ff0d; }
.language-option[aria-checked="true"] .language-option-code { color: #80bdff; }
.language-option[aria-checked="true"] .language-check { opacity: 1; }
.language-option:hover { color: #f0f6ff; background: #c4dfff09; }
.language-option:focus-visible { color: #f0f6ff; background: #3793ff18; }
.language-option:focus-visible::before {
  content: '';
  position: absolute;
  left: 0;
  top: 17px;
  bottom: 17px;
  width: 2px;
  border-radius: 2px;
  background: #80bdff;
}

@keyframes language-appear {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 700px) {
  .header-shell .header:has(.language-control:not([hidden])) {
    width: 270px;
    gap: 9px;
    padding-inline: 13px;
  }
}

.motion-reduced .language-panel { animation: none; }
.motion-reduced :is(.language-toggle, .language-chevron, .language-option) { transition: none; }
@media (prefers-reduced-motion: reduce) {
  html:not(.motion-active) .language-panel { animation: none; }
  html:not(.motion-active) :is(.language-toggle, .language-chevron, .language-option) { transition: none; }
}

@media (forced-colors: active) {
  .language-toggle:focus-visible, .language-option:focus-visible { outline: 1px solid Highlight; outline-offset: -2px; }
  .header .language-panel { border: 1px solid CanvasText; }
  .language-check { stroke: Highlight; }
}
