/* 拾数笔记：暖纸与墨
   单栏 680px，衬线标题 + 无衬线正文 + 等宽点缀；全局一层极淡噪点做纸张颗粒。 */

:root {
  --bg: #faf8f5;          /* 宣纸白 */
  --ink: #1c1917;         /* 深炭黑 */
  --muted: #57534e;       /* 暖中灰：次要描述 */
  --faint: #a8a29e;       /* 浅暖灰：序号、年份 */
  --line: rgba(28, 25, 23, .08);
  --hover: rgba(28, 25, 23, .03);
  --dash: rgba(28, 25, 23, .12);
  --tag-bg: rgba(28, 25, 23, .045);
  --nav-idle: #78716c;
  --accent: #b45309;     /* 琥珀：只用在 logo 花心和光标 */
  --focus: #2563eb;
  --noise-o: .025;

  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --font-sans: Inter, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111110;
  --ink: #edebe8;
  --muted: #a8a29e;
  --faint: #6b6560;
  --line: rgba(237, 235, 232, .08);
  --hover: rgba(237, 235, 232, .04);
  --dash: rgba(237, 235, 232, .14);
  --tag-bg: rgba(237, 235, 232, .06);
  --nav-idle: #8a847e;
  --accent: #f59e0b;
  --focus: #93c5fd;
  --noise-o: .04;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 纸张颗粒 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: var(--noise-o);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--ink); color: var(--bg); }

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

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 导航 ---------- */

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 4rem;
  margin-bottom: 5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.brand-mark { width: 20px; height: 20px; flex: none; }
.brand-mark rect { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.brand-mark .core { fill: var(--accent); stroke: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 14px;
}
.nav-links a {
  position: relative;
  font-weight: 400;
  color: var(--nav-idle);
  transition: color .2s var(--ease);
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--ink); }
/* 激活态：文字下方一个 3px 圆点 */
.nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: 50%;
  background: currentColor;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: -4px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.theme-toggle:hover { color: var(--ink); background: var(--hover); }
.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

main:focus { outline: none; }

/* ---------- Hero 与页标题 ---------- */

.hero-title,
.page-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--ink);
}
.hero-title { font-size: 2.1rem; }
.lede {
  margin: 1.25rem 0 4rem;
  max-width: 52ch;
  font-size: .95rem;
  line-height: 1.75;
  color: var(--muted);
}

/* ---------- 栏目 ---------- */

.section + .section { margin-top: 4.5rem; }

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 .75rem;
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 400;
  letter-spacing: .08em;
  color: var(--muted);
}
.section-label span { display: inline-flex; align-items: center; gap: 8px; }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .68rem;
  letter-spacing: 0;
  color: var(--faint);
}
.section-label a {
  color: var(--faint);
  transition: color .2s var(--ease);
}
.section-label a:hover { color: var(--ink); }

/* ---------- 作品列表：聚光灯悬停 ---------- */

.proj-list {
  list-style: none;
  margin: 0 -12px;
  padding: 0;
}

.proj {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  gap: 0 .75rem;
  align-items: baseline;
  padding: 1.1rem 12px;
  border-radius: 10px;
  transition: all .25s var(--ease);
}
.proj-list li + li .proj { box-shadow: 0 -1px 0 var(--line); }

@media (hover: hover) {
  .proj-list:hover .proj { opacity: .45; }
  .proj-list .proj:hover {
    opacity: 1;
    padding-left: 16px;
    background: var(--hover);
    box-shadow: none;
  }
  .proj-list .proj:hover + * .proj,
  .proj-list li:hover + li .proj { box-shadow: none; }
}

.num {
  font-family: var(--font-mono);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

.proj-title {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.005em;
}
.arrow {
  width: 11px;
  height: 11px;
  flex: none;
  align-self: center;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .35;
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.proj:hover .arrow { opacity: 1; transform: translate(2px, -2px); }

.proj-desc {
  display: block;
  margin-top: .3rem;
  font-size: .9rem;
  line-height: 1.65;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: .65rem;
}
.tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 18px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- 随笔列表 ---------- */

.note-list {
  list-style: none;
  margin: 0 -12px;
  padding: 0;
}
.note-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0 .75rem;
  align-items: baseline;
  padding: .85rem 12px;
  border-radius: 10px;
  transition: all .25s var(--ease);
}
.note-list li + li .note-row { box-shadow: 0 -1px 0 var(--line); }
@media (hover: hover) {
  .note-list:hover .note-row { opacity: .45; }
  .note-list .note-row:hover { opacity: 1; background: var(--hover); padding-left: 16px; box-shadow: none; }
}
.note-title { font-weight: 500; }
.note-sum { display: block; margin-top: .2rem; font-size: .88rem; color: var(--muted); }

/* ---------- 空状态 ---------- */

.empty {
  padding: 1.6rem 1.4rem;
  border: 1px dashed var(--dash);
  border-radius: 12px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: .9rem;
  color: var(--faint);
}
.cursor {
  display: inline-block;
  margin-left: 2px;
  font-family: var(--font-mono);
  font-style: normal;
  color: var(--accent);
  animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 随笔正文 ---------- */

.post-meta {
  margin: 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--faint);
}
.post-meta .tag { color: var(--muted); }
.post .page-title { margin-bottom: 2.5rem; }

.prose { font-size: 1rem; line-height: 1.85; color: var(--ink); }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.2em; }
.prose h2, .prose h3 {
  margin: 2.2em 0 .7em;
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.4;
}
.prose h2 { font-size: 1.3rem; }
.prose h3 { font-size: 1.1rem; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose a {
  text-decoration: underline;
  text-decoration-color: var(--dash);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color .2s var(--ease);
}
.prose a:hover { text-decoration-color: currentColor; }
.prose blockquote {
  margin: 1.6em 0;
  padding: 0 0 0 1.1em;
  border-left: 2px solid var(--line);
  font-family: var(--font-serif);
  color: var(--muted);
}
.prose blockquote p { margin: 0; }
.prose code {
  font-family: var(--font-mono);
  font-size: .86em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--hover);
  border: 1px solid var(--line);
}
.prose pre {
  margin: 0 0 1.4em;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--hover);
  font-size: .85rem;
  line-height: 1.65;
}
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: .9rem;
}
.post-nav a { color: var(--muted); transition: color .2s var(--ease); }
.post-nav a:hover { color: var(--ink); }
.post-nav small {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .06em;
  color: var(--faint);
}
.post-nav .next { text-align: right; }

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

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.link-list li + li { box-shadow: 0 -1px 0 var(--line); }
.link-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .85rem 0;
  transition: color .2s var(--ease);
}
.link-list a span:last-child {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--faint);
}
.link-list a:hover { color: var(--muted); }

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

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 7rem;
  padding: 1.5rem 0 3rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--faint);
}
.site-footer a { transition: color .2s var(--ease); }
.site-footer a:hover { color: var(--ink); }

/* ---------- 入场：内容轻轻浮现 ---------- */

@media (prefers-reduced-motion: no-preference) {
  main > * { animation: rise .6s var(--ease) both; }
  main > *:nth-child(2) { animation-delay: .06s; }
  main > *:nth-child(3) { animation-delay: .12s; }
  main > *:nth-child(4) { animation-delay: .18s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .cursor { animation: none; }
}

/* ---------- 窄屏 ---------- */

@media (max-width: 560px) {
  .page { padding: 0 20px; }
  .nav { padding-top: 2.25rem; margin-bottom: 3.5rem; }
  .nav-links { gap: 14px; font-size: 13.5px; }
  .hero-title { font-size: 1.75rem; }
  .lede { margin-bottom: 3rem; }
  .proj { grid-template-columns: 1.9rem minmax(0, 1fr) auto; }
  .note-row { grid-template-columns: 1fr; }
  .note-row .num { margin-bottom: 2px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { text-align: left; }
  .site-footer { margin-top: 5rem; }
}
@media (max-width: 380px) {
  .brand span { display: none; }
}
