/* ───────────────────────────────────────────────────────────
   博客样式 · 编辑式精致极简
   字体：标题 Fraunces / 正文 Newsreader
   配色变量在 :root 与 [data-theme="dark"] 里，想改颜色改这里
   ─────────────────────────────────────────────────────────── */

:root {
  --bg: #fcfaf4;          /* 暖纸白 */
  --bg-soft: #f3eee2;
  --fg: #221d16;          /* 暖墨黑 */
  --fg-soft: #7a7060;     /* 次要文字 */
  --line: #e7dfce;        /* 分隔线 */
  --accent: #a8432b;      /* 赭红 */
  --accent-2: #c25e44;
  --code-bg: #f1ece0;
  --shadow: 0 18px 40px -24px rgba(60, 40, 15, 0.35);
  --measure: 40rem;       /* 正文阅读宽度 */
  --frame: 44rem;         /* 页面框宽度 */
  --text: 1.125rem;       /* 正文字号（≈18px）。觉得大就调小，觉得小就调大 */
}

[data-theme="dark"] {
  --bg: #14130e;
  --bg-soft: #1d1b14;
  --fg: #ece5d6;
  --fg-soft: #9a9080;
  --line: #2c2920;
  --accent: #e0795f;
  --accent-2: #eb8d75;
  --code-bg: #211e16;
  --shadow: 0 18px 44px -24px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Newsreader", "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  font-size: var(--text);
  line-height: 1.75;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s ease, color 0.4s ease;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

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

/* ── 顶栏 ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px max(24px, (100% - var(--frame)) / 2);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

/* ── 搜索 ────────────────────────────────────────────────── */
.search { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute; left: 12px; color: var(--fg-soft); pointer-events: none;
}
.search input {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 8px 14px 8px 34px;
  width: clamp(150px, 34vw, 230px);
  transition: width 0.25s ease, border-color 0.2s, background 0.2s;
}
.search input::placeholder { color: var(--fg-soft); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  width: clamp(180px, 42vw, 300px);
}
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(440px, 86vw);
  max-height: 64vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 30;
}
.search-results.show { display: block; }
.search-results .r-item {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--fg);
}
.search-results .r-item:last-child { border-bottom: none; }
.search-results .r-item:hover,
.search-results .r-item.active { background: var(--bg-soft); }
.search-results .r-title {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.3;
}
.search-results .r-excerpt {
  display: block;
  margin-top: 3px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--fg-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-results mark { background: color-mix(in srgb, var(--accent) 24%, transparent); color: inherit; border-radius: 2px; }
.search-results .r-empty { padding: 16px; color: var(--fg-soft); font-size: 0.9rem; }

.wordmark {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--fg);
}
.wordmark:hover { color: var(--accent); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg-soft);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(15deg); }
.theme-toggle svg { display: block; }
[data-theme="light"] .i-moon,
[data-theme="dark"] .i-sun { display: none; }

/* ── 主体框 ─────────────────────────────────────────────── */
main {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── 首页 ───────────────────────────────────────────────── */
.intro {
  padding: 72px 0 40px;
  border-bottom: 1px solid var(--line);
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.intro-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.6rem, 7vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
}
.intro-tagline {
  margin: 18px 0 0;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--fg-soft);
  max-width: 32rem;
}

.archive { padding: 56px 0 40px; }
.year-group {
  padding: 28px 0;
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(0.12s + var(--gi, 0) * 0.07s);
}
.year-label {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 400;
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  color: var(--fg-soft);
  margin: 0 0 6px;
}

.post-list { list-style: none; margin: 0; padding: 0; }
.post-item { border-bottom: 1px solid var(--line); }
.post-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 16px 0;
  color: var(--fg);
  transition: padding-left 0.25s ease;
}
.post-link:hover { padding-left: 10px; color: var(--fg); }
.post-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.3;
  transition: color 0.2s;
}
.post-link:hover .post-name { color: var(--accent); }
.post-link .post-date {
  flex-shrink: 0;
  font-size: 0.92rem;
  color: var(--fg-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.empty { color: var(--fg-soft); padding: 40px 0; font-style: italic; }

/* ── 文章页 ─────────────────────────────────────────────── */
.post {
  max-width: var(--measure);
  margin: 0 auto;
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.post-header {
  padding: 64px 0 36px;
  text-align: center;
}
.post-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2rem, 5.5vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.018em;
  margin: 0 0 14px;
}
.post-meta {
  font-size: 0.95rem;
  color: var(--fg-soft);
  letter-spacing: 0.04em;
}

.post-body { font-size: var(--text); }
.post-body > p:first-of-type {
  font-size: 1.24rem;
  line-height: 1.62;
  color: var(--fg);
}
.post-body p { margin: 1.35em 0; }
.post-body h2, .post-body h3 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 2em 0 0.6em;
}
.post-body h2 { font-size: 1.7rem; }
.post-body h3 { font-size: 1.35rem; }
.post-body em { font-style: italic; }
.post-body strong { font-weight: 600; }
.post-body a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.post-body a:hover { text-decoration-color: var(--accent); }

.post-body ul, .post-body ol { padding-left: 1.4em; margin: 1.2em 0; }
.post-body li { margin: 0.3em 0; }

.post-body blockquote {
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.3em;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--fg-soft);
}
.post-body blockquote p { margin: 0.4em 0; }

/* 图片 / 视频：带阴影、可超出阅读宽度一点，更舒展 */
figure { margin: 2.4em 0; text-align: center; }
.post-body img,
.post-body video {
  max-width: min(100%, 52rem);
  width: auto;
  max-height: 80vh;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.post-body img { cursor: zoom-in; transition: opacity 0.2s; }
.post-body img:hover { opacity: 0.92; }
figcaption {
  margin-top: 0.7em;
  font-size: 0.92rem;
  font-style: italic;
  color: var(--fg-soft);
}

/* 图片放大灯箱 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 12, 8, 0.9);
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.2s ease;
  touch-action: none;
  overflow: hidden;
}
.lightbox.show { opacity: 1; }
.lightbox img {
  max-width: 94vw;
  max-height: 92vh;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.post-body pre {
  background: var(--code-bg);
  padding: 18px 20px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 1.6em 0;
  font-size: 0.95rem;
  line-height: 1.6;
}
.post-body code {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
}
.post-body pre code { background: none; padding: 0; font-size: 1em; }

.post-body hr {
  border: none;
  margin: 2.8em auto;
  width: 40%;
  text-align: center;
  color: var(--fg-soft);
}
.post-body hr::before {
  content: "·  ·  ·";
  letter-spacing: 0.5em;
  font-size: 1.1rem;
}

.post-foot {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 1rem;
}

/* ── 页脚 ───────────────────────────────────────────────── */
.site-footer {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 48px 24px;
  text-align: center;
  color: var(--fg-soft);
  font-size: 0.9rem;
}

/* ── 入场动效 ───────────────────────────────────────────── */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}

/* ── 小屏 ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  body { font-size: 1.0625rem; }
  .post-body { font-size: 1.0625rem; }
  .post-body > p:first-of-type { font-size: 1.16rem; }
  .post-link { gap: 10px; }
  .post-name { font-size: 1.25rem; }
  .post-link .post-date { font-size: 0.82rem; }
  .intro { padding: 48px 0 32px; }
}
