/* ============================================================
   ZQI · 悬浮音乐播放器（在线曲目 + 本地文件）
   assets/player.css —— 只被前台页面加载，admin.html 不引

   列表里有两类曲目，靠 .is-online / 分组标签区分：
     在线曲目  后台维护，带封面缩略图，访客删不掉
     本地文件  访客自己拖进来的，行尾有移除按钮

   设计约束（跟全站一套语言）：
     · 只用 style.css 里已有的 CSS 变量，不引入新色值
     · 圆角只用 --r-* 系列；按钮沿用 .icon-btn 的圆形观感
     · 颜色跟随 html[data-theme] 自动切换，无需额外深色样式

   两态：
     [data-state="min"]  圆形迷你按钮（FAB），常驻右下角
     [data-state="open"] 完整播放面板，播放列表浮在面板正上方
   ============================================================ */

:root {
  --zqp-gap:     clamp(14px, 2.2vw, 26px);  /* 距视口右下角的间距 */
  --zqp-bottom:  calc(var(--zqp-gap) + env(safe-area-inset-bottom, 0px));
  --zqp-w:       min(330px, calc(100vw - var(--zqp-gap) * 2));
  --zqp-h:       52px;   /* 根节点实测高度，player.js 会用 ResizeObserver 覆盖 */
  --zqp-total:   52px;   /* 根节点 + 展开的播放列表，用于「回到顶部」避让 */
}

/* hidden 属性真正生效 —— 作用域锁在播放器内部，不影响其它组件 */
.zqp-root [hidden] { display: none !important; }

.zqp-root {
  position: fixed;
  right: var(--zqp-gap);
  bottom: var(--zqp-bottom);
  z-index: 86;              /* 低于导航(90)，高于正文 */
  width: var(--zqp-w);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0;
  text-align: left;
  pointer-events: none;     /* 根节点不挡正文点击，内部元素各自恢复 */
}
.zqp-root > * { pointer-events: auto; }

/* ---------- 1. 迷你按钮 ---------- */
.zqp-fab {
  position: relative;
  align-self: flex-end;
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  transition: color .28s var(--ease), transform .28s var(--ease),
              box-shadow .28s var(--ease);
}
.zqp-fab:hover  { color: var(--accent); transform: translateY(-3px); }
.zqp-fab:active { transform: scale(.94); }
.zqp-fab svg    { width: 20px; height: 20px; }

.zqp-root[data-state="open"] .zqp-fab { display: none; }
.zqp-root[data-playing="1"] .zqp-fab  { color: var(--accent); }
.zqp-root[data-playing="0"] .zqp-fab-eq,
.zqp-root[data-playing="1"] .zqp-fab-note { display: none; }

/* 有在线歌单时，迷你按钮右上角挂个数量小角标 */
.zqp-root[data-state="min"] .zqp-fab:not([data-count=""])::before {
  content: attr(data-count);
  position: absolute;
  top: -2px; right: -2px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-size: 10px; font-weight: 600; line-height: 17px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
  animation: zqpPop .3s var(--ease);
}

/* 迷你态下的三格跳动，表示「正在放」 */
.zqp-fab-eq { display: flex; align-items: flex-end; gap: 2.5px; height: 16px; }
.zqp-fab-eq i {
  width: 3px; border-radius: 2px; background: currentColor;
  animation: zqpBar .9s var(--ease) infinite alternate;
}
.zqp-fab-eq i:nth-child(1) { height: 8px;  animation-delay: -.35s; }
.zqp-fab-eq i:nth-child(2) { height: 16px; animation-delay: -.15s; }
.zqp-fab-eq i:nth-child(3) { height: 11px; animation-delay: -.6s; }

/* 桌面端悬停提示（文案由 player.js 按歌单内容写入 --zqp-fab-label） */
.zqp-fab::after {
  content: var(--zqp-fab-label, "本地音乐");
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translate(6px, -50%);
  white-space: nowrap;
  font-size: 12px; font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--text-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s var(--ease), transform .26s var(--ease);
}
.zqp-fab:hover::after { opacity: 1; transform: translate(0, -50%); }

/* ---------- 2. 主面板 ---------- */
.zqp-panel {
  position: relative;
  width: 100%;
  padding: 12px 14px 13px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  box-shadow: var(--shadow-md);
  transition: background-color .45s var(--ease), border-color .3s var(--ease),
              box-shadow .3s var(--ease);
}
.zqp-root[data-state="min"] .zqp-panel { display: none; }

/* 拖拽文件进来时的强调态 */
.zqp-root.is-drag .zqp-panel {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}

/* --- 2.1 曲目信息行 --- */
.zqp-top { display: flex; align-items: center; gap: 10px; height: 42px; }

.zqp-badge {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.zqp-badge svg { width: 19px; height: 19px; }
/* 播放中：外圈轻微呼吸 */
.zqp-root[data-playing="1"] .zqp-badge { animation: zqpBreath 2.6s var(--ease) infinite; }

.zqp-now { min-width: 0; flex: 1; }
.zqp-title {
  display: block;
  font-size: 13.5px; font-weight: 600;
  letter-spacing: -.012em;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zqp-sub {
  display: block;
  margin-top: 2px;
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.zqp-tools { flex: 0 0 auto; display: flex; align-items: center; gap: 1px; }

/* --- 2.2 通用小圆钮 --- */
.zqp-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  color: var(--text-2);
  transition: color .22s var(--ease), background-color .22s var(--ease),
              transform .3s var(--ease);
}
.zqp-btn:hover  { color: var(--accent); background: var(--accent-soft); }
.zqp-btn:active { transform: scale(.9); }
.zqp-btn svg    { width: 16px; height: 16px; }
.zqp-btn.is-on  { color: var(--accent); }

/* 图标分层容器：靠父级状态切换显示哪一个 */
.zqp-play-icon, .zqp-pause-icon,
.zqp-vol-on, .zqp-vol-off,
.zqp-rep-all, .zqp-rep-one { display: grid; place-items: center; }

/* --- 2.3 进度条 --- */
.zqp-seek {
  display: flex; align-items: center; gap: 8px;
  height: 20px; margin-top: 9px;
}
.zqp-time {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}
.zqp-time.zqp-dur { text-align: right; }

/* --- 2.4 操作行 --- */
.zqp-ctrl { display: flex; align-items: center; gap: 3px; height: 40px; margin-top: 5px; }

.zqp-play {
  position: relative;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  margin: 0 2px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  transition: transform .26s var(--ease), box-shadow .26s var(--ease),
              background-color .45s var(--ease);
}
.zqp-play:hover  { transform: scale(1.06); box-shadow: 0 4px 14px var(--accent-soft); }
.zqp-play:active { transform: scale(.95); }
.zqp-play svg    { width: 16px; height: 16px; }
.zqp-root[data-playing="1"] .zqp-play-icon,
.zqp-root[data-playing="0"] .zqp-pause-icon { display: none; }

/* 自动播放被浏览器拦下时，给播放键套一圈呼吸提示 */
.zqp-root.need-tap .zqp-play::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: zqpRing 1.8s var(--ease) infinite;
}

.zqp-vol { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; padding-left: 2px; }
.zqp-root.is-muted .zqp-vol-on,
.zqp-root:not(.is-muted) .zqp-vol-off { display: none; }

/* 循环模式：off / all / one 三态 */
.zqp-root[data-repeat="one"] .zqp-rep-all,
.zqp-root:not([data-repeat="one"]) .zqp-rep-one { display: none; }

/* --- 2.5 range 控件（进度 / 音量共用） --- */
.zqp-range {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  min-width: 40px;
  height: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.zqp-range:disabled { cursor: default; opacity: .5; }

.zqp-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(to right,
    var(--accent) 0 var(--fill, 0%),
    var(--surface-2) var(--fill, 0%) 100%);
}
.zqp-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px; height: 11px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  transition: transform .2s var(--ease);
}
.zqp-range:hover::-webkit-slider-thumb,
.zqp-range:focus-visible::-webkit-slider-thumb { transform: scale(1.18); }

.zqp-range::-moz-range-track {
  height: 4px; border-radius: 3px; background: var(--surface-2);
}
.zqp-range::-moz-range-progress {
  height: 4px; border-radius: 3px; background: var(--accent);
}
.zqp-range::-moz-range-thumb {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.zqp-range:focus { outline: none; }
.zqp-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* --- 2.6 空状态 / 拖拽区 --- */
.zqp-empty {
  margin-top: 10px;
  padding: 15px 12px 16px;
  border: 1px dashed var(--accent-line);
  border-radius: var(--r-md);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .25s var(--ease), background-color .25s var(--ease),
              color .25s var(--ease);
}
.zqp-empty:hover { border-color: var(--accent); color: var(--text-2); }
.zqp-empty strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
}
.zqp-empty span { display: block; line-height: 1.7; }
.zqp-root.is-drag .zqp-empty { border-color: var(--accent); background: var(--accent-soft); }

/* 有曲目后收起空状态，反之收起进度 / 操作行 */
.zqp-root:not([data-empty="1"]) .zqp-empty { display: none; }
.zqp-root[data-empty="1"] .zqp-seek,
.zqp-root[data-empty="1"] .zqp-ctrl,
.zqp-root[data-empty="1"] .zqp-tip { display: none; }

.zqp-tip {
  margin-top: 9px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

/* ---------- 3. 播放列表（浮在面板正上方，不改变面板高度） ---------- */
.zqp-list {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(100% + 9px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  box-shadow: var(--shadow-md);
  transform-origin: bottom right;
  animation: zqpPop .26s var(--ease);
}

.zqp-list-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.zqp-list-head b { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.zqp-list-head .zqp-clear {
  margin-left: auto;
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  color: var(--muted);
  transition: color .2s var(--ease), background-color .2s var(--ease);
}
.zqp-list-head .zqp-clear:hover { color: var(--accent); background: var(--accent-soft); }

.zqp-tracks {
  list-style: none;
  margin: 0; padding: 5px;
  max-height: min(46vh, 262px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.zqp-tracks::-webkit-scrollbar { width: 6px; }
.zqp-tracks::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 3px;
}
.zqp-tracks::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.zqp-track {
  display: flex; align-items: center; gap: 9px;
  padding: 0 8px;
  height: 40px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-2);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.zqp-track:hover { background: var(--accent-soft); color: var(--text); }
.zqp-track.is-current { color: var(--accent); }
.zqp-track.is-current .zqp-track-title { font-weight: 600; color: var(--accent); }

.zqp-track-no {
  flex: 0 0 auto;
  width: 18px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.zqp-track.is-current .zqp-track-no { color: var(--accent); }

.zqp-track-eq { display: none; align-items: flex-end; gap: 2px; height: 12px; }
.zqp-track.is-current .zqp-track-eq { display: flex; }
.zqp-track.is-current .zqp-track-no { display: none; }
.zqp-track-eq i {
  width: 2px; border-radius: 1px; background: currentColor;
  animation: zqpBar .9s var(--ease) infinite alternate;
}
.zqp-track-eq i:nth-child(1) { height: 6px;  animation-delay: -.3s; }
.zqp-track-eq i:nth-child(2) { height: 12px; animation-delay: -.1s; }
.zqp-track-eq i:nth-child(3) { height: 8px;  animation-delay: -.5s; }
.zqp-root[data-playing="0"] .zqp-track-eq i { animation-play-state: paused; }

.zqp-track-main { flex: 1; min-width: 0; }
.zqp-track-title {
  display: block;
  font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zqp-track-artist {
  display: block;
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zqp-track-dur {
  flex: 0 0 auto;
  font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.zqp-track-del {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  color: var(--muted);
  opacity: 0;
  transition: opacity .2s var(--ease), color .2s var(--ease), background-color .2s var(--ease);
}
.zqp-track-del svg { width: 13px; height: 13px; }
.zqp-track:hover .zqp-track-del,
.zqp-track-del:focus-visible { opacity: 1; }
.zqp-track-del:hover { color: #d9534f; background: rgba(217, 83, 79, .1); }

/* 在线曲目的封面缩略图（后台没传封面时退回序号，见 rowHTML） */
.zqp-track-thumb {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* 分组标题：在线曲目 / 本地文件。吸顶，滚动时始终知道自己在听哪一类 */
.zqp-group {
  display: flex; align-items: center; gap: 8px;
  height: 30px;
  padding: 0 8px;
  position: sticky; top: -5px;   /* 抵消 .zqp-tracks 的 5px 内边距 */
  z-index: 1;
  background: var(--surface);
  font-size: 11px; font-weight: 600;
  letter-spacing: .05em;
  color: var(--muted);
  cursor: default;
}
.zqp-group::after {
  content: "";
  order: 2;
  flex: 1; height: 1px;
  background: var(--line);
}
.zqp-group > span {
  order: 3;
  flex: 0 0 auto;
  font-size: 10.5px; font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.zqp-list-foot {
  padding: 9px 14px 11px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.zqp-list-foot .zqp-more {
  margin-left: auto;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  border: 1px solid var(--line);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.zqp-list-foot .zqp-more:hover { color: var(--accent); border-color: var(--accent-line); }

/* ---------- 4. Toast（覆盖在面板上，不与列表抢位置） ---------- */
.zqp-toast {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 0 18px;
  border-radius: var(--r-lg);
  text-align: center;
  font-size: 12.5px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  /* 纯提示层，不吞点击 —— 否则提示期间整个面板都按不动 */
  pointer-events: none;
  transition: opacity .24s var(--ease), visibility .24s;
}
.zqp-toast.show { opacity: 1; visibility: visible; }

/* ---------- 5. 页面联动：避让 & 底部安全区 ---------- */
/* 回到顶部按钮始终待在播放器上方，靠 JS 实测的 --zqp-total 自动让位
   （--zqp-total 含展开的播放列表，--zqp-h 只有面板本身） */
body.has-player .to-top {
  bottom: calc(var(--zqp-bottom) + var(--zqp-total, 52px) + 12px);
}
/* 面板展开时才补底部留白，避免遮住页脚；迷你态不加，保持原有留白节奏 */
body.has-player.zqp-open {
  padding-bottom: calc(var(--zqp-h, 52px) + 18px);
}

/* ---------- 6. 响应式 ---------- */
@media (max-width: 760px) {
  :root { --zqp-gap: 12px; }

  .zqp-root {
    left: 12px;
    right: 12px;
    width: auto;
  }
  .zqp-fab { width: 48px; height: 48px; }
  .zqp-fab::after { display: none; }

  .zqp-panel { padding: 11px 12px 12px; }
  .zqp-badge { width: 38px; height: 38px; }
  .zqp-top   { height: 38px; }
  .zqp-ctrl  { gap: 2px; }
  .zqp-track-del { opacity: 1; }
  .zqp-tracks { max-height: min(44vh, 240px); }
  .zqp-list { transform-origin: bottom center; }
}

@media (max-width: 380px) {
  .zqp-time { min-width: 28px; font-size: 10.5px; }
  .zqp-vol  { gap: 2px; }
  .zqp-range { min-width: 30px; }
}

/* ---------- 7. 兜底 ---------- */
@media (prefers-reduced-motion: reduce) {
  .zqp-fab-eq i, .zqp-track-eq i { animation: none; }
  .zqp-root[data-playing="1"] .zqp-badge { animation: none; }
  .zqp-list { animation: none; }
  .zqp-root.need-tap .zqp-play::after { animation: none; }
}

@media print {
  .zqp-root { display: none !important; }
}

@keyframes zqpBar {
  from { transform: scaleY(.35); }
  to   { transform: scaleY(1); }
}
@keyframes zqpBreath {
  0%, 100% { background: var(--accent-soft); }
  50%      { background: color-mix(in srgb, var(--accent) 26%, transparent); }
}
@keyframes zqpPop {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
}
@keyframes zqpRing {
  0%   { opacity: .9; transform: scale(.97); }
  70%  { opacity: 0;  transform: scale(1.28); }
  100% { opacity: 0;  transform: scale(1.28); }
}
