/* ==========================================================================
   云悦 · 悬浮玻璃音乐播放器   music-player.css
   --------------------------------------------------------------------------
   说明：
   1. 本文件只负责“外观”，播放逻辑在 music-player.js 中；
   2. 颜色全部复用主页 style.css 里已有的 CSS 变量（--primary / --text /
      --muted），所以后台改“主题色”、前台切换明暗主题时，播放器会自动跟着变；
   3. 所有类名都以 mp- 开头，不会和主页现有样式冲突。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 播放器舞台（整个播放器的固定定位容器）
   fixed：固定在浏览器窗口上，不随页面滚动；
   right / bottom：停在屏幕右下角，这是悬浮播放器最不挡内容的位置；
   z-index: 900：低于站点的自定义鼠标光圈（9999），高于正文内容。
   -------------------------------------------------------------------------- */
.mp {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 900;
    color: var(--text);
    font-family: inherit;
    -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   2. 主卡片（那个“小窗口”）
   -------------------------------------------------------------------------- */
.mp-card {
    position: relative;
    width: 320px;
    padding: 13px 13px 11px;
    border-radius: 26px;

    /* 玻璃拟态：半透明白 + 背景模糊 + 内高光 */
    background: linear-gradient(150deg,
            rgba(255, 255, 255, .17) 0%,
            rgba(255, 255, 255, .05) 46%,
            rgba(255, 255, 255, .11) 100%);
    border: 1px solid rgba(255, 255, 255, .16);
    backdrop-filter: blur(26px) saturate(175%);
    -webkit-backdrop-filter: blur(26px) saturate(175%);
    box-shadow:
        0 26px 70px rgba(3, 6, 20, .50),
        0 2px 8px rgba(3, 6, 20, .22),
        inset 0 1px 0 rgba(255, 255, 255, .22);

    transform-origin: right center;
    /* 收起 / 展开的滑行动画：先快后稳的缓动曲线，看起来更“贵” */
    transition: transform .62s cubic-bezier(.22, 1, .36, 1),
                opacity .45s ease,
                box-shadow .4s ease;
    will-change: transform;
}

/* 收起状态下，卡片整体滑出屏幕右侧，并禁止点击 */
.mp.is-docked .mp-card {
    transform: translateX(calc(100% + 90px));
    opacity: 0;
    pointer-events: none;
}

/* 卡片内的柔光装饰层：单独一个 div，只为把光斑裁切在圆角内 */
.mp-glare {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
}

.mp-glare .g1 {
    position: absolute;
    right: -70px;
    top: -110px;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary) 0%, transparent 68%);
    opacity: .42;
    filter: blur(6px);
}

.mp-glare .g2 {
    position: absolute;
    left: -80px;
    bottom: -100px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, #00d4ff 0%, transparent 70%);
    opacity: .22;
}

/* --------------------------------------------------------------------------
   3. 顶部一行：封面 + 歌名 + 歌手 + 右侧两个小按钮
   -------------------------------------------------------------------------- */
.mp-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 11px;
}

/* 封面：没有封面图时显示渐变色块 + 音符图标 */
.mp-cover {
    position: relative;
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 15px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary), #00d4ff);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .34);
}

.mp-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: mpFadeIn .5s ease both;
}

.mp-cover-note {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    opacity: .92;
}

.mp-cover-note svg {
    width: 22px;
    height: 22px;
}

/* 歌名 / 歌手，超长自动省略 */
.mp-meta {
    flex: 1;
    min-width: 0;
}

.mp-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: .01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-artist {
    margin-top: 3px;
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 顶部两个图标按钮（静音 / 收起），要压过 style.css 里全局的 button 样式 */
.mp-icon {
    flex: none;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: transparent;
    box-shadow: none;
    color: var(--muted);
    cursor: pointer;
    transition: color .2s ease, background .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mp-icon:hover {
    color: var(--text);
    background: rgba(255, 255, 255, .10);
    transform: none;
    filter: none;
}

.mp-icon svg {
    display: block;
    width: 14px;
    height: 14px;
}

/* --------------------------------------------------------------------------
   4. 底部一行：上一首 / 播放 / 下一首 / 进度条 / 时间
   -------------------------------------------------------------------------- */
.mp-bar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 11px;
}

/* 圆形按钮通用样式，同样要覆盖全局 button 的渐变胶囊样式 */
.mp-btn {
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--text);
    background: rgba(255, 255, 255, .10);
    box-shadow: none;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease, color .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mp-btn svg {
    display: block;
    width: 16px;
    height: 16px;
}

.mp-btn:hover {
    background: rgba(255, 255, 255, .15);
    transform: translateY(-1px);
    filter: none;
}

.mp-btn:active {
    transform: scale(.93);
}

/* 中间的播放 / 暂停键：主题色渐变 + 外发光 */
.mp-play {
    width: 38px;
    height: 38px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #00c2ff);
    box-shadow:
        0 9px 22px rgba(124, 92, 255, .45),
        inset 0 1px 0 rgba(255, 255, 255, .38);
}

.mp-play:hover {
    background: linear-gradient(135deg, var(--primary), #00c2ff);
    filter: brightness(1.06);
    box-shadow:
        0 11px 28px rgba(124, 92, 255, .60),
        inset 0 1px 0 rgba(255, 255, 255, .45);
}

.mp-play svg {
    width: 16px;
    height: 16px;
}

/* 进度条：外层是 22px 高的透明热区，方便点击/拖动 */
.mp-progress {
    position: relative;
    flex: 1;
    height: 22px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.mp-track {
    position: relative;
    width: 100%;
    height: 3px;
    border-radius: 99px;
    background: rgba(255, 255, 255, .20);
    transition: height .22s ease;
}

/* 已播放部分：主题色到青色的渐变，带一点光晕 */
.mp-fill {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), #00d4ff);
    box-shadow: 0 0 10px rgba(0, 212, 255, .45);
}

/* 进度圆点：只有 hover 时才出现，避免平时太花 */
.mp-knob {
    position: absolute;
    top: 50%;
    left: 0;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(124, 92, 255, .32);
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}

.mp-progress:hover .mp-knob,
.mp-progress.is-seeking .mp-knob {
    opacity: 1;
}

.mp-progress:hover .mp-track {
    height: 4px;
}

/* 时间：等宽数字，播放时不会左右跳动 */
.mp-time {
    flex: none;
    font-size: 11px;
    color: var(--muted);
    opacity: .9;
    font-variant-numeric: tabular-nums;
    letter-spacing: .03em;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   5. 收起状态下的“贴边把手”
   卡片收起后，屏幕右边缘会留一条 38×104 的玻璃小条，鼠标移上去就展开。
   -------------------------------------------------------------------------- */
.mp-handle {
    position: absolute;
    top: auto;
    bottom: 0;
    right: -20px;                 /* 抵消 .mp 的 right:20px，正好贴住屏幕边缘 */
    width: 38px;
    height: 104px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .18);
    border-right: none;
    border-radius: 20px 0 0 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .05));
    backdrop-filter: blur(24px) saturate(175%);
    -webkit-backdrop-filter: blur(24px) saturate(175%);
    box-shadow: -12px 0 34px rgba(3, 6, 20, .45), inset 1px 0 0 rgba(255, 255, 255, .22);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateX(10px);
    transition: opacity .42s ease .12s,
                transform .55s cubic-bezier(.22, 1, .36, 1);
    -webkit-tap-highlight-color: transparent;
}

.mp.is-docked .mp-handle {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* 把手上的小唱片封面 */
.mp-handle-cover {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary), #00d4ff);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .14);
}

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

/* 把手下方的三条横杠：播放时从左到右泛起，提示“这里在放歌” */
.mp-handle-eq {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.mp-handle-eq i {
    display: block;
    width: 13px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary);
    opacity: .55;
}

.mp.is-playing .mp-handle-eq i:nth-child(1) { animation: mpBar 1.6s ease-in-out infinite; }
.mp.is-playing .mp-handle-eq i:nth-child(2) { animation: mpBar 1.6s ease-in-out .25s infinite; }
.mp.is-playing .mp-handle-eq i:nth-child(3) { animation: mpBar 1.6s ease-in-out .5s infinite; }

/* --------------------------------------------------------------------------
   6. “点击开启声音”小气泡
   浏览器不允许带声音自动播放时，会弹这个提示，用户点一下页面任意位置即可出声。
   -------------------------------------------------------------------------- */
.mp-hint {
    position: absolute;
    left: 50%;
    bottom: -36px;
    transform: translateX(-50%) translateY(6px);
    padding: 7px 13px;
    border-radius: 99px;
    font-size: 11px;
    line-height: 1.4;
    color: #fff;
    white-space: nowrap;
    background: rgba(10, 14, 30, .82);
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
    z-index: 3;
}

.mp-card.is-need-gesture .mp-hint {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   7. 亮色主题适配（主页切换到浅色时，玻璃要变白、文字变深）
   -------------------------------------------------------------------------- */
body.light .mp-card {
    background: linear-gradient(150deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .74));
    border-color: rgba(80, 100, 160, .15);
    box-shadow:
        0 22px 60px rgba(80, 100, 160, .22),
        0 2px 8px rgba(80, 100, 160, .08),
        inset 0 1px 0 rgba(255, 255, 255, .95);
}

body.light .mp-btn {
    background: rgba(23, 32, 51, .07);
    color: var(--text);
}

body.light .mp-btn:hover {
    background: rgba(23, 32, 51, .12);
}

/* 播放键在亮色下要保持主题色渐变，不能被上面的 .mp-btn 规则盖掉 */
body.light .mp-play {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #00c2ff);
    box-shadow: 0 9px 22px rgba(124, 92, 255, .40), inset 0 1px 0 rgba(255, 255, 255, .38);
}

body.light .mp-play:hover {
    background: linear-gradient(135deg, var(--primary), #00c2ff);
    box-shadow: 0 11px 28px rgba(124, 92, 255, .55), inset 0 1px 0 rgba(255, 255, 255, .45);
}

body.light .mp-track {
    background: rgba(23, 32, 51, .15);
}

body.light .mp-icon:hover {
    background: rgba(23, 32, 51, .08);
}

body.light .mp-handle {
    background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .78));
    border-color: rgba(80, 100, 160, .16);
    box-shadow: -12px 0 34px rgba(80, 100, 160, .18), inset 1px 0 0 rgba(255, 255, 255, .95);
}

body.light .mp-hint {
    background: rgba(23, 32, 51, .86);
}

/* --------------------------------------------------------------------------
   8. 窄屏适配：手机上改为贴右下角，卡片收窄，避免挡住正文
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
    .mp {
        right: 12px;
        top: auto;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        transform: none;
    }

    .mp-card {
        width: min(300px, calc(100vw - 30px));
        padding: 12px 12px 10px;
        border-radius: 22px;
    }

    .mp-handle {
        top: auto;
        bottom: 0;
        right: -12px;
        height: 86px;
        width: 34px;
        transform: translateX(10px);
    }

    .mp.is-docked .mp-handle {
        transform: translateX(0);
    }

    .mp-hint {
        bottom: auto;
        top: -34px;
    }
}

/* 非常矮的窗口（如横屏手机）再收一点 */
@media (max-height: 560px) and (max-width: 860px) {
    .mp-card {
        padding: 10px 12px 9px;
    }

    .mp-cover {
        width: 44px;
        height: 44px;
        border-radius: 13px;
    }
}

/* --------------------------------------------------------------------------
   9. 动效
   -------------------------------------------------------------------------- */
@keyframes mpBar {
    0%, 100% { opacity: .35; transform: scaleX(.7); }
    50%      { opacity: 1;   transform: scaleX(1); }
}

@keyframes mpFadeIn {
    from { opacity: 0; transform: scale(1.06); }
    to   { opacity: 1; transform: scale(1); }
}

/* 用户系统里开了“减少动效”时，取消所有滑动与跳动 */
@media (prefers-reduced-motion: reduce) {
    .mp-card,
    .mp-handle,
    .mp-fill,
    .mp-hint {
        transition-duration: .01ms !important;
    }

    .mp-handle-eq i {
        animation: none !important;
    }
}
