/* =========================================================
   XX科技 · 响应式适配层 v1.0
   加载顺序：必须在 theme.css 之后
   策略：桌面优先，向下用 max-width 覆盖，最大限度保留原设计
   断点：1199 / 991 / 767 / 479
   ========================================================= */

/* =========================================================
   一、通用规则（对所有断点生效）
   ========================================================= */

/* 图片与媒体永不超出容器 —— 防止横向滚动条 */
img, svg, video { max-width: 100%; }

/* 长英文 / URL 强制断行，避免撑破窄容器 */
body { overflow-x: hidden; word-break: break-word; }

/* 标题使用 balance 换行，避免手机端出现孤立单字（"孤字"） */
h1, h2, h3, .display { text-wrap: balance; }

/* 正文段落使用 pretty 换行，避免末行只剩一两个字 */
p, blockquote { text-wrap: pretty; }

/* 触控目标最小尺寸（移动端可点击区域不小于 44×44） */
@media (hover: none) {
  .btn { min-height: 48px; }
  .nav__link { padding: 12px 0; }
}

/* 汉堡菜单控件：桌面端必须隐藏，仅在 ≤991 显示，
   否则 label 会以默认 inline 形态出现在导航栏里 */
.nav-burger { display: none; }
.nav-toggle { display: none; }

/* 修正首屏容器内边距：
   .hero__inner 与 .container 是同一个元素，v1 样式表里的
   `padding: 92px 0 96px` 简写把 .container 的左右 40px 覆盖成了 0。
   桌面端因容器居中留有空白看不出问题，窄屏下会导致内容贴边被裁切。
   此处只补回左右内边距，上下值保持不变。 */
.hero__inner {
  padding-left: 40px;
  padding-right: 40px;
}

/* =========================================================
   二、≤1199px：小笔记本 / 横屏平板
   容器与间距收紧，栅格不变
   ========================================================= */
@media (max-width: 1199px) {
  .container { padding: 0 32px; }

  .section { padding: 88px 0; }
  .section--tight { padding: 64px 0; }

  /* 首屏两栏比例微调，给文字更多横向空间
     注：上下内边距必须拆开写，不能用 padding 简写，否则会冲掉左右内边距 */
  .hero__inner {
    gap: 44px;
    padding-top: 76px;
    padding-bottom: 80px;
    padding-left: 32px;
    padding-right: 32px;
  }
  .hero h1 { font-size: 48px; }

  .page-hero__split { gap: 44px; padding: 52px 0 68px; }
  .page-hero h1 { font-size: 40px; }
  .page-hero__media .photo { height: 300px; }

  .split { gap: 52px; }
  .contact-grid { gap: 44px; }
  .footer__top { gap: 36px; }

  .h2 { font-size: 36px; }
  .display { font-size: 52px; }
}

/* =========================================================
   三、≤991px：平板（竖屏）/ 大屏手机横屏
   核心变化：导航折叠为汉堡菜单、双栏改单栏、四栏改两栏
   ========================================================= */
@media (max-width: 991px) {

  /* ---------- 3.1 容器与区块节奏 ---------- */
  .container { padding: 0 28px; }
  .section { padding: 72px 0; }
  .section--tight { padding: 56px 0; }
  .section-head { margin-bottom: 40px; }

  /* ---------- 3.2 导航：折叠为汉堡菜单 ---------- */
  /* 导航栏高度改为自适应，菜单展开时撑开容器（不用绝对定位，
     避免被 .hero / .page-hero 的 overflow:hidden 裁切） */
  .nav { height: auto; }
  .nav__inner {
    flex-wrap: wrap;
    min-height: 64px;
    padding-top: 0;
    padding-bottom: 0;
    row-gap: 0;
  }

  /* 汉堡按钮：三条横线 */
  .nav-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    margin-left: auto;
    cursor: pointer;
    order: 2;
  }
  .nav-burger span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--lt-text);
    transition: transform .28s ease, opacity .2s ease;
  }
  /* 展开态：横线变叉号 */
  .nav-toggle:checked ~ .nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-burger span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked ~ .nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* 桌面 CTA 在移动端收进菜单，避免与汉堡挤在一行 */
  .nav__cta { display: none; }

  /* 菜单本体：默认收起，勾选后展开 */
  .nav__menu {
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height .32s ease;
  }
  .nav-toggle:checked ~ .nav__menu { max-height: 420px; }

  .nav__link {
    display: block;
    /* 左侧 14px 内边距是为激活态色条留出的间距：
       色条绝对定位在 left:0（宽 3px），若沿用原来的 2px 内边距，
       文字会与色条重叠 1px。改为 14px 后两者之间留出约 11px，
       且所有菜单项同步内缩，互相之间依然严格左对齐。
       右侧维持 2px，不改变文字块的右边界。 */
    padding: 14px 2px 14px 14px;
    border-bottom: 1px solid var(--lt-line-2);
    font-size: 15.5px;
  }
  /* 激活态下划线在竖排菜单里改为左侧色条 */
  .nav__link.is-active::after {
    left: 0;
    right: auto;
    top: 50%;
    bottom: auto;
    width: 3px;
    height: 16px;
    transform: translateY(-50%);
  }
  .nav--dark .nav__link { color: var(--lt-text-2); }
  .nav--dark .nav__link.is-active { color: var(--lt-text); }

  /* ---------- 3.3 首屏：两栏改单栏 ---------- */
  .hero__inner {
    grid-template-columns: 1fr;
    gap: 44px;
    padding-top: 44px;
    padding-bottom: 56px;
    padding-left: 28px;
    padding-right: 28px;
  }
  .hero h1 { font-size: 38px; line-height: 1.24; }
  .hero__desc { font-size: 16px; max-width: 100%; }
  .hero__actions { flex-wrap: wrap; gap: 12px; margin-bottom: 40px; }
  .hero__meta { gap: 36px; padding-top: 28px; flex-wrap: wrap; }
  .hero__meta-item .num { font-size: 26px; }

  /* 浮动卡片在窄屏会因负偏移溢出，改为贴近边界 */
  .float-card--a { left: 0; bottom: 12px; }
  .float-card--b { right: 0; top: -18px; }

  /* ---------- 3.4 内页头：两栏改单栏，照片移到文字下方 ---------- */
  .page-hero__split {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 36px 0 48px;
  }
  .page-hero h1 { font-size: 33px; line-height: 1.26; }
  .page-hero p { max-width: 100%; }
  .page-hero__media { order: 2; }
  .page-hero__media .photo { height: 260px; }
  .head-metrics { gap: 34px; margin-top: 28px; padding-top: 24px; flex-wrap: wrap; }
  .head-metrics .num { font-size: 26px; }

  /* ---------- 3.5 栅格：四栏→两栏，三栏→单栏 ---------- */
  /* 三栏卡片文字量大，两列会挤压，直接转单列阅读更舒适 */
  .grid-3 { grid-template-columns: 1fr; gap: 20px; }

  /* 四栏卡片信息密度低，两列最平衡 */
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 20px; }

  /* ---------- 3.6 图文分栏改单栏 ---------- */
  .split { grid-template-columns: 1fr; gap: 36px; }
  /* 统一规则：图片始终排在文字之后，保证先读后看 */
  .split--reverse .split__media { order: 0; }
  .split .split__media { order: 2; }

  /* ---------- 3.7 指标条：四列→两列 ---------- */
  .stats__inner { grid-template-columns: repeat(2, 1fr); padding: 34px 0; row-gap: 26px; }
  .stat { border-right: none; }
  .stat:nth-child(odd) { border-right: 1px solid var(--lt-line-2); }
  .stat:nth-child(1), .stat:nth-child(2) { padding-bottom: 26px; border-bottom: 1px solid var(--lt-line-2); }
  .stat .num { font-size: 32px; }

  .stat-band { grid-template-columns: repeat(2, 1fr); gap: 16px; }

  /* ---------- 3.8 客户 Logo 墙：六列→三列 ---------- */
  .logo-wall { grid-template-columns: repeat(3, 1fr) !important; }
  .logo-cell { height: 84px; }

  /* ---------- 3.9 流程步骤：四列→两列 ---------- */
  .steps { grid-template-columns: repeat(2, 1fr); gap: 32px 0; }
  .step { padding: 0 22px; }
  /* 第三列起是新一行的第一列，去掉左边框 */
  .step:nth-child(2n+1) { border-left: none; padding-left: 0; }

  /* ---------- 3.10 CTA：左右排列改上下堆叠 ---------- */
  .cta { padding: 60px 0; }
  .cta__inner { flex-direction: column; align-items: flex-start; gap: 28px; }
  .cta h2 { font-size: 30px; }
  .cta__actions { flex-wrap: wrap; gap: 12px; }
  .cta p { max-width: 100%; }

  /* ---------- 3.11 页脚：四列→两列 ---------- */
  .footer__top { grid-template-columns: repeat(2, 1fr); gap: 32px; }
  .footer__bottom { flex-wrap: wrap; gap: 12px; }

  /* ---------- 3.12 联系页与表单 ---------- */
  .contact-grid { grid-template-columns: 1fr; gap: 40px; }
  .form-card { padding: 30px 26px; }

  /* ---------- 3.13 图片模块比例 ---------- */
  .photo { border-radius: var(--r-md); }
  .team-card .photo { height: 180px; }
  .case-card__cover { height: 176px; }
  .media, .media--glass { min-height: 300px; }
  .media--glass { padding: 28px 24px; }

  /* ---------- 3.14 时间轴 ---------- */
  .timeline { padding-left: 34px; }
  .tl-item::before { left: -33px; }

  /* ---------- 3.15 覆盖页面内联的固定列宽栅格 ----------
     部分页面用行内 style 写了 grid-template-columns:360px 1fr 这类固定值，
     媒体查询无法覆盖行内声明，必须用 !important 兜底，否则窄屏必然横向溢出 */
  .grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 36px !important;
  }
}

/* =========================================================
   四、≤767px：手机（主流竖屏）
   字号阶梯下调、全部单列、间距压缩
   ========================================================= */
@media (max-width: 767px) {

  /* ---------- 4.1 容器与节奏 ---------- */
  .container { padding: 0 20px; }
  .section { padding: 56px 0; }
  .section--tight { padding: 44px 0; }
  .section-head { margin-bottom: 32px; }
  .section-head--center { text-align: left; }
  .section-head--center .eyebrow { justify-content: flex-start; }

  /* ---------- 4.2 字号阶梯（正文 15px / 行高 1.8 保证小屏易读） ---------- */
  body { font-size: 15px; line-height: 1.8; }
  .display { font-size: 30px; line-height: 1.22; }
  .h2 { font-size: 24px; line-height: 1.32; }
  .h3 { font-size: 19px; }
  .h4 { font-size: 16px; }
  .lead { font-size: 15.5px; line-height: 1.8; }
  .body-sm { font-size: 14px; line-height: 1.8; }
  .eyebrow { font-size: 11px; margin-bottom: 14px; }

  /* 首屏标题：28px 是保证一行能放下 6-8 个汉字的临界值 */
  .hero h1 { font-size: 29px; line-height: 1.3; letter-spacing: -0.02em; }
  .hero__desc { font-size: 15px; line-height: 1.8; }
  .hero h1 .hl { padding: .02em .10em .06em; border-radius: .16em; }
  .hero__badge { font-size: 11.5px; height: 30px; padding: 0 12px; }
  .hero__inner {
    gap: 36px;
    padding-top: 32px;
    padding-bottom: 44px;
    padding-left: 20px;
    padding-right: 20px;
  }
  .hero__actions { margin-bottom: 32px; }
  .hero__meta { gap: 24px; justify-content: space-between; }
  .hero__meta-item .num { font-size: 23px; }
  .hero__meta-item p { font-size: 11.5px; }

  .page-hero h1 { font-size: 26px; }
  .page-hero p { font-size: 14.5px; line-height: 1.8; }
  .page-hero__media .photo { height: 200px; }
  .head-metrics { gap: 20px; justify-content: space-between; }
  .head-metrics .num { font-size: 22px; }
  .head-metrics p { font-size: 11px; }

  /* ---------- 4.3 按钮：全宽堆叠更易点按 ---------- */
  .btn { height: 48px; padding: 0 22px; font-size: 14.5px; }
  .btn--sm { height: 40px; padding: 0 18px; }
  .hero__actions .btn,
  .cta__actions .btn { flex: 1 1 100%; }

  /* ---------- 4.4 数据看板简化 ---------- */
  .dash { padding: 18px; border-radius: var(--r-md); }
  .dash__kpi { gap: 10px; }
  .dash__kpi-card { padding: 12px; }
  .dash__kpi-card strong { font-size: 18px; }
  .float-card { padding: 10px 13px; }
  .float-card strong { font-size: 12.5px; }
  .float-card small { font-size: 10.5px; }
  .float-card--b { top: -14px; }

  /* ---------- 4.5 栅格：全部单列 ---------- */
  .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; gap: 16px; }

  /* 卡片内边距压缩 */
  .card { padding: 26px 22px; }
  .product-card__head { padding: 26px 22px 20px; }
  .product-card__body { padding: 22px 22px 26px; }
  .industry-card { padding: 22px 20px; }
  .quote-card { padding: 26px 22px; }
  .form-card { padding: 26px 20px; }
  .branch { padding: 20px; }
  .value-card { padding: 24px 20px; }

  /* ---------- 4.6 指标与 Logo 墙 ---------- */
  .stats__inner { padding: 28px 0; row-gap: 22px; }
  .stat .num { font-size: 28px; }
  .stat p { font-size: 12px; }

  .stat-band { gap: 12px; }
  .stat-band__item { padding: 18px 16px; }
  .stat-band__item .num { font-size: 22px; }
  .stat-band__item p { font-size: 11.5px; }

  .logo-wall { grid-template-columns: repeat(2, 1fr) !important; }
  .logo-cell { height: 72px; }
  .logo-cell span { font-size: 14px; }

  /* ---------- 4.7 流程步骤：单列，左边框改上边框 ---------- */
  .steps { grid-template-columns: 1fr; gap: 0; }
  .step {
    border-left: none;
    border-top: 1px solid var(--lt-line);
    padding: 22px 0 0;
    margin-bottom: 22px;
  }
  .step:first-child { border-top: none; padding-top: 0; }
  .step h4 { font-size: 16px; }
  .step p { font-size: 13.5px; }

  /* ---------- 4.8 页脚：单列 ---------- */
  .footer { padding-top: 44px; }
  .footer__top { grid-template-columns: 1fr; gap: 28px; padding-bottom: 32px; }
  .footer__about { max-width: 100%; }
  .footer__bottom { flex-direction: column; align-items: flex-start; gap: 10px; font-size: 12px; }

  /* ---------- 4.9 表单两列改单列 ---------- */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .field { margin-bottom: 16px; }
  .field input, .field select { height: 48px; font-size: 15px; }
  .field textarea { height: 104px; }

  /* ---------- 4.10 图片模块：比例改为 4:3 更耐看 ---------- */
  .photo { border-radius: var(--r-md); }
  .team-card .photo { height: 200px; }
  .case-card__cover { height: 168px; }
  .case-card__body { padding: 22px 20px; }
  .case-metrics { gap: 16px; flex-wrap: wrap; }
  .case-metrics div .num { font-size: 19px; }
  .case-metrics div p { font-size: 11px; }

  /* 图文分栏里的图片高度收敛 */
  .split .photo[style*="height"],
  .split .photo { height: 240px !important; }

  /* ---------- 4.11 架构图：缩小内边距，SVG 自适应 ---------- */
  .media--glass { min-height: 260px; padding: 20px 16px; }
  .media { min-height: 240px; }

  /* ---------- 4.12 服务网络：节点与标签缩小 ---------- */
  .map-abstract { height: 220px; }
  .map-pin__label { font-size: 10px; padding: 1px 6px; }
  .map-pin__dot { width: 12px; height: 12px; border-width: 2px; }

  /* ---------- 4.13 时间轴紧凑化 ---------- */
  .timeline { padding-left: 26px; }
  .timeline::before { left: 7px; }
  .tl-item { padding-bottom: 28px; }
  .tl-item::before { left: -25px; width: 12px; height: 12px; }
  .tl-year { font-size: 12px; }
  .tl-item h4 { font-size: 15.5px; }
  .tl-item p { font-size: 13.5px; }

  /* ---------- 4.14 强调块与提示 ---------- */
  .note-box { padding: 14px 16px; font-size: 13.5px; }
  .heading-metrics { gap: 16px; }

  /* 区块内的大间距内联样式统一收敛（覆盖 HTML 行内值） */
  .section .grid[style*="gap"] { gap: 20px !important; }
}

/* =========================================================
   五、≤479px：小屏手机
   极限压缩，保证不出现横向滚动
   ========================================================= */
@media (max-width: 479px) {
  .container { padding: 0 16px; }
  .section { padding: 48px 0; }

  /* 小屏的 gutter 也要同步到首屏容器 */
  .hero__inner { padding-left: 16px; padding-right: 16px; }

  .hero h1 { font-size: 26px; }
  .page-hero h1 { font-size: 23px; }
  .h2 { font-size: 22px; }

  .hero__meta { gap: 16px; }
  .hero__meta-item .num { font-size: 21px; }
  .stat .num { font-size: 25px; }

  .head-metrics { gap: 14px; }
  .head-metrics .num { font-size: 19px; }
  .head-metrics p { font-size: 10px; letter-spacing: 0; }

  .btn { height: 46px; font-size: 14px; padding: 0 18px; }
  .logo-cell { height: 64px; }
  .logo-cell span { font-size: 13px; letter-spacing: .02em; }

  .cta h2 { font-size: 22px; }
  .footer__col h4 { margin-bottom: 14px; }

  .case-metrics { gap: 12px; }
  .case-metrics div .num { font-size: 17px; }

  /* 小屏下隐藏装饰性浮层，避免遮挡关键文字 */
  .float-card--b { display: none; }
}

/* =========================================================
   六、横屏与超宽屏补充
   ========================================================= */

/* 手机横屏：视口高度小，压缩首屏纵向留白 */
@media (max-width: 900px) and (orientation: landscape) {
  .hero__inner { padding-top: 28px; padding-bottom: 36px; }
  .page-hero__split { padding: 24px 0 32px; }
  .page-hero__media .photo { height: 190px; }
}

/* 超宽屏：容器适当放宽，避免内容过度居中显空 */
@media (min-width: 1600px) {
  :root { --container: 1280px; }
  .hero__inner { gap: 72px; }
}

/* 高对比度偏好的用户：加强细边框可见性 */
@media (prefers-contrast: more) {
  .card, .product-card, .case-card, .quote-card, .branch { border-color: #94AFC8; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* 打印：去掉背景色与阴影，保证文字可读 */
@media print {
  .nav, .cta, .footer { display: none; }
  body { background: #fff; color: #000; }
  .section { padding: 20px 0; }
}

/* =========================================================
   移动端 / 平板端导航吸顶（≤991px）
   ---------------------------------------------------------
   与 PC 端方案保持一致：用 position:fixed 而非 sticky。
   原因是导航位于 .hero / .page-hero 内部，这两个容器设有
   overflow:hidden（用于裁切背景光晕），会让 sticky 失效；
   且 sticky 的粘滞范围受父容器高度限制，滚过首屏就会消失。

   代价是导航脱离文档流，需给容器补同高的上内边距占位，
   否则首屏内容会顶到视口最上方。
   ========================================================= */
@media (max-width: 991px) {
  .nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    /* 未滚动时保持透明，与首屏渐变自然融合（沿用原有观感）。
       分隔线沿用 .nav--dark 的 1px 淡蓝，与改造前完全一致，不做修改 */
    background: transparent;
    transition: background-color .3s ease, box-shadow .3s ease, border-color .3s ease;
  }

  /* 滚动后、或菜单展开时切为白色毛玻璃：
     固定导航会压在任意内容之上，必须有实底才能保证文字可读。
     菜单展开时即使停在页面顶部也要实底，否则竖排菜单项会浮在首屏渐变上。 */
  .nav.is-stuck,
  .nav.is-open {
    background: rgba(255, 255, 255, .94);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    backdrop-filter: blur(12px) saturate(150%);
    border-bottom-color: rgba(6, 66, 122, .10);
    box-shadow: 0 1px 2px rgba(6, 66, 122, .05), 0 6px 18px rgba(6, 66, 122, .09);
  }

  /* 占位补偿：≤991 下导航高 65px（min-height 64 + 1px 下边框）。
     补上后首屏视觉与改造前完全一致，内容不会被导航压住。 */
  .hero,
  .page-hero {
    padding-top: 65px;
  }

  /* 固定导航会遮住锚点目标的顶部，站内跳转需留出偏移 */
  html { scroll-padding-top: 78px; }

  /* 展开的菜单现在是固定导航的一部分：超出屏幕时内部滚动，
     并限制最大高度，避免小屏（如横屏 320×480）被截断无法触达末项 */
  .nav-toggle:checked ~ .nav__menu {
    max-height: min(72vh, 420px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}
