/* IFI Asia language picker: intentionally scoped to avoid changing page layouts. */
.language-picker {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-width: 0;
}

.language-toggle {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  margin: 0;
  padding: .28rem .55rem;
  border: 1px solid rgba(201, 166, 45, .56);
  border-radius: 999px;
  color: var(--gold-light, #f4ecd4);
  background: rgba(15,27,45, .42);
  cursor: pointer;
  font-family: var(--sans, "DM Sans", Arial, sans-serif);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1;
  white-space: nowrap;
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, opacity .18s ease;
}

.language-toggle:hover,
.language-toggle:focus-visible,
.language-picker.is-open .language-toggle {
  border-color: var(--gold-light, #f4ecd4);
  color: #fff;
  background: rgba(201, 166, 45, .14);
}

.language-toggle:focus-visible,
.language-option:focus-visible {
  outline: 2px solid var(--gold-light, #f4ecd4);
  outline-offset: 3px;
}

.language-toggle.is-busy {
  cursor: progress;
  opacity: .78;
}

.language-toggle.is-busy .language-caret {
  animation: ifi-language-spin .75s linear infinite;
}

.language-globe {
  width: 1rem;
  height: 1rem;
  flex: 0 0 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.45;
}

.language-code {
  min-width: 2.05em;
  text-align: center;
}

.language-caret {
  width: .42rem;
  height: .42rem;
  margin-inline-start: .08rem;
  border-inline-end: 1px solid currentColor;
  border-block-end: 1px solid currentColor;
  transform: translateY(-.12rem) rotate(45deg);
  transition: transform .18s ease;
}

.language-picker.is-open .language-caret {
  transform: translateY(.1rem) rotate(225deg);
}

.language-listbox {
  position: fixed;
  z-index: 1100;
  display: block;
  max-height: min(340px, calc(100dvh - 1rem));
  margin: 0;
  padding: .38rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(201, 166, 45, .62);
  border-radius: 12px;
  color: #f7f4ea;
  background: #0f1b2d;
  box-shadow: 0 14px 36px rgba(4, 11, 20, .36), 0 0 0 1px rgba(247, 244, 234, .05);
  font-family: var(--sans, "DM Sans", Arial, sans-serif);
  scrollbar-color: rgba(226, 196, 90, .72) rgba(247, 244, 234, .08);
  scrollbar-width: thin;
}

.language-listbox[hidden] {
  display: none;
}

.language-option {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .52rem .68rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(247, 244, 234, .84);
  cursor: pointer;
  line-height: 1.3;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease;
}

.language-option + .language-option {
  border-top: 1px solid rgba(247, 244, 234, .08);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.language-option:hover,
.language-option:focus-visible,
.language-option[aria-selected="true"] {
  border-color: rgba(226, 196, 90, .46);
  color: #fff;
  background: rgba(201, 166, 45, .14);
}

.language-option[aria-selected="true"]::after {
  width: .42rem;
  height: .72rem;
  flex: 0 0 .42rem;
  margin-inline-start: auto;
  border-inline-end: 2px solid var(--gold-light, #f4ecd4);
  border-block-end: 2px solid var(--gold-light, #f4ecd4);
  content: '';
  transform: translateY(-.1rem) rotate(45deg);
}

.language-native {
  min-width: 0;
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.language-english {
  flex: 0 0 auto;
  color: rgba(247, 244, 234, .57);
  font-size: .67rem;
  text-align: end;
}

.language-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.language-status[data-state="error"] {
  position: fixed;
  z-index: 1200;
  left: 50%;
  bottom: 20px;
  width: min(360px, calc(100vw - 32px));
  height: auto;
  margin: 0;
  padding: 12px 16px;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border: 1px solid var(--gold);
  border-radius: 10px;
  color: var(--paper);
  background: var(--navy);
  font: 14px/1.5 var(--sans);
  transform: translateX(-50%);
}

@keyframes ifi-language-spin {
  from { transform: translateY(-.12rem) rotate(45deg); }
  to { transform: translateY(-.12rem) rotate(405deg); }
}

/* Long translated navigation labels get the existing menu treatment before 760px. */
@media (min-width: 761px) and (max-width: 940px) {
  .site-header .menu-toggle {
    display: inline-flex;
    order: 3;
  }
  .site-header .primary-navigation {
    position: absolute;
    z-index: 60;
    top: calc(100% + 1px);
    right: 0;
    left: 0;
    display: none;
    align-items: stretch;
    flex-direction: column;
    gap: 0;
    padding: .55rem var(--page-pad) 1rem;
    border-bottom: 1px solid rgba(226, 196, 90, .2);
    background: rgba(8,20,38, .98);
  }
  .site-header .primary-navigation.is-open { display: flex; }
  .site-header .nav-link {
    padding: .65rem .1rem;
    border-bottom: 1px solid rgba(247, 244, 234, .08);
    font-size: .78rem;
    white-space: normal;
  }
  .site-header .nav-link::after { display: none; }
  .site-header .language-picker {
    align-self: flex-start;
    margin-top: .6rem;
  }
  .site-header .nav-cta {
    align-self: flex-start;
    margin-top: .65rem;
  }
}

@media (max-width: 760px) {
  .site-header .language-picker {
    align-self: flex-start;
    margin-top: .6rem;
  }
  .site-header .language-toggle { min-height: 34px; }
  .language-listbox {
    max-width: calc(100vw - 1rem);
    border-radius: 12px;
  }
  .language-option { min-height: 44px; }
}

html[dir="rtl"] .language-listbox {
  direction: rtl;
}

html[dir="rtl"] .language-option {
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  .language-toggle,
  .language-caret,
  .language-option { transition: none; }
  .language-toggle.is-busy .language-caret { animation: none; }
}

/* Preserve existing layouts while allowing translated words and scripts to wrap. */
html:not([lang="en"]) h1,
html:not([lang="en"]) h2,
html:not([lang="en"]) h3,
html:not([lang="en"]) p,
html:not([lang="en"]) .button,
html:not([lang="en"]) .footer-column a { overflow-wrap: anywhere; }
html[lang="zh-Hant"] {
  --sans: "DM Sans", "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  --serif: "Playfair Display", "Songti TC", "PMingLiU", "Noto Serif CJK TC", serif;
}
html[lang="ar"] {
  --sans: "DM Sans", "Noto Sans Arabic", Tahoma, sans-serif;
  --serif: "Playfair Display", "Noto Naskh Arabic", "Traditional Arabic", serif;
}
@media (max-height: 600px) and (max-width: 940px) {
  .site-header .primary-navigation { max-height: calc(100dvh - var(--site-header-height)); overflow-y: auto; }
}

/* Full-bleed Activity bands retain their layout in both reading directions. */
.activity-section .division-intro,
.activity-section .roadmap-intro {
  width: var(--ifi-viewport-width, 100vw);
  margin-left: 0;
  margin-right: 0;
  margin-inline-start: calc((100% - var(--ifi-viewport-width, 100vw)) / 2);
  margin-inline-end: 0;
}
