/**
 * visual-enhancements.css — 超级视觉交互增强层
 * 绰瑞超创 · 2026
 * 配合 visual-engine.js 使用
 */

/* ===== 自定义光标光环 ===== */
.cursor-aura {
  position: fixed;
  width: 28px; height: 28px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 99998;
  transform: translate(-50%, -50%);
  transition: width 0.25s, height 0.25s, border-color 0.25s, opacity 0.25s;
  opacity: 0;
  mix-blend-mode: screen;
}
.cursor-aura.active { opacity: 0.6; }
.cursor-aura.hover {
  width: 48px; height: 48px;
  border-color: var(--accent);
  opacity: 0.8;
}
.cursor-dot {
  position: fixed;
  width: 6px; height: 6px;
  background: var(--primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 99999;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 0 8px var(--primary);
}
.cursor-dot.active { opacity: 1; }
@media (hover: none), (max-width: 768px) {
  .cursor-aura, .cursor-dot { display: none !important; }
}

/* ===== 粒子画布 ===== */
#particleCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
  contain: strict; /* 性能：隔离布局与绘制 */
}

/* ===== 滚动渐入动画 ===== */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}
.reveal.reveal-left { transform: translateX(-40px); }
.reveal.reveal-right { transform: translateX(40px); }
.reveal.reveal-left.revealed,
.reveal.reveal-right.revealed { transform: translateX(0); }
.reveal.reveal-scale { transform: scale(0.85); }
.reveal.reveal-scale.revealed { transform: scale(1); }
.reveal.reveal-blur { filter: blur(12px); }
.reveal.reveal-blur.revealed { filter: blur(0); }

/* 交错延迟 */
.reveal[data-delay="1"] { transition-delay: 0.08s; }
.reveal[data-delay="2"] { transition-delay: 0.16s; }
.reveal[data-delay="3"] { transition-delay: 0.24s; }
.reveal[data-delay="4"] { transition-delay: 0.32s; }
.reveal[data-delay="5"] { transition-delay: 0.40s; }
.reveal[data-delay="6"] { transition-delay: 0.48s; }

/* ===== 3D 倾斜卡片 ===== */
.tilt-card {
  transform-style: preserve-3d;
  transition: transform 0.15s ease-out, box-shadow 0.3s;
  will-change: transform;
}
.tilt-card .tilt-inner {
  transform: translateZ(30px);
  transform-style: preserve-3d;
}
.tilt-card .tilt-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle at var(--shine-x, 50%) var(--shine-y, 50%),
    rgba(255,255,255,0.15) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 2;
}
.tilt-card:hover .tilt-shine { opacity: 1; }
@media (hover: none) { .tilt-card { transform: none !important; } }

/* ===== 磁性按钮 ===== */
.magnetic-btn {
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* ===== 动画计数器 ===== */
.counter {
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

/* ===== 渐变光球（浮动装饰） ===== */
.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
  will-change: transform, opacity;
  contain: paint; /* 性能：隔离绘制 */
}
.gradient-orb.orb-1 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, var(--primary), transparent 70%);
  top: 10%; left: -5%;
  animation: orbFloat1 18s ease-in-out infinite;
}
.gradient-orb.orb-2 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, var(--secondary), transparent 70%);
  bottom: 15%; right: -3%;
  animation: orbFloat2 22s ease-in-out infinite;
}
.gradient-orb.orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  top: 50%; right: 20%;
  animation: orbFloat3 16s ease-in-out infinite;
  opacity: 0.25;
}
@keyframes orbFloat1 {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(60px,-40px) scale(1.15); }
  66% { transform: translate(-30px,50px) scale(0.9); }
}
@keyframes orbFloat2 {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(-50px,30px) scale(1.2); }
  66% { transform: translate(40px,-50px) scale(0.85); }
}
@keyframes orbFloat3 {
  0%,100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-80px,-60px) scale(1.3); }
}

/* ===== 打字机光标 ===== */
.typewriter-cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--primary);
  margin-left: 4px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
  box-shadow: 0 0 8px var(--primary);
}
@keyframes blink {
  0%,50% { opacity: 1; }
  51%,100% { opacity: 0; }
}

/* ===== 增强卡片玻璃态 ===== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.glass-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.5;
}

/* ===== 涟漪效果 ===== */
.ripple {
  position: relative;
  overflow: hidden;
}
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* ===== 页面渐入 ===== */
.page-fade-in {
  animation: pageFadeIn 0.5s ease-out;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 浮动动画 ===== */
.float-anim {
  animation: floatY 4s ease-in-out infinite;
}
@keyframes floatY {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ===== 文字渐变流动 ===== */
.text-gradient-flow {
  background: linear-gradient(135deg, var(--primary), var(--accent), var(--secondary), var(--primary));
  background-size: 300% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: textGradientFlow 6s ease infinite;
}
@keyframes textGradientFlow {
  0% { background-position: 0% center; }
  100% { background-position: 300% center; }
}

/* ===== 导航栏滑入指示器 ===== */
.nav-slide-indicator {
  position: absolute;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  border-radius: 2px;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 10;
}

/* ===== 滚动进度条（顶部） ===== */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--secondary));
  z-index: 9997;
  transition: transform 0.1s linear;
  box-shadow: 0 0 10px var(--primary);
}

/* ===== 卡片悬浮光晕 ===== */
.post-card, .t-tutorial-card, .t-cat-card {
  position: relative;
}
.post-card::after, .t-tutorial-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background: radial-gradient(
    circle at var(--card-mx, 50%) var(--card-my, 50%),
    rgba(0,229,255,0.08) 0%,
    transparent 50%
  );
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 0;
}
.post-card:hover::after, .t-tutorial-card:hover::after {
  opacity: 1;
}

/* ===== 无障碍：减少动画 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; filter: none !important; }
  #particleCanvas, .cursor-aura, .cursor-dot { display: none !important; }
}
