/* Language switcher: desktop = after main nav (right); mobile = between logo area and hamburger */

#main-header #et-top-navigation {
  gap: 0;
}

.hc-lang-switch {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.hc-lang-switch__link {
  color: #2d3e50;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 2px;
  white-space: nowrap;
}

.hc-lang-switch__link:hover,
.hc-lang-switch__link:focus {
  color: #0d1b2a;
  text-decoration: underline;
}

.hc-lang-switch__link--active {
  color: #b8962e;
  cursor: default;
  text-decoration: none;
}

.hc-lang-switch__link--active:hover {
  text-decoration: none;
}

.hc-lang-switch__sep {
  color: #c5cdd6;
  user-select: none;
  padding: 0 2px;
  font-weight: 400;
}

@media (min-width: 981px) {
  #main-header #et-top-navigation {
    justify-content: flex-end !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    padding-right: 40px !important;
  }

  #main-header #top-menu-nav {
    width: auto !important;
    flex: 0 1 auto !important;
    margin: 0 !important;
  }

  #main-header #top-menu {
    justify-content: flex-end !important;
    flex-wrap: nowrap !important;
  }

  .hc-lang-switch {
    flex: 0 0 auto !important;
    margin-left: 16px !important;
  }
}

@media (max-width: 980px) {
  #main-header #et-top-navigation {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    width: auto !important;
    flex: 1 1 auto !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  #main-header #top-menu-nav {
    display: none !important;
  }

  /* 手機可讀、略小於博客語言鈕，避免頂欄過滿 */
  .hc-lang-switch {
    order: 1 !important;
    margin-left: auto !important;
    margin-right: 6px !important;
    font-size: 14px !important;
    letter-spacing: 0.02em !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
  }

  #main-header .hc-lang-switch__link {
    padding: 4px 6px !important;
    border-radius: 4px !important;
  }

  #main-header .hc-lang-switch__sep {
    padding: 0 2px !important;
    margin: 0 !important;
    opacity: 0.85;
    font-weight: 400 !important;
  }

  #main-header #et_mobile_nav_menu {
    order: 2 !important;
    flex: 0 0 auto !important;
  }

  /*
   * icons-fix 手機版 .logo_container 可達 min(68vw, 280px)，與「語言列 + 漢堡」同列時
   * #et-top-navigation 剩寬過窄，漢堡會被擠出視口右側（看似「消失」）。
   */
  #main-header:has(.hc-lang-switch) > .container.et_menu_container {
    overflow: visible !important;
  }

  #main-header:has(.hc-lang-switch) .logo_container {
    max-width: min(46vw, 188px) !important;
  }

  #main-header #et-top-navigation:has(.hc-lang-switch) {
    min-width: 0 !important;
    gap: 4px !important;
  }

  #main-header:has(.hc-lang-switch) .hc-lang-switch {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    justify-content: flex-end !important;
  }

  #main-header:has(.hc-lang-switch) #et_mobile_nav_menu {
    flex-shrink: 0 !important;
    display: block !important;
  }

  #main-header:has(.hc-lang-switch) #et_mobile_nav_menu .mobile_nav,
  #main-header:has(.hc-lang-switch) .mobile_menu_bar {
    flex-shrink: 0 !important;
  }
}

@media (max-width: 380px) {
  /* 極窄屏略收字級與 logo，避免擠壓漢堡 */
  #main-header:has(.hc-lang-switch) .hc-lang-switch {
    font-size: 13px !important;
  }

  #main-header .hc-lang-switch__link {
    padding: 3px 5px !important;
  }

  #main-header:has(.hc-lang-switch) .logo_container {
    max-width: min(40vw, 160px) !important;
  }
}
