/* =========================================================
   光标跟随动效 — 仙人森林品牌配色（emerald / teal / lime）
   柔光晕（缓动跟随 + 物理形变）+ 拖尾链（水流转向）+ 精确圆点
   配色见下方 :root / 明暗主题变量
   ========================================================= */

/* 光晕 + 拖尾 + 精确圆点共用定位 */
.cursor-glow,
.cursor-trail,
.cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  transform: translate(-100px, -100px);
  will-change: transform;
}

/* 柔光晕：品牌三色径向渐变 + 模糊
   尺寸 / 透明度已收敛，避免盖住正文与按钮 */
.cursor-glow {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  z-index: 9998;
  background: radial-gradient(circle at 50% 50%,
      var(--cur-a) 0%,
      var(--cur-b) 38%,
      var(--cur-c) 62%,
      transparent 72%);
  filter: blur(28px);
  opacity: var(--cur-op);
  mix-blend-mode: var(--cur-blend);
  transition: width .25s ease, height .25s ease, opacity .25s ease;
}
body.cursor-hot .cursor-glow {
  width: 300px;
  height: 300px;
  opacity: calc(var(--cur-op) + .14);
}

/* 拖尾链（水流转向）：小尺寸、低透明、依次 lerp 跟随前一个，
   转弯时整条尾巴自然弯成弧线。尺寸 / 透明度由 JS 按序号递增设置 */
.cursor-trail {
  z-index: 9997;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
      var(--cur-a) 0%,
      var(--cur-b) 45%,
      transparent 70%);
  filter: blur(14px);
  mix-blend-mode: var(--cur-blend);
  transition: opacity .5s ease;   /* 待机时优雅淡出，避免静止还挂着尾巴 */
}

/* 待机藤蔓层（累积生长，不擦除）：茎一笔笔叠加上去 */
#cursor-idle-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9996;
}

/* 待机装饰层（叶 / 花）：叠在藤蔓之上，每帧擦除重画，
   用于"生长出现"动画（从 0 长到满、淡入），不直接画在累积层上 */
#cursor-idle-deco {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9996;
}

/* 待机时拖尾淡出 */
body.idle .cursor-trail { opacity: 0 !important; }

/* 精确小圆点：几乎贴着真实指针 */
.cursor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cur-dot);
  box-shadow: 0 0 12px var(--cur-dot-glow);
  z-index: 9999;
  transition: width .2s ease, height .2s ease;
}
body.cursor-hot .cursor-dot {
  width: 12px;
  height: 12px;
}

/* 品牌色（与站点 --accent-grad 一致） */
:root {
  --cur-a: #2bd47d;  /* emerald */
  --cur-b: #1fb6a6;  /* teal */
  --cur-c: #b6f24a;  /* lime */
}

/* 暗色：screen 混合 → 在深森林背景上自然发光（透明度已收敛） */
html[data-theme="dark"] {
  --cur-blend: screen;
  --cur-op: .38;
  --cur-dot: #eafff4;
  --cur-dot-glow: rgba(77, 255, 166, .9);
}

/* 亮色：纸色背景上用极低透明度绿雾，不挡正文；圆点转深色可见 */
html[data-theme="light"] {
  --cur-blend: normal;
  --cur-op: .14;
  --cur-dot: #06170f;
  --cur-dot-glow: rgba(31, 182, 166, .5);
}

/* 触摸设备 / 无鼠标：隐藏自定义光标，避免突兀 */
@media (hover: none), (pointer: coarse) {
  .cursor-glow,
  .cursor-trail,
  .cursor-dot { display: none !important; }
}
