/* 背景音乐播放器：右上角悬浮球 + 微信风白色卡片面板。
 *
 * 默认位置顶距与右距相等（同一个 --mu-edge，改一处两边同步）。为此层级必须高于
 * .nav(100)：顶距 14px 时球压在导航条上，低于它就会被盖住变成点不到的球。
 * 安全性核对过——导航是居中标题，右侧的 #navPublish 在前台是 display:none，
 * 球不挡任何控件；同时仍低于表情面板 140 / toast 260 / 大图 viewer 300 / mask 400，
 * 看大图时球不会浮在图像上。
 * 位置不做持久化——拖动只改内联 style，刷新即回到下面这个默认值。 */

.mu {
  --mu-edge: 14px;
  position: fixed;
  /* 刘海/状态栏用 env(safe-area-inset-top) 让出，保证"视觉顶距"仍等于右距；
     笔记本与手机上该值为 0，此时 top 与 right 就是同一个 14px。 */
  top: calc(env(safe-area-inset-top) + var(--mu-edge));
  right: var(--mu-edge);
  z-index: 101;
  font-size: 14px;
}
/* 拖动后改用 left/top 定位，必须放开 right——两端同时锚定会被拉回右侧 */
.mu.is-dragged { right: auto; }

/* ---------------- 悬浮球 ---------------- */
.mu-fab {
  display: block; width: 46px; height: 46px; margin-left: auto;
  padding: 0; border: 3px solid var(--wx-line, #E7E7E7); border-radius: 50%;
  background: #fff; color: var(--wx-green, #07C160); cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
  transition: transform .18s, box-shadow .18s;
  /* 不写 touch-action:none，触屏按住拖动会被浏览器先当成页面滚动，球根本拖不动 */
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.mu-fab:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, .14); }
.mu-fab:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
/* 拖动中：放大一档并去掉过渡，跟手比"顺滑"更重要 */
.mu-fab.is-grabbing { cursor: grabbing; transform: scale(1.06); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); transition: none; }
.mu-fab:focus-visible { outline: 2px solid var(--wx-green, #07C160); outline-offset: 2px; }
.mu-fab-disc {
  display: block; width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.mu-fab-disc svg { width: 22px; height: 22px; }
.mu-fab-disc img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 播放中唱片旋转；暂停即停在当前角度（比直接消失更贴合"暂停"语义） */
.mu.is-playing .mu-fab-disc { animation: muSpin 9s linear infinite; }
@keyframes muSpin { to { transform: rotate(360deg); } }

/* ---------------- 面板：默认开在球下方，下方空间不够时自动翻到上方 ---------------- */
.mu-panel {
  position: absolute; top: 54px; right: 0; width: 268px;
  padding: 12px 14px 10px; background: #fff;
  border: .5px solid var(--wx-line, #E7E7E7); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
  opacity: 0; transform: translateY(-8px) scale(.98); pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.mu.panel-up .mu-panel { top: auto; bottom: 54px; transform: translateY(8px) scale(.98); }
/* 球被拖到屏幕左侧时，面板改贴球左缘向右展开，否则会伸出屏幕外点不到 */
.mu.panel-left .mu-panel { right: auto; left: 0; }
.mu.is-open .mu-panel { opacity: 1; transform: none; pointer-events: auto; }

.mu-now { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mu-cover {
  flex: none; width: 40px; height: 40px; border-radius: 6px; overflow: hidden;
  background: #F2F2F2; color: #B2B2B2;
  display: flex; align-items: center; justify-content: center;
}
.mu-cover svg { width: 20px; height: 20px; }
.mu-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mu-meta { min-width: 0; flex: 1; }
.mu-title {
  color: #191919; font-size: 14px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mu-artist {
  color: #9A9A9A; font-size: 12px; line-height: 1.4; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 进度条：自绘（不用 input[range]，样式在微信风下更好控制，且支持键盘方向键） */
.mu-bar { position: relative; height: 14px; margin: 10px 0 2px; cursor: pointer; touch-action: none; }
.mu-bar::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; margin-top: -2px;
  height: 4px; border-radius: 2px; background: #E7E7E7;
}
.mu-fill {
  position: absolute; left: 0; top: 50%; margin-top: -2px; height: 4px; width: 0;
  border-radius: 2px; background: var(--wx-green, #07C160);
}
.mu-knob {
  position: absolute; top: 50%; left: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
  opacity: 0; transition: opacity .15s;
}
.mu-bar:hover .mu-knob, .mu-bar:focus-visible .mu-knob, .mu.is-playing .mu-knob { opacity: 1; }
.mu-bar:focus-visible { outline: 2px solid var(--wx-green, #07C160); outline-offset: 2px; border-radius: 4px; }

.mu-time { display: flex; justify-content: space-between; font-size: 11px; color: #B2B2B2; font-variant-numeric: tabular-nums; }

/* ---------------- 控件行 ---------------- */
.mu-ctrls { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.mu-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: #576B95; cursor: pointer;
  transition: background .15s, color .15s;
}
.mu-btn:hover { background: #F2F5FA; }
.mu-btn:active { background: #E8EDF5; }
.mu-btn:focus-visible { outline: 2px solid var(--wx-green, #07C160); outline-offset: -2px; }
.mu-btn svg { width: 18px; height: 18px; }
.mu-play { color: var(--wx-green, #07C160); width: 34px; height: 34px; }
.mu-play svg { width: 22px; height: 22px; }
.mu-play:hover { background: #EAF7EF; }
.mu-play:active { background: #DCEFE5; }

.mu-mode { width: auto; padding: 0 7px; gap: 3px; font-size: 11px; color: #9A9A9A; white-space: nowrap; }
.mu-mode svg { width: 15px; height: 15px; }
.mu-mode-label { line-height: 1; }
.mu-ctrls .mu-mode { margin-right: auto; }

/* 音量：点音量键浮出滑条 */
.mu-volwrap { position: relative; display: inline-flex; }
.mu-range {
  position: absolute; right: 0; bottom: 34px; width: 0; height: 30px;
  opacity: 0; pointer-events: none; transition: opacity .15s;
  accent-color: var(--wx-green, #07C160);
}
.mu.show-vol .mu-range { width: 96px; opacity: 1; pointer-events: auto; }

/* ---------------- 提示条（复用站内的观感，但不依赖 feed.js 的 toast）---------------- */
.mu-toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, .8); color: #fff; font-size: 13px;
  padding: 8px 14px; border-radius: 6px; opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; z-index: 261; max-width: 78vw; text-align: center;
}
.mu-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 移动端：点球后"绽放"成卡片 ----------------
 * 面板的缩放原点由 JS 精确设在球心（--mu-ox/--mu-oy），所以视觉上是从球本身
 * 长出一张卡，而不是"某个面板凭空出现"；球里的封面与卡里的封面是同一张图，
 * 空间连续。关闭走手势：上滑卡片（顶部把手提示）或点卡片以外区域。
 * 只用 transform/opacity，不碰布局属性，符合本站特效的性能约束。 */
.mu-handle {
  display: none; width: 36px; height: 4px; border-radius: 2px;
  background: #E3E3E3; margin: -2px auto 9px;
}

@media (max-width: 719px) {
  .mu-fab { width: 42px; height: 42px; }
  .mu-panel {
    width: min(272px, calc(100vw - 28px));
    transform-origin: var(--mu-ox, 100%) var(--mu-oy, 0px);
  }
  .mu.is-open .mu-panel { animation: muBloom .24s cubic-bezier(.22, .8, .28, 1) both; }
  .mu.is-closing .mu-panel { animation: muTuck .17s ease-in both; }
  @keyframes muBloom {
    from { opacity: 0; transform: scale(.15); }
    to   { opacity: 1; transform: scale(1); }
  }
  @keyframes muTuck {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(.15); }
  }
  .mu-handle { display: block; }
  /* 音量控件在移动端隐藏（手机音量交给系统侧键，留着就是无效控件）*/
  .mu-volwrap { display: none; }
  /* 必须排除 .mu-mode：它也带 .mu-btn 类，媒体查询在文件末尾、同权重下会赢过
     `.mu-mode { width: auto }`，把"图标+文字"的模式键压成 36px，实测文字被挤到 11px。 */
  .mu-btn:not(.mu-mode) { width: 36px; height: 36px; }
  .mu-mode { height: 36px; padding: 0 9px; }
  .mu-play { width: 42px; height: 42px; }
  .mu-ctrls { gap: 8px; }
  /* 触摸目标变大后，进度条也要跟着加厚一点才好拖 */
  .mu-bar { height: 20px; }
}

/* ---------------- 减弱动效：唱片不转、面板不做位移动画 ---------------- */
@media (prefers-reduced-motion: reduce) {
  .mu.is-playing .mu-fab-disc { animation: none; }
  .mu-panel, .mu-fab, .mu-toast, .mu-knob { transition: none; }
  .mu.is-open .mu-panel { transform: none; }
}

/* ---------------- 空歌单：播放器照常显示，动作键置灰 ---------------- */
.mu.is-empty .mu-btn:disabled { opacity: .35; cursor: default; background: none; }
.mu.is-empty .mu-bar { pointer-events: none; opacity: .45; }
.mu.is-empty .mu-title { color: #9A9A9A; }

/* ---------------- 自动播放被拦时的提示 ----------------
   只有一行小字、不带卡片与边框：访客点任意处即消失（由 JS 摘除）。
   没有这句，被浏览器拦住的"自动播放"看起来就跟功能坏了一样。 */
.mu-hint {
  position: absolute; top: 52px; right: 0; white-space: nowrap;
  font-size: 12px; line-height: 1.4; color: var(--wx-sub, #676D73);
  background: rgba(255, 255, 255, .86); border-radius: 6px; padding: 3px 8px;
  animation: muHintIn .25s ease both;
}
@keyframes muHintIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* 面板展开时让位：两者都锚在球下方同一带（提示 top:52px、面板 top:54px），
   实测提示会压在面板头部上。面板开着时播放键就在眼前，这句提示也没有
   继续存在的必要——它的作用只是告诉访客"点任意处即可开播"。 */
.mu.is-open .mu-hint { display: none; }
