/* TechTutorials - 主样式文件 */
/* 版本: 2.0 | 包含暗色主题和响应式设计 */

:root {
    /* 亮色主题变量 */
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --background-color: #ffffff;
    --surface-color: #f8fafc;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* 代码高亮颜色 */
    --code-bg: #f1f5f9;
    --code-text: #334155;
    --code-comment: #64748b;
    --code-keyword: #dc2626;
    --code-string: #059669;
    --code-number: #d97706;
}

[data-theme="dark"] {
    /* 暗色主题变量 */
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    
    /* 暗色主题代码高亮 */
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --code-comment: #94a3b8;
    --code-keyword: #f87171;
    --code-string: #34d399;
    --code-number: #fbbf24;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* 导航栏 */
.navbar {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo:hover {
    color: var(--secondary-color);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.nav-links a:hover {
    background-color: var(--primary-color);
    color: white;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
}

/* 主要内容区域 */
main {
    flex: 1;
    padding: 2rem 0;
}

/* 英雄区域 */
.hero {
    text-align: center;
    padding: 4rem 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: 1rem;
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.25rem;
    max-width: 600px;
    margin: 0 auto 2rem;
    opacity: 0.9;
}

.cta-button {
    display: inline-block;
    background-color: white;
    color: var(--primary-color);
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* 文章网格 */
.section-title {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-color);
    position: relative;
    padding-bottom: 0.5rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 4rem;
}

.article-card {
    background-color: var(--surface-color);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
}

.article-image {
    height: 180px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
}

.article-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.article-content h3 a {
    color: var(--text-color);
    text-decoration: none;
}

.article-content h3 a:hover {
    color: var(--primary-color);
}

.article-excerpt {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    flex: 1;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: auto;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tag {
    background-color: var(--code-bg);
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 分类网格 */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.category-card {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: 0.75rem;
    text-align: center;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s;
    border: 1px solid var(--border-color);
}

.category-card:hover {
    transform: translateY(-3px);
}

.category-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.category-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.category-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* 文章页面样式 */
.article-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.article-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.article-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.article-meta {
    display: flex;
    justify-content: center;
    gap: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.article-content {
    font-size: 1.125rem;
    line-height: 1.8;
}

.article-content h2 {
    font-size: 1.75rem;
    margin: 2.5rem 0 1rem;
    color: var(--text-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.article-content h3 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    color: var(--text-color);
}

.article-content p {
    margin-bottom: 1.5rem;
}

.article-content ul, .article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.article-content code {
    background-color: var(--code-bg);
    color: var(--code-text);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

.article-content pre {
    background-color: var(--code-bg);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.article-content pre code {
    background: none;
    padding: 0;
    color: var(--code-text);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* 代码高亮 */
.token.comment { color: var(--code-comment); }
.token.keyword { color: var(--code-keyword); }
.token.string { color: var(--code-string); }
.token.number { color: var(--code-number); }
.token.function { color: #3b82f6; }
.token.operator { color: #8b5cf6; }

/* 广告容器 */
.ad-container {
    margin: 2rem 0;
    text-align: center;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface-color);
    border-radius: 0.5rem;
    border: 1px dashed var(--border-color);
    padding: 1rem;
}

.ad-container ins {
    width: 100%;
    max-width: 728px;
    margin: 0 auto;
}

/* 页脚 */
.footer {
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.footer-section p {
    color: var(--text-secondary);
    line-height: 1.7;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.75rem;
}

.footer-section ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section ul li a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.25rem;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    
    .articles-grid {
        grid-template-columns: 1fr;
    }
    
    .article-header h1 {
        font-size: 2rem;
    }
    
    .article-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 3rem 0;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .article-content {
        font-size: 1rem;
    }
    
    .article-content h2 {
        font-size: 1.5rem;
    }
    
    .article-content h3 {
        font-size: 1.25rem;
    }
}

/* 实用类 */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }


/* 主页特有样式补充 */
.categories-section {
    margin: 4rem 0;
}

.category-count {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* 特色教程区域 */
.featured-section {
    margin: 4rem 0;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.featured-card {
    background-color: var(--surface-color);
    border-radius: 0.75rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.featured-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
}

.featured-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.featured-card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.featured-card ul {
    list-style: none;
    padding: 0;
}

.featured-card li {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.featured-card li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.featured-card a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s;
    display: block;
    padding: 0.5rem 0;
}

.featured-card a:hover {
    color: var(--primary-color);
    padding-left: 0.5rem;
}

/* 统计区域 */
.stats-section {
    margin: 4rem 0;
    padding: 3rem 0;
    background-color: var(--surface-color);
    border-radius: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.stat-item {
    padding: 1.5rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* 社交链接 */
.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-link {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.social-link:hover {
    background-color: var(--secondary-color);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1.1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 2rem 1rem;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .featured-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .social-links {
        justify-content: center;
    }
}