/* ============================================================
   移动端 / 平板 响应式适配  —  Coaxwave 静态站通用模板
   说明：桌面端（>1024px）沿用 1440px 设计稿，本文件仅在
   平板（≤1024px）与手机（≤640px）断点生效，不会改动桌面布局。
   核心修复：解除 .tq-wrapper 的 transform:scale() 整页缩放，
   改为真正的流式重排，让手机上字号、栅格、导航都正常可读。
   适用：
     · 主域 articles.html / article.html 用 .sidebar（cross-article）
     · 子域 article.html 用 .toc（in-article，门禁 §25.8.2）
     · 子域在 ≤1024px 取消 sticky 以避免压住正文；≤640px 完全隐藏
   ============================================================ */

/* ---------- 汉堡按钮基础样式（默认隐藏，仅手机显示） ---------- */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* =====================================================
   平板及以下（≤1024px）：解除整页缩放，改为流式布局
   - .layout 在此断点提前切单列，避免 641–1024px 区间
     把 H1 / 正文挤到右侧 ~40px 窄列，造成"标题竖排"假象
   - .toc（子域 in-article 目录）取消 sticky，避免压住正文
   ===================================================== */
@media (max-width: 1024px) {
  :root { --page-padding: 32px; }

  body { min-width: 0; }

  /* 关键：取消缩放，画布改为 100% 宽 */
  .tq-wrapper {
    width: 100% !important;
    transform: none !important;
    padding-top: 64px;
  }

  .header {
    width: 100% !important;
    left: 0 !important;
    transform: none !important;
    padding: 0 24px;
  }

  /* Hero 上下堆叠 */
  .hero {
    flex-direction: column;
    gap: 32px;
    padding: 40px var(--page-padding) 56px;
    min-height: 0;
  }
  .hero h1 { font-size: 44px; }
  .hero .lead { max-width: 100%; }
  .hero-visual { flex: none; width: 100%; height: 260px; object-fit: cover; }
  .hero-actions { flex-wrap: wrap; }

  /* 规格区：图文上下排 */
  .spec-grid { flex-direction: column; gap: 24px; }
  .spec-visual { flex: none; width: 100%; height: 300px; object-fit: cover; }

  /* 对比卡片 1 列 */
  .card-grid { grid-template-columns: 1fr; gap: 24px; }

/* 产品 / 应用 / 选型 / 文章 / 四大产品线：2 列 */
.product-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
.app-grid     { grid-template-columns: repeat(2, 1fr); gap: 16px; }
.guide-grid   { grid-template-columns: repeat(2, 1fr); gap: 18px; }
.article-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
.line-grid    { grid-template-columns: repeat(2, 1fr); gap: 18px; }

  /* 文章详情页 layout：≤1024 提前切单列（不止 ≤640 才切），
     避免平板把 H1/正文挤进 1fr 右侧窄列。 */
  .layout {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 110px var(--page-padding) 60px;
    max-width: 100%;
    margin: 0;
  }

  /* 子域 in-article 目录：平板及以上不再 sticky，避免浮层挡正文；
     完全隐藏保留到 ≤640（与 .sidebar 等价处理见下）。 */
  .toc {
    position: static;
    max-height: none;
    top: auto;
  }

  /* 宽表横向滚动，避免溢出 */
  .polarity-table,
  .spec-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 页脚堆叠 */
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 24px; }
}

/* =====================================================
   手机（≤640px）：单列 + 汉堡抽屉菜单
   - .sidebar / .toc 在此完全隐藏（共用一条规则）
   - .article-title 移动端字号 + 断字兜底
   - h1/h2/h3 全局断字兜底，避免长中/英文 H1 在窄屏挤压成"竖排"
   ===================================================== */
@media (max-width: 640px) {
  :root { --page-padding: 18px; }

  .tq-wrapper { padding-top: 56px; }
  .header {
    height: 56px;
    min-height: 56px;
    padding: 0 16px;
    justify-content: flex-start;
    gap: 12px;
  }
  .logo svg { width: 44px; }
  .logo span { display: none; }

  h1 { font-size: 24px; line-height: 1.3; }
  h2 { font-size: 22px; margin-bottom: 20px; }
  h3 { font-size: 17px; }
  section { padding: 44px var(--page-padding); }

  /* 全局断字兜底：覆盖任何 build.py 模板里未设 word-break 的长 H1 */
  h1, h2, h3, p, li, td, th {
    overflow-wrap: anywhere;
    word-break: break-word;
    -webkit-hyphens: auto;
    hyphens: auto;
  }

  /* 文章详情页正文容器内边距收紧（从 36 44 → 20 22） */
  .article-body { padding: 22px 20px !important; }

  /* 文章 H1：移动端 22–24px，与正文过渡自然 */
  .article-title {
    font-size: 22px !important;
    line-height: 1.3;
    margin-bottom: 12px;
  }

  .hero { padding: 28px var(--page-padding) 44px; gap: 24px; }
  .hero h1 { font-size: 32px; }
  .hero .lead { font-size: 15px; }
  .hero-visual { height: 200px; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; }

  .overview p,
  .product-intro,
  .drawing-section p { max-width: 100%; }

  /* 所有卡片网格单列 */
  .product-grid,
  .app-grid,
  .guide-grid,
  .article-grid,
  .line-grid { grid-template-columns: 1fr; }

  /* 文章详情页：单列满宽 + 目录完全隐藏 */
  .layout {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 72px var(--page-padding) 48px;
  }
  .sidebar, .toc { display: none !important; }

  .product-img { height: 200px; object-fit: cover; }
  .card { padding: 22px; }
  .card-visual { height: 180px; }

  /* 规格键值列收窄，避免挤压 */
  .spec-row { grid-template-columns: 110px 1fr; padding: 14px 16px; }

  /* 浮窗按钮靠下、间距收紧 */
  .float-bar { right: 14px; bottom: 76px; gap: 10px; }
  .float-btn { width: 44px; height: 44px; }
  .float-tooltip { right: 52px; }

  footer { padding: 40px var(--page-padding); }
  .footer-motto { font-size: 18px; }

  /* 图片统一限宽，杜绝横向溢出 */
  img { max-width: 100%; height: auto; }

  /* 微信联系弹窗在小屏不溢出 */
  .wechat-modal { width: 90vw; max-width: 340px; padding: 22px; }
  .wechat-modal img { width: 170px; }

  /* ---------- 汉堡菜单 ---------- */
  .nav-toggle { display: flex; margin-left: auto; }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px 16px;
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: 0 16px 32px rgba(0,0,0,.5);
  }
  .header.nav-open .nav { display: flex; }

  .nav a {
    padding: 13px 4px;
    font-size: 15px;
    line-height: 1.4;
    border-bottom: 1px solid var(--border);
    white-space: normal;
  }
  .nav a:last-child { border-bottom: none; }

  /* 若某些页面导航含下拉，手机上改为常驻展开的子列表 */
  .nav-dropdown { position: static; }
  .nav-trigger { padding: 13px 4px; border-bottom: 1px solid var(--border); }
  .nav-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: transparent;
    margin: 0;
    padding: 0 0 10px 10px;
    min-width: 0;
    max-height: none;
  }
  .nav-menu a { white-space: normal; padding: 9px 4px; border-bottom: 1px solid var(--border); }
  .nav-menu a:last-child { border-bottom: none; }
}

/* =====================================================
   浮窗 / 弹窗 / 微信联系 兜底样式（v1.3 补丁）
   适用：所有页面（含极简 layout 页如 privacy.html）
   根因：privacy.html 用极简内联 style，未定义 .float-bar /
         .qr-card / .wechat-modal-overlay，file:// 直接打开
         时浏览器默认渲染 = 大块元素占据 footer 下方。
   修复：以下规则无论哪页渲染，都按本规则出兜底。
   ===================================================== */
.float-bar {
  position: fixed !important;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex !important;
  flex-direction: column;
  gap: 12px;
  width: auto;
  height: auto;
}
.float-bar.hidden,
.float-btn.hidden { display: none !important; }
.float-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cyan);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  position: relative;
}
.float-btn svg,
.float-btn img {
  width: 22px;
  height: 22px;
  max-width: 22px;
  object-fit: contain;
}
.float-tooltip {
  position: absolute;
  right: 52px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.float-btn:hover .float-tooltip { opacity: 1; }
/* 微信二维码卡：默认隐藏，触发 .active 才显示；
   内嵌 <img> 强制限宽，避免拉伸为 footer 后的大图 */
.qr-card { display: none !important; position: absolute; right: 56px; bottom: 0; background: var(--bg-elevated); border: 1px solid var(--border); padding: 12px; border-radius: 10px; width: 180px; text-align: center; }
.qr-card.active { display: block !important; }
.qr-card img { width: 160px; height: auto; max-width: 100%; }
.qr-card p { font-size: 12px; line-height: 1.5; margin-top: 8px; color: var(--text-secondary); }
/* 微信联系整层弹窗：默认隐藏，.active 才覆盖 */
.wechat-modal-overlay { display: none !important; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; align-items: center; justify-content: center; }
.wechat-modal-overlay.active { display: flex !important; }
.wechat-modal { background: var(--bg-elevated); border-radius: 14px; padding: 24px; max-width: 340px; width: 90vw; position: relative; text-align: center; }
.wechat-modal .close { position: absolute; top: 8px; right: 8px; background: transparent; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; }
.wechat-modal img { width: 170px; max-width: 80vw; height: auto; margin: 12px auto; }
/* 邮箱链接样式 */
.email-link { color: var(--cyan); text-decoration: none; }
.email-link:hover { text-decoration: underline; }
