/* ================================
   温若 · 水墨音乐播放器
   ================================ */

.music-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ── 悬浮按钮 ── */

.music-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(12, 15, 10, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(245, 240, 230, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  transition: all 0.4s var(--ease-brush);
  padding: 0;
}

.music-btn:hover {
  transform: scale(1.1) rotate(-5deg);
  color: var(--text-paper);
  border-color: rgba(196, 90, 74, 0.4);
  box-shadow: 0 0 32px rgba(196, 90, 74, 0.25);
}

.music-btn.active {
  background: var(--accent-cinnabar);
  border-color: var(--accent-cinnabar);
  color: #fff;
  transform: rotate(360deg);
  box-shadow: 0 0 40px rgba(196, 90, 74, 0.35);
}

/* ── 面板 ── */

.music-panel {
  width: 340px;
  height: 480px;
  background: rgba(26, 31, 24, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(245, 240, 230, 0.08);
  border-radius: 20px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.96);
  transform-origin: bottom right;
  transition: all 0.45s var(--ease-brush);
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
}

.music-panel.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.music-panel-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 水墨纹理背景 */
.music-panel-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 20% -10%, rgba(196, 90, 74, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse 80% 60% at 80% 110%, rgba(91, 122, 118, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

/* ── 头部 ── */

.music-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(245, 240, 230, 0.06);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.music-cover {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-ink-2);
  display: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.music-header-info {
  flex: 1;
  min-width: 0;
}

.music-playlist-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.05em;
}

.music-song-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.1em;
}

/* ── 歌曲列表 ── */

.music-list-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.music-list {
  height: 100%;
  overflow-y: auto;
  padding: 6px 0;
}

.music-list::-webkit-scrollbar {
  width: 3px;
}

.music-list::-webkit-scrollbar-track {
  background: transparent;
}

.music-list::-webkit-scrollbar-thumb {
  background: rgba(245, 240, 230, 0.08);
  border-radius: 2px;
}

.music-list::-webkit-scrollbar-thumb:hover {
  background: rgba(196, 90, 74, 0.3);
}

/* ── 列表项 ── */

.music-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.25s ease;
  position: relative;
}

.music-list-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 2px;
  height: 60%;
  background: var(--accent-cinnabar);
  border-radius: 1px;
  transition: transform 0.25s ease;
}

.music-list-item:hover {
  background: rgba(245, 240, 230, 0.03);
}

.music-list-item:hover::after {
  transform: translateY(-50%) scaleY(1);
}

.music-list-item.active {
  background: rgba(196, 90, 74, 0.08);
}

.music-list-item.active::after {
  transform: translateY(-50%) scaleY(1);
}

.music-list-item.active .music-item-name {
  color: var(--accent-cinnabar);
}

.music-list-item.active .music-item-num {
  color: var(--accent-cinnabar);
}

/* 不可播放标记 */
.music-list-item.unavailable {
  opacity: 0.4;
  pointer-events: none;
}

.music-list-item.unavailable .music-item-name::after {
  content: ' ✦';
  color: var(--accent-cinnabar);
  font-size: 10px;
}

/* 加载中标记 */
.music-list-item.loading .music-item-num::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent-cinnabar);
  border-top-color: transparent;
  border-radius: 50%;
  animation: inkSpin 0.8s linear infinite;
}

/* ── 序号/均衡器 ── */

.music-item-num {
  width: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* 播放均衡器动画 */
.music-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 14px;
}

.music-eq span {
  display: block;
  width: 2.5px;
  background: var(--accent-cinnabar);
  border-radius: 1px;
  animation: eqBounce 0.6s ease-in-out infinite;
}

.music-eq span:nth-child(1) { height: 100%; animation-delay: 0s; }
.music-eq span:nth-child(2) { height: 60%; animation-delay: 0.15s; }
.music-eq span:nth-child(3) { height: 80%; animation-delay: 0.3s; }

@keyframes eqBounce {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.3); }
}

/* ── 歌曲信息 ── */

.music-item-info {
  flex: 1;
  min-width: 0;
}

.music-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-serif);
}

.music-item-artist {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.music-item-dur {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── 播放控制栏 ── */

.music-player-bar {
  border-top: 1px solid rgba(245, 240, 230, 0.06);
  padding: 10px 16px 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.music-track-info {
  text-align: center;
  margin-bottom: 8px;
}

.music-track-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-paper);
  font-family: var(--font-serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-track-artist {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 进度条 ── */

.music-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.music-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(245, 240, 230, 0.08);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  overflow: visible;
}

.music-progress-fill {
  height: 100%;
  background: var(--accent-cinnabar);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
  position: relative;
}

.music-progress-fill::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  background: var(--accent-cinnabar);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 0 8px rgba(196, 90, 74, 0.5);
}

.music-progress-bar:hover .music-progress-fill::after {
  opacity: 1;
}

.music-time {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── 控制按钮 ── */

.music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.mc-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  transition: all 0.25s ease;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mc-btn:hover {
  color: var(--text-paper);
  transform: scale(1.15);
}

.mc-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-cinnabar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(196, 90, 74, 0.35);
  transition: all 0.3s ease;
}

.mc-play:hover {
  background: #d4685a;
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(196, 90, 74, 0.45);
}

/* ── 加载/错误状态 ── */

.music-loading,
.music-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px;
  text-align: center;
  gap: 12px;
  cursor: pointer;
}

/* 水墨加载动画 */
.ink-spinner {
  width: 32px;
  height: 32px;
  position: relative;
}

.ink-spinner::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--accent-cinnabar);
  border-radius: 50%;
  animation: inkSpin 1s linear infinite;
}

.ink-spinner::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px solid transparent;
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: inkSpin 0.8s linear infinite reverse;
}

@keyframes inkSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── 响应式 ── */

@media (max-width: 480px) {
  .music-widget {
    bottom: 16px;
    right: 16px;
  }

  .music-btn {
    width: 46px;
    height: 46px;
  }

  .music-panel {
    width: calc(100vw - 32px);
    max-width: 340px;
    height: 420px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .music-btn,
  .music-panel,
  .mc-btn,
  .mc-play,
  .music-list-item {
    transition: none !important;
    animation: none !important;
  }

  .music-eq span {
    animation: none !important;
  }

  .ink-spinner::before,
  .ink-spinner::after {
    animation: none !important;
  }
}
