/* common.css - 个人主页公共样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #0f172a;
    line-height: 1.5;
    scroll-behavior: smooth;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #5b6e8c;
}

/* 主容器网格布局 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    align-items: start;
}

/* ========= 左侧栏样式 ========= */
.sidebar {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
    border-radius: 2rem;
    padding: 2rem 1.5rem;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: transform 0.25s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.6);
    position: sticky;
    top: 2rem;
}
@media (max-width: 850px) {
    .sidebar {
        position: static;      /* 恢复普通文档流 */
        top: auto;             /* 清除 top 值 */
        align-self: auto;      /* 清除网格对齐 */
        margin-bottom: 1rem;   /* 可选：增加与内容的间距 */
    }
}

/* 文章详情页在移动端隐藏侧边栏，主内容区域占满整行 */
@media (max-width: 850px) {
    body.article-page .sidebar {
        display: none;
    }
    body.article-page .container {
        grid-template-columns: 1fr;   /* 强制单列布局，避免空白列 */
    }
    /* 可选：确保主内容区域占满 */
    body.article-page .main-content {
        grid-column: span 1;
        width: 100%;
    }
}

.sidebar:hover {
    box-shadow: 0 25px 40px -16px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.avatar {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}
.avatar-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;          /* 确保图片超出部分隐藏，保持圆形 */
    background: #f0f0f0;       /* 可选：图片加载时的背景色 */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 15px 25px -8px rgba(59,130,246,0.3);
    transition: transform 0.3s cubic-bezier(0.2,0.9,0.4,1.1);
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;         /* 确保图片覆盖整个圆形区域，可能裁剪边缘 */
    display: block;
}

.avatar-circle:hover {
    transform: scale(1.02);
}

.name {
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    background: linear-gradient(120deg, #0f172a, #1e293b);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}
.title {
    text-align: center;
    font-weight: 500;
    color: #3b82f6;
    background: #eef2ff;
    display: inline-block;
    width: auto;
    margin: 0 auto 1rem auto;
    padding: 0.25rem 1rem;
    border-radius: 40px;
    font-size: 0.85rem;
    letter-spacing: 0.3px;
}
.bio {
    text-align: center;
    color: #334155;
    margin: 1rem 0 1.5rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 0 0.25rem;
}
.info-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
    color: #1e293b;
    font-size: 0.9rem;
    background: #f8fafc;
    padding: 0.6rem 1rem;
    border-radius: 1.2rem;
    transition: background 0.2s;
}
.info-item i {
    width: 24px;
    color: #3b82f6;
    font-size: 1.1rem;
}
.info-item:hover {
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}
.social-links {
    display: flex;
    justify-content: center;
    gap: 1.4rem;
    margin-top: 1.8rem;
    flex-wrap: wrap;
}
.social-links a {
    color: #475569;
    font-size: 1.5rem;
    transition: all 0.2s ease;
    display: inline-flex;
    text-decoration: none; 
}
.social-links a:hover {
    color: #3b82f6;
    transform: translateY(-3px) scale(1.05);
}

/* ========= 右侧卡片区域 ========= */
.main-content {
    animation: fadeSlideUp 0.8s ease-out;
    transition: height 0.6s ease-out;  /* 新增高度过渡 */
    min-width: 0;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 1.8rem;
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
}
.section-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #0f172a, #2d3a5e);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}
.section-header p {
    color: #5b6e8c;
    font-size: 0.9rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.8rem;
}

@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
}
.card-link {
    text-decoration: none;
    display: block;
    height: 100%;
}
.card {
    background: #ffffff;
    border-radius: 1.6rem;
    padding: 1.5rem;
    transition: all 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.05), 0 1px 1px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(203, 213, 225, 0.4);
    display: flex;
    flex-direction: column;
    height: 100%;
    cursor: pointer;
}
.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 36px -12px rgba(0, 0, 0, 0.15);
    border-color: #3b82f6;
}

.card-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    padding: 0.2rem 0.8rem;
    border-radius: 40px;
    font-size: 0.7rem;
    font-weight: 600;
    width: fit-content;
    margin-bottom: 1rem;
    color: #2563eb;
    letter-spacing: 0.3px;
}
.card-tag i {
    font-size: 0.7rem;
}
.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    color: #0f172a;
}
.card-preview {
    color: #334155;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0.5rem 0 1.2rem 0;
    flex: 1;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
    border-top: 1px solid #eef2ff;
    padding-top: 0.9rem;
}
.read-more-link {
    font-weight: 600;
    color: #3b82f6;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.4rem 0.8rem;
    border-radius: 2rem;
    transition: all 0.2s;
    background: #eff6ff;
    text-decoration: none;
}
.read-more-link i {
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.read-more-link:hover {
    background: #3b82f6;
    color: white;
    gap: 8px;
}
.read-more-link:hover i {
    transform: translateX(3px);
    color: white;
}
.date-badge {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 文章详情页样式 */
.article-content {
    background: #ffffff;
    border-radius: 1.6rem;
    padding: 2rem;
    box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(203, 213, 225, 0.4);
}
.back-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    color: #3b82f6;
    text-decoration: none;
    padding: 0.5rem 1.2rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    transition: all 0.2s;
}
.back-home:hover {
    background: #3b82f6;
    color: white;
    transform: translateX(-3px);
}
.article-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #0f172a, #2d3a5e);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eef2ff;
    color: #5b6e8c;
    font-size: 0.9rem;
}
.article-body {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #1e293b;
}
.article-body p {
    margin-bottom: 1.25rem;
}
.article-body h3 {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.4rem;
    font-weight: 700;
}
.article-body h4 {
    margin: 1.2rem 0 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
}
.article-body ul, .article-body ol {
    margin: 0.75rem 0 1rem 1.5rem;
}
.article-body li {
    margin-bottom: 0.4rem;
}
.article-body blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1.2rem;
    margin: 1rem 0;
    color: #475569;
    font-style: italic;
}
/* 行内代码 */
.article-body code {
    background: #f0f2f5;
    color: #d73a49;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    font-weight: 500;
    border: 1px solid #e2e8f0;
}

/* 代码块 */
.article-body pre {
    background: #0d1117;
    color: #e6edf3;
    padding: 1rem;
    border-radius: 0.8rem;
    overflow-x: auto;
    margin: 1.2rem 0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid #30363d;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;   /* 保持代码格式 */
    position: relative;
    overflow-y: hidden;

    /* 关键：滚动更顺滑 */
    scroll-behavior: smooth;

    /* 防止滚动条占空间（现代浏览器） */
    scrollbar-gutter: stable both-edges;
}

/* 默认隐藏 */
.article-body pre::-webkit-scrollbar {
    height: 6px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

/* 滑块轨道 */
.article-body pre::-webkit-scrollbar-track {
    background: transparent;
}

/* 滑块 */
.article-body pre::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35); /* 低对比 */
    border-radius: 999px;
    transition: background 0.2s ease;
}

/* hover 或滚动时显示 */
.article-body pre:hover::-webkit-scrollbar,
.article-body pre.scrolling::-webkit-scrollbar {
    opacity: 1;
}

/* hover 时增强 */
.article-body pre:hover::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.6);
}


/* 代码块内的 code 重置 */
.article-body pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
    font-size: inherit;
    border: none;
    font-weight: normal;
}

/* 页脚 */
.footer-note {
    text-align: center;
    margin-top: 3rem;
    color: #62748c;
    font-size: 0.75rem;
    border-top: 1px solid #e2e8f0;
    padding-top: 1.8rem;
}

/* 动画 */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式 */
@media (max-width: 850px) {
    .container {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1.5rem;
    }
    .sidebar {
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }
    .cards-grid {
        grid-template-columns: 1fr;
    }
    .section-header h2 {
        font-size: 1.6rem;
    }
    .article-title {
        font-size: 1.6rem;
    }
}
@media (max-width: 480px) {
    .article-title {
        font-size: 1.4rem;
    }
    .card-title {
        font-size: 1.25rem;
    }
    .article-content {
        padding: 1.5rem;
    }
}
/* ========== 分页样式 ========== */
.pagination {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 850px) {
    .pagination {
        gap: 0.3rem;
    }
    .pagination .page-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    .pagination .nav-btn,
    .pagination .first-btn,
    .pagination .last-btn {
        font-size: 0.8rem;
        padding: 0 0.2rem;
    }
}
/* 通用按钮样式（首尾、上一页、下一页） */
.pagination .nav-btn,
.pagination .first-btn,
.pagination .last-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: #57606a;
    padding: 0 0.5rem;
    transition: color 0.2s, opacity 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pagination .nav-btn:hover,
.pagination .first-btn:hover,
.pagination .last-btn:hover {
    color: #0366d6;
}
.pagination .nav-btn.disabled,
.pagination .first-btn.disabled,
.pagination .last-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* 页码圆圈 */
.pagination .page-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #d0d7de;
    background: #ffffff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pagination .page-btn:hover:not(.active) {
    background: #f6f8fa;
    border-color: #c0c7cd;
}
.pagination .page-btn.active {
    background: #0366d6;
    border-color: #0366d6;
    color: white;
    cursor: default;
}

/* 页面切换动画 */
.page {
    display: none;
    animation: none;
}
.page.active {
    display: block;
    animation: fadeSlideUp 0.4s ease-out;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 20px 0;
    font-size: 14px; 
}
th, td {
    border: 1px solid #333;
    padding: 2px 12px;
    text-align: left;
    vertical-align: top;
    font-size: 14px; 
}
th {
    background-color: #f0f0f0;
    font-weight: bold;
}

    .expression {

    word-break: break-all;
    white-space: pre-wrap;
}

.article-body {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #1e293b;
    transition: opacity 0.2s ease;
    opacity: 1;
}
.article-body.fade-out {
    opacity: 0;
}

/* 数学公式样式 */
.math-block {
    margin: 1.5rem 0;
    overflow-x: auto;
    text-align: center;
}
.math-inline {
    white-space: nowrap;
    padding: 0 0.1em;
}

/* 文章内容图片自适应（基础） */
.article-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
    border-radius: 8px;
    box-sizing: border-box;
}

/* 防止文章内容溢出 */
.article-body {
    overflow-x: hidden;
    word-wrap: break-word;
}

@media (max-width: 850px) {
    .container {
        width: 100%;
        padding: 1rem;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .article-content,
    .article-body {
        width: 100%;
        box-sizing: border-box;
        min-width: 0;              /* ⭐关键：允许收缩 */
        overflow-x: hidden;
    }

    .article-body {
        overflow-wrap: break-word; /* ⭐替代 word-wrap */
        word-break: break-word;
    }

    .article-body img {
        display: block;
        width: 100%;
        max-width: 100%;
        height: auto;
        margin: 1rem 0;
    }
}

/* ========== 夜间模式（跟随系统） ========== */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
        color: #e2e8f0;
    }

    /* 滚动条暗色 */
    ::-webkit-scrollbar-track {
        background: #1e293b;
    }
    ::-webkit-scrollbar-thumb {
        background: #475569;
    }
    ::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }

    /* 左侧栏 */
    .sidebar {
        background: rgba(15, 23, 42, 0.8);
        backdrop-filter: blur(2px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.3);
    }
    .sidebar:hover {
        box-shadow: 0 25px 40px -16px rgba(0, 0, 0, 0.4);
    }

    .name {
        background: linear-gradient(120deg, #e2e8f0, #94a3b8);
        background-clip: text;
        -webkit-background-clip: text;
    }
    .title {
        background: #1e293b;
        color: #60a5fa;
    }
    .bio {
        color: #cbd5e1;
    }
    .info-item {
        background: #1e293b;
        color: #e2e8f0;
    }
    .info-item i {
        color: #60a5fa;
    }
    .info-item:hover {
        background: #2d3a5e;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }
    .social-links a {
        color: #94a3b8;
    }
    .social-links a:hover {
        color: #60a5fa;
    }

    /* 右侧卡片区域 */
    .section-header h2 {
        background: linear-gradient(135deg, #e2e8f0, #94a3b8);
        background-clip: text;
        -webkit-background-clip: text;
    }
    .section-header p {
        color: #94a3b8;
    }

    .card {
        background: #1e293b;
        border: 1px solid #334155;
        box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.3);
    }
    .card:hover {
        border-color: #60a5fa;
        box-shadow: 0 24px 36px -12px rgba(0, 0, 0, 0.4);
    }
    .card-tag {
        background: #2d3a5e;
        color: #93c5fd;
    }
    .card-title {
        color: #f1f5f9;
    }
    .card-preview {
        color: #cbd5e1;
    }
    .card-meta {
        color: #94a3b8;
        border-top-color: #334155;
    }
    .read-more-link {
        background: #2d3a5e;
        color: #60a5fa;
    }
    .read-more-link:hover {
        background: #60a5fa;
        color: #0f172a;
    }

    /* 文章详情页 */
    .article-content {
        background: #1e293b;
        border: 1px solid #334155;
        box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.3);
    }
    .back-home {
        background: #2d3a5e;
        color: #60a5fa;
    }
    .back-home:hover {
        background: #60a5fa;
        color: #0f172a;
    }
    .article-title {
        background: linear-gradient(135deg, #e2e8f0, #94a3b8);
        background-clip: text;
        -webkit-background-clip: text;
    }
    .article-meta {
        color: #94a3b8;
        border-bottom-color: #334155;
    }
    .article-body {
        color: #e2e8f0;
    }
    .article-body blockquote {
        border-left-color: #60a5fa;
        color: #cbd5e1;
    }
    /* 行内代码 */
    .article-body code {
        background: #0f172a;
        color: #f87171;
        border-color: #334155;
    }
    /* 代码块 */
    .article-body pre {
        background: #0f172a;
        border-color: #334155;
        color: #e2e8f0;
    }
    /* 表格 */
    table {
        border-color: #334155;
    }
    th, td {
        border-color: #334155;
    }
    th {
        background-color: #2d3a5e;
        color: #e2e8f0;
    }
    td {
        background-color: #1e293b;
        color: #e2e8f0;
    }

    /* 页脚 */
    .footer-note {
        color: #94a3b8;
        border-top-color: #334155;
    }

    /* 分页控件 */
    .pagination .nav-btn,
    .pagination .first-btn,
    .pagination .last-btn {
        color: #94a3b8;
    }
    .pagination .nav-btn:hover,
    .pagination .first-btn:hover,
    .pagination .last-btn:hover {
        color: #60a5fa;
    }
    .pagination .page-btn {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }
    .pagination .page-btn:hover:not(.active) {
        background: #2d3a5e;
        border-color: #475569;
    }
    .pagination .page-btn.active {
        background: #60a5fa;
        border-color: #60a5fa;
        color: #0f172a;
    }
}