/* ==========================================================================
   纸上代码 - 极简阅读型博客样式
   设计原则：大量留白、衬线正文、克制的强调色、无多余装饰
   组织顺序：变量 → 基础 → 布局 → 组件 → 页面 → 响应式
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #fcfcfa;
  --bg-soft: #f5f4f0;
  --text: #1b1a17;
  --text-soft: #6a675f;
  --text-mute: #9c988f;
  --line: #e4e1d8;
  --line-strong: #cfcbc0;
  --accent: #a8442a;
  --code-bg: #f5f4f0;

  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --wrap: 720px;
  --radius: 3px;
}

:root[data-theme="dark"] {
  --bg: #131312;
  --bg-soft: #1c1c1a;
  --text: #e8e6e0;
  --text-soft: #a3a099;
  --text-mute: #6e6b64;
  --line: #2a2a27;
  --line-strong: #3d3d38;
  --accent: #d97757;
  --code-bg: #1c1c1a;
}

/* ---------- 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

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

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* ---------- 布局 ---------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  padding-top: 34px;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: -10px;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  transition: color 0.2s ease;
}

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

.nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 500;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

/* 根据当前主题显示对应图标 */
.theme-toggle .icon-moon,
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

main {
  display: block;
}

.site-footer {
  margin-top: 96px;
  padding: 28px 0 44px;
  border-top: 1px solid var(--line);
  color: var(--text-mute);
  font-size: 12.5px;
  letter-spacing: 0.03em;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
}

.site-footer a:hover {
  color: var(--text-soft);
}

/* ---------- 首页 ---------- */
.hero {
  padding: 68px 0 52px;
  border-bottom: 1px solid var(--line);
}

.hero-title {
  margin: 0 0 20px;
  font-family: var(--font-serif);
  font-size: clamp(32px, 8vw, 42px);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: 0.02em;
}

.hero-desc {
  margin: 0;
  max-width: 30em;
  color: var(--text-soft);
  font-size: 15.5px;
  line-height: 1.85;
}

.hero-meta {
  margin-top: 26px;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  text-transform: uppercase;
}

.section {
  padding-top: 56px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.section-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.section-more {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 1px;
}

.section-more:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- 文章列表项 ---------- */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.post-item {
  border-bottom: 1px solid var(--line);
  padding: 26px 0 24px;
}

.post-item-title {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.post-item-title a {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0 1px;
  transition: background-size 0.3s ease, color 0.2s ease;
}

.post-item-title a:hover {
  color: var(--accent);
  background-size: 100% 1px;
}

.post-item-desc {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.8;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--text-mute);
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

/* ---------- 文章列表页：搜索与筛选 ---------- */
.page-head {
  padding: 56px 0 0;
}

.page-title {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(26px, 6vw, 32px);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.page-desc {
  margin: 0;
  color: var(--text-soft);
  font-size: 14.5px;
}

.toolbar {
  margin-top: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field svg {
  position: absolute;
  left: 0;
  width: 15px;
  height: 15px;
  color: var(--text-mute);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 44px;
  padding: 0 0 0 24px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 15.5px;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input::placeholder {
  color: var(--text-mute);
}

.search-input:focus {
  border-color: var(--accent);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
  margin-top: 18px;
}

/* 标签筛选做成轻量文字，避免大量按钮边框打断阅读节奏 */
.filter-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  border: none;
  background: none;
  color: var(--text-mute);
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.2s ease;
}

.filter-tag::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 11px;
  height: 1px;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.filter-tag:hover {
  color: var(--text-soft);
}

.filter-tag[aria-pressed="true"] {
  color: var(--text);
}

.filter-tag[aria-pressed="true"]::after {
  opacity: 1;
}

.result-count {
  margin: 22px 0 14px;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--text-mute);
}

.empty-state {
  padding: 64px 0;
  text-align: center;
  color: var(--text-mute);
  font-size: 14.5px;
}

/* ---------- 文章详情页 ---------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  height: 2px;
  width: var(--progress, 0%);
  background: var(--accent);
  transition: width 0.1s linear;
}

.article {
  padding-top: 56px;
}

.article-header {
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.article-title {
  margin: 0 0 18px;
  font-family: var(--font-serif);
  font-size: clamp(27px, 6.5vw, 35px);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.article-body {
  padding-top: 36px;
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.95;
  letter-spacing: 0.01em;
}

.article-body p {
  margin: 0 0 1.5em;
}

/* 中文字体在 600 字重下常回退到常规字重，小标题改用无衬线以拉开层级 */
.article-body h2 {
  margin: 2.6em 0 1em;
  font-family: var(--font-sans);
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.06em;
}

.article-body h3 {
  margin: 2em 0 0.8em;
  font-size: 17.5px;
  font-weight: 700;
  line-height: 1.6;
}

.article-body h2:first-child,
.article-body h3:first-child {
  margin-top: 0;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.5em;
  padding-left: 1.4em;
}

.article-body li {
  margin-bottom: 0.5em;
}

.article-body li::marker {
  color: var(--text-mute);
}

.article-body blockquote {
  margin: 0 0 1.6em;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--line-strong);
  color: var(--text-soft);
  font-size: 15.5px;
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body hr {
  margin: 2.4em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.article-body code {
  padding: 0.15em 0.4em;
  border-radius: var(--radius);
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.article-body pre.code-block {
  position: relative;
  margin: 0 0 1.7em;
  padding: 24px 20px 18px;
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.article-body pre.code-block code {
  padding: 0;
  background: none;
  font-size: 13px;
  line-height: 1.62;
  white-space: pre;
}

/* 代码块语言角标 */
.article-body pre.code-block::after {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}

/* 文末上下篇 */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.article-nav-link {
  display: block;
  padding: 4px 0;
  min-height: 44px;
}

.article-nav-link.next {
  text-align: right;
}

.article-nav-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.article-nav-title {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  transition: color 0.2s ease;
}

.article-nav-link:hover .article-nav-title {
  color: var(--accent);
}

.article-nav-link.is-empty {
  visibility: hidden;
}

/* ---------- 关于页 ---------- */
.about {
  padding-top: 56px;
}

.about-intro {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--line);
}

.avatar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--text-soft);
  user-select: none;
}

.about-name {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
}

.about-role {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.prose {
  padding-top: 36px;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.95;
}

.prose h2 {
  margin: 2.2em 0 0.8em;
  font-size: 19px;
  font-weight: 600;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose p {
  margin: 0 0 1.4em;
  color: var(--text);
}

.prose ul {
  margin: 0 0 1.4em;
  padding-left: 1.4em;
}

.prose li {
  margin-bottom: 0.5em;
}

.prose li::marker {
  color: var(--text-mute);
}

.link-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
}

.link-label {
  flex: none;
  min-width: 54px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--text-mute);
}

.link-list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--text-soft);
  transition: color 0.2s ease;
}

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

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .wrap {
    padding: 0 20px;
  }

  .site-header {
    padding-top: 22px;
  }

  .hero {
    padding: 48px 0 40px;
  }

  .section {
    padding-top: 44px;
  }

  .post-item {
    padding: 22px 0 20px;
  }

  .post-item-title {
    font-size: 19px;
  }

  .article {
    padding-top: 40px;
  }

  .article-body {
    font-size: 16px;
    line-height: 1.9;
  }

  .article-body pre.code-block {
    padding: 22px 16px 14px;
    margin-left: -20px;
    margin-right: -20px;
    border-radius: 0;
  }

  .article-nav {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .article-nav-link.next {
    text-align: left;
  }

  .site-footer {
    margin-top: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
