/* ==========================================================================
   钟以豪的个人博客 · 设计系统
   风格：暖色纸感 + 墨色文字 + 赭石点缀（editorial / typography-first）
   说明：仅用系统字体，不依赖任何外部字体/CDN，适配国内访问与备案。
   ========================================================================== */

/* ---------- 设计令牌（浅色） ---------- */
:root {
  --bg: #fbfaf6;
  --bg-soft: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f7f5ef;
  --text: #1f1d1a;
  --text-soft: #4a4742;
  --muted: #837d72;
  --border: #e7e2d7;
  --border-strong: #d8d2c4;
  --accent: #b65a32;          /* 赭石 / terracotta */
  --accent-soft: #f3e3d8;
  --accent-ink: #8f4222;
  --link: #a2511f;
  --shadow: 0 1px 2px rgba(31, 29, 26, .04), 0 8px 24px rgba(31, 29, 26, .06);
  --shadow-soft: 0 1px 2px rgba(31, 29, 26, .04);

  --maxw: 1080px;
  --maxw-read: 720px;
  --radius: 14px;
  --radius-sm: 9px;
  --space: clamp(1rem, 0.6rem + 1.6vw, 1.5rem);

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", Georgia,
    "Times New Roman", serif;

  --header-h: 64px;
}

/* ---------- 设计令牌（深色） ---------- */
[data-theme="dark"] {
  --bg: #15140f;
  --bg-soft: #1b1a14;
  --surface: #1e1c16;
  --surface-2: #24221b;
  --text: #ece7da;
  --text-soft: #c7c1b2;
  --muted: #9a9384;
  --border: #2c2a22;
  --border-strong: #3a372c;
  --accent: #db8a5d;
  --accent-soft: #36281e;
  --accent-ink: #e8a47b;
  --link: #e09565;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .3);
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color .3s ease, color .3s ease;
}

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

a {
  color: var(--link);
  text-decoration: none;
  transition: color .2s ease;
}
a:hover { color: var(--accent-ink); }

h1, h2, h3, h4 {
  line-height: 1.3;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--space);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; color: #fff; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  margin-right: auto;
}
.brand:hover { color: var(--text); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: var(--shadow-soft);
}
.brand-mark.small { width: 30px; height: 30px; font-size: 1rem; border-radius: 9px; }

.brand-sub { color: var(--muted); font-weight: 500; }

.nav {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.nav a {
  color: var(--text-soft);
  font-weight: 500;
  padding: .45rem .8rem;
  border-radius: 999px;
  font-size: .95rem;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.is-active { color: var(--accent-ink); background: var(--accent-soft); }

.header-actions { display: flex; align-items: center; gap: .35rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 11px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }

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

.nav-toggle { display: none; }

/* 移动导航抽屉 */
.mobile-nav {
  display: none;
  flex-direction: column;
  gap: .2rem;
  padding: .5rem var(--space) 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  color: var(--text-soft);
  font-weight: 500;
  padding: .7rem .6rem;
  border-radius: 10px;
}
.mobile-nav a:hover { background: var(--surface-2); color: var(--text); }
.mobile-nav a.is-active { color: var(--accent-ink); background: var(--accent-soft); }

/* ---------- 主区 ---------- */
main { display: block; }

.section { padding-block: clamp(2.5rem, 1.6rem + 4vw, 4.5rem); }
.section-tight { padding-block: clamp(1.8rem, 1.2rem + 2vw, 2.6rem); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.eyebrow::before {
  content: "";
  width: 22px; height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}
.section-head h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem); margin: 0; }
.section-head .more { font-weight: 600; font-size: .95rem; white-space: nowrap; }

/* ---------- 首页 Hero ---------- */
.hero {
  padding-block: clamp(3rem, 2rem + 6vw, 6rem);
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(60% 120% at 100% 0%, var(--accent-soft) 0%, transparent 55%);
}
.hero-inner { max-width: 760px; }
.hero h1 {
  font-size: clamp(2rem, 1.4rem + 3.4vw, 3.4rem);
  margin: 1rem 0 0;
  letter-spacing: -0.02em;
}
.hero h1 .accent { color: var(--accent); }
.hero p.lead {
  font-size: clamp(1.05rem, 0.98rem + 0.5vw, 1.25rem);
  color: var(--text-soft);
  margin: 1.1rem 0 0;
  max-width: 60ch;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  margin-top: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.3rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }

/* ---------- 文章列表 ---------- */
.post-list { display: grid; gap: .4rem; }

.post-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: .4rem 1.5rem;
  padding: 1.25rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background .2s ease, border-color .2s ease, transform .15s ease;
}
.post-item:hover {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.post-item h3 {
  margin: 0;
  font-size: 1.2rem;
  grid-column: 1;
}
.post-item h3 a { color: var(--text); }
.post-item h3 a:hover { color: var(--accent-ink); }
.post-item .post-date {
  grid-column: 2;
  grid-row: 1;
  color: var(--muted);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.post-item .post-excerpt {
  grid-column: 1 / -1;
  margin: .1rem 0 0;
  color: var(--text-soft);
}
.post-item .post-tags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .6rem;
}

.tag {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .15rem .6rem;
  border-radius: 999px;
}
.tag.accent { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }

/* ---------- 卡片网格（关于页/亮点） ---------- */
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-soft);
}
.card h3 { margin: .2rem 0 .5rem; font-size: 1.1rem; }
.card p { margin: 0; color: var(--text-soft); }
.card .card-ico {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  margin-bottom: .9rem;
}
.card .card-ico svg { width: 21px; height: 21px; }

/* ---------- 关于页 / 个人简介 ---------- */
.profile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.6rem;
  align-items: center;
}
.avatar {
  width: 96px; height: 96px;
  border-radius: 22px;
  background: linear-gradient(150deg, var(--accent), var(--accent-ink));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 2.4rem;
  box-shadow: var(--shadow);
  flex: none;
}
.profile h1 { margin: 0 0 .3rem; font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.2rem); }
.profile .role { color: var(--accent-ink); font-weight: 600; }
.profile .profile-bio { color: var(--text-soft); margin: .6rem 0 0; }

.fact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.fact-list li { display: flex; gap: .7rem; align-items: flex-start; color: var(--text-soft); }
.fact-list .fi {
  flex: none; width: 22px; height: 22px; color: var(--accent-ink);
  margin-top: .2rem;
}
.fact-list .fi svg { width: 18px; height: 18px; }

/* ---------- 文章正文 ---------- */
.article {
  max-width: var(--maxw-read);
  margin-inline: auto;
}
.article-head { margin-bottom: 2rem; }
.article-head h1 {
  font-size: clamp(1.7rem, 1.3rem + 2vw, 2.5rem);
  margin: .8rem 0 .8rem;
  line-height: 1.25;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1rem;
  color: var(--muted);
  font-size: .92rem;
}
.article-meta .dot { color: var(--border-strong); }

.prose { color: var(--text-soft); font-size: 1.05rem; }
.prose > * + * { margin-top: 1.25rem; }
.prose h2 {
  font-size: 1.45rem;
  margin-top: 2.4rem;
  color: var(--text);
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}
.prose h3 { font-size: 1.2rem; margin-top: 1.8rem; color: var(--text); }
.prose p { margin: 0; }
.prose a { font-weight: 500; border-bottom: 1px solid color-mix(in srgb, var(--link) 35%, transparent); }
.prose a:hover { border-bottom-color: var(--accent-ink); }
.prose ul, .prose ol { margin: 0; padding-left: 1.4rem; }
.prose li { margin-top: .5rem; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--text); }
.prose blockquote {
  margin: 0;
  padding: .8rem 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .12em .4em;
  border-radius: 6px;
}
.prose pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  line-height: 1.6;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: .88rem; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }
.prose figure { margin: 0; }
.prose figcaption { color: var(--muted); font-size: .9rem; text-align: center; margin-top: .5rem; }

/* 文末导航 / 返回 */
.post-foot {
  max-width: var(--maxw-read);
  margin: 3rem auto 0;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- 归档页 ---------- */
.archive-year {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--muted);
  margin: 2rem 0 .4rem;
  font-weight: 700;
}
.archive-list { list-style: none; padding: 0; margin: 0; }
.archive-list li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .7rem .3rem;
  border-bottom: 1px solid var(--border);
}
.archive-list li:hover { background: var(--surface); }
.archive-list .a-date {
  color: var(--muted);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  flex: none;
  width: 5.5rem;
}
.archive-list .a-title { color: var(--text); font-weight: 500; }
.archive-list .a-title:hover { color: var(--accent-ink); }

/* ---------- 通用页眉（非首页） ---------- */
.page-head {
  padding-block: clamp(2.4rem, 1.6rem + 3vw, 3.6rem);
  border-bottom: 1px solid var(--border);
  background: radial-gradient(70% 130% at 0% 0%, var(--accent-soft) 0%, transparent 55%);
}
.page-head h1 { font-size: clamp(1.8rem, 1.4rem + 2vw, 2.6rem); margin: .7rem 0 0; }
.page-head p { color: var(--text-soft); margin: .7rem 0 0; max-width: 60ch; }

/* ---------- 页脚（含备案号） ---------- */
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem 2rem;
  justify-content: space-between;
  align-items: flex-start;
  padding-block: 2.4rem;
}
.footer-brand { display: flex; align-items: center; gap: .7rem; }
.footer-name { margin: 0; font-weight: 700; color: var(--text); }
.footer-tag { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; }

.footer-meta { text-align: right; }
.footer-meta p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.9; }
.footer-meta .beian a {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.footer-meta .beian a:hover { color: var(--accent-ink); }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-soft); font-size: .9rem; }

/* ---------- 进入动画（渐进增强：无 JS 时内容始终可见） ---------- */
.reveal { transition: opacity .6s ease, transform .6s ease; }
.js .reveal { opacity: 0; transform: translateY(14px); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .nav { display: none; }
  .nav-toggle { display: grid; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .profile { grid-template-columns: 1fr; text-align: left; }
  .post-item { grid-template-columns: 1fr; }
  .post-item .post-date { grid-column: 1; grid-row: auto; }
  .footer-inner { flex-direction: column; }
  .footer-meta { text-align: left; }
  .archive-list li { flex-direction: column; gap: .2rem; }
  .archive-list .a-date { width: auto; }
}

/* ---------- 降低动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
}
