/* ============================================================
   匠参谋 - 移动端体验增强层 (mobile.css)
   目标：统一全站手机端视觉节奏、修复内联 grid 溢出、补齐触控体验
   加载顺序：style.css 之后加载；仅在 <=768px 生效，桌面端零影响
   ============================================================ */

/* ============ 0. 基础：安全区 / 触控 / 字号 ============ */
@media (max-width:768px){
  :root{
    --m-pad:16px;              /* 统一左右安全边距 */
    --m-gap:12px;              /* 统一卡片间距 */
    --m-radius:14px;
    --m-bar-h:62px;            /* 底部操作栏高度 */
  }
  html{scroll-padding-top:70px;-webkit-text-size-adjust:100%}
  body{line-height:1.7;padding-bottom:calc(var(--m-bar-h) + env(safe-area-inset-bottom))}
  .container{padding-left:var(--m-pad);padding-right:var(--m-pad)}

  /* 全覆盖：任何内联 grid 在手机端一律单列（修复 about/contact/city 溢出） */
  .container > div[style*="grid-template-columns"],
  .container > section[style*="grid-template-columns"],
  .detail-wrap[style*="grid-template-columns"],
  .trust-inner[style*="grid-template-columns"],
  .flow-grid[style*="grid-template-columns"]{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:var(--m-gap)!important;
    min-width:0!important;
  }
  /* 内联 flex 横向排列在窄屏改纵向 */
  .trust-item[style*="flex-direction:column"]{flex-direction:column!important}

  /* 所有卡片/块不溢出 */
  .card,.detail-main,.side-box,.biz-card,.service-card,.case-card,.faq-item,.hero-stats,
  .trust-item,.why-card,.testi-card,.section-head,.page-banner,.cta{
    max-width:100%;min-width:0;box-sizing:border-box;
  }
  img,video,iframe{max-width:100%!important}
  /* 长数字/邮箱/电话强制换行，禁止撑破容器 */
  small,p,span,div,h1,h2,h3,h4{overflow-wrap:anywhere}
  .trust-item small,.trust-item b{word-break:break-word}

  /* ============ 1. 顶部工具条 ============ */
  .topbar{font-size:11.5px}
  .topbar-inner{height:32px;justify-content:center!important}
  .topbar-contact{font-size:11.5px;white-space:nowrap}
  .topbar .sub-badge{margin-left:0;font-size:11px}

  /* ============ 2. 导航 / 抽屉 ============ */
  .site-header{box-shadow:0 2px 12px rgba(20,40,90,.06)}
  .header-inner{height:58px;gap:8px}
  .logo-mark{width:38px;height:38px;font-size:20px;border-radius:11px}
  .logo-text b{font-size:17.5px}
  .header-actions{gap:6px}
  .menu-toggle{width:38px;height:38px;font-size:17px}
  /* 手机端顶部放一个紧凑的城市按钮（桌面版城市切换被隐藏） */
  .m-city-btn{
    display:inline-flex;align-items:center;gap:4px;max-width:118px;
    background:var(--primary-light);color:var(--primary);border:0;border-radius:9px;
    padding:8px 10px;font-size:12.5px;font-weight:600;cursor:pointer;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  }
  .m-city-btn i{font-size:12px;flex-shrink:0}
  /* 抽屉里的城市切换入口 */
  .drawer-nav .m-city-link{color:var(--primary);font-weight:600}
  .drawer{width:88%;max-width:380px}
  .drawer-nav a{padding:15px;min-height:50px;font-size:15.5px}
  .drawer-cta .btn{min-height:46px}

  /* ============ 3. Banner 统一 ============ */
  .page-banner,.hero{padding-top:44px;padding-bottom:48px}
  .page-banner h1{font-size:25px;line-height:1.35;letter-spacing:-.3px}
  .page-banner p{font-size:13.5px;line-height:1.6}
  .crumb{font-size:12px;margin-top:10px;line-height:1.6}
  .hero h1{font-size:29px;line-height:1.34}
  .hero p.lead{font-size:14.5px}
  .hero-tags{gap:7px}
  .hero-tags span{font-size:11px;padding:6px 11px}
  .hero-btns{gap:10px}
  .hero-btns .btn{flex:1 1 46%;min-width:0;padding:13px 10px;font-size:14px;white-space:normal;text-align:center}

  /* ============ 4. Hero 搜索框 ============ */
  .hero-search{flex-direction:column;gap:8px;padding:8px;border-radius:12px}
  .hero-search input{width:100%;padding:12px 12px;font-size:14px;background:var(--bg);border-radius:8px}
  .hero-search button{width:100%;padding:13px;font-size:14.5px;border-radius:8px}

  /* ============ 5. 数字统计卡：统一 2 列，无孤行 ============ */
  .hero-stats{grid-template-columns:repeat(2,1fr)!important;gap:14px 10px;padding:20px 16px}
  .hero-stat b{font-size:26px!important}
  .hero-stat span{font-size:11.5px;line-height:1.4}

  /* ============ 6. 信任背书 / 快捷联系卡：2 列，电话不竖排 ============ */
  .trust-inner{grid-template-columns:repeat(2,1fr)!important;gap:10px!important}
  .trust-item{padding:14px 10px!important;gap:9px!important;align-items:center!important}
  .trust-item .ti-icon{width:38px;height:38px;flex-shrink:0;font-size:17px!important}
  .trust-item b{font-size:13px!important;line-height:1.35}
  .trust-item small{font-size:11.5px!important;line-height:1.4;word-break:break-word}
  /* 联系页内联 3 列卡片：覆盖为单列并让文字横排 */
  .trust-inner[style*="repeat(3"]{grid-template-columns:1fr!important}
  .trust-inner[style*="repeat(3"] .trust-item{
    flex-direction:row!important;align-items:center!important;gap:14px!important;padding:16px!important;
  }
  .trust-inner[style*="repeat(3"] .trust-item b{font-size:14px!important}
  .trust-inner[style*="repeat(3"] .trust-item small{font-size:13px!important}

  /* ============ 7. 分类筛选标签：横滑单行，节省首屏 ============ */
  .filter-tabs{
    flex-wrap:nowrap!important;overflow-x:auto!important;overflow-y:hidden;
    -webkit-overflow-scrolling:touch;scrollbar-width:none;
    margin:0 calc(var(--m-pad)*-1) 18px!important;padding:4px var(--m-pad) 8px!important;
    scroll-snap-type:x proximity;
  }
  .filter-tabs::-webkit-scrollbar{display:none}
  .filter-tabs a{
    flex:0 0 auto;scroll-snap-align:start;
    padding:9px 16px!important;font-size:13.5px!important;white-space:nowrap;
    border-radius:22px!important;
  }
  /* 二级分类区（细分）：同样横滑，但保留标签前缀 */
  .filter-tabs.sub{background:var(--bg);border-radius:0;margin-bottom:20px!important}
  /* 通用：class 里含 filter-tabs 且父级浅灰底的都横滑 */
  [class*="filter-tabs"]{overscroll-behavior-x:contain}

  /* ============ 8. 服务 / 案例 / 资讯卡片 ============ */
  .service-grid,.case-grid,.biz-grid,.why-grid,.testi-grid,.news-list{grid-template-columns:1fr!important;gap:14px!important}
  .service-card,.case-card,.biz-card,.why-card,.testi-card{border-radius:var(--m-radius)!important}
  .service-card-body{padding:18px!important}
  .service-card h3{font-size:17px!important}
  .service-card .price{font-size:16px!important}
  .service-card p{font-size:13px!important;line-height:1.65}
  .service-card .meta-row{gap:10px;margin:12px 0;font-size:11.5px}
  .case-cover{height:140px!important}
  .case-body{padding:18px!important}
  .news-item{padding:15px 0!important;gap:12px}
  .news-date{width:50px!important}
  .news-date b{font-size:19px!important}
  .news-item h4{font-size:14.5px!important;line-height:1.5}
  .news-item p{font-size:12.5px!important;-webkit-line-clamp:2;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}

  /* ============ 9. 流程时间轴：单列左对齐，杜绝孤行 ============ */
  .flow-grid{grid-template-columns:1fr!important;gap:0!important;margin-top:8px!important}
  .flow-grid::before{display:none!important}
  .flow-step{
    display:grid;grid-template-columns:52px 1fr;grid-template-rows:auto auto;
    column-gap:14px;text-align:left!important;align-items:center;
    padding:12px 0!important;border-bottom:1px solid var(--line-2);
  }
  .flow-step:last-child{border-bottom:0}
  .flow-num{
    width:48px!important;height:48px!important;font-size:17px!important;
    margin:0!important;grid-row:1/3;box-shadow:0 0 0 4px var(--bg);
  }
  .flow-step h4{font-size:15px!important;margin:0 0 2px!important;align-self:end}
  .flow-step p{font-size:12.5px!important;margin:0;align-self:start;line-height:1.55}
  .flow-step .step-time{margin-top:4px!important;font-size:10.5px!important}

  /* ============ 10. 详情页：单列 + 正文可读 ============ */
  .detail-wrap{grid-template-columns:1fr!important;gap:16px!important}
  .detail-main{padding:20px 16px!important;border-radius:var(--m-radius)!important}
  .detail-main h1{font-size:22px!important;line-height:1.4}
  .detail-content{font-size:14px!important;line-height:1.85}
  .detail-content h2,.detail-content h3{font-size:17px!important;margin:20px 0 10px!important}
  .detail-content li{margin-bottom:7px}
  .detail-meta{font-size:12px!important;margin-bottom:18px!important}
  .form-grid2{grid-template-columns:1fr!important;gap:14px!important}
  .side-box{padding:18px!important}
  .side-box h3{font-size:15.5px!important}

  /* ============ 11. 表单：单列 + 大输入框（防 iOS 缩放） ============ */
  .form-grid{grid-template-columns:1fr!important;gap:14px!important}
  .form-group input,.form-group select,.form-group textarea{
    font-size:16px!important;padding:12px 13px!important;border-radius:9px!important;
    max-width:100%;width:100%;
  }
  .form-group textarea{min-height:110px}
  .form-group label{font-size:13.5px!important}
  .btn-block{min-height:48px}

  /* ============ 12. FAQ / 城市省市折叠 ============ */
  .faq-q{font-size:14px!important;padding:15px 14px!important;line-height:1.5}
  .faq-a{padding:0 14px 16px!important;font-size:13px!important}
  .faq-item{margin-bottom:10px!important;border-radius:11px!important}
  details.faq-q > span{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
  details.faq-q > span small{font-size:11px}
  /* 省市网格：手机端 2~3 列自适应 */
  details .faq-a > div[style*="grid-template-columns"]{
    grid-template-columns:repeat(3,1fr)!important;gap:7px!important;
  }
  details .faq-a > div a{font-size:12px!important;padding:9px 6px!important;text-align:center;word-break:break-all}

  /* ============ 13. 城市地图页专属 ============ */
  .container > div.trust-inner[style*="repeat(5"]{grid-template-columns:repeat(2,1fr)!important}
  .trust-inner[style*="repeat(5"] .trust-item{
    border:1px solid var(--line);border-radius:11px;padding:12px 8px!important;text-align:center;gap:3px!important;
  }
  .trust-inner[style*="repeat(5"] .trust-item b{font-size:19px!important}
  .trust-inner[style*="repeat(5"] .trust-item small{font-size:11px!important}
  /* 5个卡片2列后末项独占一行居中 */
  .container > div.trust-inner[style*="repeat(5"] > .trust-item:last-child{grid-column:1/-1;max-width:calc(50% - 5px);width:100%;justify-self:center}
  #regionSearch{flex:1 1 100%!important;min-width:0!important;width:100%!important}
  #regionSearchBtn{width:100%;min-height:44px}
  .section-title{font-size:23px!important}
  .section-sub{font-size:12.5px!important;line-height:1.6}

  /* ============ 14. 商标查询页 ============ */
  .filter-tabs a i{margin-right:4px}
  .card h3{font-size:16px!important}
  input[placeholder*="商标"],input[placeholder*="注册"]{font-size:16px!important}

  /* ============ 15. CTA / 页脚 ============ */
  .cta{padding:38px 18px!important;border-radius:15px!important;margin-top:8px!important}
  .cta h2{font-size:22px!important}
  .cta p{font-size:13.5px!important;line-height:1.6}
  .cta .btn{width:100%;min-height:46px;white-space:normal}
  .footer-main{gap:22px!important;padding-bottom:28px!important}
  .footer-col h4{font-size:14px!important;margin-bottom:12px!important}
  .footer-col a,.footer-col p{font-size:12.5px!important;margin-bottom:9px!important}
  .footer-links{font-size:12px!important;line-height:1.8}
  .footer-bottom{font-size:11px!important}

  /* ============ 16. 底部固定操作栏：三等分 + 安全区 ============ */
  .mobile-bar{
    grid-template-columns:1fr 1fr 1.3fr!important;
    padding:7px 10px calc(7px + env(safe-area-inset-bottom))!important;
    gap:6px!important;min-height:var(--m-bar-h);
  }
  .mobile-bar a{font-size:10.5px!important;min-height:46px!important;padding:5px 1px!important;gap:2px!important}
  .mobile-bar a i{font-size:18px!important}
  .mobile-bar a.primary{font-size:12.5px!important;border-radius:10px!important;gap:5px!important;padding:5px!important}
  .mobile-bar a.primary span{white-space:nowrap}

  /* ============ 17. 城市切换面板（手机端全屏抽屉式） ============ */
  .city-panel{
    position:fixed!important;left:8px!important;right:8px!important;top:58px!important;
    width:auto!important;max-width:none!important;max-height:calc(100vh - 70px)!important;
    padding:14px!important;border-radius:14px!important;z-index:210;
  }
  .city-panel .city-grid{grid-template-columns:repeat(4,1fr)!important;gap:5px!important}
  .city-panel a{font-size:12px!important;padding:7px 2px!important}
  .city-tabs button{flex:1;padding:10px 8px!important;font-size:13px!important}

  /* ============ 18. 动效降级：尊重减少动画偏好 ============ */
  .reveal{transition-duration:.45s}
}

/* ============ 窄屏微调（<=360px） ============ */
@media (max-width:360px){
  .hero h1{font-size:25px!important}
  .page-banner h1{font-size:22px!important}
  .trust-inner{grid-template-columns:1fr 1fr!important;gap:8px!important}
  .trust-item{padding:12px 7px!important}
  .trust-item small{font-size:10.5px!important}
  .mobile-bar a.primary{font-size:11.5px!important}
  .flow-step{grid-template-columns:44px 1fr;column-gap:10px}
  .flow-num{width:42px!important;height:42px!important;font-size:15px!important}
}

/* ============ 平板过渡（769~1024px）：保持协调 ============ */
@media (min-width:769px) and (max-width:1024px){
  .flow-grid{grid-template-columns:repeat(3,1fr)!important}
  .trust-inner[style*="repeat(5"]{grid-template-columns:repeat(3,1fr)!important}
  .detail-wrap[style*="grid-template-columns"]{grid-template-columns:1.3fr .7fr!important}
}
