/* ====== v4: 高级动态特效层(2026-09-28) ====== */

/* ---------- 1. 预加载动画 ---------- */
.preloader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-0);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 22px;
  transition: opacity 0.6s ease, visibility 0.6s;
}
.preloader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.preloader-inner {
  width: min(420px, 82vw);
  font-family: 'JetBrains Mono', monospace;
}
.preloader-line {
  font-size: 12px; letter-spacing: 1.5px;
  color: var(--text-2);
  opacity: 0; transform: translateX(-8px);
  transition: opacity 0.25s, transform 0.25s;
  line-height: 1.9;
}
.preloader-line.on { opacity: 1; transform: translateX(0); }
.preloader-line::before { content: '> '; color: var(--neon-cyan); }
.preloader-line:last-child.on { color: var(--neon-cyan); }
.preloader-line:last-child.on::after {
  content: '_'; animation: blink 0.9s steps(1) infinite; margin-left: 2px;
}
.preloader-bar {
  margin-top: 14px; height: 2px;
  background: rgba(120, 180, 255, 0.14);
  border-radius: 2px; overflow: hidden;
}
.preloader-bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
  box-shadow: 0 0 14px rgba(0, 212, 255, 0.7);
  transition: width 0.18s linear;
}
.preloader-pct {
  margin-top: 8px; font-size: 11px;
  color: var(--neon-cyan); letter-spacing: 3px;
}

/* 加载完成后才显示主体(避免闪烁) */
body:not(.loaded) .hero-content,
body:not(.loaded) .nav { opacity: 0; }

/* ---------- 2. 自定义光标 ---------- */
.cur-dot, .cur-ring {
  position: fixed; top: 0; left: 0; z-index: 9998;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s, width 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              height 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              border-color 0.28s, background 0.28s;
  margin-left: -3px; margin-top: -3px;
}
.cur-dot {
  width: 6px; height: 6px;
  background: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.9);
}
.cur-ring {
  width: 26px; height: 26px;
  margin-left: -13px; margin-top: -13px;
  border: 1px solid rgba(0, 212, 255, 0.55);
  backdrop-filter: invert(4%);
}
.cur-dot.on, .cur-ring.on { opacity: 1; }
.cur-ring.big {
  width: 46px; height: 46px;
  margin-left: -23px; margin-top: -23px;
  border-color: var(--neon-magenta);
  background: rgba(255, 79, 157, 0.08);
}
/* 触屏/无 hover 时隐藏 */
@media (hover: none), (pointer: coarse) {
  .cur-dot, .cur-ring { display: none; }
}

/* ---------- 3. 鼠标聚光 ---------- */
.project-card, .interest-card, .stat-card, .about-avatar {
  position: relative; isolation: isolate;
}
.spotlight {
  position: absolute; inset: 0; z-index: 4;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  background: radial-gradient(
    240px circle at var(--mx, 50%) var(--my, 50%),
    rgba(0, 212, 255, 0.16),
    rgba(255, 79, 157, 0.07) 42%,
    transparent 66%
  );
}
.project-card .spotlight { z-index: 5; }

/* ---------- 4. 磁吸按钮 ---------- */
.btn, .contact-link { will-change: transform; }

/* ---------- 5. 视差 ---------- */
.hero-nebula, .hero-canvas, .hero-content, .scroll-hint {
  will-change: transform;
}

/* ---------- 6. 字符扰动 ---------- */
.nav-links a, .section-title .accent, .project-title {
  transition: color 0.2s, text-shadow 0.2s;
  font-variant-ligatures: none;
}
.nav-links a { min-width: 3.2em; display: inline-block; }

/* ---------- 7. 区块标签打字 ---------- */
.section-tag.typed { position: relative; }
.section-tag.typed::after {
  content: '_';
  color: var(--neon-cyan);
  animation: blink 0.9s steps(1) infinite;
  margin-left: 3px;
}

/* ---------- 8. 数据雨 ---------- */
#rain-canvas {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: screen;
}
body { position: relative; }
/* 主体内容浮到数据雨之上
   注意:.nav 必须保持 position:fixed(style.css 已设),
   这里只能改 z-index,不能连带覆盖 position,否则导航会跟着页面滚走。 */
section, footer { position: relative; z-index: 1; }
.nav { z-index: 100; }
section { z-index: 1; }

/* ---------- 导航固定 + 渐变过渡(不突兀) ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: linear-gradient(180deg,
    rgba(5, 8, 22, 0.92) 0%,
    rgba(5, 8, 22, 0.72) 55%,
    rgba(5, 8, 22, 0.38) 82%,
    rgba(5, 8, 22, 0) 100%);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(120, 180, 255, 0.14);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  padding: 16px 32px 26px;
  transition: padding 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
              background 0.35s ease,
              box-shadow 0.35s ease,
              border-color 0.35s ease;
}
/* 滚动后收紧 + 渐变加实 */
.nav.scrolled {
  padding: 10px 32px 12px;
  background: linear-gradient(180deg,
    rgba(5, 8, 22, 0.97) 0%,
    rgba(5, 8, 22, 0.90) 62%,
    rgba(5, 8, 22, 0.66) 100%);
  border-bottom-color: rgba(0, 212, 255, 0.32);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.5),
              0 1px 0 rgba(0, 212, 255, 0.18);
}
/* 渐入动画(向下滚动时浮现,不硬切) */
.nav::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--neon-cyan) 22%,
    var(--neon-magenta) 58%,
    transparent 100%);
  opacity: 0;
  transform: scaleX(0.3);
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.nav.scrolled::after { opacity: 0.85; transform: scaleX(1); }

/* ---------- 当前所在板块高亮(滚动监听) ---------- */
.nav-links a.active { color: var(--neon-cyan); }
.nav-links a.active::before {
  content: '';
  position: absolute;
  left: 50%; top: -9px;
  width: 5px; height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan), 0 0 18px rgba(0, 212, 255, 0.6);
  animation: nav-dot-pulse 1.9s ease-in-out infinite;
}
@keyframes nav-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.55); opacity: 0.65; }
}

/* 首页入口:带房子标记 + 品红主色,与其他项区分 */
.nav-links a.nav-home {
  color: var(--neon-magenta);
  padding-left: 20px;
}
.nav-links a.nav-home::before {
  content: '\2302';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--neon-magenta);
  text-shadow: 0 0 8px rgba(255, 79, 157, 0.8);
}
.nav-links a.nav-home:hover {
  color: var(--neon-magenta);
  text-shadow: 0 0 10px rgba(255, 79, 157, 0.7);
}
.nav-links a.nav-home::after { display: none; }
.nav-links a.nav-home.active { color: var(--neon-magenta); }
.nav-links a.nav-home.active::after {
  display: block;
  background: linear-gradient(90deg, var(--neon-magenta), var(--neon-cyan));
}

/* 内容区顶部留白,避免固定导航遮挡 section 标题 */
section[id] { scroll-margin-top: 92px; }

/* 移动端:本文件在 style.css 之后加载,需自带覆盖 */
@media (max-width: 720px) {
  .nav { padding: 12px 20px 18px; }
  .nav.scrolled { padding: 9px 20px 10px; }
  .nav-links { display: none; }
  section[id] { scroll-margin-top: 72px; }
}

/* ---------- 9. 玻璃拟态强化 ---------- */
.project-card, .interest-card, .stat-card, .contact-link {
  backdrop-filter: blur(14px) saturate(1.25);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
}

/* ---------- 10. 霓虹文字发光呼吸 ---------- */
.section-title .accent, .contact-title .accent {
  animation: neon-breathe 4.5s ease-in-out infinite;
}
@keyframes neon-breathe {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(0, 212, 255, 0.35)); }
  50%      { filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.75)); }
}

/* ---------- 11. 边框流光卡片 ---------- */
.project-card, .interest-card {
  --edge: var(--neon-cyan);
}
.project-card::after, .interest-card::after {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--ang, 0deg),
    transparent 0deg, var(--neon-cyan) 60deg, var(--neon-magenta) 120deg, transparent 200deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  z-index: 6;
}
.project-card:hover::after, .interest-card:hover::after { opacity: 1; }
@property --ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.project-card, .interest-card {
  animation: ang-spin 3.2s linear infinite;
}
@keyframes ang-spin { to { --ang: 360deg; } }

/* ---------- 12. 减弱动效时全部关掉 ---------- */
@media (prefers-reduced-motion: reduce) {
  .preloader { display: none; }
  .cur-dot, .cur-ring, #rain-canvas { display: none !important; }
  .project-card, .interest-card, .section-title .accent, .contact-title .accent {
    animation: none !important;
  }
  .project-card::after, .interest-card::after { display: none; }
  body:not(.loaded) .hero-content, body:not(.loaded) .nav { opacity: 1; }
}

/* ---------- 13. 移动端瘦身 ---------- */
@media (max-width: 720px) {
  #rain-canvas { opacity: 0.10; }
  .project-card::after, .interest-card::after { display: none; }
  .preloader-inner { width: 86vw; }
}
