/* ============================================
   统一样式 - 导航、布局、暗色模式
   ============================================ */

:root {
    /* 亮色主题 */
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f5f5f5;
    --bg-code: #f6f8fa;
    --text-primary: #1a1a1a;
    --text-secondary: #333333;
    --text-muted: #666666;
    --border-color: #e1e4e8;
    --accent-color: #0969da;
    --accent-hover: #0860ca;
    --shadow: rgba(0, 0, 0, 0.1);
    
    /* 导航 */
    --nav-bg: rgba(255, 255, 255, 0.95);
    --nav-border: #e1e4e8;
    --nav-text: #1a1a1a;
    
    /* 过渡 */
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    /* 暗色主题 */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-code: #161b22;
    --text-primary: #e6edf3;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --accent-color: #58a6ff;
    --accent-hover: #79c0ff;
    --shadow: rgba(0, 0, 0, 0.3);
    
    --nav-bg: rgba(13, 17, 23, 0.95);
    --nav-border: #30363d;
    --nav-text: #e6edf3;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif, "Meiryo";
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

/* ============================================
   导航栏
   ============================================ */

.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--nav-border);
    padding: 0.75rem 0;
    box-shadow: 0 2px 4px var(--shadow);
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--nav-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand .icon {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
    list-style: none;
}

.navbar-menu a {
    color: var(--nav-text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.navbar-menu a:hover {
    color: var(--accent-color);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-toggle,
.theme-toggle,
.menu-toggle {
    background: none;
    border: none;
    color: var(--nav-text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

.search-toggle svg,
.theme-toggle svg,
.menu-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
}

.search-toggle:hover,
.theme-toggle:hover,
.menu-toggle:hover {
    background-color: var(--bg-tertiary);
}

.menu-toggle {
    display: none;
}

/* 搜索框 */
.search-container {
    position: relative;
    display: none;
}

.search-container.active {
    display: block;
}

.search-box {
    width: 300px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.search-box:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.search-results.active {
    display: block;
}

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

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

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

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

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

.search-highlight {
    background-color: rgba(9, 105, 218, 0.2);
    padding: 0 2px;
    border-radius: 2px;
}

/* ============================================
   主布局
   ============================================ */

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 主内容区域：占据全宽 */
.main-content {
    width: 100%;
    max-width: 100%;
    /* 确保内容不会溢出 */
    overflow-wrap: break-word;
}

/* 文章内容包装器：应用原始HTML的布局样式 */
.article-content-wrapper {
    max-width: 780px;
    margin: 0 auto;
    padding: 48px 24px;
    box-sizing: border-box;
}

/* 文章内容区域 */
.article-content {
    width: 100%;
}

/* ============================================
   分享按钮
   ============================================ */

.share-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.share-button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.share-button .icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.share-button:hover {
    background-color: var(--bg-secondary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* ============================================
   阅读进度条
   ============================================ */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--bg-tertiary);
    z-index: 1001;
}

.reading-progress-bar {
    height: 100%;
    background-color: var(--accent-color);
    width: 0%;
    transition: width 0.1s;
}

/* ============================================
   返回顶部按钮
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 999;
}

.back-to-top .icon {
    width: 1.5rem;
    height: 1.5rem;
    stroke: white;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

/* ============================================
   响应式设计
   ============================================ */

@media screen and (max-width: 1024px) {
    .main-container {
        padding: 1.5rem;
    }
}

@media screen and (max-width: 768px) {
    .navbar-container {
        padding: 0 1rem;
    }
    
    .navbar-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background-color: var(--nav-bg);
        border-bottom: 1px solid var(--nav-border);
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 0;
        display: none;
    }
    
    .navbar-menu.active {
        display: flex;
    }
    
    .navbar-menu li {
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .navbar-menu li:last-child {
        border-bottom: none;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .search-box {
        width: 100%;
    }
    
    .main-container {
        padding: 1rem;
    }
    
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
    }
}

/* ============================================
   首页样式
   ============================================ */

.homepage {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.hero {
    text-align: center;
    padding: 4rem 0;
    margin-bottom: 4rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 800px;
    margin: 0 auto;
}

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

.article-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--accent-color);
}

.article-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.article-card-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.article-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================
   工具类
   ============================================ */

.hidden {
    display: none !important;
}

.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; }

/* ============================================
   图标样式
   ============================================ */

.icon {
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    fill: none;
    transition: var(--transition);
    color: inherit;
}

/* 文章卡片中的图标 */
.article-card-meta .icon {
    width: 1rem;
    height: 1rem;
    margin-right: 0.25rem;
    vertical-align: middle;
}

/* about页面功能图标 */
.feature-item .icon {
    width: 1.5rem;
    height: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

