/*
 * Dragon Silk Road — Home Hero FX (SVG tech background)
 * ---------------------------------------------------------------------------
 * Additive enhancement layer for the homepage .home-hero (reveal) module.
 * 纯增量：不改写 home-hero-rail-v4.css 任何规则，只在 hero 背景区新增
 * 多层 SVG 科技风特效（极光 / 透视网格 / 电路 / 节点星座 / 全息雷达 /
 * 轨道枢纽 / 扫描光束 / 波形 / 光标聚光），全部由 CSS 关键帧常驻动画
 * —— 页面静止时也在持续运转。
 *
 * 驱动变量（由 home-hero-fx.js 写入 .home-hero）：
 *   --fx-progress : hero 滚出视口进度 0..1
 *   --fx-px       : 指针归一化 X 0..1（相对 hero）
 *   --fx-py       : 指针归一化 Y 0..1
 * 各层通过 calc() 由这两个变量派生旋转/缩放/位移/透明度，JS 只写变量、
 * 不逐帧写样式。层级：fx(z:-1) < route-field/ambient(z:0) < 内容 grid(z:2)，
 * 雷达光环从 Trade Control Room 玻璃面板背后透出并越过其上/下边缘。
 *
 * 无障碍与性能：
 *   - 全部图层 pointer-events:none / aria-hidden（JS 设置）；
 *   - 仅 transform/opacity/stroke-dashoffset/filter 参与动画；
 *   - 关键帧内不引用变量、animation-duration 不变（避免动画跳变）；
 *   - ≤1020px 单列布局降档、≤720px 再降档。
 */

body.page-home .home-hero {
  --fx-progress: 0;
  --fx-px: 0.5;
  --fx-py: 0.5;
  --fx-cyan: #79dbe6;
  --fx-orange: #ed6428;
  --fx-jade: #70d7ae;
}

/* ═══════════════════════════════════════════════════════════════════════
   FX 根层
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint;
}

/* 所有直接子层统一绝对定位（按各自 inset 落位） */
.home-hero-fx > * {
  position: absolute;
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════
   1. aurora —— 模糊光斑（静止：缓慢漂移+呼吸；滚动：增亮）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__aurora {
  inset: -20% -6% auto auto;
  width: min(60vw, 880px);
  height: min(60vw, 880px);
  opacity: calc(.55 + var(--fx-progress) * .25);
  background:
    radial-gradient(circle at 40% 40%, rgba(121, 219, 230, .24), transparent 58%),
    radial-gradient(circle at 66% 62%, rgba(237, 100, 40, .16), transparent 55%),
    radial-gradient(circle at 50% 28%, rgba(112, 215, 174, .12), transparent 50%);
  filter: blur(62px) saturate(1.15);
  mix-blend-mode: screen;
  animation: hfx-aurora-drift 24s ease-in-out infinite alternate;
}

.home-hero-fx__aurora::after {
  content: "";
  position: absolute;
  inset: 16% 8% auto auto;
  width: 46%;
  height: 46%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(43, 118, 162, .4), transparent 66%);
  filter: blur(46px);
  animation: hfx-aurora-pulse 8.5s ease-in-out infinite alternate;
}

@keyframes hfx-aurora-drift {
  from { transform: translate3d(-2%, -1.5%, 0) scale(1); }
  to   { transform: translate3d(2.5%, 2.5%, 0) scale(1.07); }
}

@keyframes hfx-aurora-pulse {
  from { opacity: .5; transform: scale(.92); }
  to   { opacity: .95; transform: scale(1.08); }
}

/* ═══════════════════════════════════════════════════════════════════════
   2. grid —— 底部透视数字网格（静止：无缝循环横移；滚动：视角翻起）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__grid {
  inset: auto 0 0 0;
  height: 44%;
  perspective: 900px;
  transform-origin: 50% 100%;
  transform: rotateX(calc(62deg + var(--fx-progress) * 8deg));
}

.home-hero-fx__grid svg {
  inset: 0;
  width: 100%;
  height: 100%;
  animation: hfx-grid-drift 22s linear infinite;
}

@keyframes hfx-grid-drift {
  /* 5% = 视口宽 × (40/800 viewBox) = 恰好一格，任意宽度下循环无缝 */
  from { transform: translate3d(-5%, 0, 0); }
  to   { transform: translate3d(0, 0, 0); }
}

/* ═══════════════════════════════════════════════════════════════════════
   3. circuit —— 电路走线（数据流常驻流动；滚动增亮微转）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__circuit {
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: calc(.55 + var(--fx-progress) * .28);
  rotate: calc(var(--fx-progress) * 1.2deg);
}

.home-hero-fx__circuit path,
.home-hero-fx__circuit polyline {
  fill: none;
  stroke: rgba(121, 219, 230, .38);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 12 26;
  animation: hfx-circuit-flow 3.4s linear infinite;
}

.home-hero-fx__circuit path.is-warm {
  stroke: rgba(237, 100, 40, .42);
  animation-duration: 4.6s;
}

.home-hero-fx__circuit path.is-jade {
  stroke: rgba(112, 215, 174, .38);
  animation-duration: 5.3s;
}

.home-hero-fx__circuit .fx-pad {
  fill: rgba(121, 219, 230, .2);
  stroke: rgba(121, 219, 230, .52);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  animation: hfx-pad-breathe 4.6s ease-in-out infinite;
}

@keyframes hfx-circuit-flow {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -88; }
}

@keyframes hfx-pad-breathe {
  50% { fill-opacity: .28; stroke-opacity: .68; }
}

/* ═══════════════════════════════════════════════════════════════════════
   4. nodes —— 数据节点星座（静止：错峰闪烁；滚动：放大上浮；
              指针：90px 内节点点亮 + 相连边高亮）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__nodes {
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .95;
  transform: scale(calc(1 + var(--fx-progress) * .13));
}

.home-hero-fx__nodes line.fx-edge {
  stroke: rgba(255, 255, 255, .11);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: stroke .3s ease, stroke-width .3s ease, opacity .3s ease;
}

.home-hero-fx__nodes line.fx-edge.is-near {
  stroke: rgba(121, 219, 230, .6);
  stroke-width: 1.6;
  opacity: 1;
}

.home-hero-fx__nodes circle.fx-node {
  fill: var(--fx-node-color, var(--fx-cyan));
  opacity: .5;
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity .28s ease, transform .28s ease;
  animation: hfx-node-twinkle var(--fx-node-period, 3.4s) ease-in-out infinite;
  animation-delay: var(--fx-node-delay, 0s);
}

.home-hero-fx__nodes circle.fx-node.is-near {
  opacity: 1;
  transform: scale(1.9);
  filter: drop-shadow(0 0 8px var(--fx-node-glow, rgba(121, 219, 230, .95)));
}

@keyframes hfx-node-twinkle {
  0%, 100% { opacity: .4; }
  50%      { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════
   5. radar —— 全息雷达（Trade Control Room 后方光环：环线与扫描锥
      从 workspace 玻璃后透出并越过其上/下边缘；滚动偏转增亮）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__radar {
  inset-inline-end: clamp(-240px, -14vw, -120px);
  top: clamp(-160px, -8vw, -40px);
  width: clamp(620px, 62vw, 980px);
  height: clamp(620px, 62vw, 980px);
  opacity: calc(.72 + var(--fx-progress) * .16);
  transform: rotate(calc(var(--fx-progress) * 32deg));
  -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, .5) 0 34%, #000 62%, transparent 88%);
  mask-image: radial-gradient(circle, rgba(0, 0, 0, .5) 0 34%, #000 62%, transparent 88%);
}

.home-hero-fx__radar svg {
  inset: 0;
  width: 100%;
  height: 100%;
}

.home-hero-fx__radar circle.fx-ring {
  fill: none;
  stroke: rgba(121, 219, 230, .46);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 3 7;
  animation: hfx-ring-spin 64s linear infinite;
}

.home-hero-fx__radar circle.fx-ring:nth-of-type(2) {
  stroke: rgba(255, 255, 255, .2);
  stroke-dasharray: 26 10;
  animation-direction: reverse;
  animation-duration: 86s;
}

.home-hero-fx__radar line.fx-tick {
  stroke: rgba(121, 219, 230, .3);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.home-hero-fx__radar .fx-sweep {
  transform-box: view-box;
  transform-origin: 300px 300px;
  animation: hfx-radar-sweep 8.5s linear infinite;
}

.home-hero-fx__radar .fx-sweep path {
  fill: url("#hfx-sweep-grad");
}

.home-hero-fx__radar .fx-sweep line {
  stroke: url("#hfx-sweep-grad");
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.home-hero-fx__radar circle.fx-ping {
  fill: none;
  stroke: rgba(121, 219, 230, .6);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  animation: hfx-ping 4.6s ease-out infinite;
}

.home-hero-fx__radar circle.fx-ping.is-warm {
  stroke: rgba(237, 100, 40, .5);
  animation-delay: 2.3s;
}

@keyframes hfx-ring-spin {
  to { transform: rotate(360deg); }
}

@keyframes hfx-radar-sweep {
  to { transform: rotate(360deg); }
}

@keyframes hfx-ping {
  0%   { transform: scale(.16); opacity: 0; }
  12%  { opacity: .9; }
  70%  { transform: scale(1); opacity: .12; }
  100% { transform: scale(1); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════
   6. orbits —— 左下通信枢纽（椭圆轨道 + 发光数据包；滚动轻微扩张）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__orbits {
  --fx-orbits-size: clamp(280px, 28vw, 430px);
  /* 首页 hero 为内容驱动（高度 ≈ 1.2×视口），bottom 锚定会落到首屏之外。
     改为 top 锚定：hub 进入首屏下部可见区，滚动离开时随 hero 上移。 */
  inset-inline-start: clamp(-36px, -2vw, 20px);
  top: clamp(400px, 50%, 640px);
  width: var(--fx-orbits-size);
  height: var(--fx-orbits-size);
  opacity: calc(.78 + var(--fx-progress) * .14);
  transform: scale(calc(1 + var(--fx-progress) * .1));
}

.home-hero-fx__orbits .fx-orbit {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(121, 219, 230, .3);
  border-radius: 50%;
  transform: scaleY(.34);
}

.home-hero-fx__orbits .fx-orbit:nth-child(2) {
  inset: 12%;
  border-color: rgba(255, 255, 255, .2);
}

.home-hero-fx__orbits .fx-orbit:nth-child(3) {
  inset: 24%;
  border-color: rgba(237, 100, 40, .3);
}

.home-hero-fx__orbits .fx-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, #d4f5fa 0%, rgba(121, 219, 230, .55) 45%, transparent 72%);
  box-shadow: 0 0 24px rgba(121, 219, 230, .7);
  animation: hfx-hub-pulse 3.2s ease-in-out infinite;
}

@keyframes hfx-hub-pulse {
  50% { transform: scale(1.5); box-shadow: 0 0 38px rgba(121, 219, 230, .95); }
}

/* 数据包复用 rotate+translateX 轨道动画；包体放在 scaleY(.34) 的
   椭圆轨道内，::after 反向 scaleY 抵消压扁保持正圆。 */
.home-hero-fx__orbits .fx-packet {
  --packet-start: 0deg;
  --packet-radius: calc(var(--fx-orbits-size) * .5);
  --packet-duration: 13s;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px;
  animation: hfx-packet-orbit var(--packet-duration) linear infinite;
  animation-delay: var(--packet-delay, 0s);
}

.home-hero-fx__orbits .fx-packet::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--fx-cyan);
  box-shadow: 0 0 13px rgba(121, 219, 230, .95), 0 0 28px rgba(121, 219, 230, .4);
  transform: scaleY(2.94);
}

.home-hero-fx__orbits .fx-packet.is-warm::after {
  background: var(--fx-orange);
  box-shadow: 0 0 13px rgba(237, 100, 40, .9), 0 0 28px rgba(237, 100, 40, .4);
}

.home-hero-fx__orbits .fx-packet.is-jade::after {
  background: var(--fx-jade);
  box-shadow: 0 0 13px rgba(112, 215, 174, .9), 0 0 28px rgba(112, 215, 174, .4);
}

@keyframes hfx-packet-orbit {
  from { transform: rotate(var(--packet-start)) translateX(var(--packet-radius)); }
  to   { transform: rotate(calc(var(--packet-start) + 360deg)) translateX(var(--packet-radius)); }
}

/* ═══════════════════════════════════════════════════════════════════════
   7. beam —— 垂直扫描光束（常驻横扫；滚动增亮）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__beam {
  inset-block: 0;
  inset-inline-start: 0;
  width: clamp(230px, 31vw, 500px);
  opacity: calc(.56 + var(--fx-progress) * .32);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(121, 219, 230, .1) 38%,
    rgba(121, 219, 230, .28) 50%,
    rgba(121, 219, 230, .1) 62%,
    transparent 100%
  );
  filter: blur(1.5px);
  mix-blend-mode: screen;
  animation: hfx-beam-sweep 8.6s cubic-bezier(.45, 0, .55, 1) infinite;
}

.home-hero-fx__beam::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(121, 219, 230, .6) 18%, rgba(121, 219, 230, .6) 82%, transparent);
}

@keyframes hfx-beam-sweep {
  0%   { translate: -34vw 0; }
  50%  { translate: 100vw 0; }
  100% { translate: -34vw 0; }
}

/* ═══════════════════════════════════════════════════════════════════════
   8. wave —— 底部数据波形（相位常驻流动，低透明度与 route-field 共存）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__wave {
  inset: auto 0 3% 0;
  height: clamp(64px, 10vh, 132px);
  opacity: calc(.36 + var(--fx-progress) * .28);
  -webkit-mask-image: linear-gradient(to top, #000 30%, transparent 95%);
  mask-image: linear-gradient(to top, #000 30%, transparent 95%);
}

.home-hero-fx__wave svg {
  inset: 0;
  width: 100%;
  height: 100%;
}

.home-hero-fx__wave path {
  fill: none;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 900 1400;
  animation: hfx-wave-flow 16s linear infinite;
}

.home-hero-fx__wave path:nth-child(1) { stroke: rgba(121, 219, 230, .45); }
.home-hero-fx__wave path:nth-child(2) { stroke: rgba(237, 100, 40, .34); animation-duration: 22s; animation-delay: -6s; }
.home-hero-fx__wave path:nth-child(3) { stroke: rgba(112, 215, 174, .28); animation-duration: 27s; animation-delay: -12s; }

@keyframes hfx-wave-flow {
  to { stroke-dashoffset: -2300; }
}

/* ═══════════════════════════════════════════════════════════════════════
   9. cursor —— 鼠标跟随聚光灯 + 十字准线（仅 fine pointer 创建）
   ═══════════════════════════════════════════════════════════════════════ */
.home-hero-fx__cursor {
  inset: 0;
  opacity: 0;
  transition: opacity .45s ease;
}

.home-hero-fx__cursor.is-engaged {
  opacity: 1;
}

.home-hero-fx__cursor .fx-spotlight {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(360px, 38vw, 640px);
  height: clamp(360px, 38vw, 640px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(121, 219, 230, .15) 0%, rgba(43, 118, 162, .07) 42%, transparent 68%);
  mix-blend-mode: screen;
  pointer-events: none;
}

.home-hero-fx__cursor .fx-cross-v,
.home-hero-fx__cursor .fx-cross-h {
  position: absolute;
  left: 0;
  top: 0;
  background: rgba(121, 219, 230, .18);
  pointer-events: none;
}

.home-hero-fx__cursor .fx-cross-v {
  width: 1px;
  height: 100%;
}

.home-hero-fx__cursor .fx-cross-h {
  width: 100%;
  height: 1px;
}

/* 指针视差：translate 独立属性与关键帧 transform 正交合成（景深分层） */
.home-hero-fx__aurora   { translate: calc((var(--fx-px) - .5) * -6px)  calc((var(--fx-py) - .5) * -6px); }
.home-hero-fx__grid     { translate: calc((var(--fx-px) - .5) * 10px)  calc((var(--fx-py) - .5) * 6px); }
.home-hero-fx__circuit  { translate: calc((var(--fx-px) - .5) * -16px) calc((var(--fx-py) - .5) * -12px); }
.home-hero-fx__nodes    { translate: calc((var(--fx-px) - .5) * -26px) calc((var(--fx-py) - .5) * -20px); }
.home-hero-fx__radar    { translate: calc((var(--fx-px) - .5) * 14px)  calc((var(--fx-py) - .5) * 10px); }
.home-hero-fx__orbits   { translate: calc((var(--fx-px) - .5) * -10px) calc((var(--fx-py) - .5) * 8px); }
.home-hero-fx__wave     { translate: calc((var(--fx-px) - .5) * 8px)   calc((var(--fx-py) - .5) * -4px); }

/* 聚光灯/准线跟随（hero 首屏近似全视口，vw/vh 即 hero 坐标） */
.home-hero-fx__cursor .fx-spotlight {
  translate: calc(var(--fx-px) * 100vw - 50%) calc(var(--fx-py) * 100svh - 50%);
}

.home-hero-fx__cursor .fx-cross-v { translate: calc(var(--fx-px) * 100vw) 0; }
.home-hero-fx__cursor .fx-cross-h { translate: 0 calc(var(--fx-py) * 100svh); }

/* ═══════════════════════════════════════════════════════════════════════
   响应式降档
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1020px) {
  .home-hero-fx__radar {
    inset-inline-end: -120px;
    top: -80px;
    width: 520px;
    height: 520px;
    opacity: .55;
  }
  .home-hero-fx__orbits {
    top: clamp(480px, 58%, 700px);
    opacity: calc(.5 + var(--fx-progress) * .1);
    transform: none;
  }
  .home-hero-fx__grid { transform: rotateX(60deg); }
  .home-hero-fx__circuit { opacity: .48; }
  .home-hero-fx__cursor { display: none; }
}

@media (max-width: 720px) {
  .home-hero-fx__radar {
    width: 380px;
    height: 380px;
    inset-inline-end: -100px;
    top: -40px;
  }
  .home-hero-fx__orbits {
    width: 200px;
    height: 200px;
  }
  .home-hero-fx__wave { height: 58px; }
}
