/* ============================================================================
   潮荣电子 · 全站移动端适配  mobile.css
   ----------------------------------------------------------------------------
   背景：站内页面有两套样式来源
     A. 新版页面（产品页 / 首页 / 产品总览）→ 引用 theme.css
     B. 旧版页面（文章页 / 关于 / 联系 / 专题等 200 页）→ 各自内联 <style>
   本文件作为唯一移动端覆盖层，在 </head> 最末加载，两套页面共用。
   以后调手机端样式只改这一份，不需要再逐页重刷。
   断点：≤900（平板竖屏）/ ≤768（手机）/ ≤420（小屏手机）
   ========================================================================== */

/* ---------- 0. 全局安全网 ---------- */
img, video, iframe, svg { max-width: 100%; }
img { height: auto; }
pre, code { overflow-x: auto; }
p, li, td, th { overflow-wrap: break-word; }
/* 有些老页面只给表格套了 class 却没定义样式，这里兜底，保证宽表在容器内横滑 */
.table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- 1. 间距令牌降级 ---------- */
@media (max-width: 900px) {
  :root { --gutter: 32px; --section-y: 56px; }
}
@media (max-width: 768px) {
  :root { --gutter: 16px; --section-y: 44px; }
}

/* ---------- 2. 平板 ---------- */
@media (max-width: 900px) {
  .video-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .footer__cols { gap: 24px !important; }
}

/* ---------- 3. 手机（主战场） ---------- */
@media (max-width: 768px) {

  /* 3.1 双层 gutter 归零 ---------------------------------------------------
     .section 与 .container 各带 48px，叠加后 375px 屏只剩 183px。
     改成：外层 section 留 16px，内层 container 不再重复。 */
  .section {
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-top: 40px !important;
    padding-bottom: 40px !important;
  }
  .section > .container,
  .hero > .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
  }
  .container { padding-left: 16px !important; padding-right: 16px !important; max-width: 100% !important; }
  .content { padding: 0 16px 40px !important; max-width: 100% !important; }

  /* 3.2 头图 -------------------------------------------------------------- */
  .hero {
    padding: 40px 16px 44px !important;
    min-height: 0 !important;
  }
  .hero__inner { grid-template-columns: minmax(0, 1fr) !important; gap: 24px !important; text-align: left; }
  .hero__title { font-size: clamp(1.5rem, 7vw, 2rem) !important; }
  .hero__desc { margin-bottom: 24px !important; }
  .hero__ctas { justify-content: flex-start; }
  .art-header, .hdr, .article-header {
    padding: 32px 16px 26px !important;
  }
  .art-header h1, .hdr h1, .article-header h1 { font-size: clamp(1.35rem, 6vw, 1.9rem) !important; }

  /* 3.3 导航 -------------------------------------------------------------- */
  .nav__inner { padding: 0 16px !important; gap: 12px !important; }
  .nav__logo img { height: 34px !important; }
  /* 菜单绝对定位，展开 8 个产品子项会超出屏幕 → 限高可滚 */
  .nav__links {
    padding: 12px 16px 20px !important;
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .nav__links a, .nav-links a { padding: 12px 0 !important; }
  .nav__dropdown a { padding: 10px 0 !important; }
  .nav__cta { margin: 12px 0 0 !important; }
  .nav__toggle { width: 44px; height: 44px; }

  /* 3.4 表格：手机端同样用「表格」呈现（与 PC 一致） ----------------------
     规格参数 / 常用厚度与尺寸 / 材料性能参数 / 可选颜色 / 同类材料对比，
     PC 端本来就是表格，手机端再拆成卡片会把「列与列的对应关系」全丢掉。
     做法：保留真实表格 + 紧凑排版；四列以上的表在 .table-scroll 内横滑，
     首列做成粘性列，滑到右边也知道这行是什么。 */
  .table-scroll, .table-wrap, .tw {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
    margin-bottom: 10px;
  }

  table.spec-table, table.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.5;
    table-layout: auto;
  }
  table.spec-table caption, table.compare-table caption {
    font-size: 14px !important;
    font-weight: 700;
    text-align: left;
    padding: 0 0 8px !important;
    color: var(--text, #1a1a2e);
  }
  table.spec-table th, table.spec-table td,
  table.compare-table th, table.compare-table td {
    padding: 8px 8px !important;
    border-bottom: 1px solid var(--border, #e5eaf2);
    vertical-align: top;
    text-align: left;
    white-space: normal !important;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  table.spec-table thead th, table.compare-table thead th {
    background: #f1f5f9;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2, #475569);
    white-space: nowrap !important;
  }
  /* 行标题（首列）：浅底 + 加粗蓝字，和 PC 的观感一致 */
  table.spec-table tbody th[scope="row"],
  table.compare-table tbody th[scope="row"] {
    background: #f8fafc;
    font-weight: 700;
    color: var(--accent, #0057b8);
    position: sticky;
    left: 0;
    z-index: 2;
  }
  /* 只有两三列时给首列定宽，避免「项目」被挤成一字一行 */
  table.spec-table:not(:has(thead th:nth-child(4))) tbody th[scope="row"] { width: 36%; }
  table.spec-table tbody tr:nth-child(even) td,
  table.compare-table tbody tr:nth-child(even) td { background: #fbfdff; }
  /* 四列以上（厚度尺寸表、CNC 能力表、材料对比表）：给最小宽度，横滑看全 */
  table.spec-table:has(thead th:nth-child(4)),
  table.compare-table:has(thead th:nth-child(4)) { min-width: 560px; }

  /* 3.5 网格：两列/多列一律降级 ------------------------------------------- */
  .about-grid,
  .contact-grid,
  .compare-grid,
  .detail-grid,
  .pros-cons,
  .dim-grid,
  .form-row,
  .products-grid,
  .apps-grid,
  .promo-band {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 24px !important;
  }
  .fact-grid, .stats-bar { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
  .art-grid, .cert-grid, .results-grid, .mat-grid,
  .svc-grid, .video-grid, .prod-grid, .process-grid,
  .features, .schedule, .filter-row, .industry-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .spec-grid { grid-template-columns: minmax(0, 1fr) !important; }
  /* 视频/专题页是「正文 + 300px 侧栏」的 .content 网格 */
  .content { grid-template-columns: minmax(0, 1fr) !important; }

  /* 老页面大量用内联 style 写死两列/三列/「1fr 300px」，类选择器管不到。
     手机端统一降单列，但保留页脚两列、数据统计两列。 */
  [style*="grid-template-columns"]:not(.footer__cols):not(.fact-grid):not(.stats-bar):not(.hero__inner) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* 网格子项默认 min-width:auto，内容（表格）撑不回来就会顶出屏幕 */
  [style*="grid-template-columns"] > * { min-width: 0; }

  /* 3.6 卡片与表单 -------------------------------------------------------- */
  .prod-body, .spec-box, .contact-form, .card { padding: 16px !important; }
  .contact-bar {
    padding: 26px 16px !important;
    border-radius: 12px !important;
    margin-top: 32px !important;
  }
  .contact-bar h3 { font-size: 1.05rem !important; }
  .contact-bar a { padding: 12px 20px !important; width: 100%; box-sizing: border-box; }
  .cta-section { padding: 40px 16px !important; }
  .art-nav { flex-direction: column !important; gap: 10px !important; }

  /* 3.7 页脚 -------------------------------------------------------------- */
  .footer { padding: 40px 16px 28px !important; }
  .footer__cols { grid-template-columns: 1fr 1fr !important; gap: 22px !important; }
  .footer__legal { flex-direction: column; gap: 8px !important; }

  /* 3.8 触控与可读性 ------------------------------------------------------ */
  /* iOS 聚焦 input 会自动放大页面，字号必须 ≥16px */
  input, select, textarea { font-size: 16px !important; }
  .nav__links a, .nav-links a, .footer__col a, .art-nav a { min-height: 40px; }
  .btn, .btn-p, .btn-s, .form-submit { min-height: 44px; }
  .section-tag, .sec-tag { letter-spacing: 2px !important; }

  /* 3.9 联系组件 ----------------------------------------------------------
     手机端统一用吸底条（电话/微信/询盘），右下悬浮柱会挡住正文，直接收起。 */
  .float-contact { display: none !important; }
  .contact-sticky {
    box-sizing: border-box !important;
    display: grid;
    /* 列数自适应：无 WhatsApp 时 3 项 3 列，预留位激活后 4 项 4 列（10-18） */
    grid-template-columns: none !important;
    grid-auto-flow: column !important;
    grid-auto-columns: minmax(0, 1fr) !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;          /* 用 left/right 定位，勿用 100vw（含滚动条宽度会溢出） */
    max-width: none !important;
    padding: 0 !important;
    overflow: hidden;
  }
  .contact-sticky a, .contact-sticky button {
    min-width: 0;
    padding: 12px 2px !important;
    font-size: .8125rem !important;
    white-space: nowrap;
  }
  body { padding-bottom: 56px; }

  /* 3.10 文章页 ----------------------------------------------------------- */
  .art-body { padding: 20px 16px 36px !important; border-radius: 0 !important; }
  .article-body { padding: 24px 16px 40px !important; }
  .art-grid { gap: 14px !important; }
}

/* ---------- 4. 小屏手机 ---------- */
@media (max-width: 420px) {
  .stats, .fact-grid, .app-grid, .product-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .footer__cols { grid-template-columns: minmax(0, 1fr) !important; }
  .art-nav { flex-direction: column !important; }
  .contact-bar { padding: 22px 14px !important; }
  .hero { padding: 32px 14px 36px !important; }
  .section { padding-left: 14px !important; padding-right: 14px !important; }
  .container { padding-left: 14px !important; padding-right: 14px !important; }
}
