/* ==========================================================================
   动效系统 v2 —— 「看得见的动」
   --------------------------------------------------------------------------
   v1 的问题：循环周期 5.5–8s、幅度 2–4px，实测虽然 animation-name 生效，
   但用户几乎察觉不到，等于"没动"。

   v2 的调整：
     ① 循环周期压到 2.4–4s —— 用户视线停留时间内至少能看完一轮
     ② 幅度放大到 4–10px —— 在大屏上真正看得见
     ③ 新增滚动驱动视差与错峰 —— 页面滚动时持续有变化，不依赖循环
     ④ 悬停反馈加强 —— 卡片抬升 6px、加边框发光

   仍然保留：全部包在 prefers-reduced-motion: no-preference 内，
   用户关闭动效时页面完全静态、功能不受影响。
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {

  /* ================= ① 入场：错峰更明显 ================= */
  .reveal { transition: opacity .7s var(--ease), transform .7s var(--ease); }

  /* 进场从「淡入上移」改为「淡入上移 + 轻微缩放」，层次更明显 */
  html.js .reveal { opacity: 0; transform: translateY(26px) scale(.985); }

  .feats .reveal:nth-child(2), .entries .reveal:nth-child(2),
  .guards .reveal:nth-child(2), .pain .reveal:nth-child(2),
  .steps .reveal:nth-child(2), .docs .reveal:nth-child(2),
  .demos .reveal:nth-child(2), .contact .reveal:nth-child(2) { transition-delay: .09s; }

  .feats .reveal:nth-child(3), .entries .reveal:nth-child(3),
  .guards .reveal:nth-child(3), .pain .reveal:nth-child(3),
  .steps .reveal:nth-child(3), .docs .reveal:nth-child(3),
  .demos .reveal:nth-child(3), .contact .reveal:nth-child(3) { transition-delay: .18s; }

  .entries .reveal:nth-child(4), .steps .reveal:nth-child(4) { transition-delay: .26s; }
  .entries .reveal:nth-child(5), .steps .reveal:nth-child(5) { transition-delay: .33s; }
  .entries .reveal:nth-child(6) { transition-delay: .40s; }
  .entries .reveal:nth-child(7) { transition-delay: .46s; }
  .entries .reveal:nth-child(8) { transition-delay: .52s; }
  .feats .reveal:nth-child(4), .docs .reveal:nth-child(4) { transition-delay: .22s; }
  .feats .reveal:nth-child(5), .docs .reveal:nth-child(5) { transition-delay: .28s; }
  .feats .reveal:nth-child(6), .docs .reveal:nth-child(6) { transition-delay: .34s; }
  .feats .reveal:nth-child(7), .docs .reveal:nth-child(7) { transition-delay: .40s; }
  .feats .reveal:nth-child(8), .docs .reveal:nth-child(8) { transition-delay: .46s; }
  .feats .reveal:nth-child(9), .docs .reveal:nth-child(9) { transition-delay: .52s; }

  /* ================= ② 交互：悬停更有存在感 ================= */

  /* ⚠️ 优先级陷阱：style.css 里 `html.js .reveal` 的特指度是 (0,2,1)，
     它会压过普通的 `.entry:hover`（0,2,0）。而带 reveal 的卡片在
     JS 加完 .in 之前 transform 一直被 reveal 规则锁着 —— 表现为
     "悬停没反应"。因此所有 hover 的 transform 都必须写成三段式，
     与 reveal 处于同一特指度层级。 */
  .feat, .entry, .guard, .pain-card, .step, .plan, .doc-card, .demo, .contact-card {
    transition: transform .3s var(--ease), border-color .3s var(--ease),
                box-shadow .3s var(--ease), background .3s var(--ease);
  }
  html.js .feat:hover, html.js .entry:hover, html.js .guard:hover,
  html.js .pain-card:hover, html.js .doc-card:hover,
  html.js .demo:hover, html.js .contact-card:hover,
  .feat:hover, .entry:hover, .guard:hover, .pain-card:hover,
  .doc-card:hover, .demo:hover, .contact-card:hover {
    transform: translateY(-6px);
    border-color: rgba(14,143,255,.38);
    box-shadow: 0 10px 28px -12px rgba(0,0,0,.55), 0 0 0 1px rgba(14,143,255,.14);
  }
  html.js .step:hover, .step:hover { transform: translateY(-4px); }

  html.js .plan:hover, .plan:hover { transform: translateY(-7px); }
  html.js .plan-featured:hover, .plan-featured:hover {
    border-color: var(--blue);
    box-shadow: 0 14px 34px -14px rgba(14,143,255,.45), 0 0 0 1px rgba(14,143,255,.3);
  }

  /* 8 条路编号：右移 + 点亮 + 放大 */
  html.js .entry:hover .no, .entry:hover .no {
    color: var(--blue); transform: translateX(6px) scale(1.08);
  }

  /* 护栏卡图标轻微摆动 */
  html.js .guard:hover .ico, .guard:hover .ico { transform: scale(1.14) rotate(-4deg); }

  /* 功能卡图标：悬停轻微放大 */
  html.js .feat:hover .ico, .feat:hover .ico { transform: scale(1.12); }

  /* 8 条路入口格：悬停抬升 + 缩放 */
  .hero-ways a { transition: transform .26s var(--ease), border-color .26s var(--ease), background .26s var(--ease); }
  .hero-ways a:hover { transform: translateY(-4px) scale(1.03); }

  /* 按钮：悬停时轻微上浮 + 发光 */
  .btn { transition: transform .22s var(--ease), box-shadow .22s var(--ease), background .22s var(--ease); }
  html.js .btn:hover, .btn:hover { transform: translateY(-2px); }
  html.js .btn-primary:hover, .btn-primary:hover { box-shadow: 0 8px 22px -10px rgba(14,143,255,.7); }

  /* ================= ③ 氛围：加快 + 加幅度 ================= */

  /* Hero 锁扣：5.5s → 2.8s，呼吸范围明显放大 */
  .hero-vault .lock {
    animation: vault-breathe 2.8s ease-in-out infinite;
  }
  @keyframes vault-breathe {
    0%, 100% { box-shadow: 0 0 0 3px rgba(217,164,65,.08); }
    50%      { box-shadow: 0 0 0 9px rgba(217,164,65,.22); }
  }

  /* Hero 保险箱：6.5s/±2px → 3.4s/±4px */
  .hero-vault { animation: vault-float 3.4s ease-in-out infinite; }
  @keyframes vault-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
  }

  /* 大标题下划线：8s → 4.2s，扫光更频繁更亮 */
  .hero h1 .accent {
    background-size: 100% 100%, 220% 100%;
    background-repeat: no-repeat;
    background-image:
      linear-gradient(transparent 62%, rgba(14,143,255,.24) 62%),
      linear-gradient(100deg, transparent 38%, rgba(255,255,255,.26) 50%, transparent 62%);
    animation: accent-sweep 4.2s ease-in-out infinite;
  }
  @keyframes accent-sweep {
    0%, 52%, 100% { background-position: 0 0, -120% 0; }
    78%           { background-position: 0 0, 220% 0; }
  }

  /* 徽章组依次弹入 —— 首屏就有层次感 */
  @media (min-width: 641px) {
    .badges .badge { animation: badge-pop .5s var(--ease) backwards; }
    .badges .badge:nth-child(1) { animation-delay: .05s; }
    .badges .badge:nth-child(2) { animation-delay: .13s; }
    .badges .badge:nth-child(3) { animation-delay: .21s; }
    .badges .badge:nth-child(4) { animation-delay: .29s; }
  }
  @keyframes badge-pop {
    from { opacity: 0; transform: translateY(10px) scale(.9); }
    to   { opacity: 1; transform: none; }
  }

  /* FAQ 展开：答案下滑淡入，比原来明显 */
  .faq details[open] .ans { animation: ans-in .38s var(--ease); }
  @keyframes ans-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
  }

  /* 动图区边框呼吸，暗示"正在播放" */
  .demo-frame:not(.is-empty):not(.is-pending) { animation: demo-glow 3.2s ease-in-out infinite; }
  @keyframes demo-glow {
    0%, 100% { box-shadow: 0 0 0 1px rgba(14,143,255,.10); }
    50%      { box-shadow: 0 0 0 1px rgba(14,143,255,.30), 0 6px 20px -10px rgba(14,143,255,.35); }
  }

  /* 分组序号徽章轻微脉冲 */
  .demo-group-no { animation: group-pulse 3.6s ease-in-out infinite; }
  @keyframes group-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(14,143,255,0); }
    50%      { box-shadow: 0 0 0 6px rgba(14,143,255,.12); }
  }

  /* 复制成功：青色反馈 + 弹跳 */
  .copy-btn.is-done {
    color: var(--teal);
    border-color: rgba(0,209,193,.42);
    background: var(--teal-dim);
    animation: copy-bounce .4s var(--ease);
  }
  @keyframes copy-bounce {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.07); }
    100% { transform: scale(1); }
  }

  /* ================= ④ 图片出场动效 =================
     图片比文字更需要"入场感" —— 静态图突然出现会显得生硬，
     这里让它们从轻微下移 + 缩放 + 去模糊中浮现，滚动时依次出现。 */

  /* 装饰图与动图的进场：下移 + 微缩放，比卡片稍慢以示区分 */
  @media (prefers-reduced-motion: no-preference) {
    .deco {
      opacity: 0;
      transform: translateY(30px) scale(.97);
      filter: blur(4px);
      transition: opacity .75s var(--ease), transform .75s var(--ease),
                  filter .75s var(--ease);
    }
    .deco.is-in {
      opacity: 1;
      transform: none;
      filter: none;
    }

    /* 同一行两张图错开 90ms，视觉上像"先后浮现"而不是一起出现 */
    .deco-pair .deco:nth-child(2) { transition-delay: .09s; }
    .deco-split .deco { transition-delay: .05s; }

    /* 动图入场时额外轻微"放大归位"，强化播放感 */
    .demo .demo-frame img { transition: transform .8s var(--ease); }
    .demo.is-in .demo-frame img { animation: demo-settle 1.1s var(--ease) both; }
    @keyframes demo-settle {
      0%   { transform: scale(1.04); }
      100% { transform: scale(1); }
    }
  }

  /* 无 JS 时的兜底：html 没有 .js 类时不隐藏，避免内容丢失 */
  html:not(.js) .deco { opacity: 1; transform: none; filter: none; }

  /* ================= ⑤ 滚动驱动：进度条 + 导航 + 回顶 ================= */

  /* 进度条加高到 3px，加发光，渐变更明显 */
  .progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: linear-gradient(90deg, var(--blue), var(--teal), var(--brass));
    box-shadow: 0 0 10px rgba(14,143,255,.5);
    z-index: 60; pointer-events: none;
    transition: width .1s linear;
  }

  /* 导航滚动后：毛玻璃更明显 */
  .nav.stuck {
    border-bottom-color: var(--line);
    background: rgba(15,17,21,.92);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
  }

  /* 回到顶部：带缩放出现，悬停再抬升 */
  .to-top {
    position: fixed; right: 22px; bottom: 22px;
    width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--text-2); cursor: pointer;
    opacity: 0; transform: translateY(14px) scale(.86); pointer-events: none;
    transition: opacity .3s var(--ease), transform .3s var(--ease),
                border-color .2s var(--ease), color .2s var(--ease);
    z-index: 50;
  }
  .to-top.show { opacity: 1; transform: none; pointer-events: auto; }
  .to-top:hover { border-color: var(--blue); color: var(--blue-hover); transform: translateY(-3px); }
}