/* Halo-Theme-ResVault - Complete CSS Rewrite for Halo 2.x */
/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.6; color: var(--text); background: var(--bg);
}
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea { font: inherit; }

/* === CSS Variables === */
:root {
    --primary: #1e90ff;
    --primary-dark: #0070e0;
    --primary-light: rgba(30,144,255,0.1);
    --bg: #f5f7fa;
    --bg-white: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --border: #e8e8e8;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 8px;
}
[data-theme="dark"] {
    --primary: #4da6ff;
    --primary-dark: #80c4ff;
    --primary-light: rgba(77,166,255,0.15);
    --bg: #0f0f1a;
    --bg-white: #1a1a2e;
    --text: #e0e0e0;
    --text-light: #a0a0b0;
    --text-muted: #666680;
    --border: #2a2a3e;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.4);
}

/* === Layout === */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* === Header === */
.site-header {
    background: var(--bg-white); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 60px; gap: 20px;
}
.site-logo { display: flex; align-items: center; gap: 4px; font-size: 20px; font-weight: 700; color: var(--text); }
.site-logo img { height: 36px; width: auto; }
.logo-prefix { color: var(--text-light); }
.logo-highlight { color: var(--primary); }
.main-nav { display: flex; gap: 20px; flex: 1; }
.main-nav a { color: var(--text-light); font-size: 15px; padding: 8px 0; border-bottom: 2px solid transparent; transition: all 0.2s; }
.main-nav a:hover { color: var(--primary); border-bottom-color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.search-form { display: flex; }
.search-form input {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; width: 180px; background: var(--bg); color: var(--text);
}
.search-form input:focus { outline: none; border-color: var(--primary); }
.theme-toggle {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 18px; transition: all 0.3s;
}
.theme-toggle:hover { background: var(--primary); color: #fff; }
.menu-toggle { display: none; padding: 8px; font-size: 20px; }

/* === Main Content === */
.site-main { min-height: calc(100vh - 200px); padding: 24px 0; }

/* === Banner === */
.banner-area { margin-bottom: 24px; }
.carousel { position: relative; border-radius: var(--radius); overflow: hidden; }
.carousel-track { position: relative; width: 100%; aspect-ratio: 16/7; }
.carousel-slide { position: absolute; inset: 0; opacity: 0; transition: opacity 0.6s; }
.carousel-slide.active { opacity: 1; }
.carousel-slide img { width: 100%; height: 100%; object-fit: cover; }
.carousel-caption {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7)); color: #fff; font-size: 18px; font-weight: 600;
}
.carousel-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,0.4); color: #fff; padding: 12px 8px;
    font-size: 18px; z-index: 10; border-radius: 4px;
}
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }
.carousel-dots { position: absolute; bottom: 12px; right: 16px; display: flex; gap: 6px; z-index: 10; }
.carousel-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.5); cursor: pointer; }
.carousel-dot.active { background: #fff; }

/* === Recommend Section === */
.recommend-section { margin-bottom: 24px; }
.section-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; padding-left: 12px; border-left: 3px solid var(--primary); }
.recommend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

/* === Category Tabs === */
.category-tabs { margin-bottom: 20px; }
.tab-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-btn {
    padding: 8px 16px; border-radius: var(--radius); font-size: 14px;
    background: var(--bg); color: var(--text-light); border: 1px solid var(--border); transition: all 0.2s;
}
.tab-btn.active, .tab-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === Post List === */
.post-list { display: grid; gap: 20px; margin-bottom: 24px; }
.post-list.grid-2 { grid-template-columns: repeat(2, 1fr); }
.post-list.grid-3 { grid-template-columns: repeat(3, 1fr); }
.post-list.list-view { grid-template-columns: 1fr; }
.post-list.list-view .post-card { display: grid; grid-template-columns: 240px 1fr; }
.post-card {
    background: var(--bg-white); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); transition: all 0.3s;
}
.post-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card-cover { display: block; aspect-ratio: 16/10; overflow: hidden; position: relative; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.post-card:hover .card-cover img { transform: scale(1.05); }
.card-rating {
    position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.6);
    color: #ff9900; padding: 2px 8px; border-radius: 4px; font-size: 13px;
}
.card-body { padding: 14px 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-title a { color: var(--text); }
.card-excerpt { font-size: 13px; color: var(--text-light); margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); }

/* === Pagination === */
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 24px 0; }
.page-link { padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-light); }
.page-link:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.current { color: var(--text-muted); font-size: 14px; }

/* === Article Detail === */
.breadcrumb { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-light); }
.breadcrumb .sep { margin: 0 8px; }
.breadcrumb .current { color: var(--text); }
.article-layout { display: grid; gap: 24px; }
.article-layout.with-sidebar { grid-template-columns: 1fr 300px; }
.article-main { min-width: 0; }
.article-detail { background: var(--bg-white); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); }
.article-title { font-size: 24px; font-weight: 700; margin-bottom: 16px; line-height: 1.4; }
.article-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; color: var(--text-muted); margin-bottom: 16px; align-items: center; }
.article-meta .avatar { width: 28px; height: 28px; border-radius: 50%; }
.meta-author { display: flex; align-items: center; gap: 6px; }
.article-tags { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tag-link {
    padding: 4px 12px; background: var(--primary-light); color: var(--primary);
    border-radius: 20px; font-size: 13px;
}
.article-content { font-size: 16px; line-height: 1.8; color: var(--text); }
.article-content h2 { font-size: 22px; margin: 32px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.article-content h3 { font-size: 18px; margin: 24px 0 12px; }
.article-content p { margin-bottom: 16px; }
.article-content img { border-radius: var(--radius); margin: 16px 0; }
.article-content pre { background: #1e1e1e; color: #d4d4d4; padding: 16px; border-radius: var(--radius); overflow-x: auto; margin: 16px 0; position: relative; }
.article-content code { font-family: "Fira Code", "Consolas", monospace; font-size: 14px; }
.article-content blockquote { border-left: 4px solid var(--primary); padding: 12px 20px; background: var(--primary-light); margin: 16px 0; border-radius: 0 var(--radius) var(--radius) 0; }

/* === Article Actions === */
.article-actions { display: flex; gap: 12px; padding: 20px 0; border-top: 1px solid var(--border); margin-top: 24px; }
.btn-action {
    padding: 8px 20px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; color: var(--text-light); transition: all 0.2s;
}
.btn-action:hover { border-color: var(--primary); color: var(--primary); }
.btn-action.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === Neighbor Nav === */
.neighbor-nav { display: flex; justify-content: space-between; gap: 16px; padding: 20px 0; border-top: 1px solid var(--border); margin-top: 16px; }
.neighbor-nav a { font-size: 14px; color: var(--text-light); flex: 1; }
.neighbor-nav a:hover { color: var(--primary); }
.prev-log { text-align: left; }
.next-log { text-align: right; }

/* === Related Posts === */
.related-posts { margin-top: 24px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

/* === Comments === */
.comments-section { margin-top: 24px; background: var(--bg-white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

/* === Sidebar === */
.article-sidebar { position: sticky; top: 80px; align-self: start; }
.sidebar-widget {
    background: var(--bg-white); border-radius: var(--radius); padding: 16px;
    margin-bottom: 16px; box-shadow: var(--shadow);
}
.widget-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.widget-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.widget-list li:last-child { border-bottom: none; }
.widget-list a { color: var(--text-light); }
.widget-list a:hover { color: var(--primary); }
.rank-list li { display: flex; align-items: center; gap: 8px; }
.rank-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%; font-size: 12px;
    background: var(--bg); color: var(--text-muted);
}
.rank-num.top3 { background: var(--primary); color: #fff; }
.category-list li { display: flex; justify-content: space-between; }
.category-list .count { color: var(--text-muted); font-size: 13px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-item {
    padding: 4px 10px; background: var(--bg); border-radius: 20px;
    font-size: 13px; color: var(--text-light); border: 1px solid var(--border);
}
.tag-item:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === Download Box === */
.download-box { margin: 24px 0; padding: 20px; background: var(--primary-light); border: 1px solid var(--primary); border-radius: var(--radius); }
.box-title { font-size: 16px; font-weight: 700; color: var(--primary-dark); margin-bottom: 12px; }
.download-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.download-card { background: var(--bg-white); border-radius: var(--radius); padding: 16px; text-align: center; border: 1px solid var(--border); }
.btn-download {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 10px 16px; background: var(--primary); color: #fff;
    border-radius: var(--radius); font-size: 14px; font-weight: 600;
}
.btn-download:hover { background: var(--primary-dark); color: #fff; }
.card-pwd { margin-top: 8px; font-size: 12px; color: #856404; background: #fff3cd; border-radius: 4px; padding: 4px 8px; display: inline-block; }

/* === TOC === */
.toc-container {
    position: fixed; right: 20px; top: 80px; width: 220px;
    max-height: calc(100vh - 120px); overflow-y: auto; background: var(--bg-white);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; z-index: 50;
}
.toc-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.toc a { display: block; padding: 4px 0; font-size: 13px; color: var(--text-light); }
.toc a:hover, .toc a.active { color: var(--primary); }
.toc .toc-h3 { padding-left: 16px; }
.toc .toc-h4 { padding-left: 32px; }

/* === Reading Progress === */
.reading-progress { position: fixed; top: 0; left: 0; width: 0; height: 3px; background: var(--primary); z-index: 9999; transition: width 0.1s; }

/* === Share Modal === */
.share-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.share-modal-content { background: var(--bg-white); border-radius: var(--radius); padding: 24px; max-width: 400px; width: 90%; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.share-actions button { padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }

/* === Page Templates === */
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.page-desc { color: var(--text-light); margin-bottom: 20px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* === Archives === */
.archives-list { background: var(--bg-white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.archive-year { font-size: 20px; font-weight: 700; margin: 24px 0 12px; color: var(--primary); }
.archive-year:first-child { margin-top: 0; }
.archive-posts li { padding: 8px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 12px; font-size: 14px; }
.archive-date { color: var(--text-muted); min-width: 80px; }

/* === Categories Grid === */
.categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.category-card {
    background: var(--bg-white); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); transition: all 0.3s;
}
.category-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.category-card h3 { font-size: 16px; margin-bottom: 8px; }
.category-card p { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.post-count { font-size: 13px; color: var(--text-muted); }

/* === Tags Cloud Page === */
.tags-cloud-page { display: flex; flex-wrap: wrap; gap: 12px; background: var(--bg-white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.tags-cloud-page .tag-item { padding: 8px 16px; font-size: 14px; }

/* === Error Page === */
.error-page { text-align: center; padding: 80px 20px; }
.error-code { font-size: 80px; font-weight: 700; color: var(--primary); }
.error-msg { font-size: 20px; margin: 16px 0; }
.error-desc { color: var(--text-light); margin-bottom: 24px; }
.btn-primary {
    display: inline-block; padding: 12px 32px; background: var(--primary);
    color: #fff; border-radius: var(--radius); font-size: 16px; font-weight: 600;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

/* === Footer === */
.site-footer { background: var(--bg-white); border-top: 1px solid var(--border); padding: 24px 0; margin-top: 40px; }
.footer-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 16px; }
.footer-links a { color: var(--text-light); font-size: 14px; }
.footer-links a:hover { color: var(--primary); }
.footer-copyright { text-align: center; font-size: 13px; color: var(--text-muted); }
.footer-custom { text-align: center; margin-top: 12px; }

/* === Ad Area === */
.ad-area { margin: 12px 0; text-align: center; }
.ad-area img { max-width: 100%; border-radius: var(--radius); }

/* === Back to Top === */
.back-to-top {
    position: fixed; bottom: 30px; right: 30px; width: 44px; height: 44px;
    background: var(--primary); color: #fff; border-radius: 50%; font-size: 20px;
    display: none; align-items: center; justify-content: center; z-index: 90;
    box-shadow: var(--shadow-hover);
}

/* === Code Block === */
.code-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; background: #2d2d2d; border-radius: var(--radius) var(--radius) 0 0;
}
.code-lang { font-size: 12px; color: #888; text-transform: uppercase; }
.code-header .btn-copy {
    padding: 4px 12px; font-size: 12px; color: #ccc; border: 1px solid #555;
    border-radius: 4px; cursor: pointer;
}
.code-header .btn-copy:hover { background: #555; color: #fff; }
.article-content pre .code-header { margin: -16px -16px 0; }

/* === Responsive === */
@media (max-width: 768px) {
    .header-inner { flex-wrap: wrap; }
    .main-nav { display: none; width: 100%; flex-direction: column; gap: 0; }
    .main-nav.open { display: flex; }
    .main-nav a { padding: 12px 0; border-bottom: 1px solid var(--border); }
    .menu-toggle { display: block; }
    .search-form input { width: 120px; }
    .post-list.grid-2, .post-list.grid-3 { grid-template-columns: 1fr; }
    .post-list.list-view .post-card { grid-template-columns: 1fr; }
    .article-layout.with-sidebar { grid-template-columns: 1fr; }
    .article-sidebar { position: static; }
    .toc-container { display: none; }
    .recommend-grid { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: 1fr 1fr; }
    .carousel-track { aspect-ratio: 16/10; }
}
@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .article-detail { padding: 16px; }
    .article-title { font-size: 20px; }
    .related-grid { grid-template-columns: 1fr; }
}
