/* ========================================
   Atomic Player - 优化版音乐播放器
   参考Apple Music风格设计
   ======================================== */

:root {
    --primary: #ff6b35;
    --primary-light: #ff8c5a;
    --primary-dark: #e55a2b;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --bg-dark: rgba(0, 0, 0, 0.2);
    --bg-darker: rgba(0, 0, 0, 0.4);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-lyrics: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-lyrics-active: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* ========================================
   背景层
   ======================================== */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.bg-cover {
    position: absolute;
    inset: -50px;
    width: calc(100% + 100px);
    height: calc(100% + 100px);
    object-fit: cover;
    filter: blur(100px) saturate(1.3);
    transform: scale(1.15);
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1), transform 2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.bg-cover.loaded {
    opacity: 0.6;
    transform: scale(1.05);
}

.bg-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, 
        rgba(0, 0, 0, 0.3) 0%, 
        rgba(0, 0, 0, 0.5) 50%, 
        rgba(0, 0, 0, 0.7) 100%);
}

/* ========================================
   主播放器区域
   ======================================== */
.player-main {
    flex: 1;
    display: grid;
    grid-template-columns: 45% 55%;
    gap: 2rem;
    padding: 2rem 3rem;
    overflow: hidden;
    min-height: 0;
}

/* ========================================
   左侧：专辑封面和控制
   ======================================== */
.player-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: 2rem;
    padding-bottom: 2rem;
}

/* 播放列表切换按钮 */
.btn-toggle-playlist {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--ease-spring);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.btn-toggle-playlist:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.btn-toggle-playlist svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* 专辑区域 */
.album-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    max-height: 100%;
}

.album-cover-wrapper {
    position: relative;
    width: min(320px, 35vh);
    height: min(320px, 35vh);
    background: transparent;
    flex-shrink: 0;
}

.album-disc {
    width: 100%;
    height: 100%;
    position: relative;
    background: transparent;
}

.disc-vinyl {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: background 0.8s ease, box-shadow 0.8s ease;
}

.disc-vinyl.has-cover {
    background: transparent;
    box-shadow: none;
}

.disc-vinyl.default-cover {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.4),
        0 10px 30px rgba(0, 0, 0, 0.3);
}



/* 专辑封面图片 */
.album-cover-img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    z-index: 5;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
}

.album-cover-img[src]:not([src=""]) {
    opacity: 1;
    transform: scale(1);
}

.disc-label {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 3;
}

.disc-label.visible {
    display: flex;
}

.disc-icon {
    font-size: 3rem;
    color: white;
}

.album-glow {
    display: none;
}

/* 歌曲信息 */
.song-info {
    text-align: center;
    width: 100%;
    max-width: 400px;
    padding: 0 1.5rem;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.song-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    max-height: 4.5rem;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.song-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.song-artist {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1) 0.15s;
}

.song-artist.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   右侧：纯文字歌词
   ======================================== */
.player-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 2rem;
    position: relative;
}

.lyrics-wrapper {
    width: 100%;
    max-width: 600px;
    height: 75vh;
    overflow: hidden;
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 15%,
        black 85%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 15%,
        black 85%,
        transparent 100%
    );
}

.lyrics-content {
    padding: 45vh 0;
    text-align: center;
    transition: transform 0.8s var(--ease-lyrics);
    will-change: transform;
    position: relative;
}

.lyrics-line {
    font-size: 1.5rem;
    line-height: 2.2;
    color: var(--text-muted);
    transition: all 1.2s var(--ease-lyrics);
    opacity: 0;
    transform: scale(0.88) translateY(10px);
    font-weight: 500;
    padding: 0.3rem 0;
    cursor: pointer;
    filter: blur(2px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    animation: lyricAppear 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes lyricAppear {
    to {
        opacity: 0.35;
        transform: scale(0.88) translateY(0);
    }
}

.lyrics-line:hover {
    opacity: 0.7;
}

.lyrics-line.active {
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    opacity: 1;
    transform: scale(1) translateY(0);
    text-shadow: 
        0 0 40px rgba(255, 255, 255, 0.3),
        0 0 80px rgba(255, 255, 255, 0.1);
    letter-spacing: 0.02em;
    transition: all 0.8s var(--ease-lyrics-active);
    filter: blur(0);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.6;
    padding: 0.5rem 1rem;
}

/* 歌词变为已播放状态的退场动画 */
@keyframes lyricDeactivate {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
        color: white;
    }
    15% {
        filter: blur(0.15px);
    }
    30% {
        filter: blur(0.4px);
    }
    45% {
        filter: blur(0.7px);
    }
    60% {
        filter: blur(1px);
    }
    75% {
        filter: blur(1.25px);
    }
    85% {
        opacity: 0.55;
    }
    92% {
        opacity: 0.48;
    }
    100% {
        opacity: 0.45;
        transform: scale(0.92) translateY(2px);
        filter: blur(1.5px);
        color: var(--text-secondary);
    }
}

/* 歌词激活时的入场动画 */
@keyframes lyricActivate {
    0% {
        opacity: 0.35;
        transform: scale(0.88) translateY(8px);
        filter: blur(2px);
    }
    15% {
        filter: blur(1.85px);
    }
    30% {
        filter: blur(1.6px);
    }
    45% {
        filter: blur(1.25px);
    }
    60% {
        filter: blur(0.9px);
    }
    72% {
        filter: blur(0.6px);
    }
    82% {
        filter: blur(0.35px);
    }
    90% {
        filter: blur(0.15px);
    }
    95% {
        filter: blur(0.05px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

.lyrics-line.active {
    animation: lyricActivate 1.2s var(--ease-lyrics-active) forwards;
}

.lyrics-line.passed {
    color: var(--text-secondary);
    transform: scale(0.92) translateY(2px);
    opacity: 0.45;
    filter: blur(1.5px);
    animation: lyricDeactivate 1s var(--ease-lyrics) forwards;
}

.lyrics-waiting {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-top: -45vh;
}

/* 等待开始的三个点 */
.lyrics-waiting-dots {
    position: absolute;
    top: 50%;
    left: calc(50% + 1rem);
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    z-index: 10;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.lyrics-waiting-dots.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -250%) scale(0.7);
}

.lyrics-waiting-dots.hidden .dot {
    transform: scale(0.5);
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.lyrics-waiting-dots.hidden .dot:nth-child(1) {
    transition-delay: 0s;
}

.lyrics-waiting-dots.hidden .dot:nth-child(2) {
    transition-delay: 0.08s;
}

.lyrics-waiting-dots.hidden .dot:nth-child(3) {
    transition-delay: 0.16s;
}

.lyrics-waiting-dots .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
    opacity: 1;
}

.lyrics-waiting-dots .dot.active {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.7), 0 0 80px rgba(255, 255, 255, 0.3);
    transform: scale(1.5);
}

/* ========================================
   播放列表侧边栏
   ======================================== */
.playlist-sidebar {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s var(--ease-smooth);
}

.playlist-sidebar.open {
    pointer-events: auto;
    opacity: 1;
}

.playlist-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.playlist-sidebar.open .playlist-overlay {
    opacity: 1;
}

.playlist-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s var(--ease-out-expo);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-sidebar.open .playlist-panel {
    transform: translateX(0);
}

.playlist-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.playlist-panel-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.btn-close-playlist {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease-smooth);
}

.btn-close-playlist:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.btn-close-playlist svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* 搜索框 */
.playlist-search {
    position: relative;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.playlist-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transition: all 0.2s;
}

.playlist-search input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.playlist-search input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.playlist-search svg {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    fill: rgba(255, 255, 255, 0.5);
}

/* 播放列表内容 */
.playlist-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.playlist-panel-content::-webkit-scrollbar {
    width: 6px;
}

.playlist-panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    margin: 0.25rem 0;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.playlist-item.active {
    background: rgba(255, 255, 255, 0.1);
}

.playlist-item.active .playlist-number {
    color: #fff;
    font-weight: 600;
}

.playlist-item.active .playlist-title {
    color: #fff;
    font-weight: 600;
}

.playlist-number {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    min-width: 24px;
    text-align: center;
}

.playlist-info {
    flex: 1;
    min-width: 0;
}

.playlist-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-artist {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.2rem;
}

.playlist-duration {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.playlist-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: #999;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.playlist-stats {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
    color: #999;
}

/* ========================================
   底部控制栏
   ======================================== */
.player-controls {
    padding: 1.5rem 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.controls-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-control {
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--ease-spring);
    backdrop-filter: blur(10px);
}

.btn-control:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.btn-control:active {
    transform: scale(0.88);
    background: rgba(255, 255, 255, 0.45);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-control svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.btn-control.active {
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.btn-play {
    width: 64px;
    height: 64px;
    border: none;
    background: white;
    border-radius: 50%;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--ease-spring);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.btn-play:hover {
    transform: scale(1.08);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
}

.btn-play:active {
    transform: scale(0.88);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-play svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* 进度条 */
.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 500px;
}

.time-current,
.time-total {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
}

.time-current {
    text-align: right;
}

.progress-bar {
    flex: 1;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    position: relative;
    overflow: visible;
}

.progress-fill {
    height: 100%;
    background: white;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
    position: relative;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s var(--ease-spring);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.progress-bar:hover .progress-fill::after {
    transform: translateY(-50%) scale(1);
}

/* 音量控制 */
.volume-wrapper {
    position: relative;
    display: inline-block;
}

.volume-popover {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    padding: 1rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s var(--ease-smooth);
    margin-bottom: 10px;
}

.btn-volume:hover + .volume-popover,
.volume-popover:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.volume-slider {
    width: 120px;
    height: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.volume-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    position: relative;
}

.volume-fill {
    height: 100%;
    background: white;
    border-radius: 2px;
    width: 70%;
    transition: width 0.1s, height 0.1s;
    position: absolute;
    top: 0;
    left: 0;
}

.volume-track {
    position: relative;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 1024px) {
    .player-main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .player-right {
        display: none;
    }
    
    .album-cover-wrapper {
        width: min(260px, 30vh);
        height: min(260px, 30vh);
    }
    
    .song-title {
        font-size: 1.6rem;
    }
    
    .playlist-panel {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .player-main {
        padding: 1rem;
    }
    
    .player-controls {
        padding: 1rem;
    }
    
    .album-cover-wrapper {
        width: min(200px, 25vh);
        height: min(200px, 25vh);
    }
    
    .song-title {
        font-size: 1.3rem;
        max-width: 280px;
    }
    
    .btn-play {
        width: 56px;
        height: 56px;
    }
    
    .btn-play svg {
        width: 24px;
        height: 24px;
    }
    
    /* 移动端音量菜单竖向 */
    .volume-popover {
        bottom: 100%;
        left: 50%;
        top: auto;
        transform: translateX(-50%) translateY(10px);
        padding: 1rem 1.5rem;
        margin-bottom: 10px;
        margin-left: 0;
    }
    
    .btn-volume:hover + .volume-popover,
    .volume-popover:hover {
        transform: translateX(-50%) translateY(0);
    }
    
    .volume-slider {
        width: 20px;
        height: 100px;
        flex-direction: column;
    }
    
    .volume-track {
        width: 4px;
        height: 100%;
    }
    
    .volume-fill {
        top: auto;
        bottom: 0;
        width: 100%;
        height: 70%;
    }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    fill: currentColor;
    margin-bottom: 1rem;
    opacity: 0.5;
}
