/*!
 * styles.css — Folio
 * 纸感编辑风 + 渐变刊头 + 卡片列表
 */

:root {
  --bg: #f7f4ee;
  --card: #fffdf9;
  --ink: #1b1916;
  --ink-soft: #2a2621;
  --muted: #726b60;
  --faint: #a49b8d;
  --rule: #e4ded3;
  --line: #e8e0d4;
  --accent: #9a5b3a;
  --accent-soft: #f3e9e2;
  --wrap: 1040px;
  --read: 720px;

  --serif: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", SimSun, Georgia, serif;
  --sans: "Noto Sans SC", "Noto Sans CJK SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font: 17px/1.85 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(900px 500px at 88% -12%, #fdf1e6 0%, transparent 62%),
    var(--bg);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }

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

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 32px;
}

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

.top { border-bottom: 1px solid var(--rule); }

.top .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 74px;
}

.brand {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: .24em;
  text-transform: uppercase;
  padding-right: .24em;
}

.nav {
  display: flex;
  gap: 28px;
  font-size: 13.5px;
  letter-spacing: .08em;
  color: var(--muted);
}

.nav a { position: relative; padding: 6px 0; transition: color .2s; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); }
.nav a.on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
}

/* ---------------- 渐变刊头 ---------------- */

.hero { padding: 42px 0 10px; }

.banner {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 54px 48px 42px;
  color: #fff8f1;
  background: linear-gradient(135deg, #b4532f 0%, #9a5b3a 46%, #74432e 100%);
  box-shadow: 0 30px 60px -32px rgba(122, 64, 38, .55);
}

.banner::before {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  right: -90px;
  top: -130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 216, 182, .18), transparent 70%);
  pointer-events: none;
}

.banner::after {
  content: "F";
  position: absolute;
  right: 26px;
  bottom: -62px;
  font: 700 230px/1 var(--serif);
  color: rgba(255, 248, 241, .07);
  pointer-events: none;
}

.banner > * { position: relative; z-index: 1; }

.kicker {
  margin: 0 0 20px;
  font: 11.5px/1.6 var(--mono);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: rgba(255, 248, 241, .62);
}

.banner h1 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(30px, 4.6vw, 42px);
  line-height: 1.38;
  letter-spacing: .02em;
  white-space: pre-line;
}

.banner .lead {
  margin: 0;
  max-width: 46ch;
  color: rgba(255, 248, 241, .82);
  font-size: 16px;
  line-height: 1.9;
}

.search {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 440px;
  margin-top: 32px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 248, 241, .32);
  transition: border-color .25s;
}

.search:focus-within { border-color: rgba(255, 248, 241, .78); }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font: 15px var(--sans);
  color: #fff8f1;
  padding: 2px 0;
}

.search input::placeholder { color: rgba(255, 248, 241, .5); }

.search .hint {
  font: 11px var(--mono);
  letter-spacing: .08em;
  color: rgba(255, 248, 241, .45);
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 38px;
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 248, 241, .2);
}

.stats b {
  display: block;
  font: 600 22px/1.4 var(--serif);
  letter-spacing: .02em;
}

.stats span { font-size: 12.5px; color: rgba(255, 248, 241, .64); }

/* ---------------- 标签 ---------------- */

.tags-row {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 34px 0 6px;
  flex-wrap: wrap;
}

.tags-row .label {
  font: 11.5px/1.6 var(--mono);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--faint);
}

.chips { display: flex; gap: 9px; flex-wrap: wrap; }

.chip {
  font: 12.5px/1.4 var(--sans);
  letter-spacing: .04em;
  padding: 5px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}

.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------------- 列表区 ---------------- */

.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 38px 0 18px;
}

.section-head h2 {
  margin: 0;
  font: 600 12px var(--sans);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.section-head .rule { flex: 1; height: 1px; background: var(--rule); }

.section-head .count {
  font: 12px var(--mono);
  letter-spacing: .06em;
  color: var(--faint);
  white-space: nowrap;
}

.posts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  align-items: stretch;
}

.post {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 26px 22px;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .04), 0 12px 32px -20px rgba(60, 40, 20, .18);
  transition: transform .25s, box-shadow .25s, border-color .25s;
}

.post:hover {
  transform: translateY(-3px);
  border-color: #d9c8b2;
  box-shadow: 0 2px 4px rgba(60, 40, 20, .04), 0 24px 44px -24px rgba(154, 91, 58, .4);
}

.post .meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
  flex-wrap: wrap;
}

.post time {
  font: 12px var(--mono);
  letter-spacing: .06em;
  color: var(--faint);
}

.post h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.5;
  letter-spacing: .01em;
}

.post h3 a { transition: color .2s; }
.post:hover h3 a { color: var(--accent); }

.post .excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
  max-width: 62ch;
}

.tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 3px;
  transition: background .2s, color .2s;
}

.tag:hover { background: var(--accent); color: #fff8f1; }

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

.loading {
  grid-column: 1 / -1;
  margin: 40px 0;
  color: var(--faint);
  font-size: 14px;
  letter-spacing: .04em;
}

.state {
  grid-column: 1 / -1;
  padding: 44px 0 52px;
  text-align: center;
}

.state-title {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
}

.state-detail { margin: 0 0 6px; color: var(--muted); font-size: 14.5px; }
.state-detail a { color: var(--accent); border-bottom: 1px solid rgba(154, 91, 58, .35); }
.state-hint { margin: 0; color: var(--faint); font-size: 13px; }
.state-hint a { color: var(--accent); }
.state-hint code {
  font: 12.5px var(--mono);
  background: #efe9df;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ---------------- 文章页布局（左侧大纲） ---------------- */

.article-shell { min-height: 60vh; }
.article-shell.wrap { max-width: 1280px; }

.article-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 720px) 180px;
  gap: 48px;
  justify-content: center;
  align-items: start;
}

.article-layout .article {
  max-width: none;
  margin: 0;
  padding: 52px 0 10px;
}

.article-layout > .toc { grid-column: 1; }
.article-layout > .article-main { grid-column: 2; min-width: 0; }
.article-layout > .article-side { grid-column: 3; }

.article-side { min-height: 1px; }

/* 左侧浮动大纲 */
.toc {
  position: sticky;
  top: 40px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 56px 0 24px;
  font-size: 13px;
  line-height: 1.7;
  scrollbar-width: thin;
}

.toc-title {
  margin: 0 0 12px;
  font: 11px var(--mono);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--faint);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--rule);
}

.toc-item a {
  display: block;
  padding: 4px 0 4px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted);
  transition: color .2s, border-color .2s;
}

.toc-item a:hover { color: var(--ink); }
.toc-item a.on { color: var(--accent); border-left-color: var(--accent); }
.toc-sub a { padding-left: 28px; font-size: 12.5px; }

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

.article {
  max-width: var(--read);
  margin: 0 auto;
  padding: 52px 0 10px;
}

.back {
  display: inline-block;
  margin-bottom: 28px;
  font: 13px var(--mono);
  letter-spacing: .06em;
  color: var(--faint);
  transition: color .2s;
}

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

.article-head { padding-bottom: 26px; border-bottom: 1px solid var(--rule); margin-bottom: 34px; }

.article-head .meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.article-head time {
  font: 12.5px var(--mono);
  letter-spacing: .05em;
  color: var(--faint);
}

.article-head .dot { color: var(--faint); }

.article-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(30px, 4.2vw, 40px);
  line-height: 1.42;
  letter-spacing: .01em;
}

.article-lead {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16.5px;
  line-height: 1.85;
}

.content {
  font-size: 17px;
  line-height: 1.95;
  color: var(--ink-soft);
}

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

.content p { margin: 0 0 20px; }

.content h2 {
  margin: 46px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 25px;
  line-height: 1.5;
  color: var(--ink);
}

.content h3 {
  margin: 34px 0 12px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.55;
  color: var(--ink);
}

.content h4 { margin: 28px 0 10px; font-size: 17px; color: var(--ink); }

.content a {
  color: var(--accent);
  border-bottom: 1px solid rgba(154, 91, 58, .35);
  transition: border-color .2s;
}

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

.content ul,
.content ol { margin: 0 0 20px; padding-left: 1.5em; }

.content li { margin: 6px 0; }
.content li > ul,
.content li > ol { margin: 6px 0; }

.content blockquote {
  margin: 28px 0;
  padding: 4px 0 4px 24px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-family: var(--serif);
  font-size: 17px;
}

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

.content code {
  font: 14px var(--mono);
  background: #efe9df;
  padding: 2px 6px;
  border-radius: 4px;
  color: #6b4a34;
}

.content pre {
  margin: 0 0 24px;
  padding: 18px 20px;
  background: #f1ece2;
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow-x: auto;
  line-height: 1.7;
}

.content pre code {
  font-size: 13.5px;
  background: none;
  padding: 0;
  color: #3d332b;
}

.content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 28px 0;
  border-radius: 10px;
  border: 1px solid var(--rule);
}

.content hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 38px 0;
}

.content table {
  width: 100%;
  margin: 0 0 24px;
  border-collapse: collapse;
  font-size: 15px;
}

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

.content th { background: #f1ece2; font-weight: 600; }

.content strong { font-weight: 600; color: var(--ink); }

/* KaTeX 数学公式 */
.content .katex { font-size: 1.06em; }

.content .katex-display {
  margin: 26px 0;
  padding: 4px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.content .katex-display > .katex { white-space: normal; }

/* Mermaid 图 */
.content .mermaid {
  margin: 28px 0;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow-x: auto;
  text-align: center;
}

.content .mermaid svg { max-width: 100%; height: auto; }

/* 大纲点击定位时留一点上边距 */
.content h2,
.content h3 { scroll-margin-top: 28px; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 14.5px;
}

.post-nav a { color: var(--muted); transition: color .2s; }
.post-nav a:hover { color: var(--accent); }
.post-nav .next { text-align: right; margin-left: auto; }

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

.article .content > h1:first-child {
  margin-bottom: 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(28px, 3.6vw, 36px);
  line-height: 1.45;
  color: var(--ink);
}

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

footer {
  margin-top: 64px;
  border-top: 1px solid var(--rule);
  padding: 34px 0 60px;
  text-align: center;
}

.foot-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--muted);
}

.foot-links a:hover { color: var(--ink); }
.foot-links .dot { color: var(--faint); }

.icp {
  margin: 20px 0 0;
  font: 12px/2 var(--mono);
  letter-spacing: .02em;
  color: var(--muted);
}

.icp a {
  color: var(--muted);
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
}

.icp a:hover { color: var(--ink); border-bottom-color: var(--rule); }

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

@media (max-width: 1200px) {
  .article-shell.wrap { max-width: 1040px; }
  .article-layout { grid-template-columns: minmax(0, 720px); }
  .article-layout > .toc,
  .article-layout > .article-main,
  .article-layout > .article-side { grid-column: auto; }
  .article-side { display: none; }
  .toc { display: none; }
}

@media (max-width: 880px) {
  .posts { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  .nav { gap: 18px; font-size: 13px; }
  .banner { padding: 40px 26px 34px; border-radius: 18px; }
  .banner::after { font-size: 150px; bottom: -40px; }
  .banner h1 { font-size: clamp(26px, 8vw, 34px); }
  .stats { gap: 26px; }
  .stats b { font-size: 19px; }
  .search .hint { display: none; }
  .post { padding: 20px 20px 18px; }
  .article { padding-top: 36px; }
  .post-nav { flex-direction: column; gap: 12px; }
  .post-nav .next { text-align: left; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: .01ms !important; }
}
