/*!
 * GM Language Switcher — 样式表
 * 适配 goldenmountainmachine.com（深灰 #1a2126 + 白底工业风）
 * 全部使用 px 尺寸，避免受站点 html{font-size:5xx%} 的 rem 缩放影响
 */

/* ============ 容器 ============ */
.gmls {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  vertical-align: middle;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1;
  z-index: 9990;
}
.gmls,
.gmls * {
  box-sizing: border-box;
}

/* 按钮与面板之间 9px 空隙的「隐形桥」：
   否则鼠标从按钮移向面板时会穿过空隙触发 mouseleave，面板在用户点到之前就收起了 */
.gmls::after {
  content: "";
  position: absolute;
  top: 100%;
  left: -12px;
  right: -12px;
  height: 14px;
  display: none;
}
.gmls.is-open::after {
  display: block;
}

/* ============ 触发按钮 ============ */
.gmls-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px 0 10px;
  margin: 0;
  border: 1px solid #dcddde;
  border-radius: 8px;
  background: #fff;
  color: #1a2126;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}
.gmls-btn:hover {
  border-color: #9aa0a3;
  background: #f7f8f8;
}
.gmls-btn:focus-visible {
  outline: 2px solid #1a2126;
  outline-offset: 2px;
}
.gmls.is-open .gmls-btn {
  border-color: #1a2126;
  background: #f2f4f5;
}
.gmls.is-loading .gmls-btn {
  opacity: 0.55;
  pointer-events: none;
}

.gmls-globe {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  display: block;
  color: #4a5054;
}
.gmls.is-open .gmls-globe {
  color: #1a2126;
}
.gmls-code {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.gmls-caret {
  width: 9px;
  height: 6px;
  flex: 0 0 auto;
  display: block;
  color: #6b7175;
  transition: transform 0.2s ease;
}
.gmls.is-open .gmls-caret {
  transform: rotate(180deg);
}

/* ============ 下拉面板 ============ */
.gmls-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  left: auto;
  min-width: 306px;
  padding: 7px;
  background: #fff;
  border: 1px solid #e6e8e8;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 24, 32, 0.11),
    0 2px 6px rgba(16, 24, 32, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
  pointer-events: none;
}
.gmls.is-open .gmls-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* 桌面端不需要指向箭头：面板为白色、站点 header 也是白色，
   同色叠加后箭头轮廓不可见，直接靠阴影 + 位置表达层级更干净。
   移动端会重新启用这个伪元素作为抽屉顶部的拖拽指示条。 */
.gmls-panel::before {
  content: "";
  display: none;
}

.gmls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px 8px;
}
.gmls-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8f9395;
}

/* ============ 语言列表 ============ */
.gmls-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.gmls-item {
  margin: 0;
  padding: 0;
  list-style: none;
}
.gmls-item > a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 9px;
  border-radius: 7px;
  color: #1a2126;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.gmls-item > a:hover,
.gmls-item > a:focus-visible {
  background: #f2f4f5;
  outline: none;
}
.gmls-item.is-active > a {
  background: #eef1f2;
  font-weight: 600;
}
.gmls-flag {
  width: 20px;
  height: 14px;
  flex: 0 0 auto;
  display: block;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.09);
}
.gmls-flag svg {
  width: 100%;
  height: 100%;
  display: block;
}
.gmls-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 阿姆哈拉语（Ge'ez 文字）：指定支持埃塞俄比亚文字的字体，
   否则会回落到系统默认 sans-serif，字形偏细、与相邻语言不统一 */
.gmls-item > a[lang="am"],
.gmls-item > a[lang="am"] .gmls-name {
  font-family: "Ebrima", "Nyala", "Noto Sans Ethiopic", "Abyssinica SIL",
    sans-serif;
}
.gmls-tick {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  display: block;
  color: #1a2126;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.gmls-item.is-active .gmls-tick {
  opacity: 1;
}

/* 滚动条（桌面） */
.gmls-list::-webkit-scrollbar {
  width: 6px;
}
.gmls-list::-webkit-scrollbar-thumb {
  background: #dcddde;
  border-radius: 3px;
}

/* ============ 遮罩（仅移动端生效） ============ */
.gmls-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s;
  z-index: 9998;
}

/* ============ 平板 / 手机：底部抽屉 ============ */
@media screen and (max-width: 900px) {
  .gmls-btn {
    height: 34px;
    padding: 0 9px;
    gap: 5px;
  }
  .gmls-code {
    font-size: 11px;
  }
  .gmls-globe {
    width: 14px;
    height: 14px;
  }
  .gmls-caret {
    width: 8px;
  }
  .gmls-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    min-width: 0;
    width: 100%;
    padding: 8px 14px calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    box-shadow: 0 -8px 40px rgba(16, 24, 32, 0.18);
    transform: translateY(100%);
    z-index: 9999;
  }
  /* 小尖角改成抽屉顶部的拖拽指示条 */
  .gmls-panel::before {
    display: block;
    position: absolute;
    top: 8px;
    left: 50%;
    right: auto;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    background: #dcddde;
    border: 0;
    border-radius: 2px;
    transform: none;
  }
  .gmls.is-open .gmls-panel {
    transform: translateY(0);
  }
  .gmls-head {
    padding: 16px 4px 12px;
    border-bottom: 1px solid #ececec;
    margin-bottom: 8px;
  }
  .gmls-list {
    grid-template-columns: 1fr 1fr;
    max-height: 58vh;
  }
  .gmls-item > a {
    padding: 12px 10px;
    font-size: 14px;
  }
  .gmls.is-open .gmls-mask {
    opacity: 1;
    visibility: visible;
  }
  .gmls-mask {
    display: block;
  }
}
@media screen and (min-width: 901px) {
  .gmls-mask {
    display: none;
  }
}

/* ============ 减少动效偏好 ============ */
@media (prefers-reduced-motion: reduce) {
  .gmls-panel,
  .gmls-caret,
  .gmls-btn,
  .gmls-mask {
    transition: none !important;
  }
}
