/* ==========================================================================
   网易云热歌榜播放器：毛玻璃浮动按钮 + 可展开面板
   ========================================================================== */

.music-player {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2400;
  font-family: 'Microsoft YaHei', sans-serif;
}

/* ---- 浮动按钮 ---- */
.player-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-left: auto;
  padding: 0;
  color: #fff;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: radial-gradient(120% 140% at 20% 0%, rgba(255, 255, 255, 0.26), transparent 60%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.25s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.25s ease;
}

.player-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.player-toggle:focus-visible,
.player-icon-btn:focus-visible,
.player-play:focus-visible,
.player-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
}

.player-toggle svg {
  width: 24px;
  height: 24px;
}

.player-bars {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}

.player-bars i {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background-color: #fff;
  animation: player-bars 0.9s ease-in-out infinite;
}

.player-bars i:nth-child(2) {
  animation-delay: 0.15s;
}

.player-bars i:nth-child(3) {
  animation-delay: 0.3s;
}

.music-player.is-playing .player-toggle svg {
  display: none;
}

.music-player.is-playing .player-bars {
  display: flex;
}

@keyframes player-bars {
  0%,
  100% {
    height: 5px;
  }

  50% {
    height: 16px;
  }
}

/* ---- 面板 ---- */
.player-panel {
  display: flex;
  flex-direction: column;
  width: 360px;
  max-height: min(72vh, 560px);
  padding: 18px;
  position: absolute;
  right: 0;
  bottom: 72px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 22px;
  background: radial-gradient(120% 120% at 12% 0%, rgba(255, 255, 255, 0.18), transparent 58%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  -webkit-backdrop-filter: blur(24px) saturate(165%);
  backdrop-filter: blur(24px) saturate(165%);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.28s;
}

.player-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.player-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-cover {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background-color: rgba(255, 255, 255, 0.1);
}

.player-head-text {
  min-width: 0;
  flex: 1;
}

.player-head-text h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-head-text p {
  margin: 3px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.player-close:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.12);
}

.player-close svg {
  width: 16px;
  height: 16px;
}

.player-track {
  margin-top: 16px;
  min-height: 44px;
}

.player-track p {
  margin: 0;
}

#trackName {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#trackArtist {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- 进度 ---- */
.player-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.player-progress span {
  width: 34px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  font-variant-numeric: tabular-nums;
}

.player-progress span:last-child {
  text-align: right;
}

.player-progress input[type='range'],
.player-volume input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  margin: 0;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.85) var(--progress, 0%),
    rgba(255, 255, 255, 0.18) var(--progress, 0%)
  );
  cursor: pointer;
}

.player-progress input[type='range'] {
  flex: 1;
}

.player-progress input[type='range']::-webkit-slider-thumb,
.player-volume input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.16);
}

.player-progress input[type='range']::-moz-range-thumb,
.player-volume input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.16);
}

/* ---- 控制区 ---- */
.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.player-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #fff;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.player-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}

.player-icon-btn svg {
  width: 16px;
  height: 16px;
}

.player-mode {
  width: 32px;
  height: 32px;
}

/* 播放模式：同一按钮只显示当前模式的图标 */
.player-mode svg {
  display: none;
}

.player-mode[data-mode='list'] .icon-repeat-all,
.player-mode[data-mode='single'] .icon-repeat-one,
.player-mode[data-mode='shuffle'] .icon-shuffle {
  display: block;
}

.player-play {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  color: #212121;
  cursor: pointer;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.player-play:hover {
  transform: scale(1.05);
  background: #fff;
}

.player-play svg {
  width: 20px;
  height: 20px;
}

.player-play .pause-icon {
  display: none;
}

.player-panel.is-playing .player-play .play-icon {
  display: none;
}

.player-panel.is-playing .player-play .pause-icon {
  display: block;
}

.player-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.player-volume .player-icon-btn {
  width: 32px;
  height: 32px;
}

.player-volume input[type='range'] {
  width: 78px;
}

.player-volume .volume-off {
  display: none;
}

.player-volume.is-muted .volume-on {
  display: none;
}

.player-volume.is-muted .volume-off {
  display: block;
}

/* ---- 播放列表 ---- */
.player-list-wrap {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.player-list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.player-list-head span:first-child {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}

.player-list {
  list-style: none;
  margin: 8px -6px 0;
  padding: 0 6px 2px;
  overflow-y: auto;
  max-height: 200px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.player-list::-webkit-scrollbar {
  width: 6px;
}

.player-list::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background-color: rgba(255, 255, 255, 0.22);
}

.player-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.player-list li:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.player-list li.is-active {
  background-color: rgba(255, 255, 255, 0.14);
}

.player-list li.is-active .song-index {
  color: #ffb59a;
}

.player-list .song-index {
  width: 20px;
  flex-shrink: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.player-list .song-info {
  flex: 1;
  min-width: 0;
}

.player-list .song-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-list .song-artist {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-list .song-time {
  flex-shrink: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  font-variant-numeric: tabular-nums;
}

.player-list .player-empty {
  padding: 18px 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  cursor: default;
}

.player-list .player-empty:hover {
  background: transparent;
}

/* ---- 移动端 ---- */
@media screen and (max-width: 700px) {
  .music-player {
    right: 16px;
    bottom: 16px;
  }

  .player-panel {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 88px;
    width: auto;
    max-height: calc(100vh - 120px);
    border-radius: 20px;
  }

  .player-list {
    max-height: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-toggle,
  .player-panel,
  .player-play,
  .player-bars i {
    animation: none;
    transition: none;
  }
}
