/*
 * 页头右上角的两件东西：小语种下拉 + 搜索弹框
 *
 * 设计稿里这块只画了三个图标（地球 / 箭头 / 放大镜），没给下拉和弹框的稿子，
 * 所以外观沿用站上现成的视觉语言：
 *   下拉  —— 白底 + #DEDFE0 描边 + 轻投影，跟大导航面板一路（mega-menu.css）
 *   搜索  —— 白胶囊 + 右侧红圆钮，跟 banner 里那条搜索一路（page-banner.css）
 *
 * 语种数据来自 syn-translate 插件的 Syntr_Seo::links()（插件自带的公开接口，
 * 专门留给主题做自定义切换器），所以后台改启用语种这里自动跟着变。
 *
 * 两个面板都用 fixed 定位，top 由 JS 按页头实际下沿写进 --ht-top：
 * 页头是 Elementor 吸顶容器，CSS 的 top:100% 会落在页头中间（见 mega-menu.js 里那段注释）。
 */

.astra-ht {
  --ht-primary: #e60012;
  --ht-text: #333333;
  --ht-strong: #141414;
  --ht-muted: #808080;
  --ht-line: #dedfe0;
  --ht-bg-subtle: #f9f9f9;

  position: relative;
  display: flex;
  align-items: center;
  gap: var(--ht-gap, 16px);
  font-family: inherit;
}

/* ---------------------------------------------------------------- 触发键 */
.astra-ht__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ht-btn-gap, 8px);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ht-strong);
  font-family: inherit;
  font-size: var(--ht-label-size, 14px);
  line-height: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.astra-ht__btn:hover,
.astra-ht__btn[aria-expanded="true"] {
  opacity: 0.65;
}

.astra-ht__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--ht-icon, 18px);
  height: var(--ht-icon, 18px);
}

.astra-ht__icon img,
.astra-ht__icon svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
}

.astra-ht__caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--ht-caret, 12px);
  transition: transform 0.2s ease;
}

.astra-ht__btn[aria-expanded="true"] .astra-ht__caret {
  transform: rotate(180deg);
}

.astra-ht__caret img,
.astra-ht__caret svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
}

/* 当前语言名：窄屏藏起来，只留图标 */
.astra-ht__label {
  white-space: nowrap;
}

/* --------------------------------------------------------- 小语种下拉 */
.astra-ht__menu {
  position: absolute;
  top: calc(100% + var(--ht-menu-offset, 18px));
  right: 0;
  z-index: 1000;
  min-width: var(--ht-menu-width, 184px);
  padding: 8px 0;
  background: #ffffff;
  border: 1px solid var(--ht-line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

.astra-ht__menu[hidden] {
  display: none;
}

/* 按钮底边到面板顶边之间是块死区，鼠标移过去会先触发 mouseleave 把面板关掉。
   向上补一条透明的“桥”盖住它——它是面板的子元素，指针停在上面时不算离开。
   （跟大导航那边 .amm__panel::before 一个路数） */
.astra-ht__menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(-1 * var(--ht-menu-offset, 18px));
  height: var(--ht-menu-offset, 18px);
}

.astra-ht__langs {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.astra-ht__lang > a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: var(--ht-lang-size, 14px);
  line-height: 20px;
  font-weight: 600;
  color: var(--ht-text);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.astra-ht__lang > a:hover,
.astra-ht__lang > a:focus-visible {
  background: var(--ht-bg-subtle);
  color: var(--ht-primary);
}

.astra-ht__lang.is-current > a {
  color: var(--ht-primary);
}

.astra-ht__flag {
  flex: 0 0 auto;
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.4);
}

/* 没有国旗时占位，免得文字左右对不齐 */
.astra-ht__flag--blank {
  box-shadow: none;
}

.astra-ht__lang-check {
  margin-left: auto;
  color: var(--ht-primary);
}

/* ----------------------------------------------------------- 搜索弹框 */
.astra-ht__panel {
  position: fixed;
  left: 0;
  top: var(--ht-top, 80px);
  z-index: 999;
  width: 100%;
  padding: var(--ht-panel-pad, 32px) 16px;
  background: #ffffff;
  border-top: 1px solid var(--ht-line);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08);
}

.astra-ht__panel[hidden] {
  display: none;
}

.astra-ht__form {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: var(--ht-search-width, 706px);
  height: var(--ht-search-height, 58px);
  margin: 0 auto;
  border-radius: 999px;
  background: var(--ht-bg-subtle);
  border: 1px solid var(--ht-line);
  overflow: hidden;
}

.astra-ht__input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 calc(var(--ht-search-btn, 116px) + 16px) 0 var(--ht-search-pad, 32px);
  border: 0;
  border-radius: 999px;
  background: none;
  font-family: inherit;
  font-size: var(--ht-search-size, 16px);
  line-height: 1.4;
  color: var(--ht-strong);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.astra-ht__input::placeholder {
  color: var(--ht-muted);
  opacity: 1;
}

/* 浏览器自带的清除叉跟右边红钮打架，去掉 */
.astra-ht__input::-webkit-search-decoration,
.astra-ht__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.astra-ht__submit {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ht-search-btn, 116px);
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--ht-primary);
  color: #ffffff;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.astra-ht__submit:hover {
  filter: brightness(0.92);
}

.astra-ht__submit svg {
  display: block;
  width: var(--ht-submit-icon, 22px);
  height: var(--ht-submit-icon, 22px);
}

/* 热门搜索：点一下直接把词填进输入框并提交 */
.astra-ht__hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  width: 100%;
  max-width: var(--ht-search-width, 706px);
  margin: 16px auto 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--ht-muted);
}

.astra-ht__hint-label {
  font-weight: 600;
}

.astra-ht__hint {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: var(--ht-text);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.astra-ht__hint:hover {
  color: var(--ht-primary);
}

/* 弹框开着时压一层遮罩，点空白处关掉 */
.astra-ht__scrim {
  position: fixed;
  inset: var(--ht-top, 80px) 0 0;
  z-index: 998;
  background: rgba(0, 0, 0, 0.24);
}

.astra-ht__scrim[hidden] {
  display: none;
}

/* ======================================================= 窄屏 */
@media (max-width: 1200px) {
  .astra-ht {
    gap: var(--ht-gap-narrow, 12px);
  }

  .astra-ht__label {
    display: none;
  }

  .astra-ht__panel {
    padding: 20px 16px;
  }

  .astra-ht__form {
    height: var(--ht-search-height-narrow, 48px);
  }

  .astra-ht__input {
    padding-left: 20px;
    padding-right: calc(var(--ht-search-btn-narrow, 64px) + 12px);
    font-size: 15px;
  }

  .astra-ht__submit {
    width: var(--ht-search-btn-narrow, 64px);
  }

  .astra-ht__menu {
    top: calc(100% + 12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .astra-ht__btn,
  .astra-ht__caret,
  .astra-ht__lang > a,
  .astra-ht__submit,
  .astra-ht__hint {
    transition: none;
  }
}
