/* ============================================================
   幻 · HUAN2022A — 视觉特效增强（fx.css）
   1. 视图切换过场 fadeSlide（fx.js 触发 .fx-view-enter）
   2. 光标拖尾粒子（fx.js 对象池驱动 .fx-trail）
   3. 区块分隔光效（.section::after 渐变细线 + 光脉冲）
   4. Konami 矩阵数字雨 overlay（fx.js 创建 .fx-matrix）
   5. 导航 logo 扫光（.nav-logo::before）
   零外部依赖；所有类名带 fx- 前缀，避免与其他模块冲突
   ============================================================ */

/* ---------- 1. 视图切换过场：300ms fadeSlide 入场 ---------- */
@keyframes fx-fade-slide {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.fx-view-enter {
  animation: fx-fade-slide .3s cubic-bezier(.22, .8, .3, 1) both;
}

/* ---------- 2. 光标拖尾粒子（对象池上限 40，600ms 渐隐） ---------- */
.fx-trail {
  position: fixed; left: 0; top: 0; z-index: 89; /* 略低于自定义光标(90) */
  width: var(--s, 4px); height: var(--s, 4px);
  border-radius: 50%;
  background: rgb(var(--c, 0, 229, 255));
  box-shadow: 0 0 6px rgb(var(--c, 0, 229, 255));
  opacity: 0;                 /* 空闲态不可见 */
  pointer-events: none;
  will-change: transform, opacity;
}
.fx-trail.run { animation: fx-trail-fade .6s ease-out both; }
@keyframes fx-trail-fade {
  from { opacity: .9; transform: translate(var(--x, 0px), var(--y, 0px)) scale(1); }
  to   { opacity: 0;  transform: translate(calc(var(--x, 0px) + var(--dx, 0px)),
                                          calc(var(--y, 0px) + var(--dy, 0px))) scale(.15); }
}

/* ---------- 3. 区块分隔光效：底部细线 + 8s 循环光脉冲 ---------- */
.section { position: relative; } /* 为 ::after 提供定位基准（原本为 static，无副作用） */
.section::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  pointer-events: none;
  /* 上层：140px 宽的光脉冲沿线下移动；下层：青→紫→粉低透明度基线 */
  background-image:
    linear-gradient(90deg, transparent, rgba(0, 229, 255, .45) 50%, transparent),
    linear-gradient(90deg, rgba(0, 229, 255, .16), rgba(167, 139, 250, .18) 50%, rgba(255, 46, 136, .16));
  background-size: 140px 1px, 100% 1px;
  background-repeat: no-repeat;
  box-shadow: 0 0 8px rgba(0, 229, 255, .07); /* 极弱的静态辉光 */
  animation: fx-line-pulse 8s linear infinite;
}
@keyframes fx-line-pulse {
  from { background-position: -140px 0, 0 0; }
  to   { background-position: calc(100% + 140px) 0, 0 0; }
}

/* ---------- 4. 矩阵数字雨 overlay：z-index 999，整体透明度上限 0.5 ---------- */
.fx-matrix {
  position: fixed; inset: 0; z-index: 999;
  width: 100vw; height: 100vh;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease;
}
.fx-matrix.on { opacity: .5; } /* 淡入上限，保证不遮挡阅读 */

/* ---------- 5. 导航 logo 扫光：hover 时一道光从左到右 ---------- */
.nav-logo { position: relative; overflow: hidden; }
.nav-logo::before {
  content: "";
  position: absolute; top: -15%; bottom: -15%; left: 0; width: 34%;
  background: linear-gradient(105deg,
    transparent, rgba(0, 229, 255, .38) 45%, rgba(255, 255, 255, .5) 50%,
    rgba(0, 229, 255, .38) 55%, transparent);
  transform: translateX(-120%) skewX(-18deg); /* 初始藏在左侧外 */
  pointer-events: none;
}
.nav-logo:hover::before { animation: fx-logo-sweep .85s cubic-bezier(.3, .6, .3, 1); }
@keyframes fx-logo-sweep {
  to { transform: translateX(320%) skewX(-18deg); }
}

/* ---------- 触屏：拖尾粒子由 fx.js 禁用，CSS 兜底隐藏；logo 扫光为 hover 专属，避免点按后粘连 ---------- */
@media (hover: none), (pointer: coarse) {
  .fx-trail { display: none; }
  .nav-logo:hover::before { animation: none; }
}

/* ---------- iOS 地址栏：矩阵雨 overlay 改用 svh 视口（支持时生效，桌面 vh==svh 无变化） ---------- */
@supports (height: 100svh) {
  .fx-matrix { height: 100svh; }
}

/* ---------- 动效降级：reduced-motion 下所有新动效关闭 ---------- */
@media (prefers-reduced-motion: reduce) {
  .fx-view-enter,
  .fx-trail,
  .fx-trail.run { animation: none !important; opacity: 0 !important; }
  .section::after { animation: none !important; }
  .fx-matrix { animation: none !important; transition: none !important; opacity: 0 !important; }
  .nav-logo:hover::before { animation: none !important; opacity: 0; }
}
