/* =========================================================================
   纸境 · Inkwell — 设计系统
   编辑式阅读美学：温暖纸张底 / 墨色字 / 琥珀强调色
   ========================================================================= */

/* ---- 设计 Token ---- */
:root {
  /* 字体 */
  --font-display: "Fraunces", "Songti SC", "STSong", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-read: "Iowan Old Style", "Charter", "Georgia", "Songti SC", "STSong", serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* 明色（默认） */
  --paper: oklch(0.976 0.008 75);
  --paper-2: oklch(0.962 0.01 75);
  --surface: oklch(0.992 0.006 75);
  --ink: oklch(0.27 0.02 60);
  --ink-soft: oklch(0.45 0.02 60);
  --ink-faint: oklch(0.62 0.015 60);
  --line: oklch(0.89 0.012 70);
  --accent: oklch(0.58 0.14 45);
  --accent-soft: oklch(0.93 0.05 55);
  --accent-ink: oklch(0.32 0.1 45);
  --shadow: 0 1px 2px oklch(0.27 0.02 60 / 0.05), 0 8px 24px oklch(0.27 0.02 60 / 0.07);

  /* 尺度 */
  --maxw: 72rem;
  --readw: 42rem;
  --radius: 14px;
  --radius-sm: 9px;
  --gap: clamp(1rem, 3vw, 2rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1); /* ease-out-quart */
  --header-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: oklch(0.17 0.012 65);
    --paper-2: oklch(0.21 0.014 65);
    --surface: oklch(0.235 0.014 65);
    --ink: oklch(0.92 0.01 85);
    --ink-soft: oklch(0.74 0.015 80);
    --ink-faint: oklch(0.58 0.012 80);
    --line: oklch(0.32 0.014 70);
    --accent: oklch(0.74 0.13 60);
    --accent-soft: oklch(0.3 0.06 60);
    --accent-ink: oklch(0.95 0.06 70);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 12px 30px oklch(0 0 0 / 0.35);
  }
}

:root[data-theme="dark"] {
  --paper: oklch(0.17 0.012 65);
  --paper-2: oklch(0.21 0.014 65);
  --surface: oklch(0.235 0.014 65);
  --ink: oklch(0.92 0.01 85);
  --ink-soft: oklch(0.74 0.015 80);
  --ink-faint: oklch(0.58 0.012 80);
  --line: oklch(0.32 0.014 70);
  --accent: oklch(0.74 0.13 60);
  --accent-soft: oklch(0.3 0.06 60);
  --accent-ink: oklch(0.95 0.06 70);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 12px 30px oklch(0 0 0 / 0.35);
}

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  font-size: clamp(15px, 0.6vw + 14px, 17px);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }

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

.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---- 布局容器 ---- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(1.1rem, 4vw, 2.5rem); }

/* =========================================================================
   顶部 Header
   ========================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-family: var(--font-display); }
.brand-mark { color: var(--accent); font-size: 1.4rem; line-height: 1; transform: translateY(1px); }
.brand-name { font-weight: 600; font-size: 1.25rem; letter-spacing: 0.01em; }
.brand-sub { color: var(--ink-faint); font-weight: 400; font-size: 0.95rem; margin-left: 0.15rem; }

.site-nav { display: flex; align-items: center; gap: clamp(0.5rem, 2vw, 1.5rem); }
.nav-link {
  position: relative;
  padding: 0.4rem 0.2rem;
  color: var(--ink-soft);
  font-weight: 500;
  transition: color 0.2s var(--ease);
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease);
}
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--ink); }
.nav-link:hover::after, .nav-link[aria-current="page"]::after { transform: scaleX(1); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--ink); }
.theme-toggle-icon {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent) 0 45%, transparent 46%);
  box-shadow: inset -4px -4px 0 0 var(--accent);
  transition: box-shadow 0.3s var(--ease), background 0.3s var(--ease);
}
:root[data-theme="dark"] .theme-toggle-icon { background: var(--accent); box-shadow: none; }

/* 汉堡菜单（移动端） */
.menu-btn {
  display: none;
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.menu-btn span { width: 18px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.25s var(--ease), opacity 0.2s var(--ease); }
.site-header[data-menu="open"] .menu-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header[data-menu="open"] .menu-btn span:nth-child(2) { opacity: 0; }
.site-header[data-menu="open"] .menu-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* =========================================================================
   视图容器 / 通用
   ========================================================================= */
.view { flex: 1 0 auto; outline: none; }
.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.section-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.15; margin-top: 0.4rem; }
.lede { color: var(--ink-soft); max-width: 52ch; margin-top: 0.8rem; font-size: 1.02rem; }

/* ---- 标签 chips ---- */
.tag-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.82rem;
  transition: all 0.2s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
.chip[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.chip .count { color: var(--ink-faint); font-size: 0.75rem; }
.chip[aria-current="true"] .count { color: color-mix(in oklab, var(--paper) 75%, transparent); }

/* =========================================================================
   首页 — Hero + 精选 + 列表
   ========================================================================= */
.hero { padding-block: clamp(2.5rem, 7vw, 5rem) clamp(1.5rem, 4vw, 3rem); }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  max-width: 18ch;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero .lede { margin-top: 1.2rem; font-size: 1.1rem; }

/* 精选文章 */
.featured { margin-top: clamp(2rem, 5vw, 3.5rem); }
.featured a {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(1.2rem, 4vw, 3rem);
  align-items: center;
  padding: clamp(1.4rem, 3vw, 2.2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
.featured a:hover { transform: translateY(-4px); box-shadow: 0 14px 40px oklch(0.27 0.02 60 / 0.12); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); }
.featured .thumb {
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  background:
    radial-gradient(120% 120% at 20% 10%, var(--accent-soft), transparent 60%),
    linear-gradient(135deg, color-mix(in oklab, var(--accent) 25%, var(--paper-2)), var(--paper-2));
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 3rem; color: var(--accent);
  overflow: hidden;
}
.featured .thumb span { opacity: 0.85; }
.featured h2 { font-family: var(--font-display); font-size: clamp(1.5rem, 3.5vw, 2.1rem); line-height: 1.15; font-weight: 600; }
.featured p { color: var(--ink-soft); margin-top: 0.7rem; }
.featured .meta { margin-top: 1rem; }

/* 列表 */
.post-list { display: grid; gap: 0.4rem; margin-top: 2rem; }
.post-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: clamp(0.8rem, 2vw, 1.6rem);
  align-items: baseline;
  padding: clamp(1.1rem, 2.5vw, 1.6rem) 0.4rem;
  border-top: 1px solid var(--line);
  transition: padding-left 0.25s var(--ease), background 0.25s var(--ease);
  border-radius: var(--radius-sm);
}
.post-item:last-child { border-bottom: 1px solid var(--line); }
.post-item:hover { padding-left: 1rem; background: color-mix(in oklab, var(--paper-2) 60%, transparent); }
.post-item .date { font-variant-numeric: tabular-nums; color: var(--ink-faint); font-size: 0.85rem; white-space: nowrap; }
.post-item .body h3 { font-family: var(--font-display); font-size: clamp(1.15rem, 2.5vw, 1.45rem); font-weight: 600; line-height: 1.25; transition: color 0.2s var(--ease); }
.post-item:hover .body h3 { color: var(--accent); }
.post-item .body p { color: var(--ink-soft); margin-top: 0.35rem; font-size: 0.95rem; }
.post-item .tags { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.post-item .tags .t { font-size: 0.72rem; color: var(--ink-faint); border: 1px solid var(--line); padding: 0.12rem 0.5rem; border-radius: 999px; }

/* 空状态 */
.empty { text-align: center; padding: 4rem 1rem; color: var(--ink-soft); }
.empty .mark { font-family: var(--font-display); font-size: 3rem; color: var(--accent); }

/* =========================================================================
   文章详情
   ========================================================================= */
.article-head { padding-block: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 3vw, 2rem); }
.article-head .back {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 1.2rem;
  transition: color 0.2s var(--ease), gap 0.2s var(--ease);
}
.article-head .back:hover { color: var(--accent); gap: 0.6rem; }
.article-head h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  max-width: 22ch;
}
.article-head .meta { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; margin-top: 1.2rem; color: var(--ink-soft); font-size: 0.9rem; }
.article-head .meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-faint); }
.article-head .tag-row { margin-top: 1rem; }

/* 正文排版 */
.prose { max-width: var(--readw); margin-inline: auto; }
.prose > * + * { margin-top: 1.25em; }
.prose h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.2; margin-top: 2em; }
.prose h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; margin-top: 1.6em; }
.prose p { font-family: var(--font-read); font-size: 1.12rem; line-height: 1.85; color: color-mix(in oklab, var(--ink) 92%, transparent); }
.prose > p:first-of-type::first-letter {
  font-family: var(--font-display);
  float: left;
  font-size: 3.6em;
  line-height: 0.78;
  padding: 0.05em 0.12em 0 0;
  color: var(--accent);
  font-weight: 600;
}
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-left: 1.4em; font-family: var(--font-read); font-size: 1.08rem; line-height: 1.8; }
.prose li + li { margin-top: 0.4em; }
.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.2em 0 0.2em 1.2em;
  margin-inline: 0;
  font-family: var(--font-read);
  font-style: italic;
  font-size: 1.18rem;
  color: var(--ink-soft);
}
.prose blockquote cite { display: block; margin-top: 0.6rem; font-size: 0.9rem; font-style: normal; color: var(--ink-faint); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 0.12em 0.4em;
  border-radius: 6px;
}
.prose pre {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.7;
}
.prose pre code { background: none; border: none; padding: 0; font-size: 0.9rem; color: var(--ink); }
.prose hr { border: none; border-top: 1px solid var(--line); margin-block: 2.5em; }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* 文末 */
.article-foot { max-width: var(--readw); margin: 3rem auto 0; padding-top: 2rem; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.article-foot .next { color: var(--ink-soft); }
.article-foot .next a { color: var(--accent); font-weight: 500; }

/* 阅读进度条 */
.reading-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; background: transparent; opacity: 0; transition: opacity 0.3s var(--ease); }
.reading-progress.is-active { opacity: 1; }
.reading-progress span { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.1s linear; }

/* =========================================================================
   关于页
   ========================================================================= */
.about-wrap { max-width: var(--readw); margin-inline: auto; }
.about-wrap h1 { font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3rem); font-weight: 600; line-height: 1.1; }
.about-wrap .prose { margin-top: 1.5rem; }
.about-links { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 2rem; }
.about-links a { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); transition: all 0.2s var(--ease); }
.about-links a:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-2px); }

/* =========================================================================
   回到顶部
   ========================================================================= */
.to-top {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  bottom: clamp(1rem, 3vw, 2rem);
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.2rem;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px) scale(0.9);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 45;
}
.to-top.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.to-top:hover { background: var(--accent); }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { flex-shrink: 0; border-top: 1px solid var(--line); padding-block: 2.5rem; margin-top: 2rem; }
.footer-inner { max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(1.1rem, 4vw, 2.5rem); text-align: center; color: var(--ink-faint); font-size: 0.85rem; }
.footer-copy { font-family: var(--font-display); }
.footer-note { margin-top: 0.3rem; }

/* =========================================================================
   视图过渡（View Transitions）
   ========================================================================= */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: vt-out 0.22s var(--ease) both; }
  ::view-transition-new(root) { animation: vt-in 0.32s var(--ease) both; }
}
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

.view-fade { animation: fade-up 0.4s var(--ease) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   响应式
   ========================================================================= */
@media (max-width: 760px) {
  .menu-btn { display: flex; }
  .site-nav {
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 0.5rem clamp(1.1rem, 4vw, 2.5rem) 1rem;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
  }
  .site-header[data-menu="open"] .site-nav { transform: none; opacity: 1; pointer-events: auto; }
  .nav-link { padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
  .nav-link::after { display: none; }
  .theme-toggle { justify-content: center; margin-top: 0.7rem; padding: 0.7rem; }

  .featured a { grid-template-columns: 1fr; }
  .featured .thumb { order: -1; aspect-ratio: 16/9; }
  .post-item { grid-template-columns: 1fr; gap: 0.3rem; }
  .post-item .date { order: -1; }
  .post-item .tags { justify-content: flex-start; margin-top: 0.4rem; }
  .prose p { font-size: 1.06rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .prose > p:first-of-type::first-letter { float: none; font-size: inherit; color: inherit; padding: 0; }
}
