/* =============================================================
   LAUNCHWISE LANGUAGE SWITCHER — production
   Styled against the existing Launchwize design tokens
   (--line, --line-2, --text, --ink-50, --accent, --r-2, --paper).
   Falls back to safe defaults if tokens are absent.

   Components:
   - .lang-switcher          wrapper around the dropdown trigger
   - .lang-current           trigger button (shows the active lang code)
   - .lang-menu              the popup list (positioned absolute)
   - .lang-switcher-mobile   inline links used inside the mobile menu
   ============================================================= */
.lang-switcher {
  position: relative;
  display: inline-block;
  margin-left: 8px;
}

/* ----- trigger button ----- */
.lang-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line, #D8E0EC);
  background: transparent;
  color: var(--text, #0E1726);
  border-radius: var(--r-2, 6px);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1;
  min-height: 32px;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.lang-current:hover {
  background: var(--ink-50, #F6F8FC);
  border-color: rgba(14, 23, 38, 0.22);
}
.lang-current:focus-visible {
  outline: 2px solid var(--accent, #2F7DFF);
  outline-offset: 2px;
}
.lang-current[aria-expanded="true"] {
  background: var(--ink-50, #F6F8FC);
  border-color: rgba(14, 23, 38, 0.22);
}
.lang-current svg {
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.lang-current[aria-expanded="true"] svg {
  transform: rotate(180deg);
}
.lang-current-code {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ----- popup menu ----- */
.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 180px;
  background: var(--paper, #FFFFFF);
  color: var(--text, #0E1726);
  border: 1px solid var(--line-2, #EAF0F8);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
}
.lang-menu[hidden] { display: none; }
.lang-menu li {
  margin: 0;
  padding: 0;
  list-style: none;
}
.lang-menu li[aria-checked="true"] a {
  font-weight: 700;
  background: rgba(47, 125, 255, 0.08);
  color: var(--accent, #2F7DFF);
}
.lang-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.lang-menu a:hover {
  background: rgba(0, 0, 0, 0.04);
}
.lang-menu a:focus-visible {
  outline: 2px solid var(--accent, #2F7DFF);
  outline-offset: -2px;
}

/* ----- inline links used inside the mobile menu ----- */
.lang-switcher-mobile {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-2, #EAF0F8);
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.lang-switcher-mobile a {
  color: var(--text, #0E1726);
  text-decoration: none;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-2, 6px);
  transition: background 0.15s ease;
}
.lang-switcher-mobile a:hover {
  background: var(--ink-50, #F6F8FC);
}

/* ----- dark-mode adjustments (footer / dark sections) ----- */
@media (prefers-color-scheme: dark) {
  .lang-current {
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
  }
  .lang-current:hover,
  .lang-current[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.28);
  }
  .lang-menu {
    background: #0f1a2e;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.12);
  }
  .lang-menu li[aria-checked="true"] a {
    background: rgba(47, 125, 255, 0.18);
  }
  .lang-menu a:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  .lang-switcher-mobile {
    border-top-color: rgba(255, 255, 255, 0.1);
  }
  .lang-switcher-mobile a {
    color: #fff;
  }
  .lang-switcher-mobile a:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

/* ----- mobile (matches main 768px breakpoint) ----- */
@media (max-width: 768px) {
  .lang-switcher {
    margin-left: 0;
    margin-top: 8px;
  }
  .lang-current {
    width: 100%;
    justify-content: space-between;
    min-height: 40px;
  }
  .lang-menu {
    right: auto;
    left: 0;
    min-width: 100%;
  }
}

/* ----- respect reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  .lang-current,
  .lang-current svg,
  .lang-menu a {
    transition: none;
  }
}
