/* corporate-site responsive baseline
 * 用法：放在 tokens.css 之后引入：
 *   <link rel="stylesheet" href="/shared/styles/tokens.css">
 *   <link rel="stylesheet" href="/shared/styles/responsive.css">
 * 断点边界：1024（桌面导航/平板横屏分界）、768（平板竖屏/手机分界）、480（小手机）
 * 设计基准 1440，向下适配；平板和手机都要重新组织布局，不是整体缩放。
 */

/* ---------- 全局防横向滚动 ---------- */
html,
body {
  overflow-x: clip;
}

/* ---------- 容器与分区 ---------- */
@media (max-width: 1023px) {
  :root {
    --container: 100%;
    --gutter: 32px;
    --section-y: clamp(48px, 7vw, 88px);
  }
}

@media (max-width: 767px) {
  :root {
    --gutter: 20px;
    --section-y: clamp(40px, 9vw, 64px);
    --grid-gap: 16px;
  }
}

/* ---------- 栅格 ---------- */
.cols-2,
.cols-3,
.cols-4 {
  display: grid;
  gap: var(--grid-gap);
}

.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* 卡片数量不确定时用 auto-grid，避免写死列数 */
.auto-grid {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

/* 平板横屏 / 小笔记本：4 列降 2 列，3 列降 2 列 */
@media (max-width: 1023px) {
  .cols-4,
  .cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* 手机：全部单列；需要横滑的模块单独加 .h-scroll */
@media (max-width: 767px) {
  .cols-2,
  .cols-3,
  .cols-4 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- 左右图文 ---------- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
}

.split--reverse > :first-child {
  order: 2;
}

@media (max-width: 1023px) {
  .split,
  .split--reverse {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  .split--reverse > :first-child {
    order: 0;
  }
}

@media (max-width: 767px) {
  .split {
    gap: 24px;
  }
}

/* ---------- 导航：1024 以下统一汉堡 ---------- */
.nav-desktop {
  display: flex;
}

.nav-toggle {
  display: none;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

@media (max-width: 1023px) {
  .nav-desktop {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
  }
}

/* 抽屉打开时锁滚动（配合 JS 给 body 加 .nav-open） */
body.nav-open {
  overflow: hidden;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-items: end;
}

@media (max-width: 1023px) {
  .hero {
    min-height: 82svh;
  }
}

@media (max-width: 767px) {
  .hero {
    min-height: 74svh;
  }
}

/* 手机横屏：高度优先，别让首屏只剩标题 */
@media (max-height: 520px) and (orientation: landscape) {
  .hero {
    min-height: 100svh;
    align-items: center;
  }
}

/* ---------- 媒体比例 ---------- */
.media-16x9 {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  width: 100%;
}
.media-4x3 {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
}
.media-3x2 {
  aspect-ratio: 3 / 2;
  object-fit: cover;
  width: 100%;
}
.media-1x1 {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  width: 100%;
}
.media-3x4 {
  aspect-ratio: 3 / 4;
  object-fit: cover;
  width: 100%;
}

/* ---------- 表格：手机转卡片 ---------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  .table-cards thead {
    display: none;
  }

  .table-cards,
  .table-cards tbody,
  .table-cards tr,
  .table-cards td {
    display: block;
    width: 100%;
  }

  .table-cards tr {
    padding: var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    margin-bottom: var(--space-3);
  }

  .table-cards tr + tr {
    margin-top: 0;
  }

  .table-cards td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: var(--space-3);
    padding: 6px 0;
    border: 0;
  }

  .table-cards td::before {
    content: attr(data-label);
    color: var(--color-muted);
    font-size: var(--text-sm);
  }
}

/* ---------- Footer ---------- */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, minmax(0, 1fr));
  gap: var(--grid-gap);
}

@media (max-width: 1023px) {
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8) var(--space-4);
  }
}

@media (max-width: 479px) {
  .footer-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}

.form-grid .full {
  grid-column: 1 / -1;
}

@media (max-width: 767px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  input,
  select,
  textarea {
    font-size: 16px; /* 防止 iOS 聚焦自动放大 */
  }

  .btn,
  button[type="submit"] {
    width: 100%;
    min-height: 48px;
  }
}

/* ---------- 触控与底部固定栏 ---------- */
.tappable {
  min-width: 44px;
  min-height: 44px;
}

.fixed-cta {
  display: none;
}

@media (max-width: 767px) {
  .fixed-cta {
    display: flex;
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
    background: var(--color-surface);
    border-top: 1px solid var(--color-line);
  }
}

/* ---------- 仅悬停设备才启用 hover 效果 ---------- */
@media (hover: none) {
  .hover-only {
    display: none;
  }

  .hover-reveal {
    opacity: 1;
  }
}

@media (hover: hover) and (pointer: fine) {
  .hover-reveal {
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
  }

  .hover-reveal:hover,
  .hover-reveal:focus-within {
    opacity: 1;
  }
}

/* ---------- 显示/隐藏工具 ---------- */
.show-mobile {
  display: none;
}

@media (max-width: 767px) {
  .show-mobile {
    display: block;
  }

  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .hide-tablet {
    display: none !important;
  }
}

/* ---------- 横向滑动模块 ---------- */
.h-scroll {
  display: flex;
  gap: var(--grid-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-3);
}

.h-scroll > * {
  flex: 0 0 min(78vw, 360px);
  scroll-snap-align: start;
}

@media (min-width: 768px) {
  .h-scroll {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    overflow: visible;
    scroll-snap-type: none;
    padding-bottom: 0;
  }

  .h-scroll > * {
    flex: initial;
  }
}
