/* music_dock.css — 左下角悬浮音乐盒 */

/* 为什么放左下角:右下角已经被两个常驻控件占满了
     #back-to-top        24px/24px  z-index 900   (header.css,全站)
     .floating-actions   30px/30px  z-index 1000  (style.css,文章页等)
   左下角全站无占用,可以和它完全对称。

   下面这组值就是 #back-to-top 的镜像:
     桌面 24/24 · ≤768px 16/16 · ≤360px 12/12
   (三个样式表 header.css / style.css / style1.css 里该按钮的边距完全一致)
   这样两者的底边在同一水平线上,视觉上左右对称。

   原先那层 env(safe-area-inset-bottom) 去掉了:全站只有 tools.php、tool.php
   声明了 viewport-fit=cover,其余页面 env 恒为 0,而在这两个页面上它会把
   音乐盒额外抬高 34px,反而和返回顶部错开 —— 要对齐就必须用同一套写法。

   --md-x / --md-y 就是水平/垂直边距,改这两个值就能整体挪位置;
   想换回右边:把下面的 left 改成 right,并把 .md-panel 的
   transform-origin 改成 bottom right 即可。 */
.music-dock {
    --md-x: 24px;
    --md-y: 24px;
    position: fixed;
    left: var(--md-x);
    bottom: var(--md-y);
    z-index: 9998;
    font-size: 14px;
}

/* ---------- 悬浮按钮 ---------- */
.md-fab {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    font-size: 20px;
    background: linear-gradient(135deg, #1a7eff, #22d3ee);
    box-shadow: 0 10px 24px -8px rgba(26, 126, 255, .75);
    transition: transform .3s cubic-bezier(.2, .7, .3, 1), box-shadow .3s ease;
}
.md-fab:hover { transform: scale(1.08); box-shadow: 0 14px 28px -8px rgba(26, 126, 255, .9); }
.md-fab i { display: block; }
/* 展开时按钮收进面板内部,不再单独显示 */
.music-dock:not(.is-collapsed) .md-fab { display: none; }

/* ---------- 面板 ---------- */
.md-panel {
    width: 288px;
    /* 展开态的高度上限:屏幕矮时(手机横屏、小窗)面板不能顶出视口上沿 */
    max-height: calc(100vh - var(--md-y) - 16px);
    border-radius: 18px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(26, 126, 255, .16);
    box-shadow: 0 18px 44px -18px rgba(16, 40, 80, .45);
    overflow: hidden;
    transform-origin: bottom left;
    transition: max-height .35s cubic-bezier(.2, .7, .3, 1),
                transform .32s cubic-bezier(.2, .7, .3, 1),
                opacity .28s ease,
                border-color .3s ease;
}
/* 收起时 max-height 归零而不是只调 opacity:
   面板是流内子元素,只隐藏不收高的话,它那 ~170px 依旧把圆钮从底边
   顶到半空 —— 这就是"音乐盒和返回顶部不在一条水平线上"的真正原因。
   归零后容器高度 = 圆钮 52px,底边 24px 与返回顶部严格同线。 */
.music-dock.is-collapsed .md-panel {
    max-height: 0;
    border-color: transparent;
    transform: scale(.7) translateY(12px);
    opacity: 0;
    pointer-events: none;
}

/* 头部:封面 + 曲名 */
.md-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 10px;
}
.md-cover {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    background: linear-gradient(135deg, #1a7eff, #22d3ee);
    box-shadow: 0 8px 18px -8px rgba(26, 126, 255, .8);
    background-size: cover;
    background-position: center;
}
/* 播放时封面缓慢旋转,静止时不转(省电、也避免干扰) */
.music-dock.is-playing .md-cover i { animation: mdSpin 8s linear infinite; }
@keyframes mdSpin { to { transform: rotate(360deg); } }

.md-meta { min-width: 0; flex: 1 1 auto; }
.md-title {
    font-size: .95rem;
    font-weight: 700;
    color: #16213e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.md-artist {
    font-size: .78rem;
    color: #7b8aa0;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.md-close {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border: none;
    border-radius: 8px;
    background: rgba(16, 40, 80, .06);
    color: #6c86a3;
    cursor: pointer;
    font-size: .8rem;
}
.md-close:hover { background: rgba(16, 40, 80, .12); }

/* 进度条 */
.md-progress { padding: 0 14px; }
.md-bar {
    position: relative;
    height: 4px;
    border-radius: 4px;
    background: rgba(16, 40, 80, .1);
    cursor: pointer;
}
.md-bar i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, #1a7eff, #22d3ee);
    pointer-events: none;
}
.md-time {
    display: flex;
    gap: 4px;
    font-size: .7rem;
    color: #93a3b8;
    margin-top: 5px;
    font-variant-numeric: tabular-nums;
}
.md-time em { font-style: normal; opacity: .6; }

/* 控制按钮 */
.md-ctrl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 10px 14px 12px;
}
.md-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(16, 40, 80, .06);
    color: #4b5c72;
    cursor: pointer;
    font-size: .9rem;
    transition: all .25s ease;
}
.md-btn:hover { background: rgba(26, 126, 255, .14); color: #1a7eff; }
.md-play {
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
    color: #fff;
    background: linear-gradient(135deg, #1a7eff, #22d3ee);
    box-shadow: 0 8px 18px -8px rgba(26, 126, 255, .85);
}
.md-play:hover { color: #fff; transform: scale(1.06); box-shadow: 0 10px 22px -8px rgba(26, 126, 255, .95); }
.md-btn.is-off { opacity: .45; cursor: not-allowed; }

/* 第二行:播放模式 + 音量 */
.md-extra {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 12px;
}
.md-extra .md-btn { width: 30px; height: 30px; font-size: .78rem; }

/* 音量滑块:灰槽 + 渐变进度两层背景叠加,比例由 JS 写 --md-vol 控制 */
.md-range {
    --md-vol: 80%;
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    min-width: 0;
    height: 4px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    background:
        linear-gradient(90deg, #1a7eff, #22d3ee) no-repeat,
        rgba(16, 40, 80, .1);
    background-size: var(--md-vol) 100%, 100% 100%;
}
.md-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1a7eff;
    box-shadow: 0 2px 6px rgba(26, 126, 255, .45);
}
.md-range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: #1a7eff;
}
/* 默认焦点环在半透明面板上看不清,给键盘用户补一圈可见边框 */
.md-range:focus-visible { box-shadow: 0 0 0 2px rgba(26, 126, 255, .35); }

/* 播放列表 */
.md-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s cubic-bezier(.2, .7, .3, 1);
    border-top: 1px solid rgba(16, 40, 80, .07);
}
.music-dock.list-open .md-list { max-height: 260px; }
.md-list-head {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px 6px;
    font-size: .75rem;
    color: #7b8aa0;
}
.md-list-ul {
    margin: 0;
    padding: 0 6px 10px;
    list-style: none;
    max-height: 204px;
    overflow-y: auto;
}
.md-list-ul li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: .82rem;
    color: #4b5c72;
    transition: background .2s ease;
}
.md-list-ul li:hover { background: rgba(26, 126, 255, .08); }
.md-list-ul li.active { background: rgba(26, 126, 255, .12); color: #1a7eff; font-weight: 600; }
.md-list-ul .no {
    width: 18px;
    flex: 0 0 auto;
    text-align: center;
    font-size: .72rem;
    color: #a7b4c6;
    font-variant-numeric: tabular-nums;
}
.md-list-ul li.active .no { color: #1a7eff; }
.md-list-ul .name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}
.md-list-empty { padding: 14px; text-align: center; font-size: .8rem; color: #93a3b8; }



/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
    /* 镜像 #back-to-top 的移动端边距(16/16) */
    .music-dock { --md-x: 16px; --md-y: 16px; }
    .md-fab { width: 46px; height: 46px; font-size: 18px; }
    .md-panel { width: calc(100vw - 28px); max-width: 288px; }
}

@media (max-width: 360px) {
    /* 同上,镜像 ≤360px 时的 12/12 */
    .music-dock { --md-x: 12px; --md-y: 12px; }
    .md-panel { width: calc(100vw - 24px); }
}

/* 矮屏(手机横屏 / 小窗浏览器):先把列表压短,避免面板被 max-height 裁掉底部 */
@media (max-height: 560px) {
    .music-dock.list-open .md-list { max-height: 150px; }
    .md-list-ul { max-height: 110px; }
}
