/* ============================================================
   音乐播放器 v2 — 玻璃拟态战术风
   对齐主站设计令牌：深色玻璃面板 / 蓝色高光 / Bahnschrift 数字
   结构：.mp 收起圆钮(.mp-fab) ⇄ 展开卡片(.mp-card) + 列表抽屉(.mp-list)
   ============================================================ */

/* ---------- 容器 ---------- */
.mp {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: 320px;
  max-width: calc(100vw - 24px);
  height: 0; /* 容器本身不占位，子元素绝对定位 */
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text, #e0ecf5);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- 收起态：浮动圆钮 ---------- */
.mp-fab {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--border-strong, rgba(120, 170, 220, 0.5));
  background: linear-gradient(180deg, rgba(23, 33, 48, 0.94), rgba(13, 19, 29, 0.96));
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  color: var(--accent, #3ea6ff);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 30px rgba(0, 0, 0, 0.45);
  transition: transform 0.22s var(--ease, ease), box-shadow 0.22s, opacity 0.22s, color 0.2s;
}

.mp-fab:hover {
  transform: translateY(-3px);
  color: #fff;
}

.mp-fab:active {
  transform: translateY(-1px) scale(0.96);
}

/* 播放中：呼吸光环 */
.mp.is-playing .mp-fab {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(62, 166, 255, 0.35),
    0 0 22px rgba(62, 166, 255, 0.3),
    0 10px 30px rgba(0, 0, 0, 0.45);
}

/* 展开时圆钮缩小退场 */
.mp.is-expanded .mp-fab {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.5);
}

.mp-fab-icon,
.mp-fab-eq {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mp-fab-icon svg {
  width: 1em;
  height: 1em;
}

/* 播放中：音符 → 跳动频谱 */
.mp-fab-eq {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}

.mp.is-playing .mp-fab-icon { display: none; }
.mp.is-playing .mp-fab-eq { display: flex; }

.mp-fab-eq i {
  width: 3px;
  height: 30%;
  border-radius: 2px;
  background: currentColor;
  animation: mp-eq 0.9s ease-in-out infinite;
}

.mp-fab-eq i:nth-child(2) { animation-delay: 0.25s; }
.mp-fab-eq i:nth-child(3) { animation-delay: 0.5s; }

@keyframes mp-eq {
  0%, 100% { height: 25%; }
  50% { height: 100%; }
}

/* ---------- 展开态：玻璃卡片 ---------- */
.mp-card {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  padding: 16px 16px 12px;
  border-radius: var(--radius, 16px);
  border: 1px solid var(--border, rgba(80, 130, 180, 0.3));
  background: linear-gradient(180deg, rgba(23, 33, 48, 0.94), rgba(13, 19, 29, 0.96));
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 48px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(62, 166, 255, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s var(--ease, ease), transform 0.25s var(--ease, ease), visibility 0.25s;
}

.mp.is-expanded .mp-card {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

/* ---------- 头部：唱片封面 + 信息 ---------- */
.mp-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mp-cover {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(95, 179, 242, 0.4);
  background: #0b1627;
  box-shadow: 0 0 16px rgba(62, 166, 255, 0.2);
}

.mp-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 唱片中轴 */
.mp-cover::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #0b1627;
  border: 2px solid rgba(123, 195, 247, 0.75);
  box-shadow: 0 0 6px rgba(62, 166, 255, 0.4);
}

.mp.is-playing .mp-cover {
  animation: mp-spin 12s linear infinite;
}

@keyframes mp-spin {
  to { transform: rotate(360deg); }
}

.mp-meta {
  flex: 1;
  min-width: 0;
}

.mp-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #e0ecf5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-artist {
  font-size: 12px;
  color: var(--muted, #8aafc4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 曲目序号：军事数字字体（底栏右侧） */
.mp-track-index {
  font-family: var(--font-num, "Bahnschrift", "Segoe UI", sans-serif);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--accent, #3ea6ff);
  opacity: 0.9;
}

/* ---------- 按钮 ---------- */
.mp-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid var(--border, rgba(80, 130, 180, 0.3));
  border-radius: 10px;
  background: rgba(13, 26, 48, 0.55);
  color: var(--muted, #8aafc4);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.18s;
}

.mp-btn svg {
  width: 1em;
  height: 1em;
}

.mp-btn:hover {
  color: var(--text, #e0ecf5);
  border-color: var(--accent, #3ea6ff);
  background: var(--accent-soft, rgba(62, 166, 255, 0.14));
  transform: translateY(-1px);
}

.mp-btn:active {
  transform: translateY(0) scale(0.95);
}

/* 关闭按钮：轻量幽灵样式 */
.mp-close {
  width: 26px;
  height: 26px;
  font-size: 13px;
  border-color: transparent;
  background: transparent;
}

.mp-close:hover {
  color: var(--red, #f25c5c);
  border-color: rgba(242, 92, 92, 0.4);
  background: rgba(242, 92, 92, 0.12);
}

/* ---------- 进度条 ---------- */
.mp-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 2px 12px;
}

.mp-time,
.mp-duration {
  font-family: var(--font-num, "Bahnschrift", "Segoe UI", sans-serif);
  font-size: 11.5px;
  letter-spacing: 0.5px;
  color: var(--muted, #8aafc4);
  min-width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mp-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  position: relative;
  outline: none;
  transition: height 0.15s;
}

.mp-progress-bar:hover,
.mp-progress-bar:focus-visible {
  height: 8px;
}

.mp-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3ea6ff, #6bc4ff);
  box-shadow: 0 0 8px rgba(62, 166, 255, 0.5);
  width: 0%;
  transition: width 0.15s linear;
}

/* 键盘焦点环 */
.mp-progress-bar:focus-visible {
  box-shadow: 0 0 0 2px rgba(62, 166, 255, 0.5);
}

/* ---------- 屏外音频引擎（B站 iframe，需一定尺寸才能初始化） ---------- */
.mp-audio-engine {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 480px;
  height: 270px;
  border: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.mp-audio-fallback {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 480px;
  height: 360px;
  border: 0;
  pointer-events: none;
  opacity: 0;
}

/* ---------- 控制区 ---------- */
.mp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* 主播放键 */
.mp-play {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(123, 195, 247, 0.55);
  background: linear-gradient(180deg, #4db2fb, #1e7ad4);
  color: #04101f;
  font-size: 20px;
  box-shadow: 0 0 18px rgba(62, 166, 255, 0.35);
}

.mp-play:hover {
  color: #04101f;
  border-color: rgba(123, 195, 247, 0.8);
  background: linear-gradient(180deg, #6bc4ff, #3a9aee);
  box-shadow: 0 0 26px rgba(62, 166, 255, 0.55);
  transform: translateY(-1px) scale(1.03);
}

/* ---------- 音量区 ---------- */
.mp-volume {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 2px 4px;
}

.mp-vol-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 14px;
}

.mp-vol-slider {
  flex: 1;
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  position: relative;
  outline: none;
  user-select: none;
}

.mp-vol-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3ea6ff, #6bc4ff);
  width: 80%;
  pointer-events: none;
}

.mp-vol-thumb {
  position: absolute;
  top: 50%;
  left: 80%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #3ea6ff;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 6px rgba(62, 166, 255, 0.6);
  opacity: 0;
  transition: opacity 0.15s;
}

.mp-vol-slider:hover .mp-vol-thumb,
.mp-vol-slider:focus-visible .mp-vol-thumb {
  opacity: 1;
}

.mp-vol-slider:hover {
  height: 6px;
}

.mp-vol-slider:focus-visible {
  box-shadow: 0 0 0 2px rgba(62, 166, 255, 0.5);
}

.mp-vol-label {
  font-family: var(--font-num, "Bahnschrift", "Segoe UI", sans-serif);
  font-size: 11px;
  color: var(--muted, #8aafc4);
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- 底栏：列表 + 序号 ---------- */
.mp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(80, 130, 180, 0.18);
}

.mp-list-btn {
  width: auto;
  padding: 0 12px;
  gap: 6px;
  border-radius: 999px;
  font-size: 12px;
}

.mp-list-btn span {
  font-size: 12px;
  line-height: 1;
}

.mp.is-list-open .mp-list-btn {
  color: var(--accent, #3ea6ff);
  border-color: var(--accent, #3ea6ff);
  background: var(--accent-soft, rgba(62, 166, 255, 0.14));
}

/* ---------- 播放列表抽屉（悬浮在卡片上方，不重叠控制区） ---------- */
.mp-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  max-height: 320px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(80, 130, 180, 0.3));
  background: linear-gradient(180deg, rgba(19, 40, 70, 0.98), rgba(10, 22, 40, 0.98));
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(62, 166, 255, 0.05);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.24s var(--ease, ease), transform 0.24s var(--ease, ease), visibility 0.24s;
  z-index: 1;
}

.mp-card { overflow: visible; }

.mp.is-list-open .mp-list {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.mp-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(80, 130, 180, 0.2);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text, #e0ecf5);
}

.mp-list-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted, #8aafc4);
}

.mp-list-scroll {
  overflow-y: auto;
  max-height: 200px;
}

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

.mp-list-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.mp-list-scroll::-webkit-scrollbar-thumb {
  background: rgba(62, 166, 255, 0.4);
  border-radius: 3px;
}

.mp-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-top: 1px solid rgba(80, 130, 180, 0.1);
  transition: background 0.15s;
}

.mp-list-item:first-child {
  border-top: 0;
}

.mp-list-item:hover {
  background: rgba(62, 166, 255, 0.08);
}

.mp-list-item.active {
  background: linear-gradient(90deg, rgba(62, 166, 255, 0.16), transparent 80%);
}

.mp-list-item-num {
  font-family: var(--font-num, "Bahnschrift", "Segoe UI", sans-serif);
  font-size: 11px;
  color: var(--muted, #8aafc4);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.mp-list-item.active .mp-list-item-num {
  color: var(--accent, #3ea6ff);
}

.mp-list-item-main {
  flex: 1;
  min-width: 0;
}

.mp-list-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text, #e0ecf5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-list-item.active .mp-list-item-title {
  color: var(--accent, #3ea6ff);
}

.mp-list-item-artist {
  font-size: 11px;
  color: var(--muted, #8aafc4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 当前行频谱指示 */
.mp-list-item-eq {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  flex-shrink: 0;
  color: var(--accent, #3ea6ff);
}

.mp.is-playing .mp-list-item.active .mp-list-item-eq {
  display: flex;
}

.mp-list-item-eq i {
  width: 2.5px;
  height: 30%;
  border-radius: 1px;
  background: currentColor;
  animation: mp-eq 0.9s ease-in-out infinite;
}

.mp-list-item-eq i:nth-child(2) { animation-delay: 0.25s; }
.mp-list-item-eq i:nth-child(3) { animation-delay: 0.5s; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .mp {
    right: 12px;
    bottom: 12px;
  }
}

/* ---------- 无障碍：减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  .mp-fab,
  .mp-card,
  .mp-list,
  .mp-btn {
    transition: none;
  }

  .mp.is-playing .mp-cover {
    animation: none;
  }

  .mp-fab-eq i,
  .mp-list-item-eq i {
    animation: none;
    height: 60%;
  }
}
