/* 多语种切换器样式（现代扁平风格）
 * 设计约束：
 *   1) 组件变量统一前缀 --ls-*，只“读取”站点变量并给自身兜底值，绝不覆盖站点同名变量；
 *      自定义属性自引用（--c-gold:var(--c-gold,#xxx)）会被判定 invalid at computed-value time，
 *      导致整段边框/圆角/字号被丢弃 → 无样式裸按钮。本表一律用字面量，杜绝自引用。
 *   2) 面板/遮罩在移动端会被挂到 <body>，因此变量同时声明在三个节点上。
 *   3) 适配 PC / iOS Safari / 微信 X5 / 安卓原生浏览器：不用 inset、不依赖 :has，关键属性带前缀。
 *   4) 主色为自包含靛蓝（--ls-accent），与站点其它配色互不干扰，迁移零依赖。
 */

.lang-switcher-slot{
  display:inline-flex;
  align-items:center;
  flex-shrink:0;
  margin:0 .5rem;
  vertical-align:middle;
}

.lang-switcher,
.lang-switcher__panel,
.lang-switcher__backdrop{
  --ls-accent:#4f46e5;
  --ls-accent-deep:#3730a3;
  --ls-accent-soft:#eef2ff;
  --ls-text:#1f2937;
  --ls-muted:#6b7280;
  --ls-surface:#ffffff;
  --ls-cream:#f8fafc;
  --ls-border:#e5e7eb;
  --ls-r-sm:8px;
  --ls-r-md:12px;
  --ls-r-lg:20px;
  --ls-r-pill:999px;
  --ls-dur:.2s;
  --ls-dur-fast:.14s;
  --ls-ease:cubic-bezier(.22,.61,.36,1);
  --ls-fs-tiny:13px;
  --ls-fs-small:14px;
  --ls-shadow:0 24px 60px -12px rgba(15,23,42,.28),0 8px 20px -8px rgba(15,23,42,.14);
  --ls-z:1200;
}

.lang-switcher{position:relative;display:inline-block;font-family:inherit}

.lang-switcher__btn{
  -webkit-appearance:none;
  appearance:none;
  display:inline-flex;
  align-items:center;
  gap:.4rem;
  min-height:36px;
  padding:.42rem .72rem;
  margin:0;
  border:1px solid var(--ls-border);
  border-radius:10px;
  background:rgba(255,255,255,.92);
  -webkit-backdrop-filter:blur(10px);
  backdrop-filter:blur(10px);
  color:var(--ls-text);
  font-family:inherit;
  font-size:var(--ls-fs-tiny);
  font-weight:600;
  line-height:1.2;
  white-space:nowrap;
  cursor:pointer;
  box-shadow:0 1px 2px rgba(15,23,42,.05);
  -webkit-tap-highlight-color:transparent;
  transition:border-color var(--ls-dur-fast) var(--ls-ease),
             background-color var(--ls-dur-fast) var(--ls-ease),
             color var(--ls-dur-fast) var(--ls-ease),
             box-shadow var(--ls-dur-fast) var(--ls-ease),
             transform var(--ls-dur-fast) var(--ls-ease);
}
.lang-switcher__btn:hover,
.lang-switcher__btn[aria-expanded="true"]{
  border-color:rgba(79,70,229,.45);
  color:var(--ls-accent-deep);
  background:#fff;
  box-shadow:0 4px 14px rgba(79,70,229,.16);
}
.lang-switcher__btn:active{transform:scale(.97)}
.lang-switcher__btn:focus{outline:none}
.lang-switcher__btn:focus-visible{
  outline:2px solid var(--ls-accent);
  outline-offset:2px;
}
.lang-switcher--dark .lang-switcher__btn{
  color:#fff;
  border-color:rgba(255,255,255,.28);
  background:rgba(255,255,255,.08);
}
.lang-switcher--dark .lang-switcher__btn:hover,
.lang-switcher--dark .lang-switcher__btn[aria-expanded="true"]{
  border-color:rgba(255,255,255,.55);
  background:rgba(255,255,255,.16);
  color:#fff;
}

.lang-switcher__globe{font-size:15px;line-height:1;display:inline-block}
.lang-switcher__label{max-width:9em;overflow:hidden;text-overflow:ellipsis}
.lang-switcher__caret{
  width:6px;height:6px;
  border-right:1.6px solid currentColor;
  border-bottom:1.6px solid currentColor;
  transform:rotate(45deg) translate(-1px,-1px);
  opacity:.5;
  transition:transform var(--ls-dur) var(--ls-ease);
}
.lang-switcher__btn[aria-expanded="true"] .lang-switcher__caret{transform:rotate(225deg) translate(-1px,-1px)}

.lang-switcher__panel{
  position:absolute;
  top:calc(100% + 10px);
  right:0;
  width:280px;
  max-width:calc(100vw - 1.5rem);
  background:var(--ls-surface);
  color:var(--ls-text);
  border:1px solid var(--ls-border);
  border-radius:14px;
  box-shadow:var(--ls-shadow);
  overflow:hidden;
  opacity:0;
  visibility:hidden;
  transform:translateY(-8px) scale(.97);
  transform-origin:top right;
  transition:opacity var(--ls-dur) var(--ls-ease),
             transform var(--ls-dur) var(--ls-ease),
             visibility var(--ls-dur) var(--ls-ease);
  z-index:var(--ls-z);
  box-sizing:border-box;
}
.lang-switcher__panel.is-open{opacity:1;visibility:visible;transform:translateY(0) scale(1)}

.lang-switcher__search{
  padding:.7rem;
  border-bottom:1px solid var(--ls-border);
  background:#fbfbfd;
}
.lang-switcher__input{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  height:38px;
  padding:0 .8rem 0 2.25rem;
  border:1px solid var(--ls-border);
  border-radius:9px;
  background-color:var(--ls-surface);
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:.7rem center;
  color:var(--ls-text);
  font-family:inherit;
  font-size:var(--ls-fs-tiny);
  line-height:38px;
  box-sizing:border-box;
  transition:border-color var(--ls-dur-fast) var(--ls-ease),box-shadow var(--ls-dur-fast) var(--ls-ease);
}
.lang-switcher__input::-webkit-search-cancel-button{-webkit-appearance:none}
.lang-switcher__input:focus{
  outline:none;
  border-color:var(--ls-accent);
  box-shadow:0 0 0 3px rgba(79,70,229,.14);
}

.lang-switcher__list{
  list-style:none;
  margin:0;
  padding:.4rem;
  max-height:300px;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}
.lang-switcher__item{
  -webkit-appearance:none;
  appearance:none;
  position:relative;
  display:flex;
  align-items:center;
  gap:.6rem;
  width:100%;
  min-height:42px;
  margin:0;
  padding:.45rem .6rem;
  border:0;
  border-radius:var(--ls-r-sm);
  background:transparent;
  color:var(--ls-text);
  font-family:inherit;
  font-size:var(--ls-fs-small);
  line-height:1.35;
  text-align:start;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  transition:background-color var(--ls-dur-fast) var(--ls-ease),color var(--ls-dur-fast) var(--ls-ease);
}
.lang-switcher__item:hover,
.lang-switcher__item:focus-visible{background:var(--ls-cream);outline:none}
.lang-switcher__item.is-active{background:var(--ls-accent-soft);color:var(--ls-accent-deep);font-weight:600}
.lang-switcher__item.is-active::before{
  content:"";
  position:absolute;
  left:0;top:9px;bottom:9px;
  width:3px;
  border-radius:0 3px 3px 0;
  background:var(--ls-accent);
}
.lang-switcher__flag{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:24px;height:24px;
  font-size:16px;
  line-height:1;
  flex-shrink:0;
}
.lang-switcher__name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lang-switcher__check{
  flex-shrink:0;
  color:var(--ls-accent);
  font-size:13px;
  font-weight:700;
  opacity:0;
  transform:scale(.7);
  transition:opacity var(--ls-dur-fast) var(--ls-ease),transform var(--ls-dur-fast) var(--ls-ease);
}
.lang-switcher__item.is-active .lang-switcher__check{opacity:1;transform:scale(1)}
.lang-switcher__empty{
  padding:1.1rem .8rem;
  text-align:center;
  color:var(--ls-muted);
  font-size:var(--ls-fs-tiny);
}

.lang-switcher--mobile{width:100%}
.lang-switcher--mobile .lang-switcher__btn{width:100%;justify-content:center}
.lang-switcher--mobile .lang-switcher__panel{right:auto;left:0;width:100%}

.lang-switcher__backdrop{display:none}

/* 触屏 / 窄屏：底部弹出面板（iOS、微信、安卓浏览器统一交互） */
@media (hover:none),(max-width:900px){
  .lang-switcher__backdrop{
    display:block;
    position:fixed;
    top:0;right:0;bottom:0;left:0;
    z-index:calc(var(--ls-z) - 1);
    background:rgba(15,23,42,.55);
    -webkit-backdrop-filter:blur(3px);
    backdrop-filter:blur(3px);
    opacity:0;
    visibility:hidden;
    -webkit-tap-highlight-color:transparent;
    transition:opacity var(--ls-dur) var(--ls-ease),visibility var(--ls-dur) var(--ls-ease);
  }
  .lang-switcher__backdrop.is-open{opacity:1;visibility:visible}
  .lang-switcher__panel,
  .lang-switcher--mobile .lang-switcher__panel{
    position:fixed;
    top:auto;
    right:0;
    bottom:0;
    left:0;
    width:auto;
    max-width:none;
    max-height:72vh;
    max-height:72svh;
    display:flex;
    flex-direction:column;
    border:0;
    border-radius:var(--ls-r-lg) var(--ls-r-lg) 0 0;
    padding-bottom:env(safe-area-inset-bottom,0px);
    box-shadow:0 -18px 48px rgba(15,23,42,.36);
    transform:translateY(102%);
    transform-origin:bottom center;
    z-index:var(--ls-z);
  }
  .lang-switcher__panel.is-open{transform:translateY(0)}
  .lang-switcher__search{position:relative;flex-shrink:0;padding-top:1.1rem}
  .lang-switcher__search::before{
    content:"";
    position:absolute;
    top:8px;left:50%;
    width:40px;height:4px;
    margin-left:-20px;
    border-radius:2px;
    background:#d8dce5;
  }
  /* iOS Safari 会放大 font-size < 16px 的输入框并顶飞弹层 */
  .lang-switcher__input{height:44px;line-height:44px;font-size:16px}
  .lang-switcher__list{flex:1 1 auto;max-height:none}
  .lang-switcher__item{min-height:48px}

  /* 手机端：切换器收成右下角悬浮球（FAB）——主色渐变 + 白色地球图标，
   * 避免窄屏顶部导航放不下完整按钮、展开后压住菜单/导出等操作项。
   * 点击悬浮球 → 底部抽屉选择语种；抽屉打开时悬浮球淡出。 */
  #langSwitcher,
  .lang-switcher-slot{
    position:fixed !important;
    top:auto !important;
    right:16px !important;
    bottom:calc(16px + env(safe-area-inset-bottom,0px)) !important;
    left:auto !important;
    margin:0 !important;
    z-index:calc(var(--ls-z) + 2);
  }
  .lang-switcher__btn,
  .lang-switcher--mobile .lang-switcher__btn{
    width:54px;
    height:54px;
    min-height:54px;
    padding:0;
    gap:0;
    justify-content:center;
    border:0;
    border-radius:50%;
    background:linear-gradient(145deg,#6366f1,#4338ca);
    color:#fff;
    box-shadow:0 10px 24px rgba(79,70,229,.36),0 2px 6px rgba(15,23,42,.16);
  }
  .lang-switcher__btn:hover,
  .lang-switcher__btn[aria-expanded="true"]{
    border:0;
    background:linear-gradient(145deg,#6366f1,#4338ca);
    color:#fff;
    box-shadow:0 12px 28px rgba(79,70,229,.44);
  }
  .lang-switcher__btn .lang-switcher__label,
  .lang-switcher__btn .lang-switcher__caret{display:none}
  .lang-switcher__btn .lang-switcher__globe{
    width:24px;height:24px;
    font-size:0;
    background:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.6 2.8 4 5.8 4 9s-1.4 6.2-4 9c-2.6-2.8-4-5.8-4-9s1.4-6.2 4-9z'/%3E%3C/svg%3E");
  }
  body.is-lang-open .lang-switcher__btn{opacity:0;pointer-events:none;transform:scale(.9)}
}

@media (prefers-reduced-motion:reduce){
  .lang-switcher__btn,
  .lang-switcher__panel,
  .lang-switcher__backdrop,
  .lang-switcher__item,
  .lang-switcher__check,
  .lang-switcher__caret{transition:none}
}

body.is-lang-open{overscroll-behavior:none}
