/* ============================================================
   顶级索引 — DevLog 主题（程序员 / 代码编辑器美学）
   深色优先 · 浅色/系统 三态切换 · 等宽字体 · 语法高亮
   纯系统字体，国内访问快，无外部依赖 · 全响应式
   ============================================================ */

/* ---------- 设计变量（深色为默认） ---------- */
:root,
:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-grid: rgba(56, 139, 253, 0.05);
  --surface: #161b22;
  --surface-2: #1c2230;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --accent: #3fb950;       /* 终端绿 */
  --accent-2: #39c5cf;     /* 青 */
  --accent-3: #bc8cff;     /* 紫 */
  --accent-yellow: #d29922;
  --accent-pink: #f778ba;
  --code-bg: #1a1b26;
  --glow: rgba(63, 185, 80, 0.25);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --header-bg: rgba(13, 17, 23, 0.8);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-grid: rgba(9, 105, 218, 0.04);
  --surface: #f6f8fa;
  --surface-2: #eef1f4;
  --border: #d0d7de;
  --border-soft: #e1e4e8;
  --text: #1f2328;
  --text-dim: #57606a;
  --text-faint: #6e7781;
  --accent: #1a7f37;
  --accent-2: #0a6e8a;
  --accent-3: #8250df;
  --accent-yellow: #9a6700;
  --accent-pink: #bf3989;
  --code-bg: #f6f8fa;
  --glow: rgba(26, 127, 55, 0.18);
  --shadow: 0 8px 30px rgba(140, 149, 159, 0.18);
  --header-bg: rgba(255, 255, 255, 0.82);
  color-scheme: light;
}

/* 跟随系统：未显式指定 dark/light 时按 OS 走 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]),
  :root[data-theme="system"] {
    --bg: #ffffff;
    --bg-grid: rgba(9, 105, 218, 0.04);
    --surface: #f6f8fa;
    --surface-2: #eef1f4;
    --border: #d0d7de;
    --border-soft: #e1e4e8;
    --text: #1f2328;
    --text-dim: #57606a;
    --text-faint: #6e7781;
    --accent: #1a7f37;
    --accent-2: #0a6e8a;
    --accent-3: #8250df;
    --accent-yellow: #9a6700;
    --accent-pink: #bf3989;
    --code-bg: #f6f8fa;
    --glow: rgba(26, 127, 55, 0.18);
    --shadow: 0 8px 30px rgba(140, 149, 159, 0.18);
    --header-bg: rgba(255, 255, 255, 0.82);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 等宽字体栈（代码风） */
.mono,
.term,
.logo-mark,
.post-filename,
.section-title,
.post-meta,
.chip,
.kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

a { color: var(--accent-2); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ==================== 阅读进度条 ==================== */
.read-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  z-index: 1200;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--glow);
}

/* ==================== 顶栏 / 导航 ==================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--header-bg);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--border-soft);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; gap: 16px;
}
.logo {
  display: flex; align-items: center; gap: 9px;
  color: var(--text); font-weight: 700; font-size: 19px;
  white-space: nowrap;
}
.logo-mark {
  color: var(--accent); font-size: 20px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 7px;
}
.logo:hover { color: var(--accent); }

.site-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  color: var(--text-dim);
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 7px;
  transition: all 0.18s ease;
}
.site-nav a:hover { color: var(--accent); background: var(--surface); }
.site-nav a.current { color: var(--accent); background: var(--surface); }

/* 主题切换三态 */
.theme-switch { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.theme-switch button {
  width: 34px; height: 32px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  border-radius: 7px; cursor: pointer; font-size: 15px;
  color: var(--text-faint); transition: all 0.18s ease;
}
.theme-switch button:hover { color: var(--accent); background: var(--surface); }
.theme-switch button.active {
  color: var(--accent); background: var(--surface); border-color: var(--border);
}

/* 汉堡按钮（移动端） */
.menu-toggle {
  display: none;
  width: 38px; height: 34px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; cursor: pointer; color: var(--text);
  font-size: 18px; line-height: 1;
}

/* ==================== 主体 ==================== */
main.container { padding-top: 36px; padding-bottom: 56px; min-height: 60vh; }

/* 区块标题（代码注释风） */
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; letter-spacing: 0.04em;
  color: var(--text-dim); margin: 8px 0 18px;
  text-transform: none;
}
.section-title::before { content: "//"; color: var(--accent); font-weight: 700; }
.section-title .count { color: var(--text-faint); }
.section-title .line {
  flex: 1; height: 1px; background: var(--border-soft);
}

/* ==================== Hero：终端窗口 ==================== */
.hero { margin-bottom: 44px; }
.term-window {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.term-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.term-dot { width: 12px; height: 12px; border-radius: 50%; }
.term-dot.r { background: #ff5f56; }
.term-dot.y { background: #ffbd2e; }
.term-dot.g { background: #27c93f; }
.term-title {
  margin-left: 8px; font-size: 12.5px; color: var(--text-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.term-body {
  padding: 26px 24px 30px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14.5px; line-height: 1.9;
}
.term-line { white-space: pre-wrap; }
.term-prompt { color: var(--accent); }
.term-path { color: var(--accent-2); }
.term-cmd { color: var(--text); }
.term-comment { color: var(--text-faint); }
.term-string { color: var(--accent-3); }
.hero-title {
  font-size: clamp(30px, 6vw, 52px);
  font-weight: 800; line-height: 1.1; margin: 18px 0 10px;
  letter-spacing: -0.01em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}
.hero-title .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cursor {
  display: inline-block; width: 0.6ch; height: 1.05em;
  background: var(--accent); margin-left: 2px;
  vertical-align: -0.15em; animation: blink 1.05s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero-sub { color: var(--text-dim); font-size: 15px; margin-top: 6px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.hero-tags .chip { font-size: 13px; }

/* ==================== 文章卡片（文件卡风） ==================== */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}
.post-card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0; overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.22s ease, box-shadow 0.22s ease;
}
.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 10px 34px var(--glow);
}
.post-filename {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-faint);
  padding: 9px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-soft);
}
.post-filename .dot { color: var(--accent); }
.post-card-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; }
.post-title {
  margin: 0; font-size: 18px; font-weight: 700; line-height: 1.4;
}
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--accent); }
.post-meta {
  margin-top: 9px; color: var(--text-faint); font-size: 12.5px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.post-meta .cat { color: var(--accent-2); }
.post-meta .cat::before { content: "#"; opacity: 0.7; }
.post-excerpt {
  margin-top: 10px; color: var(--text-dim); font-size: 13.5px;
  line-height: 1.65; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card .arrow {
  margin-top: 12px; color: var(--text-faint); font-size: 13px;
  font-family: ui-monospace, monospace; transition: color 0.2s, transform 0.2s;
}
.post-card:hover .arrow { color: var(--accent); transform: translateX(3px); }

/* ==================== 单篇文章（文件窗口） ==================== */
.article-window {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow);
}
.article-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--text-faint);
}
.article-bar .fname { color: var(--text-dim); margin-left: 8px; }
.article-body { padding: 26px 28px 30px; }

.post-title-single {
  margin: 0 0 12px; font-size: clamp(24px, 4vw, 32px); font-weight: 800;
  line-height: 1.25; letter-spacing: -0.01em;
}
.post-meta-single {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  color: var(--text-faint); font-size: 13px;
  padding-bottom: 18px; border-bottom: 1px solid var(--border-soft);
}
.post-meta-single .cat { color: var(--accent-2); }
.post-meta-single .cat::before { content: "#"; opacity: 0.7; }

.post-content { margin-top: 20px; line-height: 1.85; word-wrap: break-word; }
.post-content > p:first-child { margin-top: 0; }
.post-content img {
  max-width: 100%; height: auto; border-radius: 10px;
  border: 1px solid var(--border); margin: 14px 0; display: block;
}
.post-content a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
.post-content a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 1.6em 0 0.6em; line-height: 1.4; font-weight: 700;
  position: relative; padding-left: 14px;
}
.post-content h2 { font-size: 1.5em; }
.post-content h3 { font-size: 1.25em; }
.post-content h4 { font-size: 1.08em; }
.post-content h2::before,
.post-content h3::before,
.post-content h4::before {
  content: "#"; position: absolute; left: 0; color: var(--accent);
  font-family: ui-monospace, monospace; opacity: 0.75;
}
.post-content blockquote {
  margin: 1.2em 0; padding: 10px 16px;
  background: var(--surface-2); border-left: 3px solid var(--accent-3);
  border-radius: 0 8px 8px 0; color: var(--text-dim);
}
.post-content blockquote p { margin: 0.3em 0; }
.post-content hr { margin: 2em auto; border: none; border-top: 1px solid var(--border); width: 70%; }
.post-content ul, .post-content ol { padding-left: 1.5em; }
.post-content li { margin: 0.35em 0; }
.kbd {
  background: var(--surface-2); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
  font-size: 0.85em; color: var(--text);
}

/* ---- 代码块（Chroma 语法高亮 / 暗色霓虹） ---- */
.post-content pre,
.chroma {
  background: var(--code-bg) !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow: auto;
  margin: 1.3em 0;
  font-size: 13.5px; line-height: 1.7;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.post-content pre code,
.chroma code { background: transparent; padding: 0; border: 0; font-size: inherit; }
.post-content :not(pre) > code {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 5px; font-size: 0.88em;
  font-family: ui-monospace, monospace; color: var(--accent-3);
}

/* Chroma token 调色（Tokyo-night 风） */
.chroma { color: #c0caf5; }
.chroma .err { color: #f7768e; }
.chroma .ln, .chroma .lnt, .chroma .line { color: #565f89; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr { color: #bb9af7; }
.chroma .kt { color: #7dcfff; }
.chroma .na, .chroma .nc, .chroma .no, .chroma .nd, .chroma .nx { color: #7dcfff; }
.chroma .nf { color: #7aa2f7; }
.chroma .nt { color: #f7768e; }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl,
.chroma .sd, .chroma .s2, .chroma .se, .chroma .sh, .chroma .si,
.chroma .sx, .chroma .sr, .chroma .s1, .chroma .ss { color: #9ece6a; }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi,
.chroma .il, .chroma .mo, .chroma .mx { color: #ff9e64; }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs,
.chroma .cp, .chroma .cpf { color: #565f89; font-style: italic; }
.chroma .o, .chroma .ow { color: #89ddff; }
.chroma .gd { color: #f7768e; }
.chroma .gi { color: #9ece6a; }
.chroma .gs { font-weight: 700; }
.chroma .ge { font-style: italic; }
.chroma .gu { color: #bb9af7; }

/* 分类标签 chips */
.post-tags {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border-soft);
  font-size: 13px; color: var(--text-dim);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.chip {
  display: inline-block; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--accent-2);
  padding: 4px 12px; border-radius: 20px; font-size: 12.5px;
  transition: all 0.16s ease;
}
.chip::before { content: "#"; opacity: 0.7; }
.chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ==================== 归档 / 分类 ==================== */
.archive-title {
  font-family: ui-monospace, monospace; font-size: 15px; color: var(--text-dim);
  margin: 8px 0 18px;
}
.archive-title::before { content: "~/"; color: var(--accent-2); }
.archive-title .name { color: var(--accent); }

.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px;
}
.cat-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px; transition: all 0.2s ease;
}
.cat-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 8px 26px var(--glow); }
.cat-card .cat-name { font-size: 17px; font-weight: 700; color: var(--text); }
.cat-card .cat-name::before { content: "#"; color: var(--accent-2); margin-right: 2px; }
.cat-card .cat-count { color: var(--text-faint); font-size: 13px; font-family: ui-monospace, monospace; margin-top: 4px; }

/* ==================== 分页 ==================== */
.pagination {
  list-style: none; padding: 0; display: flex; justify-content: center;
  gap: 6px; margin-top: 32px; flex-wrap: wrap;
}
.pagination li {
  background: var(--surface); border: 1px solid var(--border); border-radius: 7px;
}
.pagination a, .pagination span {
  display: inline-block; min-width: 38px; text-align: center;
  padding: 7px 12px; color: var(--text-dim); font-size: 14px;
}
.pagination a:hover { color: var(--accent); background: var(--surface-2); }
.pagination li.active { border-color: var(--accent); }
.pagination li.active a, .pagination li.active span { color: var(--accent); font-weight: 700; }

/* ==================== 页脚 ==================== */
.site-footer {
  text-align: center; color: var(--text-faint); font-size: 13px;
  padding: 30px 20px; border-top: 1px solid var(--border-soft);
  font-family: ui-monospace, monospace;
}
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--accent); }
.site-footer .heart { color: var(--accent-pink); }

/* ==================== 滚动渐入 ==================== */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .cursor { animation: none; }
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  .container { padding: 0 14px; }
  .site-header .container { height: 54px; }
  .menu-toggle { display: grid; place-items: center; }
  .site-nav {
    position: fixed; top: 54px; right: 0; left: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--header-bg); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 8px 14px 14px;
    transform: translateY(-130%); transition: transform 0.28s ease;
    max-height: calc(100vh - 54px); overflow-y: auto;
  }
  .site-nav.open { transform: translateY(0); }
  .site-nav a { padding: 12px 10px; font-size: 16px; border-radius: 8px; }
  .term-body { padding: 20px 16px 24px; font-size: 13.5px; }
  .article-body { padding: 20px 16px 24px; }
  .post-grid { grid-template-columns: 1fr; }
  main.container { padding-top: 24px; }
}
