/**
 * 首页专用样式
 * 包含英雄区域、主要布局和内容展示样式
 */

/* ===== 英雄区域 ===== */
.hero-section {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-20) 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 400px;
    display: flex;
    align-items: center;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    opacity: 0.6;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    margin: 0 0 var(--space-6) 0;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    line-height: 1.1;
    background: linear-gradient(45deg, #ffffff, #f0f8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    opacity: 0.95;
    margin: 0 0 var(--space-8) 0;
    font-weight: 400;
    line-height: 1.5;
}

/* ===== 主要布局容器 ===== */
.main-container {
    max-width: 1200px;
    margin: calc(-1 * var(--space-20)) auto var(--space-8);
    padding: 0 var(--space-6);
    position: relative;
    z-index: 3;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: var(--space-8);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    padding: var(--space-8);
}

.main-content {
    min-width: 0; /* 防止flex项目溢出 */
}

/* ===== 侧边栏 ===== */
.sidebar {
    background-color: var(--bg-primary);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    height: fit-content;
    border: 1px solid var(--bg-tertiary);
}

.sidebar h3 {
    margin: 0 0 var(--space-4) 0;
    color: var(--text-primary);
    font-size: var(--font-xl);
    font-weight: 600;
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--primary-color);
    position: relative;
}

.sidebar h3::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 30px;
    height: 2px;
    background: var(--secondary-color);
}

/* ===== 文章列表 ===== */
.post-list,
.random-post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-item {
    padding: var(--space-3);
    border-bottom: 1px solid var(--bg-tertiary);
    transition: var(--transition-base);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
}

.post-item:hover {
    background-color: var(--bg-secondary);
    transform: translateX(4px);
}

.post-item:last-child {
    border-bottom: none;
}

.post-item a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-sm);
    line-height: 1.4;
    display: block;
}

.post-item a:hover {
    color: var(--primary-color);
}

.post-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ===== 热门文章列表 ===== */
.popular-articles-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.popular-item {
    display: flex;
    align-items: flex-start;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--bg-tertiary);
    transition: var(--transition-base);
}

.popular-item:last-child {
    border-bottom: none;
}

.popular-item:hover {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding-left: var(--space-2);
    padding-right: var(--space-2);
}

.popular-item .rank {
    background: var(--gradient-primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-xs);
    font-weight: 700;
    margin-right: var(--space-3);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.popular-content {
    flex: 1;
    min-width: 0;
}

.popular-content a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    line-height: 1.4;
    transition: color var(--transition-base);
    display: block;
}

.popular-content a:hover {
    color: var(--primary-color);
}

.popular-views {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* ===== 文章网格 ===== */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-8);
    margin-bottom: var(--space-12);
}

.article-card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition-base);
    border: 1px solid var(--bg-tertiary);
    height: fit-content;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.article-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.article-card:hover img {
    transform: scale(1.05);
}

.article-card-content {
    padding: var(--space-8);
}

.article-card h3 {
    margin: 0 0 var(--space-3) 0;
    font-size: var(--font-xl);
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.article-card h3 a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-base);
}

.article-card h3 a:hover {
    color: var(--primary-color);
}

.article-excerpt {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-4);
    font-size: var(--font-base);
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-sm);
    color: var(--text-muted);
    padding-top: var(--space-3);
    border-top: 1px solid var(--bg-tertiary);
}

.article-category {
    background: var(--primary-color);
    color: white;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--font-xs);
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--transition-base);
}

.article-category:hover {
    background: var(--secondary-color);
}

.article-date,
.article-views {
    color: var(--text-muted);
}

/* ===== 分页样式 ===== */
.pagination {
    text-align: center;
    margin: var(--space-12) 0;
    padding: var(--space-8) 0;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: var(--space-3) var(--space-4);
    margin: 0 var(--space-1);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all var(--transition-base);
    font-weight: 500;
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.pagination .current {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination .disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .disabled:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--bg-tertiary);
    transform: none;
}

/* ===== 内容区块 ===== */
.content-section {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: var(--space-8);
    margin-bottom: var(--space-8);
    border: 1px solid var(--bg-tertiary);
}

.content-section h2 {
    color: var(--text-primary);
    font-size: var(--font-2xl);
    margin: 0 0 var(--space-4) 0;
    font-weight: 600;
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--primary-color);
    position: relative;
}

.content-section h2::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 50px;
    height: 2px;
    background: var(--secondary-color);
}

/* ===== 文章和页面区块 ===== */
.articles-section,
.pages-section {
    margin-bottom: var(--space-8);
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-8);
    padding: var(--space-8) 0;
}

.section-title {
    font-size: var(--font-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-3) 0;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-description {
    font-size: var(--font-lg);
    color: var(--text-secondary);
    margin: 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.article-block {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-8);
    overflow: hidden;
    border: 1px solid var(--bg-tertiary);
}

.article-block-header {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-4) var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.article-block-title {
    font-size: var(--font-xl);
    font-weight: 600;
    margin: 0;
}

.article-block-more {
    color: white;
    text-decoration: none;
    font-size: var(--font-sm);
    opacity: 0.9;
    transition: opacity var(--transition-base);
}

.article-block-more:hover {
    opacity: 1;
}

.article-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--bg-secondary);
}

.article-card-title {
    font-size: var(--font-lg);
    font-weight: 600;
    margin: 0 0 var(--space-2) 0;
    color: var(--text-primary);
    line-height: 1.4;
}

.article-card-title a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-base);
}

.article-card-title a:hover {
    color: var(--primary-color);
}

.article-card-excerpt {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin: var(--space-2) 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-3);
}

.article-card-category {
    background: var(--primary-color);
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--font-xs);
    font-weight: 500;
}

.article-card-date,
.article-card-views {
    color: var(--text-muted);
}

/* ===== 无内容消息 ===== */
.no-content-message {
    text-align: center;
    padding: var(--space-16) var(--space-8);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    margin: var(--space-8) 0;
}

.no-content-message h2 {
    color: var(--text-primary);
    font-size: var(--font-3xl);
    margin-bottom: var(--space-4);
    font-weight: 600;
}

.no-content-message p {
    color: var(--text-secondary);
    font-size: var(--font-lg);
    line-height: 1.6;
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr 280px;
        gap: var(--space-6);
    }
    
    .article-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .main-container {
        margin: calc(-1 * var(--space-8)) auto var(--space-4);
        padding: 0 var(--space-4);
    }
    
    .hero-section {
        padding: var(--space-8) 0;
        min-height: 300px;
    }
    
    .sidebar {
        order: -1;
    }
    
    .article-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 0 var(--space-2);
    }
    
    .content-wrapper {
        padding: var(--space-4);
    }
    
    .hero-section {
        padding: var(--space-6) 0;
        min-height: 250px;
    }
    
    .article-card-content {
        padding: var(--space-4);
    }
}

/* ===== 随机文章列表样式 ===== */
.random-post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.random-post-list li {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--bg-tertiary);
    transition: all var(--transition-base);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-1);
    position: relative;
}

.random-post-list li:hover {
    background-color: var(--bg-secondary);
    transform: translateX(4px);
    padding-left: var(--space-2);
    padding-right: var(--space-2);
}

.random-post-list li:last-child {
    border-bottom: none;
}

.random-post-list li a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-sm);
    line-height: 1.5;
    display: block;
    transition: color var(--transition-base);
    position: relative;
}

.random-post-list li a:hover {
    color: var(--primary-color);
}

.random-post-list li a::before {
    content: '🎲';
    margin-right: var(--space-2);
    font-size: var(--font-xs);
    opacity: 0.7;
    transition: opacity var(--transition-base);
}

.random-post-list li:hover a::before {
    opacity: 1;
}

/* ===== 分类筛选器样式 ===== */
.category-filter {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    margin-bottom: var(--space-8);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--bg-tertiary);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.category-filter span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-base);
    white-space: nowrap;
}

.category-link {
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-lg);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-sm);
    transition: all var(--transition-base);
    border: 2px solid transparent;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
}

.category-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.category-link:hover::before {
    left: 100%;
}

.category-link:hover {
    background: var(--gradient-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.category-link.active {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.category-link.active::after {
    content: '✓';
    margin-left: var(--space-1);
    font-size: var(--font-xs);
    opacity: 0.9;
}

/* ===== 分类标签样式 ===== */
.category-tag {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--font-xs);
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.category-tag:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ===== 响应式优化 ===== */
@media (max-width: 768px) {
    .category-filter {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }
    
    .category-filter span {
        margin-bottom: var(--space-2);
    }
    
    .category-link {
        margin: var(--space-1);
    }
}

@media (max-width: 480px) {
    .category-filter {
        padding: var(--space-4);
    }
    
    .category-link {
        font-size: var(--font-xs);
        padding: var(--space-1) var(--space-3);
    }
}

/* ===== 内容展示控制样式 ===== */
/* 当内容被隐藏时的样式处理 */
.no-content-message {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    margin: var(--space-6) 0;
    border: 2px dashed var(--bg-tertiary);
}

.no-content-message h2 {
    color: var(--text-secondary);
    font-size: var(--font-xl);
    margin-bottom: var(--space-4);
    font-weight: 600;
}

.no-content-message p {
    color: var(--text-tertiary);
    font-size: var(--font-base);
    margin: 0;
    line-height: 1.6;
}

/* 隐藏二级页面时的布局调整 */
.content-wrapper:has(.pages-section:empty) {
    grid-template-columns: 1fr;
}

.content-wrapper:has(.articles-section:empty) {
    grid-template-columns: 300px;
    justify-content: center;
}

.content-wrapper:has(.pages-section:empty):has(.articles-section:empty) {
    grid-template-columns: 1fr;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 随机页面功能关闭时的样式 */
.random-post-list .no-content {
    color: var(--text-tertiary);
    font-style: italic;
    text-align: center;
    padding: var(--space-4);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px dashed var(--bg-tertiary);
}

/* 分页隐藏时的间距调整 */
.pagination:empty {
    display: none;
}

.main-content:has(.pagination:empty) {
    margin-bottom: 0;
}

/* 分类筛选器隐藏时的间距调整 */
.category-filter:empty {
    display: none;
}

.main-content:has(.category-filter:empty) {
    padding-top: 0;
}

/* 响应式布局优化 */
@media (max-width: 768px) {
    .content-wrapper:has(.pages-section:empty),
    .content-wrapper:has(.articles-section:empty) {
        grid-template-columns: 1fr;
    }
    
    .no-content-message {
        padding: var(--space-6) var(--space-3);
    }
    
    .no-content-message h2 {
        font-size: var(--font-lg);
    }
}

@media (max-width: 480px) {
    .no-content-message {
        padding: var(--space-4) var(--space-2);
        margin: var(--space-4) 0;
    }
    
    .no-content-message h2 {
        font-size: var(--font-base);
        margin-bottom: var(--space-2);
    }
    
    .no-content-message p {
        font-size: var(--font-sm);
    }
}