/* =========================================
   音乐播放器漂亮样式
   旋转CD + 毛玻璃 + 动态歌词
   兼容性优化：简化多层box-shadow，添加移动端响应式
   ========================================= */

/* ---------- 音乐页面容器 ---------- */
.music-page {
  padding-bottom: var(--space-8);
}

/* ---------- 播放器主体 - 毛玻璃效果 ---------- */
.music-player-box {
  background: rgba(10, 5, 20, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 24px;
  padding: var(--space-8) var(--space-6);
  text-align: center;
  /* 简化为两层 box-shadow，兼容性更好 */
  box-shadow: 0 8px 32px rgba(168, 85, 247, 0.3);
  position: relative;
  overflow: hidden;
}

/* 光晕背景 - 使用封面图模糊 */
.music-player-box::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -30%;
  width: 160%;
  height: 160%;
  background-image: url('../images/blue-shift-cover.jpg');
  background-size: cover;
  background-position: center;
  filter: blur(50px) saturate(1.5) brightness(0.7);
  -webkit-filter: blur(50px) saturate(1.5) brightness(0.7);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

/* 让播放器内容层叠在模糊背景之上 */
.cd-container,
.music-song-info,
.lrc-display,
.music-controls,
.progress-section {
  position: relative;
  z-index: 2;
}

/* ---------- 旋转光盘（带真实封面）---------- */
.cd-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto var(--space-6);
}

/* 地面投影：椭圆深色阴影 - 简化为一层 */
.cd-container::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 24px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, transparent 70%);
  border-radius: 50%;
  z-index: 0;
}

.cd-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0a0514;
  /* 简化为两层 box-shadow：主投影 + 紫色发光 */
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(168, 85, 247, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cd-rotate 8s linear infinite;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

/* 专辑封面图 - 添加边缘高光（使用更简单的方法） */
.cd-cover {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  z-index: 1;
  /* 简化为两层：内发光 + 边缘高光 */
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.08),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
}

/* 封面图加载失败时的回退图标 */
.cd-cover-fallback {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3) 0%, transparent 50%),
    radial-gradient(circle at center, #2a1a4a 0%, #1a0a3a 100%);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  z-index: 1;
}

/* 光盘外圈：银色边缘 */
.cd-disc::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.08);
  z-index: 2;
  pointer-events: none;
}

/* 光盘内部：径向渐变高光（左上光源）*/
.cd-disc::after {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 25% 25%, rgba(255, 255, 255, 0.12) 0%, transparent 50%);
  z-index: 2;
  pointer-events: none;
}

/* CD中心孔 - 简化为两层阴影 */
.cd-center {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #1a0a2e 0%, #0a0514 60%, #000 100%);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.15),
    0 0 8px rgba(168, 85, 247, 0.3);
  position: relative;
  z-index: 3;
}

/* 光盘发光层 */
.cd-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  background: radial-gradient(ellipse at center, rgba(168, 85, 247, 0.3) 0%, transparent 70%);
  border-radius: 50%;
  z-index: 1;
  animation: glow-pulse 2s ease-in-out infinite;
}

/* 旋转动画 */
@keyframes cd-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); }
}

/* 播放时停止旋转 */
.cd-disc.paused {
  animation-play-state: paused;
}

/* ---------- 歌曲信息 ---------- */
.music-song-info {
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 2;
}

.music-song-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.music-song-artist {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ---------- 歌词显示（多行滚动） ---------- */
.lrc-display {
  margin-bottom: var(--space-6);
  position: relative;
  z-index: 2;
}

/* 歌词视窗：固定高度，带上下渐隐 */
.lrc-viewport {
  height: 180px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.6) 15%,
    rgba(0, 0, 0, 1) 35%,
    rgba(0, 0, 0, 1) 65%,
    rgba(0, 0, 0, 0.6) 85%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 0, 0, 0.6) 15%,
    rgba(0, 0, 0, 1) 35%,
    rgba(0, 0, 0, 1) 65%,
    rgba(0, 0, 0, 0.6) 85%,
    transparent 100%
  );
}

/* 歌词列表：用 transform 平移，平滑过渡（缩短到 0.15s 减少累积误差） */
.lrc-wrapper {
  transition: transform 0.15s ease-out;
  will-change: transform;
  text-align: center;
}

/* 普通歌词行 */
.lrc-line {
  line-height: 36px;
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0.45;
  transition: color 0.3s ease, opacity 0.3s ease, text-shadow 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

/* 当前行：高亮，亮色，稍大（重要：line-height/height 保持不变，避免滚动计算误差） */
.lrc-line.lrc-active {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  opacity: 1;
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
  line-height: 36px;
  height: 36px;
}

/* ---------- 播放控制按钮 ---------- */
.music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  position: relative;
  z-index: 2;
}

.ctrl-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-primary);
  padding: 0;
  /* 关键：防止触摸时出现蓝色高亮 */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

.ctrl-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.ctrl-btn:hover {
  background: rgba(168, 85, 247, 0.25);
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
}

/* 播放按钮 - 更大更突出，永远保持紫色渐变和发光 */
.play-ctrl-btn {
  position: relative;
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #A855F7 0%, #EC4899 100%) !important;
  background-image: linear-gradient(135deg, #A855F7 0%, #EC4899 100%) !important;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  /* 简化为两层 box-shadow：投影 + 发光 */
  box-shadow:
    0 4px 20px rgba(168, 85, 247, 0.5),
    0 0 40px rgba(168, 85, 247, 0.3) !important;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

.play-ctrl-btn svg {
  width: 28px;
  height: 28px;
  fill: white !important;
}

.play-ctrl-btn:hover {
  transform: scale(1.08);
  background: linear-gradient(135deg, #A855F7 0%, #EC4899 100%) !important;
  background-image: linear-gradient(135deg, #A855F7 0%, #EC4899 100%) !important;
  box-shadow:
    0 6px 30px rgba(168, 85, 247, 0.6),
    0 0 60px rgba(168, 85, 247, 0.4) !important;
}

/* 播放中状态：独立的呼吸光晕层 */
.play-ctrl-btn.is-playing::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  box-shadow:
    0 0 20px rgba(168, 85, 247, 0.6),
    0 0 40px rgba(236, 72, 153, 0.4);
  animation: pulse-glow 2s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.7;
    box-shadow:
      0 0 20px rgba(168, 85, 247, 0.5),
      0 0 40px rgba(236, 72, 153, 0.3);
  }
  50% {
    opacity: 1;
    box-shadow:
      0 0 30px rgba(168, 85, 247, 0.7),
      0 0 60px rgba(236, 72, 153, 0.5);
  }
}

/* 手机端点击瞬间：保持紫色渐变 */
.play-ctrl-btn:active {
  background: linear-gradient(135deg, #A855F7 0%, #EC4899 100%) !important;
  box-shadow:
    0 4px 20px rgba(168, 85, 247, 0.5),
    0 0 60px rgba(168, 85, 247, 0.3) !important;
  transform: scale(0.96);
}

/* 焦点态：保持紫色渐变（关键修复：防止手机端点击后焦点态覆盖默认样式） */
.play-ctrl-btn:focus,
.play-ctrl-btn:focus-visible {
  outline: none;
  background: linear-gradient(135deg, #A855F7 0%, #EC4899 100%) !important;
  background-image: linear-gradient(135deg, #A855F7 0%, #EC4899 100%) !important;
  box-shadow:
    0 4px 20px rgba(168, 85, 247, 0.5),
    0 0 40px rgba(168, 85, 247, 0.3) !important;
}

/* 普通控制按钮的焦点态也处理一下 */
.ctrl-btn:not(.play-ctrl-btn):focus {
  background: rgba(168, 85, 247, 0.15) !important;
}

/* ---------- 进度条 ---------- */
.progress-section {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
  z-index: 2;
}

.time-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: rgba(168, 85, 247, 0.2);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #A855F7, #EC4899);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.progress-track:hover .progress-thumb {
  opacity: 1;
}

/* ---------- 隐藏原生APlayer容器 ---------- */
#aplayer {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* =========================================
   移动端响应式（核心修复！）
   ========================================= */
@media (max-width: 768px) {

  /* 播放器主体：减小内边距 */
  .music-player-box {
    padding: var(--space-6) var(--space-4);
    border-radius: 20px;
  }

  /* CD光盘：缩小尺寸 */
  .cd-container {
    width: 160px;
    height: 160px;
  }

  .cd-container::after {
    width: 120px;
    height: 18px;
    bottom: -15px;
  }

  .cd-center {
    width: 20px;
    height: 20px;
  }

  .cd-cover-fallback {
    font-size: 44px;
  }

  .cd-glow {
    width: 160px;
    height: 160px;
  }

  /* 歌曲信息：缩小字体 */
  .music-song-name {
    font-size: 1.1rem;
  }

  .music-song-artist {
    font-size: 0.85rem;
  }

  /* 歌词视窗：减小高度 */
  .lrc-viewport {
    height: 144px;
  }

  .lrc-line {
    line-height: 28px;
    height: 28px;
    font-size: 12px;
    padding: 0 8px;
    transition: color 0.3s ease, opacity 0.3s ease, text-shadow 0.3s ease;
    box-sizing: border-box;
  }

  .lrc-line.lrc-active {
    font-size: 15px;
    font-weight: 600;
    line-height: 28px;
    height: 28px;
  }

  /* 控制按钮：稍微缩小但保持可点击区域 */
  .music-controls {
    gap: var(--space-4);
  }

  .ctrl-btn {
    width: 44px;
    height: 44px;
  }

  .ctrl-btn svg {
    width: 20px;
    height: 20px;
  }

  .play-ctrl-btn {
    width: 60px;
    height: 60px;
  }

  .play-ctrl-btn svg {
    width: 24px;
    height: 24px;
  }

  /* 进度条：保持触摸友好的区域 */
  .progress-track {
    height: 6px;
  }

  .progress-thumb {
    width: 14px;
    height: 14px;
    opacity: 1; /* 移动端始终显示拖动手柄 */
  }

}

/* 小屏手机（<480px）进一步优化 */
@media (max-width: 480px) {
  .music-player-box {
    padding: var(--space-5) var(--space-3);
  }

  .cd-container {
    width: 140px;
    height: 140px;
  }

  .music-controls {
    gap: var(--space-3);
  }
}
