/*
Theme Name: HuTao
Theme URI: https://typecho.org
Description: 胡桃配色左右两栏博客主题 — 惊墨乌棕 + 蝶火赤红，致敬原神
Version: 1.0.0
Author: WorkBuddy Design
Author URI: https://typecho.org
License: MIT
*/

/* ========================================
   CSS Variables — 胡桃配色方案
   ======================================== */
:root {
    /* 主色 */
    --color-ink-brown:    #2B1810;   /* 惊墨乌棕 — 侧边栏背景、标题 */
    --color-fire-red:     #C53030;   /* 蝶火赤红 — 链接、栏目标题、标签 */
    --color-gold-amber:   #C5943E;   /* 往生金 — hover、点缀 */
    --color-talisman:     #F7F2E8;   /* 符纸米白 — 页面背景 */
    --color-deep-plum:    #6B2D4B;   /* 冥蝶暗紫 — 极少量辅助 */

    /* 衍生色 */
    --color-sidebar-bg:     var(--color-ink-brown);
    --color-sidebar-text:   #F7F2E8;
    --color-sidebar-muted:  #A08070;
    --color-sidebar-border: #3C2420;
    --color-sidebar-section: var(--color-fire-red);
    --color-sidebar-hover:  var(--color-gold-amber);
    --color-sidebar-badge:  var(--color-fire-red);
    --color-sidebar-badge-text: #FFFFFF;

    --color-page-bg:      var(--color-talisman);
    --color-card-bg:      #FFFFFF;
    --color-card-border:  #E0D0C0;
    --color-text-primary: var(--color-ink-brown);
    --color-text-secondary: #5A3830;
    --color-text-muted:   #8B6050;
    --color-link:         var(--color-fire-red);
    --color-link-hover:   var(--color-gold-amber);
    --color-tag-bg:       #F5E8D8;
    --color-tag-text:     var(--color-fire-red);
    --color-cover-bg-1:   var(--color-ink-brown);
    --color-cover-bg-2:   var(--color-fire-red);

    /* 字体 */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    --font-mono: "Fira Code", "JetBrains Mono", "SF Mono", Consolas, "Courier New", monospace;

    /* 布局 */
    --sidebar-width: 260px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ========================================
   Reset
   ======================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--color-page-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

a:hover {
    color: var(--color-link-hover);
}

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

/* ========================================
   Layout Grid
   ======================================== */
.container {
    display: flex;
    min-height: 100vh;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    padding: 32px 24px 24px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--color-sidebar-border);
    border-radius: 2px;
}

/* Sidebar — 头像区 */
.sidebar-header {
    text-align: center;
    margin-bottom: 24px;
}

.sidebar-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 14px;
    display: block;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.12);
    transition: border-color 0.3s ease, transform 0.3s ease;
}

.sidebar-avatar:hover {
    border-color: var(--color-gold-amber);
    transform: scale(1.05);
}

.sidebar-avatar-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, var(--color-fire-red), var(--color-gold-amber));
    border: 2px solid rgba(255,255,255,0.12);
}

.sidebar-name {
    font-size: 18px;
    font-weight: 500;
    color: var(--color-sidebar-text);
    margin-bottom: 4px;
    cursor: pointer;
    display: inline-block;
    transition: color 0.2s ease;
}

.sidebar-name a { color: inherit; text-decoration: none; }

.sidebar-name:hover,
.sidebar-name a:hover { color: var(--color-sidebar-hover); }

.sidebar-name-hint {
    font-size: 11px;
    color: var(--color-gold-amber);
    margin-top: 2px;
    opacity: 0.8;
}

.sidebar-tagline {
    font-size: 12px;
    color: var(--color-sidebar-muted);
    margin-top: 6px;
    line-height: 1.5;
}

/* Sidebar — 联系方式 */
.sidebar-contact {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.sidebar-contact a {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--color-sidebar-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: var(--color-sidebar-muted);
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-contact a:hover { background: var(--color-fire-red); color: #fff; }

/* Sidebar — 分隔线 */
.sidebar-divider { border: none; border-top: 0.5px solid var(--color-sidebar-border); margin: 8px 0 20px; }

/* Sidebar — 板块标题 */
.sidebar-section-title {
    font-size: 12px; font-weight: 500;
    color: var(--color-sidebar-section);
    margin-bottom: 10px; letter-spacing: 0.5px; text-transform: uppercase;
}

/* Sidebar — 分类列表 */
.sidebar-categories { list-style: none; margin-bottom: 8px; }

.sidebar-categories li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 8px; border-radius: var(--radius-sm);
    font-size: 13px; color: #D4C0B0; cursor: pointer;
    transition: background 0.2s ease;
}

.sidebar-categories li:hover { background: rgba(255,255,255,0.04); }
.sidebar-categories li.sub-cat { padding-left: 28px; font-size: 12px; }
.sidebar-categories li.sub-cat a { opacity: 0.85; }
.sidebar-categories li a { color: inherit; flex: 1; }

.sidebar-categories .cat-count {
    font-size: 10px; padding: 1px 7px; border-radius: 10px;
    background: var(--color-sidebar-border); color: #A08070;
    font-weight: 400; min-width: 24px; text-align: center;
}

.sidebar-categories li.current a { color: var(--color-fire-red); }
.sidebar-categories li.current .cat-count { background: var(--color-fire-red); color: #fff; }

/* Sidebar — 最新评论 */
.sidebar-comments { list-style: none; margin-bottom: 8px; }

.sidebar-comments li {
    font-size: 12px; color: var(--color-sidebar-muted);
    margin-bottom: 6px; line-height: 1.5;
    padding-left: 8px; border-left: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.sidebar-comments li:hover { border-left-color: var(--color-fire-red); }
.sidebar-comments li a { color: #D4C0B0; }
.sidebar-comments li a:hover { color: var(--color-sidebar-hover); }

/* Sidebar — 底部 */
.sidebar-footer { margin-top: auto; padding-top: 16px; }
.sidebar-footer-text { text-align: center; font-size: 11px; color: #806050; line-height: 1.7; }
.sidebar-footer-filing { text-align: center; font-size: 10px; color: #806050; line-height: 1.7; margin-top: 4px; }
.sidebar-footer-filing a { color: #806050; }
.sidebar-footer-filing a:hover { color: var(--color-sidebar-muted); }

/* ========================================
   Content Area
   ======================================== */
.main-content {
    flex: 1 1 auto;
    width: auto;
    padding: 32px 36px 40px;
    min-width: 0;
    box-sizing: border-box;
}

.main-content > * { width: 100%; box-sizing: border-box; }

/* ========================================
   Article Cards
   ======================================== */
.post-list-header { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.post-list-header h2 { font-size: 15px; font-weight: 500; color: var(--color-text-primary); }
.post-list-badge { background: #E8D8C8; color: var(--color-text-muted); font-size: 10px; padding: 2px 8px; border-radius: 10px; }

/* 有封面文章 — 横排布局 */
.post-card {
    background: var(--color-card-bg); border-radius: var(--radius-lg);
    margin-bottom: 18px; border: 0.5px solid var(--color-card-border);
    transition: border-color 0.2s ease, transform 0.2s ease; overflow: hidden;
}

.post-card:hover { border-color: var(--color-fire-red); transform: translateY(-1px); }

.post-card-cover-layout { display: flex; }

.post-card-cover {
    width: 150px; min-height: 140px; flex-shrink: 0;
    position: relative; overflow: hidden;
}

.post-card-cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; }

.post-card-cover-placeholder {
    background: linear-gradient(135deg, var(--color-cover-bg-1), var(--color-fire-red));
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    position: absolute; top: 0; left: 0;
}

.post-card-cover-placeholder::after {
    content: ''; width: 40px; height: 40px;
    border: 1px solid rgba(255,255,255,0.2); border-radius: 50%;
}

.post-card-body { padding: 18px 22px; flex: 1; min-width: 0; }

/* 无封面文章 */
.post-card-no-cover .post-card-body { padding: 20px 22px; }

.post-card-title {
    font-size: 17px; font-weight: 500; color: var(--color-text-primary);
    margin-bottom: 6px; line-height: 1.4; transition: color 0.2s ease;
}

.post-card:hover .post-card-title { color: var(--color-fire-red); }
.post-card-title a { color: inherit; display: block; }

.post-card-meta { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.post-card-date { font-size: 12px; color: var(--color-text-muted); }

.post-card-category a {
    font-size: 11px; background: var(--color-tag-bg); color: var(--color-tag-text);
    padding: 2px 9px; border-radius: var(--radius-sm); transition: background 0.2s ease;
}

.post-card-category a:hover { background: var(--color-fire-red); color: #fff; }

.post-card-excerpt {
    font-size: 13px; color: var(--color-text-secondary); line-height: 1.75;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ========================================
   Post Detail
   ======================================== */
.post-detail {
    background: var(--color-card-bg); border-radius: var(--radius-lg);
    padding: 28px 32px; border: 0.5px solid var(--color-card-border);
}

.post-detail-header { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 0.5px solid var(--color-card-border); }
.post-detail-title { font-size: 22px; font-weight: 500; color: var(--color-text-primary); line-height: 1.4; margin-bottom: 12px; }

.post-detail-meta {
    display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
    font-size: 12px; color: var(--color-text-muted);
}

.post-detail-meta a { color: var(--color-fire-red); }

.post-detail-cover { margin-bottom: 24px; border-radius: var(--radius-md); overflow: hidden; }
.post-detail-cover img { width: 100%; }

.post-detail-content {
    font-size: 15px; color: var(--color-text-primary); line-height: 1.85; word-wrap: break-word;
}

.post-detail-content h1, .post-detail-content h2, .post-detail-content h3, .post-detail-content h4 {
    color: var(--color-ink-brown); font-weight: 500; margin: 28px 0 12px; line-height: 1.4;
}

.post-detail-content h2 { font-size: 20px; padding-left: 12px; border-left: 3px solid var(--color-fire-red); }
.post-detail-content h3 { font-size: 17px; }
.post-detail-content h4 { font-size: 15px; }
.post-detail-content p { margin-bottom: 16px; }

.post-detail-content a { color: var(--color-fire-red); border-bottom: 1px solid transparent; transition: border-color 0.2s ease; }
.post-detail-content a:hover { border-bottom-color: var(--color-fire-red); }
.post-detail-content img { border-radius: var(--radius-md); margin: 20px auto; }

.post-detail-content blockquote {
    margin: 16px 0; padding: 12px 20px;
    border-left: 3px solid var(--color-gold-amber);
    background: rgba(197,148,62,0.06);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--color-text-secondary); font-size: 14px;
}

.post-detail-content ul, .post-detail-content ol { margin: 12px 0 12px 24px; }
.post-detail-content li { margin-bottom: 6px; }

.post-detail-content pre {
    background: #1E1218; color: #D4B8A8;
    padding: 18px 22px; border-radius: var(--radius-md);
    overflow-x: auto; margin: 16px 0;
    font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
}

.post-detail-content code {
    font-family: var(--font-mono); background: rgba(197,48,48,0.06);
    color: var(--color-fire-red); padding: 1px 6px; border-radius: 3px; font-size: 0.9em;
}

.post-detail-content pre code { background: none; color: inherit; padding: 0; }
.post-detail-content hr { border: none; border-top: 0.5px solid var(--color-card-border); margin: 32px 0; }

.post-detail-content table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.post-detail-content th, .post-detail-content td { border: 0.5px solid var(--color-card-border); padding: 10px 14px; text-align: left; }
.post-detail-content th { background: var(--color-page-bg); font-weight: 500; }

.post-detail-tags {
    margin-top: 28px; padding-top: 20px; border-top: 0.5px solid var(--color-card-border);
    display: flex; flex-wrap: wrap; gap: 8px;
}

.post-detail-tags a {
    font-size: 12px; padding: 3px 12px; background: var(--color-tag-bg);
    color: var(--color-fire-red); border-radius: var(--radius-sm); transition: all 0.2s ease;
}

.post-detail-tags a:hover { background: var(--color-fire-red); color: #fff; }

.post-detail-nav { margin-top: 24px; display: flex; justify-content: space-between; font-size: 13px; }
.post-detail-nav a { color: var(--color-text-secondary); transition: color 0.2s ease; }
.post-detail-nav a:hover { color: var(--color-fire-red); }

/* ========================================
   Page
   ======================================== */
.page-detail {
    background: var(--color-card-bg); border-radius: var(--radius-lg);
    padding: 28px 32px; border: 0.5px solid var(--color-card-border);
}

.page-detail-title {
    font-size: 22px; font-weight: 500; color: var(--color-text-primary);
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 0.5px solid var(--color-card-border);
}

.page-detail-content { font-size: 15px; color: var(--color-text-primary); line-height: 1.85; }
.page-detail-content h2 { font-size: 20px; font-weight: 500; margin: 24px 0 12px; padding-left: 12px; border-left: 3px solid var(--color-fire-red); }
.page-detail-content p { margin-bottom: 16px; }
.page-detail-content a { color: var(--color-fire-red); }
.page-detail-content ul, .page-detail-content ol { margin: 12px 0 12px 24px; }

/* ========================================
   Comments
   ======================================== */
.comments-section {
    margin-top: 28px; background: var(--color-card-bg);
    border-radius: var(--radius-lg); padding: 24px 32px; border: 0.5px solid var(--color-card-border);
}

.comments-title { font-size: 16px; font-weight: 500; color: var(--color-text-primary); margin-bottom: 20px; }
.comments-list { list-style: none; margin-bottom: 24px; }

.comment-item { padding: 16px 0; border-bottom: 0.5px solid var(--color-card-border); display: flex; gap: 14px; }
.comment-item:last-child { border-bottom: none; }

.comment-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    background-color: var(--color-page-bg); background-size: cover; background-position: center;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}

.comment-avatar .avatar-letter { color: #fff; font-size: 16px; font-weight: 600; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,0.35); pointer-events: none; }
.comment-body { flex: 1; min-width: 0; }
.comment-author { font-size: 14px; font-weight: 500; color: var(--color-text-primary); margin-bottom: 2px; }
.comment-author a { color: inherit; }
.comment-meta { font-size: 11px; color: var(--color-text-muted); margin-bottom: 8px; }
.comment-meta a { color: var(--color-fire-red); }
.comment-content { font-size: 14px; color: var(--color-text-secondary); line-height: 1.7; }
.comment-content p { margin-bottom: 8px; }

.comment-children { margin-left: 30px; border-left: 2px solid var(--color-card-border); padding-left: 16px; list-style: none; }

.comment-form { margin-top: 20px; padding-top: 20px; border-top: 0.5px solid var(--color-card-border); }
.comment-form-title { font-size: 15px; font-weight: 500; color: var(--color-text-primary); margin-bottom: 16px; }
.comment-form .form-group { margin-bottom: 14px; }
.comment-form label { display: block; font-size: 13px; color: var(--color-text-secondary); margin-bottom: 4px; }

.comment-form input[type="text"], .comment-form input[type="email"],
.comment-form input[type="url"], .comment-form textarea {
    width: 100%; padding: 10px 14px; border: 0.5px solid var(--color-card-border);
    border-radius: var(--radius-md); background: var(--color-page-bg);
    font-family: var(--font-sans); font-size: 14px; color: var(--color-text-primary);
    transition: border-color 0.2s ease; outline: none;
}

.comment-form input:focus, .comment-form textarea:focus { border-color: var(--color-fire-red); background: #fff; }
.comment-form textarea { min-height: 120px; resize: vertical; }

.comment-form .submit {
    padding: 10px 24px; background: var(--color-ink-brown); color: var(--color-talisman);
    border: none; border-radius: var(--radius-md); font-size: 14px;
    font-family: var(--font-sans); cursor: pointer; transition: background 0.2s ease;
}

.comment-form .submit:hover { background: var(--color-fire-red); color: #fff; }
.comment-form .cancel-comment-reply { font-size: 12px; margin-left: 10px; }

/* ========================================
   Archive Page
   ======================================== */
.archive-header {
    background: var(--color-card-bg); border-radius: var(--radius-lg);
    padding: 24px 28px; margin-bottom: 24px; border: 0.5px solid var(--color-card-border);
}

.archive-title { font-size: 20px; font-weight: 500; color: var(--color-text-primary); }
.archive-desc { font-size: 13px; color: var(--color-text-muted); margin-top: 6px; }
.archive-list { list-style: none; }

.archive-item { display: flex; align-items: baseline; padding: 14px 0; border-bottom: 0.5px solid var(--color-card-border); gap: 20px; }
.archive-item:last-child { border-bottom: none; }
.archive-item-date { font-size: 12px; color: var(--color-text-muted); flex-shrink: 0; min-width: 90px; }
.archive-item-title { font-size: 15px; font-weight: 400; flex: 1; }
.archive-item-title a { color: var(--color-text-primary); transition: color 0.2s ease; }
.archive-item-title a:hover { color: var(--color-fire-red); }
.archive-item-count { font-size: 12px; color: var(--color-text-muted); flex-shrink: 0; }

/* ========================================
   Pagination
   ======================================== */
.pagination { display: flex; justify-content: center; gap: 6px; margin: 32px 0 0; padding: 0; list-style: none; }
.pagination li { list-style: none; }

.pagination a, .pagination span {
    display: inline-block; padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px;
    background: var(--color-card-bg); color: var(--color-text-secondary);
    border: 0.5px solid var(--color-card-border); transition: all 0.2s ease;
}

.pagination a:hover { background: var(--color-fire-red); border-color: var(--color-fire-red); color: #fff; }
.pagination li.current a, .pagination li.current span { background: var(--color-ink-brown); color: var(--color-talisman); border-color: var(--color-ink-brown); }

/* ========================================
   404 Page
   ======================================== */
.error-page {
    background: var(--color-card-bg); border-radius: var(--radius-lg);
    padding: 60px 32px; text-align: center; border: 0.5px solid var(--color-card-border);
}

.error-page h1 { font-size: 64px; font-weight: 500; color: var(--color-fire-red); margin-bottom: 12px; }
.error-page p { font-size: 15px; color: var(--color-text-secondary); margin-bottom: 24px; }

.error-page a {
    display: inline-block; padding: 10px 24px; background: var(--color-ink-brown);
    color: var(--color-talisman); border-radius: var(--radius-md); transition: background 0.2s ease;
}

.error-page a:hover { background: var(--color-fire-red); color: #fff; }

/* ========================================
   Mobile Toggle
   ======================================== */
.sidebar-toggle {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 100;
    width: 36px; height: 36px; background: var(--color-ink-brown); border: none;
    border-radius: var(--radius-sm); cursor: pointer; padding: 8px;
    flex-direction: column; justify-content: center; gap: 4px;
}

.sidebar-toggle span { display: block; height: 2px; background: var(--color-talisman); border-radius: 1px; transition: transform 0.2s ease, opacity 0.2s ease; }
.sidebar-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.sidebar-toggle.active span:nth-child(2) { opacity: 0; }
.sidebar-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9; }
.sidebar-overlay.active { display: block; }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .container { flex-direction: column; }
    .sidebar-toggle { display: flex; }
    .sidebar { position: fixed; left: -280px; top: 0; height: 100vh; width: 280px; min-width: 280px; transition: left 0.3s ease; z-index: 20; }
    .sidebar.active { left: 0; }
    .main-content { padding: 52px 16px 32px; }
    .post-card-cover-layout { flex-direction: column; }
    .post-card-cover { width: 100%; min-height: 160px; height: 160px; }
    .post-card-title { font-size: 16px; }
    .post-card-body { padding: 16px 18px; }
    .post-detail { padding: 20px 18px; }
    .post-detail-title { font-size: 19px; }
    .post-detail-content { font-size: 14px; }
    .page-detail { padding: 20px 18px; }
    .comments-section { padding: 18px; }
    .comment-children { margin-left: 16px; padding-left: 12px; }
    .archive-header { padding: 18px; }
    .archive-item { flex-direction: column; gap: 4px; }
    .archive-item-date { min-width: unset; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { width: 220px; min-width: 220px; padding: 24px 18px 20px; }
    .main-content { padding: 24px 20px 32px; }
    .post-card-cover { width: 120px; min-height: 120px; }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.post-card { animation: fadeIn 0.4s ease both; }
.post-card:nth-child(2) { animation-delay: 0.05s; }
.post-card:nth-child(3) { animation-delay: 0.10s; }
.post-card:nth-child(4) { animation-delay: 0.15s; }
.post-card:nth-child(5) { animation-delay: 0.20s; }

/* ========================================
   Utility
   ======================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.clearfix::after { content: ''; display: table; clear: both; }
