/* =====================================================================
 * MES 产品官网 - 纯静态站点补充样式（优先零 JavaScript）
 * 在 base.css / pages.css 之后引入，把原先依赖 JS 的交互改为原生 HTML + CSS：
 * :target 弹窗、checkbox 移动菜单、radio 页签 / FAQ 分页、details 折叠、锚点回顶。
 * 例外：回到顶部按钮由 assets/js/back-to-top.js 控制显隐（需判断页面是否过长）。
 * ===================================================================== */

/* 1. 隐藏状态控件（保留可访问性与键盘可聚焦） */
.nav-check, .tab-radio, .faq-radio {
  position: absolute; width: 1px; height: 1px; opacity: 0;
  pointer-events: none; margin: 0; padding: 0;
}

/* 2. 链接型按钮保持与原 button 一致的排版 */
a.btn-login { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.float-btn, a.modal__close { text-decoration: none; }
.nav-toggle { cursor: pointer; user-select: none; }
.switcher__tab { cursor: pointer; user-select: none; }

/* 3. 回到顶部按钮：仅当页面内容超出一屏时显示（由 back-to-top.js 加 .is-visible）
 *    无 JS 环境降级为常显，保证纯静态访问时按钮仍可用 */
.js .float-btn--top {
  opacity: 0; visibility: hidden; transform: translateX(20px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s ease, background .2s;
}
.js .float-btn--top.is-visible { opacity: 1; visibility: visible; transform: none; }

/* 4. 申请试用弹窗：:target 控制显隐 */
.modal-mask { display: none; }
.modal-mask:target { display: flex; opacity: 1; visibility: visible; }
.modal-mask:target .modal { transform: none; }
.modal__backdrop { position: absolute; inset: 0; z-index: 0; }
.modal { z-index: 1; }
.modal__close { z-index: 2; }

/* 5. 分页器（静态链接 / label 按钮） */
.pager__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 9px; border: 1px solid var(--line);
  border-radius: 4px; background: #fff; color: var(--text-2); font-size: 13px;
  text-decoration: none; cursor: pointer; transition: .2s; box-sizing: border-box;
}
.pager__btn:hover { border-color: var(--primary); color: var(--primary-dark); }
.pager__btn.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager__btn.is-disabled { color: #c6d0d9; cursor: default; }
.pager__btn.is-disabled:hover { border-color: var(--line); color: #c6d0d9; }
.pager__btn .icon { width: 14px; height: 14px; }

/* 6. 首页解决方案页签：radio 切换 */
#tab-sales:checked ~ .switcher__tabs label[for="tab-sales"],
#tab-production:checked ~ .switcher__tabs label[for="tab-production"],
#tab-purchase:checked ~ .switcher__tabs label[for="tab-purchase"],
#tab-warehouse:checked ~ .switcher__tabs label[for="tab-warehouse"],
#tab-lean:checked ~ .switcher__tabs label[for="tab-lean"] {
  color: var(--primary-dark); font-weight: 700; border-bottom-color: var(--primary);
}
#tab-sales:checked ~ .switcher__panel[data-i="0"],
#tab-production:checked ~ .switcher__panel[data-i="1"],
#tab-purchase:checked ~ .switcher__panel[data-i="2"],
#tab-warehouse:checked ~ .switcher__panel[data-i="3"],
#tab-lean:checked ~ .switcher__panel[data-i="4"] {
  display: grid;
}

/* 7. FAQ：radio 分页 + details 原生折叠 */
.faq-page { display: none; }
#faqPage1:checked ~ .faq-box .faq-page[data-page="1"],
#faqPage2:checked ~ .faq-box .faq-page[data-page="2"],
#faqPage3:checked ~ .faq-box .faq-page[data-page="3"],
#faqPage4:checked ~ .faq-box .faq-page[data-page="4"],
#faqPage5:checked ~ .faq-box .faq-page[data-page="5"] { display: block; }
#faqPage1:checked ~ .pager label[for="faqPage1"],
#faqPage2:checked ~ .pager label[for="faqPage2"],
#faqPage3:checked ~ .pager label[for="faqPage3"],
#faqPage4:checked ~ .pager label[for="faqPage4"],
#faqPage5:checked ~ .pager label[for="faqPage5"] {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.faq-item > summary {
  list-style: none; display: flex; gap: 12px; align-items: flex-start;
  font-size: 15px; font-weight: 700; color: var(--navy); cursor: pointer;
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary .icon { color: var(--primary); font-size: 17px; margin-top: 2px; }
.faq-item .faq-item__q { flex: 1; }
.faq-item .faq-item__toggle { color: var(--muted); font-size: 14px; transition: transform .25s; }
.faq-item[open] .faq-item__toggle { transform: rotate(45deg); color: var(--primary); }
.faq-item .faq-item__a { display: none; }
.faq-item[open] > .faq-item__a { display: block; }
.faq-item[open] { padding-bottom: 20px; }

/* 8. 移动端：checkbox 展开菜单 */
@media (max-width: 860px) {
  .nav-check:checked ~ .site-nav { transform: none; opacity: 1; visibility: visible; }
}

/* 9. 锚点跳转避开固定导航（如 about.html#contact、页内目录） */
main section[id], main > div[id], .article { scroll-margin-top: calc(var(--header-h) + 16px); }

/* 10. 申请试用弹窗：滑块与表单状态（仅 trial.js 在场时出现，无 JS 时只剩电话联系方式）
 *    显隐挂自有类 trial-is-js，绝不给 <html> 加 .js —— 见第 3 节回到顶部按钮 */
.captcha { display: none; margin: -6px 0 20px; }
.captcha__stage, .captcha__track { width: 310px; max-width: 100%; margin-left: auto; margin-right: auto; }
.captcha__stage { position: relative; border-radius: 8px; overflow: hidden; background: var(--line); }
.captcha__bg { display: block; width: 100%; }
/* 滑块块原生 47×155，与底图 310×155 同高，按宽等比缩放后纵向正好对齐 */
.captcha__piece { position: absolute; left: 0; top: 0; width: calc(100% * 47 / 310); }
.captcha__track { position: relative; height: 36px; margin-top: 10px; border-radius: 8px; background: var(--soft); }
/* 把手宽度与底图成比例，保证窄屏缩放后仍能拖到最远目标位（原生最远 262） */
.captcha__handle {
  position: absolute; left: 0; top: 0; height: 100%; width: calc(100% * 40 / 310);
  border-radius: 8px; background: #fff; color: var(--primary-dark); box-shadow: 0 2px 8px rgba(15,55,90,.18);
  display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1;
  cursor: move; user-select: none; touch-action: none;
}
.captcha__handle:hover { background: var(--primary-light); }
.captcha__foot {
  width: 310px; max-width: 100%; margin: 8px auto 0; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted);
}
.captcha__refresh { background: none; border: 0; padding: 0; color: var(--primary-dark); font-size: 12px; cursor: pointer; }

/* 11. 弹窗内的滑块与成功态只在 JS 接管后出现 */
.trial-is-js .captcha.is-on { display: block; }
.form-success { display: none; text-align: center; color: var(--primary-dark); font-size: 15px; font-weight: 700; padding: 6px 0 2px; }
.trial-form.is-done > .form-row, .trial-form.is-done > .captcha, .trial-form.is-done > .form-error,
.trial-form.is-done > .modal__submit { display: none; }
.trial-form.is-done > .form-success { display: block; }
