/**
 * KIway Language Switcher — Frontend Styles
 *
 * Inherits theme colors via CSS custom properties when present, falls back to
 * neutral defaults. All sizing uses em / rem so the switcher scales with the
 * surrounding nav text.
 */

.kiway-lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: inherit;
  line-height: 1;
}

/* Empty switcher (e.g. only one language configured) collapses cleanly. */
.kiway-lang-switcher:empty { display: none; }

.kiway-lang-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.kiway-lang-switcher__btn:hover,
.kiway-lang-switcher__btn:focus-visible {
  background: rgba(0, 0, 0, .06);
}

.kiway-lang-switcher__chevron {
  transition: transform .15s;
  opacity: .6;
}

.kiway-lang-switcher__btn[aria-expanded="true"] .kiway-lang-switcher__chevron {
  transform: rotate(180deg);
}

.kiway-lang-switcher__flag {
  display: block;
  flex-shrink: 0;
  border-radius: 1px;
}

.kiway-lang-switcher__slug {
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.85em;
  font-weight: 600;
}

.kiway-lang-switcher__name {
  font-size: 0.95em;
}

/* ─── Dropdown style ─── */
.kiway-lang-switcher--dropdown .kiway-lang-switcher__list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  z-index: 1000;
}

.kiway-lang-switcher__item {
  list-style: none;
}

.kiway-lang-switcher__item .kiway-lang-switcher__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  text-decoration: none;
  /* Dropdown items render on a white card overlay — always force an
     explicit dark color so they stay readable inside transparent navs
     (text-white over hero) where they'd otherwise inherit currentColor.
     The custom property is set per-site from the darker of primary vs
     secondary brand colors; fallback is a neutral dark.
     `!important` overrides nav-overlay `currentColor` cascades. */
  color: var(--kiway-lang-dropdown-color, #1f2937) !important;
  transition: background-color .15s;
}

.kiway-lang-switcher__item .kiway-lang-switcher__link:hover {
  background: rgba(0, 0, 0, .05);
}

.kiway-lang-switcher__item.is-current .kiway-lang-switcher__link {
  background: rgba(0, 0, 0, .04);
  color: var(--kiway-lang-dropdown-color, #1f2937) !important;
  font-weight: 600;
  cursor: default;
}

/* ─── Inline style ─── */
.kiway-lang-switcher--inline {
  gap: 6px;
}

.kiway-lang-switcher__inline-item {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 3px;
}

.kiway-lang-switcher__inline-item:hover {
  background: rgba(0, 0, 0, .06);
}

.kiway-lang-switcher__inline-item.is-current {
  font-weight: 600;
  cursor: default;
}

.kiway-lang-switcher__sep {
  opacity: .4;
  margin: 0 2px;
}

/* ─── Globe modal style ─── */
.kiway-lang-switcher--globe-modal .kiway-lang-switcher__btn,
.kiway-lang-switcher--globe-only .kiway-lang-switcher__btn {
  padding: 6px 8px;
}

.kiway-lang-switcher__current-slug {
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.85em;
  font-weight: 600;
}

.kiway-lang-switcher__modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kiway-lang-switcher__modal[hidden] { display: none !important; }

.kiway-lang-switcher__modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  cursor: pointer;
}

.kiway-lang-switcher__modal-card {
  position: relative;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.kiway-lang-switcher__modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}

.kiway-lang-switcher__modal-title {
  font-weight: 600;
  font-size: 15px;
  color: #111827;
}

.kiway-lang-switcher__modal-close {
  background: none;
  border: 0;
  padding: 6px;
  cursor: pointer;
  color: #6b7280;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kiway-lang-switcher__modal-close:hover {
  background: rgba(0, 0, 0, .06);
  color: #111827;
}

.kiway-lang-switcher__modal-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}

.kiway-lang-switcher__modal-list .kiway-lang-switcher__item {
  display: block;
}

.kiway-lang-switcher__modal-list .kiway-lang-switcher__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  /* See note on .kiway-lang-switcher__item .kiway-lang-switcher__link above —
     dropdown/modal items must stay dark over white card regardless of nav
     `text-white` cascades. */
  color: var(--kiway-lang-dropdown-color, #1f2937) !important;
  font-size: 15px;
  transition: background-color .15s;
}

.kiway-lang-switcher__modal-list .kiway-lang-switcher__link:hover {
  background: rgba(0, 0, 0, .05);
}

.kiway-lang-switcher__modal-list .kiway-lang-switcher__item.is-current .kiway-lang-switcher__link {
  background: rgba(0, 0, 0, .04);
  color: var(--kiway-lang-dropdown-color, #1f2937) !important;
  font-weight: 600;
  cursor: default;
}

/* ─── Slugs-only style ─── */
.kiway-lang-switcher--slugs-only {
  gap: 4px;
  font-size: 0.85em;
  letter-spacing: 0.4px;
}

.kiway-lang-switcher__slug-link {
  text-decoration: none;
  color: inherit;
  text-transform: uppercase;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 3px;
}

.kiway-lang-switcher__slug-link:hover {
  background: rgba(0, 0, 0, .08);
}

.kiway-lang-switcher__slug-link.is-current {
  cursor: default;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Mobile placement (slot inside / next-to-burger) ─── */
[data-kiway-lang-switcher-slot="mobile-inside-menu"] {
  display: block;
  margin: 8px 0;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
}

[data-kiway-lang-switcher-slot]:empty { display: none; }

/* ─── Harmonize header widget icon sizes ────────────────────────────
   Search trigger, lang-switcher globe, and burger button icons all
   render in the same flex row inside the nav-unit. Without this rule
   they pick up their own sizing (search via font-size, lang-switcher
   via inline width/height, burger via SVG attrs) and end up at
   different effective heights. Constrain them to a uniform 24px box
   so the row reads as a coherent set of icons. */
/* width/height/font-size are intentionally NOT !important so per-site icon
   size overrides (inline `font-size:Npx` from render_*_search /
   apply_burger_icon_size / render_*_lang_switcher) can win. The harmonize
   defaults still apply when no override exists. */
/* Scoped to ONLY the trigger icon (and lang-switcher globe / burger) — the
   search floating-bar submit/close icons would otherwise inherit 24px and
   look oversized against the input field. */
[data-kiway-nav-unit] [data-kiway-widget="search"] [data-kiway-search="true"] > i,
[data-kiway-nav-unit] [data-kiway-widget="search"] [data-kiway-search="true"] > svg,
[data-kiway-nav-unit] [data-kiway-widget="search"] .kiway-search-trigger > i,
[data-kiway-nav-unit] [data-kiway-widget="search"] .kiway-search-trigger > svg,
[data-kiway-nav-unit] [data-kiway-widget="lang-switcher"] .kiway-lang-switcher__globe,
[data-kiway-nav-unit] [data-kiway-menu-toggle] > i,
[data-kiway-nav-unit] [data-kiway-menu-toggle] > svg {
  width: 24px;
  height: 24px;
  font-size: 24px;
  line-height: 1 !important;
  flex-shrink: 0;
}
