/* ─── Language switcher ─── */
html.lang-switcher-off [data-lang-switch] {
  display: none !important;
}

.lang-switch-wrap {
  position: relative;
  z-index: 2;
}

.lang-switch {
  position: relative;
  font-family: var(--font-display, 'Syne', sans-serif);
}

html:is([lang="ru"], [lang="uk"]) {
  --font-display: 'Onest', 'Inter', sans-serif;
}

html[lang="ar"] {
  --font-display: 'Noto Sans Arabic', 'Inter', sans-serif;
}

html[lang="ja"] {
  --font-display: 'Noto Sans JP', 'Inter', sans-serif;
}

html[lang="hi"] {
  --font-display: 'Noto Sans Devanagari', 'Inter', sans-serif;
}

.lang-switch-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: inherit;
  background: rgba(245, 244, 240, 0.06);
  border: 1px solid rgba(245, 244, 240, 0.14);
  border-radius: 100px;
  padding: 8px 12px 8px 10px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, transform 0.2s, color 0.4s;
  line-height: 1;
  white-space: nowrap;
}

/* Use the same pill button style as nav CTA */
.lang-switch-trigger.nav-cta {
  background: transparent;
  border: 1.5px solid currentColor;
  padding: 10px 24px;
  letter-spacing: 0.08em;
  gap: 10px;
}

.lang-switch-label {
  display: inline-block;
}

.lang-switch-trigger:hover {
  background: rgba(245, 244, 240, 0.11);
  border-color: rgba(245, 244, 240, 0.24);
}

.lang-switch-trigger[aria-expanded="true"] {
  background: rgba(91, 79, 232, 0.2);
  border-color: rgba(91, 79, 232, 0.45);
}

.lang-switch-icon {
  width: 14px;
  height: 14px;
  opacity: 0.65;
  flex-shrink: 0;
}

.lang-switch-code { min-width: 1.6em; text-align: center; }

.lang-switch-chevron {
  width: 8px;
  height: 8px;
  opacity: 0.45;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.lang-switch-trigger[aria-expanded="true"] .lang-switch-chevron {
  transform: rotate(180deg);
  opacity: 0.7;
}

.lang-switch-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  max-height: min(360px, 58vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border-radius: 16px;
  background: rgba(14, 14, 18, 0.92);
  border: 1px solid rgba(245, 244, 240, 0.12);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.97);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.28s;
  z-index: 300;
}

.lang-switch-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.lang-switch-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  font-weight: 500;
  color: rgba(245, 244, 240, 0.72);
  background: none;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: start;
  transition: background 0.15s, color 0.15s;
}

.lang-switch-option:hover {
  background: rgba(245, 244, 240, 0.07);
  color: #F5F4F0;
}

.lang-switch-option.is-active {
  background: rgba(91, 79, 232, 0.18);
  color: #F5F4F0;
}

.lang-switch-option-code {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.45;
  flex-shrink: 0;
}

/* Nav integration */
.nav-end {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

nav.nav--light .lang-switch-trigger {
  color: #F5F4F0;
  background: rgba(245, 244, 240, 0.08);
  border-color: rgba(245, 244, 240, 0.18);
}

nav.nav--dark .lang-switch-trigger {
  color: #0A0A0A;
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}

nav.nav--dark .lang-switch-trigger[aria-expanded="true"] {
  background: rgba(91, 79, 232, 0.12);
  border-color: rgba(91, 79, 232, 0.35);
  color: #0A0A0A;
}

/* Auth / account nav (always dark) */
.auth-nav .lang-switch-trigger,
.dash-nav .lang-switch-trigger {
  color: #F5F4F0;
}

/* RTL */
html[dir="rtl"] .lang-switch-panel { right: auto; left: 0; }
html[dir="rtl"] .nav-end { flex-direction: row-reverse; }
html[dir="rtl"] .hero-inner,
html[dir="rtl"] .problem-inner,
html[dir="rtl"] .traj-inner,
html[dir="rtl"] .final-inner { text-align: right; }

/* Keep centered sections centered in RTL */
html[dir="rtl"] .solution-inner,
html[dir="rtl"] .account-inner,
html[dir="rtl"] .final-inner {
  text-align: center;
}
html[dir="rtl"] .scroll-indicator { left: auto; right: 48px; }
html[dir="rtl"] .chaos-item { flex-direction: row-reverse; text-align: right; }
html[dir="rtl"] .pillar { text-align: right; }
html[dir="rtl"] .traj-node { flex-direction: row-reverse; }
html[dir="rtl"] .eco-points li { padding-left: 0; padding-right: 16px; }
html[dir="rtl"] .eco-points li::before { left: auto; right: 0; }
html[dir="rtl"] .pm-features li { padding-left: 0; padding-right: 18px; }
html[dir="rtl"] .pm-features li::before { left: auto; right: 0; }

/* German long words: allow nice wrapping in big headlines */
html[lang="de"] .eco-headline,
html[lang="de"] .solution-headline,
html[lang="de"] .problem-headline,
html[lang="de"] .traj-headline,
html[lang="de"] .account-headline,
html[lang="de"] .final-headline {
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: anywhere;
  word-break: normal;
}

@media (max-width: 767px) {
  .nav-end { gap: 8px; }
  .lang-switch-trigger {
    padding: 9px 12px 9px 10px;
    font-size: 10px;
    gap: 6px;
  }
  .lang-switch-label { display: none; }
  .lang-switch-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    min-width: 0;
    /* svh keeps the sheet inside the visible area while the mobile browser
       chrome is on screen */
    max-height: 68svh;
    border-radius: 20px 20px 0 0;
    padding: 8px max(8px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    transform: translateY(100%);
    z-index: 10001;
  }
  .lang-switch-panel.is-open {
    transform: translateY(0);
  }
  .lang-switch-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  .lang-switch-backdrop.is-open { display: block; }
  .lang-switch-mobile-handle {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(245, 244, 240, 0.2);
    margin: 4px auto 10px;
  }
  html[dir="rtl"] .scroll-indicator { right: 20px; }
}

@media (min-width: 768px) {
  .lang-switch-mobile-handle { display: none; }
  .lang-switch-backdrop { display: none !important; }
}
