/* ==========================================================================
   森林 · 笔记 —— 站点样式
   零依赖，纯手写。改配色只要动 :root 里的变量。
   ========================================================================== */

:root {
  --bg: #fdfdfc;
  --bg-soft: #f6f6f3;
  --text: #1b1b19;
  --text-soft: #5f5f59;
  --text-faint: #93938c;
  --line: #e6e5df;
  --line-strong: #d5d4cc;
  --accent: #1f6f5c;
  --accent-soft: #e9f3f0;
  --code-bg: #f4f4f0;
  --mark-bg: #fdf3d7;
  --radius: 10px;
  --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #15171a;
  --bg-soft: #1c1f23;
  --text: #e9e9e4;
  --text-soft: #a6a6a0;
  --text-faint: #74746e;
  --line: #2a2d31;
  --line-strong: #3a3e43;
  --accent: #6fbfa5;
  --accent-soft: #1d2b28;
  --code-bg: #1c1f23;
  --mark-bg: #3a3320;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  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%;
  display: block;
  border-radius: 6px;
}

/* ---------- 顶部导航 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

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

.nav a {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-soft);
  transition: color 0.15s ease, background-color 0.15s ease;
}

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

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-soft);
  padding: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- 主区域 ---------- */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 96px;
}

.hero {
  padding: 68px 0 52px;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: 30px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero h1 .wave {
  display: inline-block;
  transform-origin: 70% 70%;
  animation: wave 2.4s ease-in-out 1;
}

@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-8deg); }
  45% { transform: rotate(6deg); }
}

.hero p {
  margin: 0;
  max-width: 52ch;
  color: var(--text-soft);
  font-size: 15.5px;
}

.hero .meta {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-soft);
}

/* ---------- 区块标题 ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------- 标签筛选 ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 16px 0 6px;
}

.filter {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .filter.active {
  color: #10201c;
}

/* ---------- 文章列表 ---------- */

.post-item {
  display: block;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  animation: rise 0.4s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.post-item .row {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.post-item time {
  flex: none;
  width: 74px;
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
}

.post-item h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.005em;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1.5px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s ease, color 0.15s ease;
  display: inline;
}

.post-item:hover h3 {
  color: var(--accent);
  background-size: 100% 1.5px;
}

.post-item .summary {
  margin: 6px 0 0 88px;
  font-size: 14.5px;
  color: var(--text-soft);
  line-height: 1.7;
}

.post-item .tags {
  margin: 9px 0 0 88px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.post-item .tags span {
  font-size: 12px;
  color: var(--text-faint);
}

.post-item .tags span::before {
  content: "#";
  opacity: 0.55;
}

.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}

/* ---------- 关于 ---------- */

.about {
  margin-top: 72px;
  padding: 28px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.about h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.about p {
  margin: 0 0 10px;
  font-size: 14.5px;
  color: var(--text-soft);
  line-height: 1.75;
}

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

.about a {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- 页脚 ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 24px 40px;
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-faint);
}

/* 页脚链接（回首页、备案号）默认与正文同色，悬停才提亮 */
.footer-inner a:hover {
  color: var(--text);
}

/* ---------- 404 页 ---------- */

.not-found {
  padding: 76px 0 32px;
}

.not-found .code {
  display: block;
  font-family: var(--mono);
  font-size: 62px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--accent);
  margin-bottom: 24px;
}

.not-found h1 {
  margin: 0 0 12px;
  font-size: 23px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.not-found p {
  margin: 0 0 10px;
  max-width: 46ch;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.8;
}

/* 把用户实际访问的路径显示出来，方便他自己判断是不是打错了 */
.not-found .path {
  display: inline-block;
  margin-top: 6px;
  max-width: 100%;
  padding: 3px 9px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-faint);
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  word-break: break-all;
}

.not-found .links {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.not-found .links a {
  padding: 7px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--text);
  transition: color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.not-found .links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* 主按钮：底色用 accent，文字用 bg —— 深浅两个主题下都自动有对比度 */
.not-found .links a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.not-found .links a.primary:hover {
  opacity: 0.86;
  color: var(--bg);
}

/* ---------- 文章页 ---------- */

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

.post-header .back {
  font-size: 13.5px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 24px;
  transition: color 0.15s ease;
}

.post-header .back:hover {
  color: var(--accent);
}

.post-header h1 {
  margin: 0 0 14px;
  font-size: 28px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-faint);
}

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

.post-body {
  padding: 36px 0 24px;
  font-size: 16px;
  line-height: 1.85;
}

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

.post-body h2 {
  margin: 2.2em 0 0.7em;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

.post-body h3 {
  margin: 1.9em 0 0.6em;
  font-size: 17px;
  font-weight: 600;
}

.post-body p {
  margin: 0 0 1.15em;
}

.post-body a {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.post-body a:hover {
  border-bottom-color: var(--accent);
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.15em;
  padding-left: 1.35em;
}

.post-body li {
  margin: 0.35em 0;
}

.post-body li::marker {
  color: var(--text-faint);
}

.post-body blockquote {
  margin: 1.4em 0;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--accent);
  color: var(--text-soft);
  font-size: 15px;
}

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

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

.post-body code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

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

.post-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 13.5px;
}

.post-body pre .lang {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.post-body img {
  margin: 1.4em 0;
  border: 1px solid var(--line);
}

.post-body strong {
  font-weight: 600;
}

.post-body mark {
  background: var(--mark-bg);
  padding: 0 2px;
  border-radius: 2px;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.4em;
  font-size: 14.5px;
}

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

.post-body th {
  background: var(--bg-soft);
  font-weight: 600;
}

/* 文末上下篇 */

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 28px 0 8px;
  border-top: 1px solid var(--line);
}

.post-nav a {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.post-nav a:hover {
  border-color: var(--line-strong);
  background: var(--bg-soft);
}

.post-nav .label {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 3px;
  letter-spacing: 0.04em;
}

.post-nav .title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

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

.post-nav .placeholder {
  visibility: hidden;
}

/* ---------- 响应式 ---------- */

@media (max-width: 560px) {
  .hero {
    padding: 44px 0 36px;
  }
  .hero h1 {
    font-size: 25px;
  }
  .post-item .row {
    display: block;
  }
  .post-item time {
    width: auto;
    display: block;
    margin-bottom: 5px;
  }
  .post-item .summary,
  .post-item .tags {
    margin-left: 0;
  }
  .post-header h1 {
    font-size: 23px;
  }
  .post-nav {
    grid-template-columns: 1fr;
  }
  .about {
    padding: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
