/* ============ 全局特效层：开屏 / 粒子 / 扫描线 / 跑马灯 / 段落导航 / 故障字 ============ */

/* ---- 开屏过场 ---- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(63, 231, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(137, 88, 255, 0.07) 1px, transparent 1px),
    var(--ink);
  background-size: 58px 58px, 58px 58px, auto;
  transition: transform 0.7s cubic-bezier(0.7, 0, 0.18, 1) 0.32s;
}

.preloader::after {
  content: "";
  position: absolute;
  top: 100%;
  left: -10%;
  right: -10%;
  height: 24vh;
  background: linear-gradient(105deg, var(--lime) 30%, var(--cyan) 60%, var(--magenta));
  transform: skewY(-3deg);
  box-shadow: 0 -20px 60px rgba(182, 255, 61, 0.5);
}

.preloader.leave {
  transform: translateY(-130%);
}

.preloader-inner {
  display: grid;
  justify-items: center;
  gap: 18px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.preloader.leave .preloader-inner {
  opacity: 0;
  transform: translateY(-22px);
}

.preloader-logo {
  width: clamp(150px, 22vw, 230px);
  filter: drop-shadow(0 0 24px rgba(63, 231, 255, 0.5));
  animation: preloaderPulse 1.4s ease-in-out infinite;
}

.preloader-bar {
  width: 220px;
  height: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

.preloader-bar span {
  display: block;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  box-shadow: 0 0 14px rgba(182, 255, 61, 0.8);
  animation: preloaderBar 1s ease-in-out infinite;
}

.preloader-text {
  color: var(--muted);
  font-family: "Saira Condensed", "Noto Sans SC", sans-serif;
  font-style: italic;
  font-weight: 800;
  letter-spacing: 0.3em;
  font-size: 13px;
}

@keyframes preloaderPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 18px rgba(63, 231, 255, 0.4)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 34px rgba(182, 255, 61, 0.55)); }
}

@keyframes preloaderBar {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(280%); }
}

/* ---- 粒子画布 ---- */
#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.85;
}

/* ---- 扫描线 + 光带 ---- */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 41;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.028) 0 1px,
    transparent 1px 4px
  );
  opacity: 0.5;
}

.scanlines::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12%;
  height: 10%;
  background: linear-gradient(180deg, transparent, rgba(63, 231, 255, 0.07), transparent);
  animation: scanSweep 7s linear infinite;
}

@keyframes scanSweep {
  to { transform: translateY(1300%); }
}

/* ---- 段落跑马灯 ---- */
.section-marquee {
  position: absolute;
  top: 0;
  left: -2%;
  right: -2%;
  z-index: 6;
  overflow: hidden;
  padding: 8px 0;
  border-top: 2px solid rgba(5, 6, 13, 0.9);
  border-bottom: 2px solid rgba(5, 6, 13, 0.9);
  transform: rotate(-1.1deg) translateY(-32%);
  font-family: "Saira Condensed", "Noto Sans SC", sans-serif;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(14px, 1.4vw, 20px);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.marquee-lime {
  background: linear-gradient(100deg, var(--lime), #d4ff5e 60%, var(--cyan));
  color: #0a1206;
  box-shadow: 0 5px 0 rgba(255, 75, 183, 0.78), 0 0 34px rgba(182, 255, 61, 0.3);
}

.marquee-magenta {
  background: linear-gradient(100deg, var(--magenta), #ff6fce 55%, var(--violet));
  color: #fff;
  text-shadow: 1px 1px 0 rgba(5, 6, 13, 0.6);
  box-shadow: 0 5px 0 rgba(63, 231, 255, 0.66), 0 0 34px rgba(255, 75, 183, 0.3);
  transform: rotate(1.1deg) translateY(-32%);
}

.marquee-track {
  display: inline-flex;
  width: max-content;
  animation: marqueeRoll 26s linear infinite;
}

@keyframes marqueeRoll {
  to { transform: translateX(-50%); }
}

/* ---- 右侧段落导航点 ---- */
.section-dots {
  position: fixed;
  right: clamp(14px, 2.4vw, 34px);
  top: 50%;
  z-index: 120;
  display: grid;
  gap: 22px;
  transform: translateY(-50%);
}

.section-dots button {
  position: relative;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.section-dots i {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(5, 6, 13, 0.6);
  transform: rotate(45deg);
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.section-dots span {
  position: absolute;
  right: 26px;
  top: 50%;
  padding: 3px 10px;
  background: rgba(5, 6, 13, 0.86);
  border: 1px solid rgba(63, 231, 255, 0.4);
  color: var(--cyan);
  font-family: "Saira Condensed", sans-serif;
  font-style: italic;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  opacity: 0;
  transform: translate(8px, -50%);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
}

.section-dots button:hover span {
  opacity: 1;
  transform: translate(0, -50%);
}

.section-dots button:hover i {
  border-color: var(--cyan);
}

.section-dots button.active i {
  border-color: var(--lime);
  background: var(--lime);
  transform: rotate(45deg) scale(1.25);
  box-shadow: 0 0 14px rgba(182, 255, 61, 0.8);
}

/* ---- 故障字（标题用） ---- */
.glitch {
  position: relative;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  clip-path: inset(50% 0 50% 0);
}

.glitch::before {
  text-shadow: -3px 0 var(--magenta);
  animation: glitchSliceA 5.6s steps(1) infinite;
}

.glitch::after {
  text-shadow: 3px 0 var(--cyan);
  animation: glitchSliceB 7.3s steps(1) infinite;
}

@keyframes glitchSliceA {
  0%, 88%, 100% { opacity: 0; clip-path: inset(50% 0 50% 0); transform: none; }
  89% { opacity: 0.85; clip-path: inset(8% 0 64% 0); transform: translate(-5px, -2px); }
  92% { opacity: 0.85; clip-path: inset(52% 0 18% 0); transform: translate(4px, 2px); }
  95% { opacity: 0.85; clip-path: inset(30% 0 42% 0); transform: translate(-3px, 1px); }
  97% { opacity: 0; }
}

@keyframes glitchSliceB {
  0%, 56%, 66%, 100% { opacity: 0; clip-path: inset(50% 0 50% 0); transform: none; }
  57% { opacity: 0.8; clip-path: inset(64% 0 6% 0); transform: translate(5px, 2px); }
  60% { opacity: 0.8; clip-path: inset(12% 0 58% 0); transform: translate(-4px, -2px); }
  63% { opacity: 0.8; clip-path: inset(40% 0 34% 0); transform: translate(3px, -1px); }
}

/* 图片故障抖动（只动 filter，避免覆盖 transform） */
@keyframes imgGlitch {
  0%, 92%, 100% { filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.62)); }
  93% { filter: drop-shadow(-6px 0 0 rgba(255, 75, 183, 0.8)) drop-shadow(0 12px 28px rgba(0, 0, 0, 0.62)) hue-rotate(18deg); }
  95% { filter: drop-shadow(6px 0 0 rgba(63, 231, 255, 0.8)) drop-shadow(0 12px 28px rgba(0, 0, 0, 0.62)); }
  97% { filter: drop-shadow(-3px 0 0 rgba(182, 255, 61, 0.7)) drop-shadow(0 12px 28px rgba(0, 0, 0, 0.62)) hue-rotate(-14deg); }
}

/* ---- 通用进场关键帧 ---- */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(38px); }
}

@keyframes fadeIn {
  from { opacity: 0; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(64px); }
}

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

/* ---- 弱动效偏好 ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #fx-canvas,
  .scanlines {
    display: none;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
