/* style.css */

/* 全局样式和重置 */
:root {
    --primary-pink: #FFB6C1; /* 淡粉色 */
    --secondary-pink: #FF69B4; /* 热门粉色 */
    --light-pink: #FFE4E1; /* 浅粉色，背景或边框 */
    --text-color-dark: #333;
    --text-color-light: #fff;
    --card-background: #FFF0F5; /* 花瓣粉 */
    --border-color: #FFC0CB; /* 粉红色，边框 */
    --hover-color: #FFDAB9; /* 桃色，用于悬停效果 */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif; /* 可以替换为更可爱的字体 */
    background-color: var(--light-pink);
    color: var(--text-color-dark);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* 确保页脚固定在底部 */
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: inherit;
}

/* 头部样式 */
.header {
    background-color: var(--primary-pink);
    color: var(--text-color-light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center; /* 左右两边对齐 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky; /* 使导航栏固定在顶部 */
    top: 0;
    z-index: 1000; /* 确保在其他内容之上 */
}

.site-title {
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.nav-list {
    display: flex;
    gap: 1.5rem;
}

.nav-item a {
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.nav-item a:hover,
.nav-item a.active {
    background-color: var(--secondary-pink);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 主要内容区域 */
.main-content {
    flex-grow: 1; /* 填充可用空间，将页脚推到底部 */
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page {
    display: none; /* 默认隐藏所有页面 */
    padding: 1.5rem;
    background-color: var(--card-background);
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.page.active {
    display: block; /* 激活的页面显示 */
}

.page h2 {
    color: var(--secondary-pink);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.05);
}

/* 歌曲列表容器 */
.song-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

/* 歌曲卡片样式 */
.song-card {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.song-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    background-color: var(--hover-color); /* 悬停背景色 */
}

.song-card-cover {
    width: 120px;
    height: 120px;
    border-radius: 50%; /* 圆形头像 */
    object-fit: cover;
    margin-bottom: 0.8rem;
    border: 3px solid var(--primary-pink); /* 粉色边框 */
}

.song-card-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--secondary-pink);
    margin-bottom: 0.3rem;
}

.song-card-artist {
    font-size: 0.95rem;
    color: #666;
}

/* 当前播放页面样式 */
.player-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #fff;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    margin: 0 auto;
}

.player-cover {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 0 5px var(--primary-pink); /* 粉色光环 */
}

.player-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 添加过渡，使启动/停止动画更平滑 */
    transition: transform 0.5s ease-out;
}

/* 定义旋转动画 */
@keyframes rotateDisk {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 应用旋转动画的类 */
.player-cover img.rotating {
    animation: rotateDisk 15s linear infinite; /* 15s是旋转一周的时间，linear表示匀速，infinite表示无限循环 */
}


.player-info {
    text-align: center;
    margin-bottom: 1.5rem;
}

.current-song-title {
    font-size: 1.8rem;
    color: var(--secondary-pink);
    margin-bottom: 0.5rem;
}

.current-artist {
    font-size: 1.2rem;
    color: #555;
}

.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 1.5rem;
}

.control-buttons {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-pink);
    color: var(--text-color-light);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.control-btn svg {
    width: 28px;
    height: 28px;
}

.control-btn:hover {
    background-color: var(--secondary-pink);
    transform: scale(1.05);
}

.progress-bar-container {
    display: flex;
    align-items: center;
    width: 80%;
    gap: 10px;
    margin-bottom: 1rem;
}

.current-time, .total-time {
    font-size: 0.9rem;
    color: #777;
    min-width: 40px; /* 确保时间显示完整 */
    text-align: center;
}

.progress-bar {
    flex-grow: 1;
    -webkit-appearance: none; /* 移除默认样式 */
    appearance: none;
    height: 8px;
    border-radius: 5px;
    background: var(--light-pink);
    outline: none;
    transition: opacity .2s;
    cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--secondary-pink);
    cursor: grab;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}

.progress-bar::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--secondary-pink);
    cursor: grab;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}

.other-controls {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* 歌词容器样式 */
.lyrics-container {
    width: 90%;
    height: 250px; /* 固定高度，内部滚动 */
    overflow-y: auto; /* 允许垂直滚动 */
    background-color: #fcfcfc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    font-size: 1.1rem;
    color: #555;
    line-height: 1.8;
    margin-top: 1.5rem;
    position: relative; /* 添加此行，确保内部元素定位的基准 */
}

.lyrics-content {
    /* 这个容器不需要设置高度或溢出，让其内容自然撑开 */
    position: relative; /* 核心改动：确保子元素 offsetTop 基于此元素计算 */
}

.lyrics-content p {
    margin-bottom: 0.5rem;
    transition: color 0.3s ease, font-weight 0.3s ease;
    padding: 2px 0; /* 增加一点上下内边距，让高亮更明显 */
}

.lyrics-content p.active-lyric {
    color: var(--secondary-pink);
    font-weight: bold;
    transform: scale(1.05);
}

/* 页脚样式 */
.footer {
    background-color: var(--primary-pink);
    color: var(--text-color-light);
    text-align: center;
    padding: 1rem;
    margin-top: auto; /* 将页脚推到底部 */
    width: 100%;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 - 手机版导航优化 */
@media (max-width: 768px) {
    .header {
        /* 在小屏幕下，让header变成一个flex容器，但方向是列，来容纳标题和导航 */
        flex-direction: column;
        padding: 0.8rem 1rem; /* 调整内边距，顶部可以小一点 */
        align-items: flex-start; /* 让标题和导航块左对齐 */
        gap: 0.5rem; /* 标题和导航块之间的间距 */
    }

    .site-title {
        width: 100%; /* 标题占据整行 */
        text-align: center; /* 标题居中 */
        margin-bottom: 0; /* 移除底部外边距，因为header的gap会处理间距 */
        font-size: 1.6rem; /* 手机版标题略小 */
        padding-bottom: 0.5rem; /* 标题下方加点内边距，与菜单分隔 */
        border-bottom: 1px solid rgba(255, 255, 255, 0.3); /* 标题下方加条线 */
    }

    .nav {
        width: 100%; /* 导航容器占据整行 */
        display: flex; /* 让导航容器内的菜单列表flex布局 */
        justify-content: center; /* 菜单列表在导航容器内居中 */
        align-items: center; /* 垂直居中 */
        padding-top: 0.5rem; /* 菜单上方加点内边距 */
    }

    .nav-list {
        flex-direction: row; /* 关键：让菜单项保持水平排列 */
        flex-wrap: wrap; /* 允许菜单项换行，以防内容过多 */
        justify-content: center; /* 菜单项在水平方向上居中 */
        gap: 0.8rem; /* 菜单项之间的间距 */
        padding: 0; /* 移除默认的ul内边距 */
        width: auto; /* 让其宽度由内容决定 */
    }

    .nav-item {
        flex-shrink: 0; /* 防止菜单项被压缩 */
    }

    .nav-item a {
        padding: 0.4rem 0.8rem; /* 调整内边距，更适合水平排列 */
        font-size: 0.95rem; /* 调整字体大小 */
        display: inline-block; /* 保持inline-block，方便水平排列和padding */
        min-width: 80px; /* 最小宽度，防止过小 */
        white-space: nowrap; /* 防止文本换行 */
    }
    
    /* 调整页面内边距和卡片大小，以适应小屏幕 */
    .main-content {
        padding: 1rem;
    }

    .page {
        padding: 1rem;
    }

    .page h2 {
        font-size: 1.8rem;
    }

    .song-list-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.8rem;
    }

    .song-card {
        padding: 0.6rem;
    }

    .song-card-cover {
        width: 80px;
        height: 80px;
        margin-bottom: 0.5rem;
    }

    .song-card-title {
        font-size: 1rem;
    }

    .song-card-artist {
        font-size: 0.85rem;
    }

    .player-container {
        padding: 1rem;
    }

    .player-cover {
        width: 120px;
        height: 120px;
        margin-bottom: 1rem;
    }

    .current-song-title {
        font-size: 1.6rem;
    }

    .current-artist {
        font-size: 1.1rem;
    }

    .control-btn {
        width: 40px;
        height: 40px;
    }

    .control-btn svg {
        width: 22px;
        height: 22px;
    }

    .progress-bar-container {
        width: 90%;
    }

    .current-time, .total-time {
        font-size: 0.85rem;
    }

    .lyrics-container {
        height: 180px; /* 手机版歌词容器高度更小 */
        font-size: 0.95rem;
        padding: 0.8rem;
    }
}

@media (max-width: 480px) {
    /* 针对更小的手机屏幕进行微调 */
    .site-title {
        font-size: 1.3rem;
    }
    .nav-item a {
        font-size: 0.9rem;
        padding: 0.4rem 0.7rem;
        min-width: 70px;
    }
    .current-song-title {
        font-size: 1.4rem;
    }

    .current-artist {
        font-size: 0.95rem;
    }
}
