/* ========================================
   FlyingChar Blog — 主样式文件

   设计原则：
   1. 大留白
   2. 克制的颜色（黑白灰 + 单一蓝色强调）
   3. 极少使用圆角
   4. 不使用渐变
   5. 动画保持自然、克制
   6. 不用毛玻璃（仅导航栏一处轻微背景模糊）
======================================== */


/* ========================================
   1. CSS 变量
   —— 改颜色、改强调色、改宽度都在这里改
======================================== */

:root {
    --background: #ffffff;            /* 页面背景 */
    --background-secondary: #f5f5f7;  /* 次级背景 */
    --text-primary: #1d1d1f;          /* 主要文字 */
    --text-secondary: #6e6e73;        /* 次要文字 */
    --border-color: #d2d2d7;          /* 分割线 / 边框 */
    --accent: #0071e3;                /* 强调色（Apple 蓝） */
    --accent-hover: #0077ed;          /* 强调色 hover */
    --navbar-background: rgba(255, 255, 255, 0.82); /* 导航栏背景 */
    --code-bg: #f5f5f7;               /* 代码块背景（浅色） */
    --code-border: #e5e5ea;
    --max-width: 1200px;              /* 全站最大内容宽度 */
    --post-width: 720px;              /* 文章正文最大阅读宽度 */
}


/* ========================================
   2. 深色模式变量
   JavaScript 给 body 加 dark 类时生效
======================================== */

body.dark {
    --background: #000000;
    --background-secondary: #161617;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --border-color: #424245;
    --accent: #2997ff;
    --accent-hover: #64b5ff;
    --navbar-background: rgba(0, 0, 0, 0.82);
    --code-bg: #161617;
    --code-border: #2c2c2e;
}


/* ========================================
   3. 基础重置
======================================== */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;   /* 锚点平滑滚动 */
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text-primary);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Display",
        "SF Pro Text",
        "PingFang SC",
        "Microsoft YaHei",
        "Segoe UI",
        sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background 0.3s ease, color 0.3s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

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

/* hidden 属性必须优先于任何 display 设置 */
[hidden] {
    display: none !important;
}

/* 锚点跳转时给导航栏留出空间，避免被遮挡 */
section[id],
article[id],
.post-content h2,
.post-content h3 {
    scroll-margin-top: 72px;
}


/* ========================================
   4. 顶部导航栏
======================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background: var(--navbar-background);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    width: min(calc(100% - 48px), var(--max-width));
    height: 56px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 28px;
}

.nav-links a {
    font-size: 14px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--text-primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
}

/* 移动端菜单按钮（三条横线），桌面端隐藏 */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 1.5px;
    background: var(--text-primary);
    margin: 0 auto;
}

/* 移动端下拉菜单（默认隐藏） */
.mobile-menu {
    display: none;
    flex-direction: column;
    padding: 8px 24px 20px;
    border-top: 1px solid var(--border-color);
}
.mobile-menu a {
    padding: 12px 0;
    font-size: 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}
.mobile-menu a:last-child {
    border-bottom: 0;
}
.mobile-menu.open {
    display: flex;
}


/* ========================================
   5. Hero 首屏
======================================== */

.hero {
    min-height: 680px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 24px;
    text-align: center;
}

.hero-content {
    max-width: 900px;
}

.hero-eyebrow,
.section-eyebrow {
    margin: 0 0 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.8px;
    color: var(--text-secondary);
}

.hero h1 {
    margin: 0;
    font-size: clamp(52px, 9vw, 96px);   /* 主标题自适应 */
    font-weight: 700;
    letter-spacing: -0.055em;
    line-height: 1.05;
}

.hero-description {
    max-width: 600px;
    margin: 32px auto 0;
    font-size: 20px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 40px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 22px;
    border-radius: 999px;   /* 唯一的胶囊圆角，仅用于按钮 */
    font-size: 15px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.button.primary {
    background: var(--accent);
    color: #fff;
}
.button.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.button.secondary {
    background: var(--background-secondary);
    color: var(--text-primary);
}


/* ========================================
   6. 通用 Section
======================================== */

.section {
    padding: 120px 24px;
}

.section-container {
    width: min(100%, var(--max-width));
    margin: 0 auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 48px;
}

.section-header h2 {
    margin: 0;
    font-size: clamp(36px, 5vw, 56px);
    letter-spacing: -0.04em;
}

.text-link {
    color: var(--accent);
    font-size: 15px;
}


/* ========================================
   7. 最新文章（杂志式网格）
======================================== */

.articles-section {
    background: var(--background-secondary);
}

/* 三列网格，用 1px 缝隙做杂志分隔线，不是圆角卡片 */
.article-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
}

.article-card {
    min-height: 360px;
    background: var(--background);
    display: flex;
    transition: background 0.25s ease;
}
.article-card:hover {
    background: var(--background-secondary);
}

/* 整张卡片可点击 */
.card-link {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 40px;
}

/* 第一篇占两列（featured） */
.article-card.featured {
    grid-column: span 2;
}

/* 卡片封面图 */
.article-cover {
    overflow: hidden;
    margin-bottom: 28px;
}
.article-cover img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;   /* 卡片封面允许裁剪，正文图片不裁剪 */
}

.article-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.article-card h3 {
    margin: 0;
    font-size: 28px;
    line-height: 1.25;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}
.article-card.featured h3 {
    font-size: 40px;
}

.article-card p {
    margin-top: 20px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.article-link {
    margin-top: auto;
    padding-top: 30px;
    color: var(--accent);
    font-size: 15px;
}
.article-link span {
    display: inline-block;
    margin-left: 4px;
    transition: transform 0.2s ease;
}
.card-link:hover .article-link span {
    transform: translateX(4px);
}

/* 无文章时的空状态 */
.empty {
    grid-column: 1 / -1;
    padding: 64px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--background);
}


/* ========================================
   8. 分类区域
======================================== */

.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-top: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
}

.category-card {
    position: relative;
    min-height: 260px;
    padding: 36px;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transition: background 0.25s ease;
}
.category-card:hover {
    background: var(--background-secondary);
}

/* 当前选中的分类卡片（筛选时高亮） */
.category-card.active {
    background: var(--background-secondary);
}
.category-card.active h3,
.category-card.active .category-arrow {
    color: var(--accent);
}

.category-number {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 48px;
}

.category-card h3 {
    margin: 0;
    font-size: 26px;
    letter-spacing: -0.025em;
}

.category-card p {
    color: var(--text-secondary);
    margin-top: 12px;
}

.category-arrow {
    position: absolute;
    right: 36px;
    bottom: 32px;
    font-size: 24px;
    color: var(--accent);
}


/* ========================================
   9. 关于区域
======================================== */

.about-section {
    padding: 160px 24px;
}

.about-container {
    width: min(100%, 850px);
    margin: 0 auto;
}

.about-container h2 {
    margin: 0 0 36px;
    font-size: clamp(52px, 7vw, 80px);
    line-height: 1.05;
    letter-spacing: -0.05em;
}

.about-text {
    max-width: 700px;
    font-size: 22px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.about-links {
    display: flex;
    gap: 28px;
    margin-top: 40px;
}
.about-links a {
    color: var(--accent);
}


/* ========================================
   10. 文章详情页整体布局
======================================== */

.post-view {
    max-width: 1040px;
    margin: 0 auto;
    padding: 80px 24px 0;
}

/* 文章头部 */
.post-header {
    max-width: var(--post-width);
    margin: 0 auto 48px;
}

.post-header-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 14px;
    margin-bottom: 24px;
}

.post-category {
    color: var(--accent);
    font-weight: 500;
}
.post-header-meta time {
    color: var(--text-secondary);
}

.post-title {
    margin: 0;
    font-size: clamp(36px, 6vw, 60px);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.post-excerpt {
    margin: 24px 0 0;
    font-size: 20px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.post-byline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    font-size: 14px;
    color: var(--text-secondary);
}
.post-author {
    font-weight: 500;
    color: var(--text-primary);
}

/* 封面图片 */
.post-cover {
    margin: 0 auto 56px;
    max-width: 1040px;
}
.post-cover img {
    width: 100%;
    height: auto;          /* 正文/封面图片不裁剪、不拉伸 */
}
.post-cover figcaption {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

/* 正文 + 目录 两栏布局 */
.post-body-wrap {
    display: flex;
    justify-content: center;   /* 正文 + 目录整体居中 */
    gap: 48px;
    align-items: flex-start;
    max-width: 1040px;
    margin: 0 auto;
}

/* 文章底部 */
.post-footer {
    max-width: var(--post-width);
    margin: 64px auto 0;
}


/* ========================================
   11. Article Content 文章正文排版
   —— 正文最大宽度 720px，不铺满屏幕
======================================== */

.post-content {
    width: var(--post-width);        /* 正文固定 720px 阅读宽度 */
    max-width: 100%;                 /* 窄屏自动收缩，不溢出 */
    min-width: 0;                    /* 防止代码块把列撑破 */
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
}

.post-content > *:first-child {
    margin-top: 0;
}

.post-content h2 {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.3;
    margin: 56px 0 20px;
}

.post-content h3 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.4;
    margin: 40px 0 16px;
}

.post-content p {
    margin: 0 0 24px;
}

/* 列表 */
.post-content ul,
.post-content ol {
    margin: 0 0 24px;
    padding-left: 24px;
}
.post-content li {
    margin: 8px 0;
}

/* 引用 */
.post-content blockquote {
    margin: 32px 0;
    padding: 4px 0 4px 24px;
    border-left: 3px solid var(--accent);
    color: var(--text-secondary);
}
.post-content blockquote p {
    margin: 0;
    font-size: 20px;
    line-height: 1.6;
}

/* 链接 */
.post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* 分割线 */
.post-content hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 48px 0;
}


/* ========================================
   12. 正文图片 / figure（可点开放大）
======================================== */

.post-content figure {
    margin: 40px 0;
}

.post-content figure img {
    width: 100%;
    height: auto;          /* 保持比例，绝不裁剪、不变形 */
    cursor: zoom-in;
    border-radius: 6px;
}

/* markdown 渲染的图片（不在 figure 里）同样可点开放大 */
.post-content img {
    cursor: zoom-in;
}

.post-content figcaption {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}


/* ========================================
   13. 代码块 / 行内代码
======================================== */

/* 行内代码 */
.post-content code {
    font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.86em;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    padding: 2px 6px;
}

/* 代码块 */
.post-content pre {
    margin: 32px 0;
    padding: 20px 22px;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    overflow-x: auto;      /* 超长代码横向滚动，不撑破页面 */
    line-height: 1.6;
}

.post-content pre code {
    display: block;
    background: none;
    border: none;
    padding: 0;
    font-size: 14px;
    white-space: pre;
    color: var(--text-primary);
}


/* ========================================
   14. 正文表格
======================================== */

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 15px;
}

.post-content th,
.post-content td {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.post-content th {
    background: var(--background-secondary);
    font-weight: 600;
}


/* ========================================
   15. 文章目录（TOC）
   —— 桌面端显示在正文右侧，手机端隐藏
======================================== */

.post-toc {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
}

.post-toc-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: 0 0 12px;
}

.post-toc a {
    display: block;
    padding: 4px 0 4px 12px;
    border-left: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.post-toc a:hover {
    color: var(--text-primary);
}
.post-toc a.toc-h3 {
    padding-left: 24px;
}
.post-toc a.active {
    color: var(--accent);
    border-left-color: var(--accent);
}


/* ========================================
   16. 文章标签 / 上一篇下一篇
======================================== */

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 48px;
}

.post-tag {
    font-size: 13px;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.post-tag:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.post-nav-item {
    display: block;
}
.post-nav-item.next {
    text-align: right;
}
.post-nav-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.post-nav-item .post-nav-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.2s ease;
}
.post-nav-item:hover .post-nav-title {
    color: var(--accent);
}

.back-link {
    display: inline-block;
    margin-top: 40px;
    color: var(--accent);
    font-size: 15px;
}


/* ========================================
   17. 阅读进度条（页面顶部细线）
======================================== */

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: var(--accent);
    z-index: 200;
    transition: width 0.1s linear;
}


/* ========================================
   18. 返回顶部按钮
======================================== */

.back-to-top {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--background);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    z-index: 150;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    border-color: var(--accent);
    color: var(--accent);
}


/* ========================================
   19. 图片查看器（Lightbox）
======================================== */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    cursor: zoom-out;
}

.lightbox img {
    max-width: 100%;
    max-height: 88vh;
    height: auto;
    cursor: default;
    border-radius: 4px;
}

.lightbox-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 28px;
    text-align: center;
    color: #d1d1d6;
    font-size: 14px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
}


/* ========================================
   20. 页脚
======================================== */

.footer {
    border-top: 1px solid var(--border-color);
    padding: 32px 24px;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 96px;
}

.footer-container {
    width: min(100%, var(--max-width));
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left {
    display: flex;
    gap: 8px;
}

.footer-right {
    display: flex;
    gap: 20px;
}
.footer-right a:hover {
    color: var(--text-primary);
}


/* ========================================
   21. 页面入场动画（克制）
======================================== */

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
    opacity: 1;
    transform: none;
}


/* ========================================
   22. 响应式设计
   —— 平板 / 手机断点在这里调
======================================== */

/* 平板：目录隐藏，正文单列 */
@media (max-width: 960px) {
    .post-toc {
        display: none;
    }
    .post-body-wrap {
        display: block;
    }
    .post-content {
        max-width: 100%;
    }
}

/* 平板：文章网格变单列 */
@media (max-width: 900px) {
    .article-grid {
        grid-template-columns: 1fr;
    }
    .article-card.featured {
        grid-column: span 1;
    }
    .article-card.featured h3 {
        font-size: 32px;
    }
}

/* 手机 */
@media (max-width: 640px) {

    /* 隐藏中间导航，显示汉堡按钮 */
    .nav-links {
        display: none;
    }
    .menu-toggle {
        display: flex;
    }

    .hero {
        min-height: 600px;
        padding-top: 80px;
        padding-bottom: 80px;
    }
    .hero-description {
        font-size: 17px;
    }

    .section {
        padding-top: 80px;
        padding-bottom: 80px;
    }

    .section-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 20px;
    }

    .article-card {
        min-height: 300px;
    }
    .card-link {
        padding: 28px;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }

    .about-section {
        padding-top: 100px;
        padding-bottom: 100px;
    }
    .about-text {
        font-size: 18px;
    }

    /* 文章页 */
    .post-view {
        padding: 48px 20px 0;
    }
    .post-title {
        font-size: 32px;
    }
    .post-excerpt {
        font-size: 17px;
    }
    .post-nav {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .post-nav-item.next {
        text-align: left;
    }

    .footer-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .footer-right {
        flex-wrap: wrap;
    }

    .back-to-top {
        right: 20px;
        bottom: 20px;
    }
    .lightbox {
        padding: 24px;
    }
}


/* ========================================
   23. 减少动画（尊重系统设置）
======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal {
        opacity: 1;
        transform: none;
    }
}
