/* ============================================================
   交互特效（进阶版）—— 由 /js/site.js 驱动
   目标：有存在感，但不影响阅读
   ============================================================ */

/* ---------- 顶部阅读进度条 ---------- */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  z-index: 9999;
  background: linear-gradient(90deg, #8fb7d1, #5b7c99, #8f7fa0);
  box-shadow: 0 0 10px rgba(91, 124, 153, .5);
  transition: width .12s linear;
  pointer-events: none;
}

/* ---------- 鼠标柔光 ---------- */
#np-cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 320px;
  margin: -160px 0 0 -160px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9997;
  opacity: 0;
  background: radial-gradient(circle, rgba(143, 183, 209, .22) 0%, rgba(143, 183, 209, .10) 38%, transparent 68%);
  transition: opacity .4s ease;
  will-change: transform;
}

#np-cursor-glow.on {
  opacity: 1;
}

/* ---------- 花瓣 ---------- */
#np-petals {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9996;
  opacity: .75;
}

/* ---------- 首屏标题渐变 ---------- */
#page-header #site-title {
  background: linear-gradient(100deg, #ffffff 10%, #cfe3f0 40%, #ffffff 60%, #e7d9ea 85%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, .35));
  animation: np-shine 9s ease-in-out infinite;
}

@keyframes np-shine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ---------- 卡片：跟随鼠标的光斑 + 微倾斜 ---------- */
.np-tilt {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}

.np-tilt::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
  background: radial-gradient(220px circle at var(--np-mx, 50%) var(--np-my, 50%),
      rgba(255, 255, 255, .55), transparent 62%);
}

.np-tilt:hover::after {
  opacity: 1;
}

/* ---------- 头像柔光 ---------- */
#aside-content .card-info .avatar-img,
#aside-content .card-info img.avatar-img {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .55), 0 0 28px rgba(91, 124, 153, .45);
  transition: box-shadow .4s ease, transform .4s ease;
}

#aside-content .card-info .avatar-img:hover {
  transform: scale(1.04) rotate(-2deg);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .7), 0 0 38px rgba(91, 124, 153, .6);
}

/* ---------- 进入视口渐显 ---------- */
.reveal-init {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .7s cubic-bezier(.22, .61, .36, 1), transform .7s cubic-bezier(.22, .61, .36, 1);
}

.reveal-in {
  opacity: 1;
  transform: none;
}

/* ---------- 页面切换淡入 ---------- */
body.np-pjax-out #page {
  opacity: .35;
  transform: translateY(6px);
}

#page {
  transition: opacity .28s ease, transform .28s ease;
}

/* ---------- 导航链接下划线动画 ---------- */
#nav .menus_item > a,
#nav a {
  position: relative;
}

#nav .menus_item > a::after,
#nav > #menus a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 2px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .3s ease;
}

#nav .menus_item > a:hover::after,
#nav > #menus a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ---------- 回到顶部：进度环 ---------- */
#go-up {
  box-shadow: 0 6px 20px rgba(23, 35, 61, .18);
  transition: transform .25s ease, box-shadow .25s ease;
}

#go-up:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(23, 35, 61, .26);
}

/* ---------- 图片悬停 ---------- */
#article-container img:hover {
  transform: scale(1.012);
  transition: transform .4s ease;
}

/* ---------- 音乐悬浮球 ---------- */
#mini-player {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  user-select: none;
}

#mp-orb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 26px rgba(23, 35, 61, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: #5b7c99;
  font-size: 19px;
  transition: transform .25s ease, box-shadow .25s ease;
}

#mp-orb:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 12px 30px rgba(23, 35, 61, .24);
}

#mp-orb.playing {
  animation: mp-pulse 2.6s ease-in-out infinite;
}

@keyframes mp-pulse {
  0%, 100% { box-shadow: 0 8px 26px rgba(23, 35, 61, .18); }
  50% { box-shadow: 0 8px 32px rgba(91, 124, 153, .55); }
}

#mp-panel {
  width: 330px;
  max-width: calc(100vw - 40px);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, .65);
  box-shadow: 0 18px 46px rgba(23, 35, 61, .22);
  transform-origin: bottom right;
  transition: opacity .28s ease, transform .28s ease;
}

#mp-panel.hidden {
  opacity: 0;
  transform: scale(.92) translateY(8px);
  pointer-events: none;
}

#mp-panel iframe {
  display: block;
  width: 100%;
  height: 418px;
  border: 0;
}

#mp-close {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  border: none;
  background: rgba(23, 35, 61, .08);
  color: #55595f;
  cursor: pointer;
  font-size: 14px;
}

#mini-player.dragging #mp-orb,
#mini-player.dragging #mp-panel {
  transition: none;
}

/* ---------- 暗色适配 ---------- */
[data-theme='dark'] #mp-orb {
  background: rgba(32, 36, 42, .85);
  color: #cbd5df;
}

[data-theme='dark'] #mp-panel {
  background: rgba(28, 32, 38, .9);
  border-color: rgba(255, 255, 255, .12);
}

[data-theme='dark'] .np-tilt::after {
  background: radial-gradient(220px circle at var(--np-mx, 50%) var(--np-my, 50%),
      rgba(143, 183, 209, .22), transparent 62%);
}

/* ---------- 手机端：关掉重特效 ---------- */
@media screen and (max-width: 768px) {
  #mini-player {
    right: 14px;
    bottom: 14px;
  }
  #mp-panel {
    width: 290px;
  }
  #np-cursor-glow,
  #np-petals {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #np-cursor-glow,
  #np-petals {
    display: none;
  }
  #page-header #site-title {
    animation: none;
  }
  .reveal-init {
    opacity: 1;
    transform: none;
  }
}
