/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    background-color: #f8fafc;
    font-size: 16px;
    margin: 0;
    padding: 0;
}

/* Container and layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header styles - 只对页面顶部的导航栏应用sticky定位 */
/* 移除通用header的sticky定位，避免文章页面标题异常粘贴 */
header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 0;
}

/* 只对导航栏应用sticky定位 */
nav {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    background-color: rgba(255, 255, 255, 0.95);
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-title:hover {
    color: #374151;
}

.site-description {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Navigation */
nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
}

nav a {
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    position: relative;
}

nav a:hover {
    color: #111827;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #111827;
    transition: width 0.2s ease;
}

nav a:hover::after {
    width: 100%;
}

/* Main content */
main {
    min-height: calc(100vh - 200px);
}

/* Article styles */
article {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

article:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 1rem;
    color: #111827;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: #374151;
    line-height: 1.7;
}

/* Links */
a {
    color: #111827;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #6b7280;
}

/* Pagination - shadcn/ui style - only prev/next */
.page-navigator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 3rem 0;
    padding: 1rem 0;
}

.page-navigator a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    min-width: auto;
    white-space: nowrap;
}

.page-navigator a:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Hide all elements except prev/next links */
.page-navigator > *:not(a) {
    display: none;
}

/* Only show links that contain prev/next text */
.page-navigator a {
    display: none;
}

.page-navigator a[href*="page"]:first-of-type,
.page-navigator a[href*="page"]:last-of-type {
    display: inline-flex;
}

/* If there are only two links, show both */
.page-navigator a:first-child,
.page-navigator a:last-child {
    display: inline-flex;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .page-navigator {
        gap: 0.5rem;
        margin: 2rem 0;
    }
    
    .page-navigator a {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* Article content styles */
.article-content {
    line-height: 1.8;
    color: #374151;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #111827;
}

.article-content h1 { font-size: 2rem; }
.article-content h2 { font-size: 1.75rem; }
.article-content h3 { font-size: 1.5rem; }
.article-content h4 { font-size: 1.25rem; }
.article-content h5 { font-size: 1.125rem; }
.article-content h6 { font-size: 1rem; }

.article-content p {
    margin-bottom: 1.5rem;
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.article-content blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: #6b7280;
    background: #f9fafb;
    padding: 1.5rem;
    border-radius: 8px;
}

/* Modern code styles - enhanced shadcn/ui inspired */
.article-content code {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: #1e293b;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    position: relative;
}

.article-content pre {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    margin: 2rem 0;
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    border: 1px solid #334155;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    backdrop-filter: blur(8px);
}

/* macOS-style window header */
.article-content pre::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3rem;
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    border-bottom: 1px solid #4b5563;
    z-index: 1;
}

/* Traffic light buttons */
.article-content pre::after {
    content: '';
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 20px 0 0 #f59e0b, 40px 0 0 #10b981;
    z-index: 2;
}

.article-content pre code {
    background: transparent;
    color: inherit;
    padding: 1.5rem;
    border: none;
    border-radius: 0;
    font-size: inherit;
    font-weight: 400;
    display: block;
    margin-top: 3rem;
    position: relative;
    z-index: 0;
    overflow-x: auto;
}

/* Enhanced scrollbar for code blocks */
.article-content pre code::-webkit-scrollbar {
    height: 8px;
}

.article-content pre code::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 4px;
}

.article-content pre code::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #475569 0%, #64748b 100%);
    border-radius: 4px;
}

.article-content pre code::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%);
}

/* Syntax highlighting */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #64748b;
}

.token.punctuation {
    color: #94a3b8;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #f472b6;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #34d399;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #60a5fa;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #a78bfa;
}

.token.function,
.token.class-name {
    color: #fbbf24;
}

.token.regex,
.token.important,
.token.variable {
    color: #fb7185;
}

/* Tables */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.article-content th,
.article-content td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.article-content th {
    background: #f9fafb;
    font-weight: 600;
    color: #111827;
}

.article-content tr:last-child td {
    border-bottom: none;
}

/* Images */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Comments */
.comments {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
}

.comment-list {
    list-style: none;
    padding: 0;
}

.comment-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.comment-author {
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
}

.comment-date {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.comment-content {
    color: #374151;
    line-height: 1.6;
}

/* Footer */
footer {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.875rem;
}

/* Navbar 样式增强 */
.navbar-blur {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* 卡片悬停效果 */
.card-hover {
    transition: all 0.2s ease-in-out;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* 侧边栏动画优化 */
#sidebar {
    will-change: transform;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    article {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .article-content {
        font-size: 15px;
    }
    
    .article-content pre {
        font-size: 13px;
        padding: 12px;
        margin: 16px -16px;
        border-radius: 0;
    }
    
    .article-content code {
        font-size: 13px;
        padding: 2px 4px;
    }
    
    .article-content pre::before {
        top: 0.75rem;
        left: 0.75rem;
        width: 8px;
        height: 8px;
        box-shadow: 14px 0 0 #f59e0b, 28px 0 0 #10b981;
    }
    
    .page-navigator {
        gap: 0.25rem;
        margin: 2rem 0;
    }
    
    .page-navigator a,
    .page-navigator span {
        min-width: 2rem;
        height: 2rem;
        padding: 0 0.75rem;
        font-size: 0.8rem;
    }
    
    nav ul {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* 移动端导航优化 */
    .navbar-mobile {
        padding: 0 16px;
    }
    
    /* 移动端卡片间距 */
    .mobile-card-spacing {
        margin: 0 -4px;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    article {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .page-navigator {
        display: none;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
