/* 全局样式 */
:root {
    --primary-color: #007bff;
    --border-color: #e9ecef;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #333;
    --text-secondary: #6c757d;
    --rank-color-1: #fe2d46;
    --rank-color-2: #f60;
    --rank-color-3: #faa90e;
    --scrollbar-color: #ccc;
    --scrollbar-bg: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    /* max-width: 1200px;*/
    margin: 0 auto;
    padding: 0 15px;
}

/* 头部样式 */
.header {
    background-color: var(--primary-color);
    color: white;
    /* 修改：减少了垂直padding */
    padding: 0.75rem 0; 
    text-align: center;
    margin-bottom: 1rem;
}

.header h1 {
    margin: 0;
    font-size: 1.8rem; /* 适当调小标题字体大小 */
}

/* 主内容区域 */
#main-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* 卡片样式 */
.card {
    background-color: var(--card-background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-header {
    display: flex;
    align-items: center;
    /* 修改：减少了padding */
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header img {
    width: 20px; /* 适当调小图标 */
    height: 20px;
    margin-right: 10px;
}

.card-header h2 {
    margin: 0;
    font-size: 1.1rem; /* 适当调小卡片标题字体 */
}

.card-body {
    padding: 0.5rem;
    max-height: 380px;
    overflow-y: auto;
    flex-grow: 1;
    /* 针对 Firefox */
    scrollbar-color: var(--scrollbar-bg) transparent;
    transition: scrollbar-color 0.3s;
}

.card-body:hover {
    /* 鼠标悬停时显示滚动条 - Firefox */
    scrollbar-color: var(--scrollbar-color) transparent;
}

/* 针对 WebKit 浏览器 (Chrome, Safari) */
.card-body::-webkit-scrollbar {
    width: 8px;
}

.card-body::-webkit-scrollbar-track {
    background: transparent;
}

.card-body::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 10px;
    border: 3px solid transparent;
}

.card-body:hover::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-color);
}


.hotlist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hotlist li {
    display: flex;
    align-items: center;
    /* 修改：减少了列表项的下边距 */
    margin-bottom: 0.5rem; 
    font-size: 0.95rem;
}

.hotlist a {
	line-height: 1.4;
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s;
    white-space: normal;
}

.hotlist a:hover {
    color: var(--primary-color);
}

.rank {
    font-weight: bold;
    font-style: italic;
    font-size: 1rem;
    min-width: 25px;
    text-align: center;
    margin-right: 10px;
    color: var(--text-secondary);
}

/* 前三名排名颜色 */
.rank.rank-1 { color: var(--rank-color-1); }
.rank.rank-2 { color: var(--rank-color-2); }
.rank.rank-3 { color: var(--rank-color-3); }

/* 页脚样式 */
.footer {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* 移动端样式 - 屏幕宽度小于768px时应用 */
@media (max-width: 768px) {
    body {
        overflow-y: hidden; /* 在移动端禁用垂直滚动 */
    }

    .container {
        padding: 0; /* 移动端不需要内边距 */
    }

    #main-content {
        display: flex; /* 使用 flexbox 进行水平布局 */
        overflow-x: auto; /* 允许水平滚动 */
        scroll-snap-type: x mandatory; /* 强制滚动捕捉 */
        height: 100vh; /* 减去头部和尾部的高度 */
        width: calc(100vw - 1rem);
        padding: 0;
        margin-top: 0.5rem; /* 为固定的头部留出空间 */
        margin-bottom: 0.5rem; /* 为固定的尾部留出空间 */
    }

    .card {
        flex: 0 0 calc(100vw - 1rem); /* 每个卡片占据整个视口宽度 */
        scroll-snap-align: start; /* 滚动时对齐到卡片的开始位置 */
    }

    .card-body {
        max-height: none; /* 移除最大高度限制，使其填充剩余空间 */
    }
    
    .header {
        padding: 0.5rem 0;
        margin-bottom: 0;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .footer {
        position: fixed; /* 固定定位 */
        bottom: 0;
        width: 100%;
        z-index: 100; /* 确保在最上层 */
    }
}
/* 新的加载占位符样式 */
.placeholder-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem; /* 与 .hotlist li 保持一致 */
    font-size: 0.95rem;    /* 与 .hotlist li 保持一致 */
}

.rank-placeholder {
    min-width: 25px;       /* 与 .rank 保持一致 */
    height: 1rem;          /* 与 .rank 字体大小接近 */
    margin-right: 10px;    /* 与 .rank 保持一致 */
    background: linear-gradient(to right, #eef0f2 8%, #e0e4e8 18%, #eef0f2 33%);
    background-size: 1200px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
}

.line-placeholder {
    height: 1.2em; /* 与列表项的行高接近 */
    flex-grow: 1;
    background: linear-gradient(to right, #eef0f2 8%, #e0e4e8 18%, #eef0f2 33%);
    background-size: 1200px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
}

/* 为加载条设置不同的随机宽度，更显逼真 */
.placeholder-item:nth-of-type(1) .line-placeholder { width: 90%; }
.placeholder-item:nth-of-type(2) .line-placeholder { width: 95%; }
.placeholder-item:nth-of-type(3) .line-placeholder { width: 85%; }
.placeholder-item:nth-of-type(4) .line-placeholder { width: 92%; }
.placeholder-item:nth-of-type(5) .line-placeholder { width: 88%; }
.placeholder-item:nth-of-type(6) .line-placeholder { width: 93%; }
.placeholder-item:nth-of-type(7) .line-placeholder { width: 89%; }

@keyframes shimmer {
    0% {
        background-position: -600px 0;
    }
    100% {
        background-position: 600px 0;
    }
}