/* ==========================================================================
   落雪音乐 (LX Server Web) - 现代化移动端原生级体验增强样式
   借鉴标杆：YesPlayMusic / Apple Music / 网易云音乐 PWA
   ========================================================================== */

:root {
    --sab: env(safe-area-inset-bottom, 0px);
    --sat: env(safe-area-inset-top, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --mobile-nav-height: 52px;
    --mobile-mini-player-height: 56px;
}

/* 黑胶慢速旋转动效 */
@keyframes spin-slow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.vinyl-spin {
    animation: spin-slow 18s linear infinite !important;
    border-radius: 50% !important;
}

.vinyl-paused {
    animation-play-state: paused !important;
}

/* ==========================================================================
   移动端响应式覆盖（屏幕宽度 < 768px）
   ========================================================================== */
@media (max-width: 767px) {
    /* 1. 顶部 Header 适配安全区并强制固定 */
    header {
        padding-top: var(--sat) !important;
        height: calc(3.5rem + var(--sat)) !important;
        flex-shrink: 0 !important;
    }

    /* 2. 页面主内容区域严格锁定高度（杜绝 iOS touch 滚动导致顶部 Header 消失） */
    main {
        overflow: hidden !important;
        padding-bottom: 0 !important;
        height: 100% !important;
        flex: 1 !important;
    }

    /* 3. 核心视图主容器底部对齐：精准贴合在 Mini 播放条上方 12px，消除多余空白并大幅增加歌曲列表可见高度 */
    #view-search,
    #view-songlist,
    #view-leaderboard,
    #view-favorites,
    #view-localmusic {
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-mini-player-height) + var(--sab) + 12px) !important;
    }

    /* 全页滚动的视图（设置、关于等）留足底部滚出距离 */
    #view-settings,
    #view-about,
    #songlist-grid,
    #sl-detail-list,
    #user-playlist-container,
    #custom-sources-list {
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-mini-player-height) + var(--sab) + 24px) !important;
        -webkit-overflow-scrolling: touch;
    }

    /* 排行榜与搜索列表内部优化：内部列表无需额外巨大内边距，分页条置底 */
    #lb-songs-list,
    #search-results {
        padding-bottom: 8px !important;
    }

    /* 排行榜分页栏：改为 100% 实心背景并置于列表之上，防止下方歌曲滑动时透过半透明背景发生文字重叠 */
    #lb-pagination {
        background-color: var(--bg-panel, #ffffff) !important;
        position: relative !important;
        z-index: 10 !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04) !important;
    }

    /* 4. 歌曲列表项优化：触控区域增大，更利于大拇指点按 */
    .song-item,
    .playlist-item,
    [data-song-id] {
        min-height: 52px !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }

    /* 4. 浮动 Mini 胶囊播放条（高仅 56px，释放近 70% 屏幕空间） */
    #player-footer {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        width: calc(100% - 20px) !important;
        bottom: calc(var(--mobile-nav-height) + var(--sab) + 8px) !important;
        height: var(--mobile-mini-player-height) !important;
        min-height: var(--mobile-mini-player-height) !important;
        padding: 0 12px !important;
        margin: 0 !important;
        border-radius: 16px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: rgba(18, 23, 41, 0.94) !important;
        backdrop-filter: blur(25px) !important;
        -webkit-backdrop-filter: blur(25px) !important;
        border: 1px solid rgba(255, 255, 255, 0.14) !important;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25) !important;
        z-index: 60 !important;
        overflow: hidden !important;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease !important;
    }

    /* 隐藏老旧的收起/展开面板按钮 */
    #btn-collapse-panel,
    #btn-expand-panel {
        display: none !important;
    }

    /* 进入全屏歌词详情页时，Mini 播放条与 Tab 导航平滑滑下离场 */
    #player-footer.is-detail-open {
        transform: translateY(200%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    #mobile-bottom-nav.is-detail-open {
        transform: translateY(120%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* 顶部 2.5px 极细微进度指示条（让上层父级 static，从而绝对贴合胶囊最顶边缘，根除横穿中间的灰色杂线） */
    #player-footer > div:nth-child(2),
    #player-footer > div:nth-child(2) > div,
    #player-footer > div:nth-child(2) > div > div {
        position: static !important;
    }

    /* 进度条容器及所有子项严格禁止拦截触控事件，杜绝阻挡按键与封面点击 */
    #player-footer > div:nth-child(2) > div:first-child,
    #player-footer > div:nth-child(2) > div:first-child * {
        pointer-events: none !important;
        height: 2.5px !important;
        max-height: 2.5px !important;
    }

    #progress-container {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 2.5px !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border-radius: 16px 16px 0 0 !important;
        z-index: 5 !important;
        margin: 0 !important;
        pointer-events: none !important;
    }

    #progress-bar {
        height: 100% !important;
        background: #10b981 !important;
        box-shadow: 0 0 10px rgba(16, 185, 129, 0.8) !important;
    }

    /* 彻底移除移动端 Mini 进度条上的圆圈触控手柄（杜绝点击后白圈突兀停在歌名上方） */
    #player-footer #progress-bar > div {
        display: none !important;
    }

    /* 隐藏 Mini 条中的繁复时间刻度和音频波形 */
    #time-current,
    #time-total,
    #visualizer-container {
        display: none !important;
    }

    /* 歌曲信息区（封面 + 歌名/歌手） */
    #player-song-info {
        flex: 1 !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        min-width: 0 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent;
    }

    /* 微缩唱片封面 */
    #player-song-info > div:first-child {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        border-radius: 10px !important;
        margin-right: 10px !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        overflow: hidden !important;
        transition: transform 0.3s ease, border-radius 0.3s ease;
    }

    #player-cover {
        border-radius: 9px !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    /* Mini 播放条文字容器垂直居中 */
    #player-song-info > div:nth-child(2) {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    /* 标题与副标题高对比度文字排版 */
    #player-title {
        font-size: 14px !important;
        font-weight: 700 !important;
        line-height: 1.25 !important;
        color: #ffffff !important;
        max-width: calc(100vw - 180px) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    #player-artist {
        font-size: 11.5px !important;
        color: #94a3b8 !important;
        line-height: 1.25 !important;
        margin-top: 2px !important;
        max-width: calc(100vw - 180px) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Mini 胶囊播放条内隐藏状态文字（如“播放中 (无损音质) 【服务器缓存】”），保持原生级极简双行布局 */
    #player-footer #player-status {
        display: none !important;
    }

    /* 彻底隐藏 Mini 条里原本桌面级混乱的 6 个微型按键 */
    #player-song-info .ml-auto {
        display: none !important;
    }

    /* 彻底解决 Mini 播放条内跑马灯重叠、重复文字乱跑的问题 */
    #player-footer .animate-marquee {
        animation: none !important;
        transform: none !important;
        display: inline-block !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    #player-footer .animate-marquee > span:not(:first-child) {
        display: none !important;
    }

    #player-footer [style*="mask-image"] {
        mask-image: none !important;
        -webkit-mask-image: none !important;
    }

    /* 右侧控制区：垂直绝对居中，杜绝任何切边或下沉 */
    #player-footer > div:nth-child(2) {
        flex: none !important;
        width: auto !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        order: 2 !important;
        gap: 2px !important;
        position: relative !important;
        z-index: 10 !important;
        pointer-events: auto !important;
    }

    /* 进度条外层容器归零，不占用竖向空间，防止把按键挤下去 */
    #player-footer > div:nth-child(2) > div:first-child {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 2.5px !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 0 !important;
        border: none !important;
    }

    #player-footer > div:nth-child(2) > div.flex.items-center,
    #player-footer > div:nth-child(2) > div:nth-child(2) {
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: 100% !important;
        gap: 4px !important;
    }

    /* 隐藏次要菜单 */
    #play-mode-btn,
    #playback-rate-btn,
    #play-mode-menu,
    #playback-rate-menu,
    button[onclick="playPrev()"] {
        display: none !important;
    }

    /* 醒目大号圆形播放键（防误触） */
    #btn-play {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        border-radius: 50% !important;
        background: #10b981 !important;
        color: #ffffff !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45) !important;
        margin: 0 4px !important;
        border: none !important;
        position: relative !important;
        z-index: 20 !important;
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    #btn-play:active {
        transform: scale(0.92) !important;
    }

    #btn-play i {
        font-size: 15px !important;
        margin-left: 2px !important;
        pointer-events: none !important;
    }

    /* 下一首按钮 */
    button[onclick="playNext()"] {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #e2e8f0 !important;
        font-size: 16px !important;
        padding: 8px !important;
        border: none !important;
        background: transparent !important;
        position: relative !important;
        z-index: 20 !important;
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    button[onclick="playNext()"]:active {
        transform: scale(0.9) !important;
    }

    /* Mini 上的播放列表快捷键 */
    #mobile-mini-queue-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #cbd5e1 !important;
        font-size: 15px !important;
        padding: 8px !important;
        border: none !important;
        background: transparent !important;
        position: relative !important;
        z-index: 20 !important;
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    #mobile-mini-queue-btn:active {
        color: #10b981 !important;
        transform: scale(0.9) !important;
    }

    /* 5. 底部原生级 Tab 导航栏 */
    #mobile-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: calc(var(--mobile-nav-height) + var(--sab)) !important;
        padding-bottom: var(--sab) !important;
        background: rgba(15, 23, 42, 0.96) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        z-index: 65 !important;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease !important;
    }

    #mobile-bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 5px 0;
        color: #94a3b8;
        font-size: 10.5px;
        transition: color 0.15s ease, transform 0.1s ease;
        -webkit-tap-highlight-color: transparent;
        background: transparent;
        border: none;
    }

    #mobile-bottom-nav button.active-mobile-tab {
        color: #10b981 !important;
        font-weight: 600;
    }

    #mobile-bottom-nav button i {
        font-size: 17px;
        margin-bottom: 2px;
    }

    /* 6. 全屏沉浸播放与歌词页（针对移动端全量优化） */
    #view-player-detail {
        z-index: 100 !important;
        padding-bottom: calc(0.5rem + var(--sab)) !important;
        background: #0f172a !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden !important;
    }

    #player-detail-container {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        flex: 1;
    }

    /* 全屏沉浸页文字与收起按钮高对比度优化 */
    #detail-title {
        color: #ffffff !important;
        font-weight: 800 !important;
    }

    #detail-artist {
        color: #cbd5e1 !important;
    }

    #btn-toggle-lyrics {
        color: #ffffff !important;
        background: rgba(255, 255, 255, 0.2) !important;
        border: 1px solid rgba(255, 255, 255, 0.25) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
    }

    #btn-toggle-lyrics:active {
        background: rgba(255, 255, 255, 0.35) !important;
    }

    #toggle-hint {
        color: #34d399 !important;
        opacity: 0.85 !important;
    }

    /* 全屏页专用底部控制栏 */
    #mobile-detail-controls {
        display: flex !important;
        width: 100%;
        padding: 0 1.5rem calc(0.5rem + var(--sab)) 1.5rem;
        flex-direction: column;
        align-items: center;
        z-index: 20;
    }

    /* 7. 自定义源卡片 Header 与空状态移动端美化（根除突兀悬挂的按钮） */
    div:has(> #btn-custom-source-manage) {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    #btn-custom-source-manage {
        padding: 4px 11px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        border-radius: 9999px !important;
        background: rgba(16, 185, 129, 0.12) !important;
        color: #059669 !important;
        border: 1px solid rgba(16, 185, 129, 0.25) !important;
        box-shadow: none !important;
        margin-left: auto !important;
        transition: all 0.2s ease !important;
    }

    #btn-custom-source-manage:active {
        background: rgba(16, 185, 129, 0.25) !important;
        transform: scale(0.96) !important;
    }

    #btn-custom-source-manage.mobile-hidden-on-empty {
        display: none !important;
    }

    /* 空状态下的黄金居中引导按钮 */
    .mobile-empty-add-btn {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 9px 20px !important;
        border-radius: 12px !important;
        background: #10b981 !important;
        color: #ffffff !important;
        font-weight: 700 !important;
        font-size: 12px !important;
        box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35) !important;
        margin-top: 12px !important;
        border: none !important;
        cursor: pointer !important;
        transition: transform 0.15s ease, background-color 0.2s ease !important;
    }

    .mobile-empty-add-btn:active {
        transform: scale(0.96) !important;
        background: #059669 !important;
    }

    /* 8. 移动端全屏歌词页与播放队列抽屉顶层适配 */
    #queue-drawer {
        z-index: 120 !important;
        padding-bottom: calc(1rem + var(--sab)) !important;
    }

    #lyric-content {
        padding-top: 60px !important;
        padding-bottom: 140px !important;
    }

    .lyric-line {
        font-size: 15.5px !important;
        line-height: 2.1 !important;
        color: rgba(255, 255, 255, 0.6) !important;
    }

    .lyric-line.active {
        font-size: 19px !important;
        font-weight: 700 !important;
        color: #10b981 !important;
        text-shadow: 0 0 16px rgba(16, 185, 129, 0.6) !important;
        transform: scale(1.04) !important;
    }
}

/* 桌面端专用样式优化（屏幕宽度 >= 768px） */
@media (min-width: 768px) {
    #mobile-bottom-nav {
        display: none !important;
    }
    #mobile-detail-controls {
        display: none !important;
    }
    #mobile-mini-queue-btn {
        display: none !important;
    }

    /* 1. 桌面端隐藏顶部 Header 导航条，消除冗余的“排行榜”标题栏，将工具栏与列表区全额上移扩容 */
    header {
        display: none !important;
    }

    /* 2. 彻底去除底栏音轨动态跳动频谱（响应用户要求彻底去除箭头所指的动态效果） */
    #visualizer-container {
        display: none !important;
    }

    /* 3. 桌面端主视图底部内边距精确设为 7rem (112px)，完美避让 96px 底部播放条并留足舒适间距，彻底杜绝翻页栏被遮挡 */
    #view-search,
    #view-songlist,
    #view-leaderboard,
    #view-favorites,
    #view-localmusic {
        padding-bottom: 7rem !important;
    }

    #view-settings,
    #view-about {
        padding-bottom: 7.5rem !important;
    }

    /* 歌单网格容器去除重复的底部内边距，释放垂直空间使得卡片完整展示 */
    #songlist-grid {
        padding-bottom: 0.5rem !important;
    }

    /* 4. 消除歌单详情页及各大歌曲列表底部的冗余空白区域（释放超 100px 视野，展示更多歌曲） */
    #songlist-detail-view {
        padding-bottom: 6.25rem !important;
    }
    #sl-detail-list,
    #lb-songs-list,
    #fav-songs-list {
        padding-bottom: 0.5rem !important;
    }

    /* 5. 侧边栏贴底优化：消除大片黑色无用留白，将账号卡片与定时工具紧贴底部播放条 */
    #main-sidebar {
        padding-bottom: 6.8rem !important; /* 完美避让 96px 播放条并留出 12px 舒适间距 */
    }
    #sidebar-footer {
        margin-top: auto !important;
        padding: 0.65rem 0.75rem 0.65rem 0.75rem !important;
    }
}

