/* 
 * Minimalist Dark Theme with Sidebar Layout
 * A refined, content-focused theme for developer blogs
 */

:root {
    /* Colors */
    --background: #0f0f11;
    --sidebar-bg: #09090b;
    --foreground: #e4e4e7;
    --muted-foreground: #a1a1aa;
    --border: #27272a;
    --accent: #f59e0b;
    --accent-muted: rgba(245, 158, 11, 0.15);
    
    /* Layout */
    --sidebar-width: 280px;
    --content-max-width: 800px;
    
    /* Typography */
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-display: 'Space Grotesk', sans-serif;
    
    /* Effects */
    --glow-sm: 0 0 20px rgba(245, 158, 11, 0.1);
    --glow-md: 0 0 40px rgba(245, 158, 11, 0.15);
    
    /* Misc */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition-fast);
}

/* Layout System */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-inner {
    padding: 2.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 3rem;
}

#site-title {
    margin-bottom: 0.75rem;
    line-height: 1.1;
}

#site-title a {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--foreground);
    letter-spacing: -0.02em;
}

.site-branding {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.site-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.site-slogan {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--muted-foreground);
    line-height: 1.5;
}

/* Navigation */
.nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1; /* Pushes footer down */
}

.nav a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin: 0 -1rem;
    border-radius: var(--radius-md);
    color: var(--muted-foreground);
    font-size: 0.9375rem;
    font-weight: 500;
}

.nav a:hover {
    color: var(--foreground);
    background: rgba(255, 255, 255, 0.05);
}

.nav a.active {
    color: var(--accent);
    background: var(--accent-muted);
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: 3rem;
    border-top: 1px solid var(--border);
    padding-top: 2rem;
}

.footer-section {
    margin-bottom: 2rem;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
    opacity: 0.7;
}

.project-list, .account-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.account-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.account-link img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    filter: grayscale(1);
    transition: var(--transition-fast);
}

.account-link:hover {
    color: var(--foreground);
}

.account-link:hover img {
    filter: grayscale(0);
}

.wx-gzh-img {
    width: 100%;
    max-width: 200px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: block;
}

.copyright {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #52525b;
    margin-top: 2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
}

/* Hero Section */
.hero-section {
    margin-bottom: 1rem;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-image {
    width: 100%;
    height: 320px;
    object-fit: cover;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    opacity: 0.9;
    mask-image: linear-gradient(to bottom, black 20%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 20%, transparent 100%);
}

.hero-slogan {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 700;
    color: var(--foreground);
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
    width: 90%;
}

/* Post List */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
}

.post-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    transition: var(--transition-fast);
}

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

.post-item:first-child {
    padding-top: 0;
}

.post-item:hover {
    background: transparent;
}

.post-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 2rem;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.post-tag {
    color: var(--accent);
}

.post-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
    flex: 1;
}

.post-title a {
    color: var(--foreground);
    transition: color 0.2s;
}

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

/* Post Detail */
.post-content {
    max-width: 100%;
}

/* About Page */
.about-container {
    max-width: 800px;
    margin: 0 auto;
}

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

.about-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--border);
    margin-bottom: 1.5rem;
}

.about-name {
    font-family: var(--font-display);
    font-size: 2rem;
    margin-bottom: 1rem;
}

.about-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--muted-foreground);
}

.about-meta a:hover {
    color: var(--accent);
}

.about-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.stat-item strong {
    color: var(--foreground);
    font-size: 1.1rem;
}

/* Project List */
.project-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.project-card {
    flex: 1 1 280px;
    max-width: 340px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: var(--glow-md);
}

.project-cover {
    height: 180px;
    overflow: hidden;
}

.project-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.project-card:hover .project-cover img {
    transform: scale(1.05);
}

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

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.project-title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.project-arrow {
    color: var(--muted-foreground);
    font-size: 1.25rem;
    transition: transform 0.2s;
}

.project-card:hover .project-arrow {
    transform: translate(2px, -2px);
    color: var(--accent);
}

.project-desc {
    color: var(--muted-foreground);
    font-size: 0.9375rem;
    line-height: 1.6;
    height: calc(1.6em * 3); /* 强制固定高度为3行 */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Code Block Styles */
.code-wrapper {
    position: relative;
    margin: 1.5rem 0;
    border-radius: 6px;
    overflow: hidden;
}

.code-wrapper pre {
    margin: 0 !important;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 10;
}

.code-wrapper:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 1rem;
}

.page-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--sidebar-bg);
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    .main-content {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    .layout-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .sidebar-inner {
        padding: 1.5rem;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    .hero-image {
        height: 200px;
    }
    
    .post-header-flex {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .post-meta {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Post Navigation */
.post-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}

.post-nav-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    background: var(--sidebar-bg);
}

.post-nav-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    background: var(--accent-muted);
}

.post-nav-label {
    font-size: 0.8rem;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-nav-title {
    color: var(--foreground);
    font-weight: 500;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-nav-prev {
    align-items: flex-start;
    text-align: left;
}

.post-nav-next {
    align-items: flex-end;
    text-align: right;
}

@media (max-width: 600px) {
    .post-nav {
        flex-direction: column;
    }
    
    .post-nav-item {
        width: 100%;
        align-items: center;
        text-align: center;
    }
}

/* Share Section */
.share-section {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.share-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--foreground);
    font-family: var(--font-display);
}

.share-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid var(--border);
    background-color: var(--sidebar-bg);
    color: var(--foreground);
}

.share-btn svg {
    transition: transform 0.2s ease;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.share-btn:hover svg {
    transform: scale(1.1);
}

.share-twitter:hover {
    background-color: #000000; /* X brand color */
    border-color: #000000;
    color: white;
}

.share-weibo:hover {
    background-color: #e6162d;
    border-color: #e6162d;
    color: white;
}

.share-linkedin:hover {
    background-color: #0077b5;
    border-color: #0077b5;
    color: white;
}

.share-copy:hover {
    background-color: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Post Layout System */
.post-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: relative;
}

.post-main {
    width: 100%;
    min-width: 0; /* Prevent flex item overflow */
}

.post-sidebar {
    width: 100%;
    order: -1; /* Show TOC above content on mobile */
}

/* Table of Contents */
.toc-container {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.toc-header {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
}

.toc-item {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.toc-link {
    color: var(--muted-foreground);
    font-size: 0.9rem;
    display: block;
    text-decoration: none;
    transition: color 0.2s;
}

.toc-link:hover {
    color: var(--accent);
}

/* Indentation for levels */
.toc-level-1 { margin-left: 0; font-weight: 600; }
.toc-level-2 { margin-left: 0; }
.toc-level-3 { margin-left: 1rem; font-size: 0.85rem; }
.toc-level-4 { margin-left: 2rem; font-size: 0.85rem; }
.toc-level-5 { margin-left: 3rem; font-size: 0.8rem; }
.toc-level-6 { margin-left: 4rem; font-size: 0.8rem; }

/* Desktop Split Layout (Wide Screens) */
@media (min-width: 1280px) {
    .post-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .post-main {
        flex: 1;
    }

    .post-sidebar {
        width: 260px;
        flex-shrink: 0;
        position: sticky;
        top: 2rem;
        order: initial; /* Reset order to display on right */
        /* Ensure it fits within viewport height */
        max-height: calc(100vh - 4rem);
    }

    .toc-container {
        margin-bottom: 0;
        max-height: calc(100vh - 4rem);
        overflow-y: auto;
    }
    
    .toc-list {
        max-height: none; /* Let container handle scroll */
    }
}
