/* ============================================
   Simple Blog - 现代简洁风格
   ============================================ */

/* TsangerJinKai02 字体 - 来自 tw93.fun */
@font-face {
    font-family: 'TsangerJinKai02';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('https://gw.alipayobjects.com/os/k/jinkai/tsanger-jinkai-w04-subset-1.woff2') format('woff2');
}

/* CSS 变量 */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --font-sans: 'TsangerJinKai02', 'STKaiti', 'KaiTi', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
    --max-width: 1200px;
    --header-height: 64px;
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #3b82f6;
        --primary-dark: #2563eb;
        --secondary: #94a3b8;
        --background: #0f172a;
        --surface: #1e293b;
        --surface-hover: #334155;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        --border: #334155;
        --border-light: #1e293b;
    }
}

/* 重置样式 */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* 容器 */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* 头部导航 */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

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

.nav-links {
    display: flex;
    list-style: none;
    gap: 32px;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
}

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

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    transition: transform 0.3s ease;
}

/* 主要内容 */
.site-main {
    min-height: calc(100vh - var(--header-height) - 80px);
    padding: 40px 0;
}

/* Hero 区域 */
.hero {
    padding: 16px 0 12px;
    text-align: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* 内容布局 */
.content-section {
    padding: 40px 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 48px;
}

.main-content {
    min-width: 0;
}

/* 侧边栏 */
.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 40px);
    height: fit-content;
}

.widget {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.widget-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: 8px;
}

.category-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.category-list a:hover {
    background-color: var(--surface-hover);
    color: var(--primary);
}

.category-list .count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-cloud .tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background-color: var(--background);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

.tag-cloud .count {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* 文章卡片 */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.post-card {
    padding: 32px;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.post-date {
    color: var(--text-muted);
}

.post-category {
    padding: 4px 12px;
    background-color: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.post-category:hover {
    background-color: var(--primary-dark);
    color: white;
}

.post-title {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 12px;
}

.post-title a {
    color: var(--text-primary);
}

.post-title a:hover {
    color: var(--primary);
}

.post-excerpt {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.7;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.post-tags .tag {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.post-tags .tag:hover {
    color: var(--primary);
}

/* 文章详情页 */
.post-single {
    max-width: 800px;
    margin: 0 auto;
}

.post-single .post-header {
    text-align: center;
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.post-single .post-title {
    font-size: 2.75rem;
    margin-bottom: 16px;
}

.post-single .post-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.post-content {
    font-size: 1.0625rem;
    line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
    margin-top: 48px;
    margin-bottom: 20px;
    font-weight: 600;
    line-height: 1.3;
}

.post-content h2 {
    font-size: 1.75rem;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.post-content h3 {
    font-size: 1.375rem;
}

.post-content p {
    margin-bottom: 24px;
}

.post-content ul,
.post-content ol {
    margin-bottom: 24px;
    padding-left: 24px;
}

.post-content li {
    margin-bottom: 8px;
}

.post-content a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.post-content blockquote {
    margin: 32px 0;
    padding: 20px 24px;
    border-left: 4px solid var(--primary);
    background-color: var(--surface);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--text-secondary);
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 2px 6px;
    background-color: var(--surface);
    border-radius: 4px;
    color: var(--primary);
}

.post-content pre {
    margin: 24px 0;
    padding: 20px;
    background-color: #1e293b;
    border-radius: var(--radius);
    overflow-x: auto;
}

.post-content pre code {
    background-color: transparent;
    color: #e2e8f0;
    padding: 0;
    font-size: 0.9rem;
}

.post-content img {
    border-radius: var(--radius);
    margin: 24px 0;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
}

.post-content th,
.post-content td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.post-content th {
    background-color: var(--surface);
    font-weight: 600;
}

.post-footer {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

/* 页面头部 */
.page-header {
    text-align: center;
    padding: 60px 0 40px;
}

.page-title {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-description {
    color: var(--text-secondary);
}

/* 分类网格 */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.category-card {
    padding: 32px;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.2s ease;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.category-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.category-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 标签云 */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    padding: 40px 0;
}

.tag-item {
    padding: 12px 20px;
    background-color: var(--surface);
    border-radius: 30px;
    border: 1px solid var(--border);
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.tag-item:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

.tag-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-left: 4px;
}

.tag-item:hover .tag-count {
    color: rgba(255, 255, 255, 0.8);
}

/* 页脚 */
.site-footer {
    padding: 40px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* 搜索弹窗 */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.search-modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
}

.search-container {
    width: 100%;
    max-width: 600px;
    background-color: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.search-input {
    width: 100%;
    padding: 20px 24px;
    font-size: 1.125rem;
    border: none;
    outline: none;
    background-color: var(--background);
    color: var(--text-primary);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: white;
    cursor: pointer;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.search-result-item {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: var(--surface);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.search-result-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
        order: -1;
    }
    
    .widget {
        margin-bottom: 16px;
    }
}

@media (max-width: 768px) {
    .hero {
        padding: 30px 0 20px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .nav-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        background-color: var(--background);
        border-bottom: 1px solid var(--border);
        padding: 16px 24px;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-links li {
        padding: 12px 0;
        border-bottom: 1px solid var(--border-light);
    }
    
    .nav-links li:last-child {
        border-bottom: none;
    }
    
    .post-card {
        padding: 24px;
    }
    
    .post-single .post-title {
        font-size: 2rem;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
    }
}

/* 代码高亮主题 */
.hljs {
    display: block;
    overflow-x: auto;
    padding: 1em;
    background: #1e293b;
    color: #e2e8f0;
}

.hljs-keyword,
.hljs-operator {
    color: #c084fc;
}

.hljs-string {
    color: #86efac;
}

.hljs-number,
.hljs-literal {
    color: #fca5a5;
}

.hljs-comment {
    color: #64748b;
    font-style: italic;
}

.hljs-function {
    color: #60a5fa;
}

.hljs-class {
    color: #fbbf24;
}

/* ============================================
   评论区样式 (Giscus)
   ============================================ */

.post-comments {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.giscus-container {
    min-height: 200px;
}

.comments-noscript {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    background-color: var(--surface);
    border-radius: var(--radius);
}

/* ============================================
   性能优化相关样式
   ============================================ */

/* 懒加载占位 */
img[data-src] {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

img[data-src].loaded {
    animation: none;
}

/* 优化字体渲染 */
html {
    text-rendering: optimizeLegibility;
}

/* 减少动画偏好支持 (可访问性) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}
