/* ============================================================
   个人博客 · 全站样式
   深浅两套配色，跟随系统偏好，可用右上角按钮手动切换
   ============================================================ */

* {
  box-sizing: border-box;
  margin: 0;
}

/* ---------- 浅色（默认） ---------- */
:root {
  color-scheme: light;
  --bg: #fbfaf8;
  --text: #26231f;
  --text-2: #55504a;
  --muted: #8d877d;
  --accent: #33628f;
  --border: #e8e4dd;
  --code-bg: #f0ede7;
}

/* ---------- 深色 ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191817;
  --text: #e9e6e1;
  --text-2: #b6b1a9;
  --muted: #8d877d;
  --accent: #7fa8cf;
  --border: #2e2c29;
  --code-bg: #232220;
}

/* 未开启 JS 时跟随系统 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #191817;
    --text: #e9e6e1;
    --text-2: #b6b1a9;
    --muted: #8d877d;
    --accent: #7fa8cf;
    --border: #2e2c29;
    --code-bg: #232220;
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main {
  flex: 1;
}

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

a {
  color: var(--accent);
}

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

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

/* ---------- 顶部导航 ---------- */
.site-header {
  padding: 26px 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
}

.theme-toggle {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* 亮色显示月亮（点击去暗色），深色显示太阳 */
.theme-toggle .icon-sun {
  display: none;
}

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

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
}

/* ---------- 首页 ---------- */
.intro {
  padding: 44px 0 4px;
}

.intro p {
  font-size: 1.05rem;
  color: var(--text-2);
  max-width: 36em;
}

.list-title {
  margin-top: 48px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

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

.post-item:last-child {
  border-bottom: none;
}

.post-item h2 {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
}

.post-item h2 a {
  color: var(--text);
  text-decoration: none;
}

.post-item h2 a:hover {
  color: var(--accent);
}

.post-meta {
  margin: 6px 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.post-excerpt {
  font-size: 0.95rem;
  color: var(--text-2);
}

/* ---------- 文章页 ---------- */
.post-header {
  padding: 48px 0 0;
}

.post-header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.45;
}

.post-header .post-meta {
  margin: 10px 0 0;
}

.prose {
  padding: 28px 0 0;
}

.prose p {
  margin: 0 0 1.2em;
}

.prose h2 {
  font-size: 1.3rem;
  margin: 2em 0 0.7em;
}

.prose h3 {
  font-size: 1.08rem;
  margin: 1.7em 0 0.6em;
}

.prose a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

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

.prose code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}

.prose pre {
  margin: 1.4em 0;
  padding: 16px 18px;
  background: var(--code-bg);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.6;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: 0.88em;
}

.prose ul,
.prose ol {
  margin: 0 0 1.2em;
  padding-left: 1.5em;
}

.prose li {
  margin: 0.3em 0;
}

.prose img {
  max-width: 100%;
  border-radius: 8px;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

.prose table {
  width: 100%;
  margin: 1.4em 0;
  border-collapse: collapse;
  font-size: 0.93em;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.prose th {
  background: var(--code-bg);
  font-weight: 600;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 52px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}

.post-nav a {
  color: var(--muted);
  text-decoration: none;
}

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

.post-nav .next {
  margin-left: auto;
  text-align: right;
}

/* ---------- 404 ---------- */
.notfound {
  padding: 80px 0;
  text-align: center;
}

.notfound h1 {
  font-size: 3rem;
  letter-spacing: 0.05em;
}

.notfound p {
  margin-top: 12px;
  color: var(--muted);
}

.notfound a {
  display: inline-block;
  margin-top: 20px;
}

/* ---------- 页脚（备案号在这里） ---------- */
.site-footer {
  margin-top: 72px;
  padding: 26px 0 34px;
  border-top: 1px solid var(--border);
}

.site-footer p {
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.site-footer .beian {
  margin-top: 6px;
}

.site-footer .divider {
  margin: 0 8px;
  opacity: 0.5;
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .site-header {
    padding: 20px 0;
  }

  .site-nav {
    gap: 14px;
  }

  .intro {
    padding-top: 32px;
  }

  .post-header {
    padding-top: 36px;
  }

  .post-header h1 {
    font-size: 1.4rem;
  }
}
