/* ==========================================================================
   M29-MOBILE · 合并返修 D 席「内容转化页移动端」(m29m-content)
   --------------------------------------------------------------------------
   Scope:  <= 767px ONLY.  Desktop (>=1024px) must not change by a single pixel.
   Pages:  PDP / Catalog / About / News & Blog hubs / Quote.
   Owner:  m29m-content.  Load LAST in <head> (after 05-subpages-*.css).
   ========================================================================== */
/* ==========================================================================
   BASE（媒体区外）· 桌面 >=768px 的兜底规则
   --------------------------------------------------------------------------
   本文件 99% 的规则都在下方 @media (max-width:767px) 内，桌面零改动。
   唯一例外：catalog 在线阅读器的「关闭」按钮只在手机端出现（手机隐藏了
   details>summary，需要另一枚关闭入口），桌面必须保持不可见，故在此锁死。
   ========================================================================== */
.cat-flip__close { display: none !important; }

@media (max-width: 767px) {

  /* ======================================================================
     1 · PDP + Quote · 52px 绿圆钮避让（只在相交时上抬，离开立即还原）
     ----------------------------------------------------------------------
     抬起量由页面内联脚本写入 --m29m-fab-lift（px），CSS 只负责位移。
     位移放在 .fy-cta-widget（fixed 容器）上，不碰 .fy-cta-fab 自身
     hover transform，也不碰全局 CTA 的 open/closed 状态。
     ====================================================================== */
  .fy-cta-widget {
    bottom: calc(76px + var(--m29m-fab-lift, 0px) + env(safe-area-inset-bottom, 0px)) !important;
    transition: bottom .18s ease, transform .18s ease;
  }
  /* M29-C 的 .m29-fab-lift 是固定 100px 的旧避让；本页改用动态量，避免双重上抬 */
  body[data-page="products"] .fy-cta-widget.m29-fab-lift {
    bottom: calc(76px + var(--m29m-fab-lift, 0px) + env(safe-area-inset-bottom, 0px)) !important;
  }
  @media (prefers-reduced-motion: reduce) {
    .fy-cta-widget { transition: none; }
  }

  /* PDP 双按钮：保证 48px 触控高、右缘不再被 52px 钮压住文字 */
  body[data-page="products"] .pdp__actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }
  body[data-page="products"] .pdp__actions .btn-primary,
  body[data-page="products"] .pdp__actions .btn-ghost {
    width: 100% !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
  }

  /* Quote 提交条：SEND ENQUIRY 与右侧绿钮同一行时不贴边 */
  body[data-page="quote"] .fy-q-submit-bar {
    align-items: center !important;
    gap: 12px !important;
  }
  body[data-page="quote"] .fy-q-submit-btn,
  body[data-page="quote"] .fy-q-submit-bar .submit-btn {
    min-height: 48px !important;
  }

  /* ======================================================================
     2 · CATALOG · 手机端在线预览 / PDF / 索取 + 单一分割线
     ----------------------------------------------------------------------
     · .cat-actions 的三枚入口在手机端占满一行，48px 触控高；
     · 原来 cat-actions 下面还有一条 details>summary「READ ONLINE ↓」——
       和上面的主按钮重复，并制造「一条线 + 一行字 + 一条线」的双层分割线；
       手机上隐藏该 summary，在线预览统一由主按钮展开，读者用翻页条里的
       关闭按钮收起；
     · 分割线统一为：每本 edition 一条 border-top，其它一律去掉。
     ====================================================================== */
  body[data-page="catalog"] .catalog-head,
  body[data-page="catalog"] .cat-ed,
  body[data-page="catalog"] .cat-qr {
    border-top: 1px solid var(--border, rgba(20, 19, 17, .12)) !important;
    border-bottom: 0 !important;
  }
  body[data-page="catalog"] .catalog-head { border-top: 0 !important; }
  body[data-page="catalog"] .cat-ed + .cat-ed { margin-top: 0 !important; }
  body[data-page="catalog"] .cat-reader {
    border-top: 0 !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  body[data-page="catalog"] .cat-reader__toggle { display: none !important; }
  body[data-page="catalog"] .cat-reader[open] {
    margin-top: 4px !important;
  }
  body[data-page="catalog"] .cat-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 0 0 4px !important;
  }
  body[data-page="catalog"] .cat-action {
    min-height: 48px !important;
    flex: 1 1 auto;
    padding: 0 16px !important;
  }
  body[data-page="catalog"] .cat-flip__viewport {
    border: 1px solid var(--border, rgba(20, 19, 17, .12));
    border-radius: 8px;
    background: var(--bg-sub, #f7f5f1);
  }
  body[data-page="catalog"] .cat-flip__bar {
    gap: 8px !important;
    padding-top: 10px !important;
  }
  body[data-page="catalog"] .cat-flip__close {
    margin-inline-start: auto;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 40px;
    padding: 0 12px !important;
    white-space: nowrap;
    border: 1px solid var(--border-strong, rgba(20, 19, 17, .28));
    border-radius: 999px;
    background: transparent;
    color: var(--ink, #141311);
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
  }
  body[data-page="catalog"] .cat-flip__spacer { display: none !important; }
  /* 翻页条里的 "REQUEST A COPY" 与上方主入口重复 → 手机端只留关闭；
     同屏只出现一次的索取入口在上方 cat-actions 里（一个信息只说一次）。 */
  body[data-page="catalog"] .cat-flip__dl { display: none !important; }
  body[data-page="catalog"] .cat-flip__bar { flex-wrap: nowrap !important; }

  /* ======================================================================
     3 · ABOUT · 专利墙 / 证书改横滑收拢（本页降高的主项）
     ----------------------------------------------------------------------
     40 张专利证书 2 列 × 20 行 = 4991px；改成一条横滑轨 ≈ 220px。
     3 张 ISO 证书 3 行 = 1915px；改成一条横滑轨 ≈ 520px。
     轨道左右出血到屏幕边缘，下一张露出 1/5，明确「可以滑」。
     ====================================================================== */
  body[data-page="about"] .ab2-patents__grid,
  body[data-page="about"] .cert-docs__list {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-inline: -20px !important;
    padding: 2px 20px 8px !important;
    grid-template-columns: none !important;
  }
  body[data-page="about"] .ab2-patents__grid::-webkit-scrollbar,
  body[data-page="about"] .cert-docs__list::-webkit-scrollbar { display: none; }

  body[data-page="about"] .ab2-patents__grid {
    gap: 8px !important;
    margin-top: 10px !important;
    margin-bottom: 0 !important;
  }
  body[data-page="about"] .ab2-patents__grid li {
    flex: 0 0 148px;
    scroll-snap-align: start;
  }
  body[data-page="about"] .ab2-patents__grid img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 800 / 1132;
  }

  body[data-page="about"] .cert-docs__list {
    gap: 12px !important;
    margin-top: 22px !important;
    margin-bottom: 0 !important;
  }
  body[data-page="about"] .certdoc {
    flex: 0 0 72%;
    max-width: 290px;
    scroll-snap-align: start;
  }

  /* 40 个品牌 Logo：手机端 4 列 × 10 行，图片懒加载前 tile 高 0、
     加载后整段从 108px 涨到 698px（CLS + 页面变长）。改成一条 64px 横滑轨，
     高度在图片加载前就固定，页面不再跳动。 */
  body[data-page="about"] .ab-brands__grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px !important;
    grid-template-columns: none !important;
    margin-inline: -20px !important;
    padding: 2px 20px 8px !important;
  }
  body[data-page="about"] .ab-brands__grid::-webkit-scrollbar { display: none; }
  body[data-page="about"] .ab-brands__grid .fy3-brand-tile {
    flex: 0 0 64px !important;
    width: 64px !important;
    height: 64px !important;
    aspect-ratio: 1 / 1;
    padding: 6px !important;
    box-sizing: border-box;
    scroll-snap-align: start;
  }
  body[data-page="about"] .ab-brands__grid .fy3-brand-tile img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
  }

  /* 4 指标：手机端 2×2，避免 「Proprietar / y Patents」在 63px 列里被拆词 */
  body[data-page="about"] .ab-story__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px 16px !important;
    margin-bottom: 24px !important;
  }
  body[data-page="about"] .ab-story__metrics dd {
    word-break: normal !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
  }

  /* ► FORMING LINE 视频灯箱：实色黑底，杜绝底层文字透出 */
  .vslot-lightbox {
    background: #000 !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .vslot-lightbox__video { background: #000 !important; }

  /* 页面级留白收紧（只影响本页手机端，桌面媒体区不动） */
  body[data-page="about"] main > section.section,
  body[data-page="about"] main > .section {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }
  body[data-page="about"] .ab-story { padding: 26px 0 !important; }
  body[data-page="about"] .ab-brands { padding: 30px 0 !important; }
  body[data-page="about"] .ab2-patents__overview {
    max-height: 168px !important;
    aspect-ratio: auto !important;
  }
  body[data-page="about"] .ab2-patents__overview img {
    height: 168px !important;
    object-fit: cover;
  }
  body[data-page="about"] .ab-story__chapters { gap: 12px !important; }
  body[data-page="about"] .ab-story__chapter { padding-bottom: 12px !important; }
  body[data-page="about"] .ab-story__chapter p { line-height: 1.6 !important; }

  /* ======================================================================
     4 · NEWS / BLOG hubs · 分类胶囊置顶 + 文章列表进首屏 + 推荐/CTA 下移
     ----------------------------------------------------------------------
     DOM 顺序是「左栏(aside) → 正文(section)」，手机端用 display:contents
     把 aside 拆开重排（不改 HTML/DOM，不影响 ≤960 的既有栅格逻辑）：
       ① 分类卡 → 顶部横滑胶囊
       ② 文章列表 → 首屏
       ③ 推荐阅读 → 文章下方
       ④ Need a sample? CTA → 最后
     ====================================================================== */
  body[data-page="news"] .fy-hub-grid,
  body[data-page="blog"] .fy-hub-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 18px !important;
  }
  body[data-page="news"] .fy-hub-sidebar,
  body[data-page="blog"] .fy-hub-sidebar {
    display: contents !important;
  }
  body[data-page="news"] .fy-hub-sidebar > .fy-side-card:nth-child(1),
  body[data-page="blog"] .fy-hub-sidebar > .fy-side-card:nth-child(1) { order: 1; }
  body[data-page="news"] .fy-hub-main,
  body[data-page="blog"] .fy-hub-main { order: 2; }
  body[data-page="news"] .fy-hub-sidebar > .fy-side-card:nth-child(2),
  body[data-page="blog"] .fy-hub-sidebar > .fy-side-card:nth-child(2) { order: 3; }
  body[data-page="news"] .fy-hub-sidebar > .fy-side-cta,
  body[data-page="blog"] .fy-hub-sidebar > .fy-side-cta { order: 4; }

  /* ① 分类 = 顶部横滑胶囊；卡片壳与eyebrow在手机上不再需要 */
  body[data-page="news"] .fy-hub-sidebar > .fy-side-card:nth-child(1),
  body[data-page="blog"] .fy-hub-sidebar > .fy-side-card:nth-child(1) {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  body[data-page="news"] .fy-hub-sidebar > .fy-side-card:nth-child(1) > .fy-side-card__eyebrow,
  body[data-page="blog"] .fy-hub-sidebar > .fy-side-card:nth-child(1) > .fy-side-card__eyebrow {
    display: none !important;
  }
  body[data-page="news"] .fy-side-cats,
  body[data-page="blog"] .fy-side-cats {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -30px !important;
    padding: 2px 30px 6px !important;
  }
  body[data-page="news"] .fy-side-cats::-webkit-scrollbar,
  body[data-page="blog"] .fy-side-cats::-webkit-scrollbar { display: none; }

  body[data-page="news"] .fy-side-cat-btn,
  body[data-page="blog"] .fy-side-cat-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    min-height: 40px !important;
    padding: 8px 14px !important;
    border: 1px solid rgba(20, 19, 17, .16) !important;
    border-radius: 999px !important;
    background: #fff !important;
    color: #141311 !important;
    font-size: 12.5px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    text-align: center !important;
    transition: background-color .16s ease, color .16s ease, border-color .16s ease;
  }
  body[data-page="news"] .fy-side-cat-btn.is-active,
  body[data-page="blog"] .fy-side-cat-btn.is-active {
    background: #1b4d3e !important;
    border-color: #1b4d3e !important;
    color: #fff !important;
  }
  body[data-page="news"] .fy-side-cat-btn.is-active::before,
  body[data-page="blog"] .fy-side-cat-btn.is-active::before {
    display: none !important;
    content: none !important;
  }
  body[data-page="news"] .fy-side-cat-count,
  body[data-page="blog"] .fy-side-cat-count {
    min-width: 18px !important;
    height: 18px !important;
    padding: 0 5px !important;
    border-radius: 999px !important;
    background: rgba(20, 19, 17, .07) !important;
    color: currentColor !important;
    font-size: 10px !important;
    line-height: 18px !important;
    text-align: center !important;
  }
  body[data-page="news"] .fy-side-cat-btn.is-active .fy-side-cat-count,
  body[data-page="blog"] .fy-side-cat-btn.is-active .fy-side-cat-count {
    background: rgba(255, 255, 255, .18) !important;
  }

  /* ② News 顶部大白边：main 预留了 136px 面包屑净空，而 hub 首屏没有面包屑 */
  /* 注意：05-subpages 在 body 里还有一条 M29-D 的 !important padding-top:34px，
     比本文件 head 里的链接更晚加载；这里用 main > 提升一级特异度压住它。 */
  body[data-page="news"] main > .fy-hub-shell {
    /* main 为面包屑预留的 136px 在 hub 首屏没有对应内容，直接抵消干净 */
    margin-top: -128px !important;
    padding-top: 16px !important;
  }
  body[data-page="news"] .fy-hub-main,
  body[data-page="blog"] .fy-hub-main { margin-top: 2px !important; }
  body[data-page="news"] .fy-hub-header,
  body[data-page="blog"] .fy-hub-header { margin-bottom: 6px !important; }
  body[data-page="news"] .fy-hub-title,
  body[data-page="blog"] .fy-hub-title { font-size: 27px !important; line-height: 1.16 !important; }

  /* 推荐阅读标题在窄屏允许 3 行（原 2 行会把长标题截成「…at…」） */
  body[data-page="news"] .fy-side-rec-item__title,
  body[data-page="blog"] .fy-side-rec-item__title {
    -webkit-line-clamp: 3 !important;
  }

  /* ③ 推荐阅读 / CTA 移到文章之后：补一个上间距，和前文分层 */
  body[data-page="news"] .fy-hub-sidebar > .fy-side-card:nth-child(2),
  body[data-page="blog"] .fy-hub-sidebar > .fy-side-card:nth-child(2) {
    margin-top: 6px !important;
  }

  /* ======================================================================
     5 · 语言子站的安全网：本文件只给英文母版页挂载；
     如被误挂到 <lang>/ 页面，下面的 body[data-page] 限定选择器也不会命中
     子站特有的 .fy-hub-shell 两列以外的结构。此处不再追加全局重置。
     ====================================================================== */
}

/* ===== M29M-HOTFIX · 正文详情页（News/Blog article）手机端侧栏重排 P1 =====
   列表页（news.html / blog/index.html）已有 display:contents 重排，但正文页
   article.html 与 news|blog/<slug>.html 未链 07 CSS，侧栏 280px 仍霸占首屏。
   这里给正文页同一套重排：分类胶囊置顶 → 正文进首屏 → 推荐 → CTA 移末尾。 */
@media (max-width: 767px) {
  html body .fy-hub-shell .fy-hub-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 18px !important;
  }
  html body .fy-hub-shell .fy-hub-sidebar {
    display: contents !important;
  }
  html body .fy-hub-shell .fy-hub-sidebar > .fy-side-card:nth-child(1) { order: 1; }
  html body .fy-hub-shell .fy-hub-main { order: 2; }
  html body .fy-hub-shell .fy-hub-sidebar > .fy-side-card:nth-child(2) { order: 3; }
  html body .fy-hub-shell .fy-hub-sidebar > .fy-side-cta { order: 4; }

  /* 分类卡：去掉卡片壳，变手机端顶部单行横滑胶囊 */
  html body .fy-hub-shell .fy-hub-sidebar > .fy-side-card:nth-child(1) {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  html body .fy-hub-shell .fy-hub-sidebar > .fy-side-card:nth-child(1) > .fy-side-card__eyebrow {
    display: none !important;
  }
  html body .fy-hub-shell .fy-side-cats {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none !important;
    padding: 0 0 4px !important;
    margin: 0 !important;
  }
  html body .fy-hub-shell .fy-side-cats::-webkit-scrollbar { display: none; }
  html body .fy-hub-shell .fy-side-cats > * { flex: 0 0 auto !important; }
  html body .fy-hub-shell .fy-side-cat-btn {
    width: auto !important;
    white-space: nowrap !important;
    min-height: 36px !important;
    padding: 7px 14px !important;
    border: 1px solid rgba(20, 19, 17, .16) !important;
    border-radius: 999px !important;
    background: #FFFFFF !important;
    gap: 8px !important;
  }
  html body .fy-hub-shell .fy-side-cat-btn.is-active {
    background: #141311 !important;
    border-color: #141311 !important;
    color: #FBF9F4 !important;
  }
  /* 正文区宽度兜底，防止 aside 拆开后 grid 轨道残留 */
  html body .fy-hub-shell .fy-hub-main {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
}

/* ===== M29M-HOTFIX · PDP 底部规格表手机端可横滑 P1 ===== */
@media (max-width: 767px) {
  html body[data-page="products"] .compare-wrap,
  html body[data-page="products"] .table-scroll,
  html body .table-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }
  html body[data-page="products"] .table-scroll > .compare,
  html body[data-page="products"] .compare-wrap .compare {
    min-width: 640px;
  }
}
