/* ============================================================
   pgy6.com 移动端 H5 页面布局与体验升级样式
   覆盖范围：P0 溢出/表单缩放/详情表格修复 + P1 首页首屏与列表页 H5 化 + P2 触控热区与中文排版
   原则：保持桌面端（>768px / >1000px）现有视觉与布局 100% 不受影响
   ============================================================ */

/* ---------- 0. 全局中文排版防孤字与安全折行（不影响桌面端布局） ---------- */
body {
  overflow-wrap: break-word;
}

:where(.rich-content a, .rich-content code) {
  overflow-wrap: anywhere;
}

#app p,
#app li {
  text-wrap: pretty;
}

h1,
h2,
h3,
#app .page-banner p,
#app .section-sub {
  text-wrap: balance;
}

body dialog.hero-lightbox .hs-lb-head h3 {
  text-wrap: nowrap;
}

/* 防止 Leaflet 地图内部 z-index(400~1000) 穿透顶栏、底部 Tab 栏与试用弹窗 */
#app .contact-page .map-container {
  position: relative;
  z-index: 1;
  isolation: isolate;
}

/* ---------- 1. P0 修复：/about 发展历程时间轴 <=1024px 横向撑破（553px 溢出 Bug） ---------- */
@media (max-width: 1024px) {
  #app .about .timeline::before {
    left: 12px;
  }

  #app .about .timeline .timeline-item,
  #app .about .timeline .timeline-item.left,
  #app .about .timeline .timeline-item:not(.left) {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: auto !important;
    text-align: left !important;
    padding: 12px 0 12px 34px !important;
    box-sizing: border-box;
  }

  #app .about .timeline .timeline-item .timeline-dot,
  #app .about .timeline .timeline-item.left .timeline-dot,
  #app .about .timeline .timeline-item:not(.left) .timeline-dot {
    left: 6px !important;
    right: auto !important;
    top: 28px;
  }

  #app .about .timeline .timeline-card {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 18px;
  }

  #app .about .brand-text,
  #app .about .brand-visual,
  #app .about .honor-layout > *,
  #app .about .team-card {
    min-width: 0;
  }
}

/* ---------- 2. 首页 <=1000px 主视觉顺序兜底（文案与 CTA 始终优先于海报轮播） ---------- */
@media (max-width: 1000px) {
  #app .home .hero-right,
  #app .home .hero-right.is-active {
    order: 0 !important;
  }

  #app .home .hero-marquee {
    min-width: 0;
    max-width: 100%;
  }
}

/* ---------- 3. 移动端 H5 页面布局与 P0/P1/P2 升级（<=768px） ---------- */
@media (max-width: 768px) {
  /* 3.1 通用区块留白、子页 Banner 紧凑化与防横向溢出 */
  #app .section {
    padding: 36px 0;
  }

  #app .page-banner {
    padding: calc(78px + env(safe-area-inset-top, 0px)) 0 26px;
  }

  #app .page-banner h1 {
    font-size: clamp(1.625rem, 1rem + 3.2vw, 2.125rem);
    line-height: 1.25;
    letter-spacing: 1px;
    margin-bottom: 8px;
  }

  #app .page-banner p {
    font-size: 14.5px;
    line-height: 1.6;
  }

  #app .section-title {
    font-size: clamp(1.4rem, 1rem + 2.4vw, 1.75rem);
    line-height: 1.3;
    margin-bottom: 8px;
  }

  #app .section-sub {
    font-size: 14.5px;
    line-height: 1.6;
    margin-bottom: 22px;
  }

  #app .neon-card,
  #app .adv-card,
  #app .product-card,
  #app .case-card,
  #app .case-row,
  #app .news-card,
  #app .news-row,
  #app .video-card,
  #app .sol-card,
  #app .strength-stat,
  #app .cert-card,
  #app .contact-info,
  #app .contact-form-wrap {
    min-width: 0;
  }

  #app .rich-content img {
    height: auto;
    max-width: 100%;
  }

  #app .rich-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #app .pager {
    flex-wrap: wrap;
    margin-top: 28px;
  }

  #app .pager .pager-btn {
    min-width: 44px;
    min-height: 44px;
    width: auto;
    padding: 0 12px;
    touch-action: manipulation;
  }

  /* 页脚移动端紧凑间距（padding-bottom 由 pgy-mobile-h5-nav.css 统一控制以无缝衔接底部导航） */
  #app .site-footer {
    padding-top: 36px;
  }

  #app .site-footer .footer-grid {
    gap: 24px;
    padding-bottom: 24px;
  }

  #app .site-footer .footer-col h5 {
    margin-bottom: 10px;
  }

  #app .site-footer .footer-col p,
  #app .site-footer .footer-col a {
    line-height: 1.9;
  }

  #app .site-footer .footer-bottom {
    padding: 16px 0;
    font-size: 12.5px;
    line-height: 1.7;
  }

  /* 3.2 首页（/）移动端首屏转化与流畅度优化 */
  #app .home .hero {
    min-height: auto;
    padding: calc(74px + env(safe-area-inset-top, 0px)) 0 36px;
  }

  #app .home .tech-canvas {
    display: none;
  }

  #app .home .hero-tags {
    gap: 6px;
    margin-bottom: 14px;
  }

  #app .home .hero-tags .data-badge {
    padding: 4px 10px;
    font-size: 12px;
  }

  #app .home .hero-title {
    font-size: clamp(1.875rem, 1rem + 4.1vw, 2.5rem);
    line-height: 1.2;
    letter-spacing: 1px;
    margin-bottom: 12px;
  }

  #app .home .hero-sub {
    font-size: 14.5px;
    line-height: 1.55;
    letter-spacing: 0.3px;
    margin-bottom: 20px;
  }

  #app .home .hero-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 22px;
  }

  #app .home .hero-btns .btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14.5px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    touch-action: manipulation;
  }

  /* 保留移动端主视觉配图，适配全宽防溢出 */
  #app .home .hero-layout.has-side-img .hero-right.is-active .hero-side-img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 14px !important;
    margin: 14px auto 0 !important;
  }

  /* 首页分类 Tab 单行横向滑动 */
  #app .home .cat-tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 4px;
  }

  #app .home .cat-tabs::-webkit-scrollbar {
    display: none;
  }

  #app .home .cat-tabs .cat-tab {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 40px;
    padding: 8px 16px;
    font-size: 13.5px;
    touch-action: manipulation;
  }

  #app .home .strength-stats {
    gap: 12px;
    margin-bottom: 20px;
  }

  #app .home .strength-stat {
    padding: 18px 12px;
  }

  #app .home .cta-section {
    padding: 48px 0;
  }

  #app .home .cta-content p {
    font-size: 15px;
    margin-bottom: 24px;
  }

  /* 3.3 AI产品矩阵（/products）H5 吸顶单行分类条 + 隐藏重复锚点条 */
  #app .products .anchor-nav {
    display: none;
  }

  #app .products .cat-bar {
    position: sticky;
    top: calc(56px + env(safe-area-inset-top, 0px));
    z-index: 40;
    background: rgba(250, 249, 245, 0.96);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0;
  }

  #app .products .cat-bar .cat-tabs {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 8px 16px;
  }

  #app .products .cat-bar .cat-tabs::-webkit-scrollbar {
    display: none;
  }

  #app .products .cat-bar .cat-tab {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 40px;
    padding: 7px 15px;
    font-size: 13.5px;
    line-height: 1.3;
    touch-action: manipulation;
  }

  #app .products .cat-heading {
    padding: 20px 0 0;
    scroll-margin-top: calc(120px + env(safe-area-inset-top, 0px));
  }

  #app .products .cat-title {
    font-size: 20px;
  }

  #app .products .cat-line {
    margin-top: 8px;
  }

  #app .products .product-grid-section {
    padding: 12px 0 24px;
  }

  #app .products .training-section {
    padding: 36px 0;
  }

  /* 3.4 案例 / 资讯 / 视频筛选栏单行横向滑动 */
  #app .cases-page .filter-row,
  #app .news-page .filter-row,
  #app .videos-page .filter-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 4px;
  }

  #app .cases-page .filter-row::-webkit-scrollbar,
  #app .news-page .filter-row::-webkit-scrollbar,
  #app .videos-page .filter-row::-webkit-scrollbar {
    display: none;
  }

  #app .cases-page .filter-tag,
  #app .news-page .filter-tag,
  #app .videos-page .filter-tag {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 40px;
    padding: 8px 16px;
    font-size: 13.5px;
    touch-action: manipulation;
  }

  /* /about 与 /contact 移动端卡片紧凑化 */
  #app .about .brand-title {
    font-size: 24px;
    margin-bottom: 18px;
  }

  #app .about .office-scene {
    height: 240px;
  }

  #app .about .team-group-title {
    font-size: 18px;
    margin: 26px 0 14px;
  }

  #app .about .avatar {
    width: 68px;
    height: 68px;
    font-size: 26px;
    margin-bottom: 12px;
  }

  #app .contact-page .form-card,
  #app .contact-page .map-card {
    padding: 22px 16px;
  }

  #app .contact-page .qr-zone {
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 20px;
  }

  /* 3.5 P0 iOS Safari / 微信内置浏览器防表单输入自动放大（>=16px）与弹窗适配 */
  #app .contact-page .form-group input,
  #app .contact-page .form-group select,
  #app .contact-page .form-group textarea,
  #app .contact-page input,
  #app .contact-page select,
  #app .contact-page textarea,
  .contact .form-group input,
  .contact .form-group select,
  .contact .form-group textarea,
  body .modal-overlay .modal-content .form-group input,
  body .modal-overlay .modal-content .form-group select,
  body .modal-overlay .modal-content .form-group textarea,
  body .modal-content input,
  body .modal-content select,
  body .modal-content textarea {
    font-size: 16px;
    line-height: 1.5;
  }

  #app .contact-page .form-group input:not(.hp-field),
  #app .contact-page .form-group select,
  .contact .form-group input:not(.hp-field),
  .contact .form-group select,
  body .modal-overlay .modal-content .form-group input:not(.hp-field),
  body .modal-overlay .modal-content .form-group select {
    min-height: 44px;
  }

  #app .contact-page .form-group textarea,
  .contact .form-group textarea {
    min-height: 100px;
  }

  body .modal-overlay {
    padding: 16px 12px;
    overscroll-behavior: contain;
  }

  body .modal-overlay .modal-content {
    width: min(92vw, 420px);
    max-width: 92vw;
    max-height: 86vh;
    max-height: 86dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 24px 20px;
    border-radius: 16px;
  }

  body .modal-overlay .modal-content h3 {
    font-size: 20px;
    padding-right: 40px;
  }

  body .modal-overlay .modal-content .modal-sub {
    margin-bottom: 18px;
  }

  body .modal-overlay .modal-content .modal-close {
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 26px;
    touch-action: manipulation;
  }

  body .modal-overlay .modal-content button[type="submit"],
  body .modal-overlay .modal-content .btn,
  #app .contact-page button[type="submit"] {
    min-height: 46px;
  }

  body .video-modal {
    padding: 14px;
  }

  body .video-modal .video-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  body .video-modal .video-modal-info {
    padding: 16px;
  }

  /* 3.6 P0 产品详情页（/products/:slug）与套餐表格移动端适配 */
  #app .pd .detail-container,
  #app .pd .detail-card {
    min-width: 0;
    max-width: 100%;
  }

  #app .pd .detail-card {
    padding: 24px 18px;
  }

  #app .pd .block-title {
    font-size: 19px;
    margin: 26px 0 14px;
  }

  #app .pd .block-title:first-child {
    margin-top: 0;
  }

  #app .pd .detail-item {
    padding: 16px;
  }

  #app .pd .price-row .data-badge {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  #app .pd .table-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: #ffffff;
    background-image:
      linear-gradient(to right, #ffffff, #ffffff),
      linear-gradient(to right, #ffffff, #ffffff),
      linear-gradient(to right, rgba(42, 38, 34, 0.08), rgba(42, 38, 34, 0)),
      linear-gradient(to left, rgba(176, 78, 47, 0.16), rgba(176, 78, 47, 0));
    background-position: left center, right center, left center, right center;
    background-repeat: no-repeat;
    background-size: 20px 100%, 20px 100%, 14px 100%, 20px 100%;
    background-attachment: local, local, scroll, scroll;
  }

  #app .pd .detail-table {
    width: 100%;
    min-width: 440px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
  }

  #app .pd .detail-table th {
    padding: 11px 12px;
    background: rgba(245, 241, 234, 0.92);
    border-bottom: 1px solid var(--border);
  }

  #app .pd .detail-table td {
    padding: 11px 12px;
    line-height: 1.55;
    vertical-align: top;
  }

  #app .pd .detail-table th:first-child,
  #app .pd .detail-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    max-width: 132px;
    white-space: normal;
    word-break: break-word;
    box-shadow: 2px 0 6px rgba(42, 38, 34, 0.05);
  }

  #app .pd .detail-table th:first-child {
    background: var(--bg-3);
    z-index: 2;
  }

  #app .pd .detail-table td:first-child {
    background: #ffffff;
  }

  #app .pd .detail-cta,
  #app .cd .cd-cta,
  #app .nd .nd-cta,
  #app .sd .sd-cta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 28px;
  }

  #app .pd .detail-cta .btn,
  #app .cd .cd-cta .btn,
  #app .nd .nd-cta .btn,
  #app .sd .sd-cta .btn {
    width: 100%;
    min-height: 44px;
    padding: 11px 12px;
    font-size: 14.5px;
    letter-spacing: 0.4px;
    text-align: center;
    white-space: nowrap;
    touch-action: manipulation;
  }

  /* 3.7 P2 移动端过小标签字号抬升至 >= 12px */
  #app .products .pc-cat-pill,
  #app .products .pc-hl-tag,
  #app .home .pv-cat,
  #app .home .demo-window .hs-counter,
  #app .home .demo-window .hs-zoom-btn,
  #app .home .demo-window .hs-marker-btn,
  body dialog.hero-lightbox .hs-counter,
  body dialog.hero-lightbox .hs-marker-btn,
  #app .site-footer .footer-qr span {
    font-size: 12px;
  }

  /* 3.8 移动端海报高清大图弹窗（<dialog>）视口动态单位适配 */
  body dialog.hero-lightbox {
    width: 96vw;
    width: 96dvw;
    max-width: 96vw;
    max-width: 96dvw;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: 14px;
  }

  body dialog.hero-lightbox .hs-lb-head {
    padding: 10px 12px;
  }

  body dialog.hero-lightbox .hs-lb-body img {
    max-height: 62vh;
    max-height: 62dvh;
  }

  body dialog.hero-lightbox .hs-lb-foot {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
  }

  body dialog.hero-lightbox .hs-lb-dots {
    order: -1;
    width: 100%;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  body dialog.hero-lightbox .hs-lb-dots::-webkit-scrollbar {
    display: none;
  }
}

/* ---------- 4. 小屏手机精细化适配（<=600px） ---------- */
@media (max-width: 600px) {
  /* 首页核心数据 2x2 精致数据卡片（消除 3+1 孤立换行） */
  #app .home .hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  #app .home .hero-stats .stat b {
    font-size: 24px;
    line-height: 1.2;
  }

  #app .home .hero-stats .stat span {
    font-size: 12.5px;
  }

  #app .pd .detail-card,
  #app .cd .cd-card,
  #app .nd .nd-card,
  #app .sd .block {
    padding: 22px 16px;
  }

  /* /products/:slug 套餐价格表在小屏（<=600px）转为纵向堆叠价格卡片，彻底告别左右滑动截断 */
  #app .pd .detail-card .table-wrap,
  #app .detail-card .table-wrap {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    background-image: none;
  }

  #app .pd .detail-card .table-wrap::after,
  #app .detail-card .table-wrap::after {
    display: none;
  }

  #app .pd .detail-card .table-wrap .detail-table,
  #app .detail-card .table-wrap .detail-table {
    display: block;
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #app .pd .detail-card .table-wrap .detail-table thead,
  #app .detail-card .table-wrap .detail-table thead {
    display: none;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody,
  #app .detail-card .table-wrap .detail-table tbody {
    display: block;
    width: 100%;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody tr,
  #app .detail-card .table-wrap .detail-table tbody tr {
    display: block;
    width: 100%;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-sizing: border-box;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody tr:last-child,
  #app .detail-card .table-wrap .detail-table tbody tr:last-child {
    margin-bottom: 0;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody td,
  #app .detail-card .table-wrap .detail-table tbody td {
    display: block;
    width: 100%;
    max-width: 100%;
    position: static;
    left: auto;
    z-index: auto;
    box-shadow: none;
    background: transparent;
    border: 0;
    padding: 0;
    white-space: normal;
    overflow-wrap: break-word;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody td:nth-child(1),
  #app .detail-card .table-wrap .detail-table tbody td:nth-child(1) {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    color: #1f1b17;
    margin-bottom: 6px;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody td:nth-child(2),
  #app .detail-card .table-wrap .detail-table tbody td:nth-child(2) {
    display: inline-block;
    width: auto;
    max-width: 100%;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--primary-deep);
    background: rgba(217, 119, 87, 0.12);
    border: 1px solid rgba(217, 119, 87, 0.28);
    border-radius: 999px;
    padding: 3px 12px;
    margin-bottom: 6px;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody td:nth-child(3),
  #app .detail-card .table-wrap .detail-table tbody td:nth-child(3) {
    font-size: 14px;
    line-height: 1.65;
    color: #4a443c;
    padding: 6px 0 0;
    border: 0;
  }

  #app .pd .detail-card .table-wrap .detail-table tbody td:nth-child(3)::before,
  #app .detail-card .table-wrap .detail-table tbody td:nth-child(3)::before {
    content: "包含功能：";
    font-weight: 600;
    color: var(--text-dim);
  }

  #app .products .product-card-body {
    padding: 16px;
  }
}

/* ---------- 5. P2 触控设备 / 移动端 >=44x44px 触控热区扩展（不与相邻控件重叠） ---------- */
@media (pointer: coarse), (max-width: 768px) {
  #app .home .demo-window .demo-topbar {
    padding: 5px 12px;
    min-height: 44px;
  }

  #app .home .demo-window .hs-nav-btn {
    position: relative;
    width: 36px;
    height: 36px;
  }

  #app .home .demo-window .hs-nav-btn::after {
    content: "";
    position: absolute;
    inset: -5px;
  }

  #app .home .demo-window .hs-zoom-btn {
    position: relative;
    min-width: 36px;
    min-height: 36px;
    padding: 4px 10px;
  }

  #app .home .demo-window .hs-zoom-btn::after {
    content: "";
    position: absolute;
    inset: -4px;
  }

  #app .home .demo-window .hs-markers {
    gap: 8px;
    padding: 6px 10px;
    min-height: 48px;
  }

  #app .home .demo-window .hs-marker-btn,
  body dialog.hero-lightbox .hs-marker-btn {
    position: relative;
    min-height: 36px;
    min-width: 44px;
    padding: 6px 11px;
  }

  /* 仅纵向扩展热区至 44px，横向 inset: 0 避免与相邻标记按钮重叠 */
  #app .home .demo-window .hs-marker-btn::after,
  body dialog.hero-lightbox .hs-marker-btn::after {
    content: "";
    position: absolute;
    inset: -4px 0;
  }

  body dialog.hero-lightbox .hs-lb-close {
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 0 14px;
    font-size: 13.5px;
  }

  body dialog.hero-lightbox .hs-lb-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 14px;
    font-size: 13.5px;
  }
}
