/* ==========================================================================
   拓路人 V8 · HERO 阶段 A（静态还原）
   独立预览目录，不引用 V7.2 的任何样式表，避免互相影响。
   桌面按参考图比例定位；≤1099px 改为流式重排（不是等比缩小）。
   ========================================================================== */

:root {
  --v8-ink: #0B1A2E;
  --v8-brand: #245FFF;
  --v8-line: #E7EBF3;
  --v8-header-h: 88px;
}

/* 锚点跳转时为固定头部留出偏移（整改 P2-9） */
html { scroll-padding-top: var(--v8-header-h); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #FFFFFF;
  color: var(--v8-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 无障碍：仅屏幕阅读器可见 */
.v8-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- 顶部 ---------- */
.v8-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--v8-header-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(8px);
}
.v8-header-inner {
  max-width: 1440px; height: 100%; margin: 0 auto;
  padding: 0 clamp(20px, 3.4vw, 52px);
  display: flex; align-items: center; gap: 32px;
}
.v8-brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--v8-ink);
  font-size: 19px; font-weight: 700; letter-spacing: .04em;
}
.v8-brand img { display: block; width: 34px; height: 34px; }

.v8-nav {
  margin-left: auto;
  display: flex; align-items: center; gap: clamp(18px, 2.4vw, 40px);
}
.v8-nav a {
  text-decoration: none; color: #374151;
  font-size: 15.5px; letter-spacing: .02em;
  transition: color .2s ease;
}
.v8-nav a:hover { color: var(--v8-brand); }

.v8-cta {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 22px; margin-left: 8px;
  border-radius: 999px; background: var(--v8-brand); color: #fff;
  font-size: 15px; font-weight: 600; text-decoration: none;
  box-shadow: 0 8px 20px rgba(36, 95, 255, .22);
  transition: background .2s ease, transform .2s ease;
}
.v8-cta:hover { background: #1B4FE0; transform: translateY(-1px); }

.v8-menu { display: none; }

/* ---------- HERO 舞台（桌面按参考图比例） ---------- */
.v8-hero {
  position: relative;
  max-width: 1760px;
  margin: 0 auto;
  margin-top: var(--v8-header-h);
  height: 0;
  padding-bottom: 36%;        /* 699 / 1944 ≈ 0.36，与参考图同比例 */
}

.v8-hero-copy {
  position: absolute;
  left: 10.4%; top: 8.2%;
  width: 22.4%;
  margin: 0;
}
.v8-title {
  margin: 0;
  display: block;
  position: relative;
  /* 静态图已移除：用原稿比例（446×556）撑住高度，
     否则 .v8-hero-copy 高度为 0 → IntersectionObserver 永不触发 → 视频不播 */
  aspect-ratio: 446 / 556;
}
.v8-calligraphy {
  display: block; width: 100%; height: auto;
}

.v8-hero-art {
  position: absolute;
  left: 39.8%; top: -2%;
  width: 62.3%;
  margin: 0;
}
.v8-sphere {
  display: block; width: 100%; height: auto;
}


/* ---------- 书写视频层（叠在静态书法上） ----------
   对位参数由视频墨迹 bbox 反算：bbox 585x686 → 框宽 305 CSS px
   视频显示宽 = 305 * 1280/585 = 667.4px  → 218.8%
   左移 = -370 * (305/585) = -192.9px      → -63.2%
   上移 = -30  * (305/585) = -15.6px       → -4.1%
   静态图始终存在（poster + 兜底 + 终态），视频只负责"写"的过程。 */
.v8-hero-copy { overflow: visible; }
/* 视频已预处理：裁到墨迹 bbox、近白压纯白、2x 尺寸。
   因此这里只需把它铺在"静态墨迹所在的矩形"上，不再做任何 scale 换算。 */
.v8-writing {
  position: absolute;
  left: -61.32%; top: -0.95%;
  width: 212.92%; height: auto; max-width: none;
  aspect-ratio: 1280 / 720;
  /* 已用 ffmpeg 把白底拉到 255（colorlevels rimax .90）并转 H.264：
     iOS 上 filter/mix-blend-mode 对视频层不生效，所以不能靠 CSS 遮灰。 */
  opacity: 0; transition: opacity .35s ease;
  pointer-events: none;
}
.v8-writing.is-on { opacity: 1; }
.v8-writing.is-done { opacity: 1; }   /* 停住不淡出 */

/* ---------- 平板 / 窄屏：改为流式重排 ---------- */
@media (max-width: 1099px) {
  :root { --v8-header-h: 72px; }

  .v8-nav { display: none; }
  .v8-menu {
    display: inline-block; margin-left: auto;
    width: 40px; height: 40px; padding: 0;
    border: 0; border-radius: 8px;
    background: transparent; cursor: pointer;
    -webkit-appearance: none; appearance: none;
    color: var(--v8-ink); line-height: 0; text-align: center;
  }
  .v8-menu-ico { display: inline-block; width: 18px; height: 14px; vertical-align: middle; }

    /* 移动导航展开面板（≤1099px） */
    .v8-nav.open {
      display: flex; flex-direction: column; align-items: stretch;
      position: fixed; left: 0; right: 0; top: var(--v8-header-h);
      background: #fff; border-bottom: 1px solid var(--v8-line);
      box-shadow: 0 14px 30px rgba(16, 32, 58, .08);
      padding: 6px clamp(20px, 4vw, 40px) 14px;
      gap: 0; z-index: 60;
    }
    .v8-nav.open a {
      padding: 13px 2px; font-size: 15px; border-bottom: 1px solid #f1f4f8;
    }
    .v8-nav.open a:last-child { border-bottom: 0; }
    .v8-nav.open .v8-cta { margin: 10px 0 0; text-align: center; }

  .v8-hero {
    height: auto; padding-bottom: 0;
    padding: clamp(28px, 4vw, 44px) clamp(20px, 4vw, 40px) clamp(40px, 5vw, 64px);
    display: grid;
    grid-template-columns: minmax(0, 42%) minmax(0, 58%);
    align-items: center;
    gap: clamp(16px, 3vw, 32px);
  }
  .v8-hero-copy, .v8-hero-art { position: static; width: auto; }
  .v8-hero-copy { max-width: 380px; }
}

/* ---------- 手机：书法在上、球体在下 ---------- */
@media (max-width: 767px) {
  :root { --v8-header-h: 64px; }

  .v8-brand { font-size: 17px; gap: 8px; }
  .v8-brand img { width: 28px; height: 28px; }
  .v8-cta { height: 40px; padding: 0 16px; font-size: 14px; }

  .v8-hero {
    grid-template-columns: 1fr;
    padding: 14px 16px 32px;
    gap: 4px;
    overflow-x: clip;          /* 防任何素材造成横向滚动 */
  }
  /* 书法：占宽约 62%，靠左，保留两列竖排的大小区分 */
  .v8-hero-copy { max-width: none; width: 62%; }
  .v8-hero-art { width: 100%; margin-top: 0; }
  .v8-sphere { width: 100%; }
}

@media (max-width: 380px) {
  .v8-hero-copy { width: 66%; }

  /* 320 档头部：品牌名与 CTA 必须单行，汉堡保持 ≥44px 点击区 */
  .v8-header-inner { gap: 10px; padding: 0 14px; }
  .v8-brand { font-size: 15px; gap: 6px; white-space: nowrap; }
  .v8-brand img { width: 24px; height: 24px; }
  .v8-cta {
    height: 36px; padding: 0 12px; margin-left: 0;
    font-size: 13px; white-space: nowrap;
  }
  .v8-menu { width: 44px; height: 44px; }
}

/* ---------- 减少动态偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 防误拖：视频/图片不是可拖拽对象 ---------- */
.v8-writing, .v8-poster, .v8-title img, #sphere3d {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;      /* 竖屏滑动仍可用于滚动页面 */
}

/* ---------- layout-stable：首屏不许跳动 ---------- */
.v8-title { min-height: 1px; }
.v8-hero-art { min-height: 1px; }
.v8-canvas-wrap {
  aspect-ratio: 1135 / 693;      /* 画布容器先占位，等 canvas 初始化不再塌陷 */
  min-height: 1px;
}
/* 极短淡入：遮住字体替换与画布首帧 */
.v8-hero { animation: v8-hero-in .22s ease-out both; }
@keyframes v8-hero-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .v8-hero { animation: none; }
}

/* ---------- 消除滚动条出现导致的宽度跳动 ---------- */
html { overflow-y: scroll; scrollbar-gutter: stable; }

/* ---------- 锁住视频合成层：避免 pause/ended 时重提升导致跳变 ---------- */
.v8-writing {
  will-change: opacity, transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}
