/* ============================================================================
 * i18n.css —— 多语言下拉（国旗 + 语言名）+ 自绘语言菜单 + 轻提示
 * ----------------------------------------------------------------------------
 * 控件由 i18n.js 注入：
 *   .i18n-switch  折叠态按钮 = 国旗 + 语言名（2 个汉字）+ 箭头
 *   .i18n-menu    展开态菜单，**挂在 <body> 上**（position:fixed），因为顶栏自己形成
 *                 层叠上下文，挂在顶栏里的弹层会被 hero 盖住（实测踩过）
 *   .i18n-flag    国旗容器；里面的 SVG 由 i18n.js 内联生成（不用 emoji —— Windows 不渲染）
 *
 * 宽度预算（折叠态固定 2 汉字 → 宽度与所选语种无关，顶栏宽度完全可预测）：
 *   桌面  7 + 18 + 4 + 26 + 4 + 9 + 7 = 75px   （双段按钮版实测 88px）
 *   ≤640  6 + 15 + 3 + 24 + 3 + 8 + 6 = 65px   （双段按钮版 73px）
 *   ≤360  5 +  0 + 2 + 23 + 2 + 7 + 5 = 44px   （隐藏国旗；双段按钮版 59px，该档只剩约 1px 余量）
 * 三档都**小于**双段按钮版，所以顶栏（尤其 320px 档）只会更宽松，不会更挤。
 *
 * 窄屏的细化值放在 mobile-v5.css / mobile-drawer.css 里，用 .header-right 提权 ——
 * 因为本文件在它们**之后**加载，同权重会把它们盖掉（这是原方案就踩过的坑）。
 * ==========================================================================*/

.i18n-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 7px;
  flex: none;
  border: 1px solid var(--c-line-2, #e6d8cf);
  border-radius: 8px;
  background: #fff;
  color: var(--c-ink-soft, #6b5b52);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.i18n-switch:hover,
.i18n-switch:focus-visible,
.i18n-switch[aria-expanded='true'] {
  border-color: var(--c-primary, #c93628);
  color: var(--c-primary, #c93628);
  outline: none;
}

/* 翻译中 / 加载中 */
.i18n-switch.is-busy {
  opacity: 0.6;
  cursor: progress;
}

/* 国旗：内联 SVG，18×12（3:2）。白底旗（日/韩/印尼）靠 SVG 自带的淡描边区分 */
.i18n-flag {
  display: inline-flex;
  width: 18px;
  height: 12px;
  flex: none;
  border-radius: 2px;
  overflow: hidden;
}

.i18n-flag-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.i18n-cur {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.i18n-caret {
  width: 9px;
  height: 9px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.6;
  transition: transform 0.15s;
}

.i18n-switch[aria-expanded='true'] .i18n-caret {
  transform: rotate(180deg);
}

/* ============================================================================
 * 语言菜单（挂在 <body> 上，position:fixed）
 * ----------------------------------------------------------------------------
 * 为什么不用原生 <select>：<option> 只能放纯文本，塞不进国旗 SVG（见 i18n.js 头部说明）。
 * 为什么挂 body：顶栏是层叠上下文，弹层挂在里面会被 hero 等区块盖住。
 * ==========================================================================*/
.i18n-menu {
  position: fixed;
  z-index: 2147483000;
  display: none;
  min-width: 172px;
  padding: 5px;
  border: 1px solid #e6d8cf;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 22px 48px -16px rgba(58, 32, 22, 0.42), 0 2px 8px -2px rgba(58, 32, 22, 0.12);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.i18n-menu.is-open {
  display: block;
  animation: hbI18nMenu 0.14s ease-out;
}

@keyframes hbI18nMenu {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.i18n-group {
  padding: 7px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #a8907f;
}

.i18n-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--c-ink, #3b2b23);
  cursor: pointer;
  white-space: nowrap;
}

.i18n-opt b {
  font-size: 13px;
  font-weight: 600;
}

.i18n-opt small {
  font-size: 11.5px;
  font-weight: 400;
  color: #9c8a7e;
}

.i18n-opt:hover,
.i18n-opt:focus-visible {
  background: #fdf2ee;
  outline: none;
}

.i18n-opt.is-on {
  background: #fdece7;
}

.i18n-opt.is-on b {
  color: var(--c-primary, #c93628);
  font-weight: 700;
}

.i18n-opt.is-on::after {
  content: '✓';
  margin-left: auto;
  padding-left: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-primary, #c93628);
}

/* 菜单里的国旗比折叠态略大一点，列表里更好认 */
.i18n-opt .i18n-flag {
  width: 21px;
  height: 14px;
}

/* 兜底：万一 translate.js 还是渲染了自带的语言下拉框，一律藏掉（我们用站内控件） */
#translate,
#translateSelectLanguage,
.translateSelectLanguage,
[id^='translateSelectLanguage'] {
  display: none !important;
}

/* ============================================================================
 * 非中文语种排版加固
 * ----------------------------------------------------------------------------
 * 2026-09-17：改版前这里只按 html[lang='en'] 生效；现在语种扩到 16 个，
 * 德语（Produktionsanlagen）、俄语、法语、葡语的长单词同样会撑破栅格，
 * 所以统一改挂 .hb-i18n-foreign（由 i18n.js 在切到任何非中文语种时加到 <html>）。
 * 只有两处例外：简体中文与繁體中文都算「中文」，不加这个类。
 *
 * 外语单词普遍比中文长（Products / Industrial / Mobile login …），实测：
 *   首页 390px 下文档被撑到 444px、320px 下 345px，手机端出现横向滚动。
 * 根因是打包 CSS 里大量栅格写的是 repeat(N, 1fr)，而 1fr ≡ minmax(auto, 1fr)，
 * 下限是 min-content —— 一个长单词就能把整格顶宽，再顶出整个页面。
 * 下面只做三件事，且全部限定非中文语种：中文 min-content 本来很小，观感与行为完全不变。
 * ==========================================================================*/

/* ① 栅格子项解除 min-content 下限，并允许长单词折行（否则文字会从卡片里戳出来） */
html.hb-i18n-foreign :where([class$='-grid'], [class*='-grid ']) > * {
  min-width: 0;
  overflow-wrap: break-word;
}

/* ② 横向 flex 行：外语更长，允许换行而不是把整行顶出视口 */
html.hb-i18n-foreign :where(.sec-head, .request-head, .foot-reward, .foot-reward-txt,
    .quote-mall-actions, .catalog-main-row, .request-filter-main) {
  flex-wrap: wrap;
}
/* 报价广场头部：标题 + 两个按钮一行排不下（641px 实测溢出 19px） */
html.hb-i18n-foreign .quote-mall-hero .wrap {
  flex-wrap: wrap;
}
html.hb-i18n-foreign .foot-reward-txt {
  min-width: 0;
}
/* 页脚二维码下方那行文案原本 white-space:nowrap，英语会撑到 308px */
html.hb-i18n-foreign .foot-reward-qr span {
  white-space: normal;
  text-align: center;
}
/* 区块标题行的「查看全部 / a.more」：bundle 里 .more{white-space:nowrap}，
   nowrap 会让它的 min-content == 整句宽度，flex 便再也无法收缩 —— 俄语把
   「今日现货参考价 · 47 个品种 查看全部 →」译成 "Сегодня существует 47
   одинарных одеял. →" 实测 315px，.sec-head 只有 292px，右端落到 329px。
   解除 nowrap 后 min-content 变成最长单词宽，自然折成两行且右对齐。 */
html.hb-i18n-foreign .sec-head .more {
  white-space: normal;
  min-width: 0;
  max-width: 100%;
  text-align: right;
}
/* 需求卡片页脚：member.js 注入的 .mv-foot-actions 在 member.css 里是 flex:none
   （不收缩）+ 内部 nowrap。中文「查看联系方式/去报价」合计 197px 放得下，英语
   「View contact details / Go to quote」变 286px，直接把父级 .demand-foot(235px)
   和整页顶到 321px（320px 视口出现横向滚动）。这里解除不可收缩 + 允许内部换行。 */
html.hb-i18n-foreign .mv-foot-actions {
  flex-shrink: 1;
  min-width: 0;
  flex-wrap: wrap;
}
/* 上面只解决了容器，按钮自己还是 flex:0 0 auto（member.css 里 flex:none）+
   文案 nowrap，不肯收缩：俄语「Посмотреть контактную информацию」实测 298px，
   容器收到 250px 后按钮仍占 300px，右端落到 335px → documentElement 335。
   所以还要让按钮本身可收缩（max-width:100% 收在容器内）并允许文案折行。
   height 由 .demand-foot .mv-contact-btn 定为 34px，两行 12.5px/1.2 ≈ 30px，
   仍能居中放下，故不必改高度。 */
html.hb-i18n-foreign .mv-contact-btn {
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
}
html.hb-i18n-foreign .mv-contact-btn > span {
  min-width: 0;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

/* ③ 顶栏：极窄屏再收一档（英语「Mobile login」+ 语言下拉同时在场，320px 会溢出） */
@media (max-width: 400px) {
  html.hb-i18n-foreign .header-in { gap: 12px; }
  html.hb-i18n-foreign .header-right { gap: 6px; }
  html.hb-i18n-foreign .btn-login { font-size: 12px; padding-left: 8px; padding-right: 8px; }
}
/* 再窄就只留「冀」字标，避免外语模式下 320~345px 之间顶栏横向溢出 */
@media (max-width: 360px) {
  html.hb-i18n-foreign .logo-txt { display: none; }
}

/* 底部导航：7 个格子 flex:1 1 0，320px 下每格只有 44px，而 .bn-item 是
   white-space:nowrap 且没裁切 —— 外语标签比中文长，会直接溢出格子压到隔壁
   （实测英语「Products」46px /「Demands」48px > 44px，渲染成 QuotesDemandsMember）。
   对策：① mobile-nav.js 里英语标签已改短（Catalog / Demand）；
        ② 这里做硬保险，任何标签都不许溢出格子。 */
html.hb-i18n-foreign .bottom-nav .bn-item > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 360px) {
  html.hb-i18n-foreign .bottom-nav .bn-item { font-size: 9.5px; letter-spacing: 0; }
}

/* 轻提示 */
.hb-i18n-toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  z-index: 100000;
  max-width: 86vw;
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(32, 22, 18, 0.93);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.65);
  animation: hbI18nIn 0.18s ease-out;
}

@keyframes hbI18nIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* 底部有导航栏的手机端，提示条再抬高一点，别压住底栏 */
@media (max-width: 640px) {
  .hb-i18n-toast {
    bottom: 92px;
    font-size: 13px;
    padding: 10px 14px;
  }
}
