/* 个人学习笔记储存 —— 全站样式(笔记本纸) */
:root {
  --desk: #F0F1EA;        /* 桌面底色 */
  --sheet: #FAFAF6;       /* 纸页 */
  --ink: #1F3A5C;         /* 蓝黑墨水 */
  --body-ink: #2C3742;    /* 正文墨色 */
  --muted: #66727F;       /* 淡墨 */
  --rule-blue: #D7E0E9;   /* 笔记本横线 */
  --seal-red: #B0432F;    /* 印泥红 */
  --margin-red: rgba(176, 67, 47, .42);
  --serif: Georgia, "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "STZhongsong", "SimSun", serif;
  --kai: "KaiTi", "STKaiti", "楷体", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--desk);
  color: var(--body-ink);
  font-family: var(--serif);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(31, 58, 92, .16); }

a { color: var(--ink); }
a:focus-visible { outline: 2px dashed var(--ink); outline-offset: 3px; }

/* 一整张纸 */
.page {
  position: relative;
  max-width: 46rem;
  margin: clamp(1.5rem, 5vh, 4rem) auto;
  background: var(--sheet);
  border: 1px solid #E2E4DC;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(31, 58, 92, .05), 0 10px 28px rgba(31, 58, 92, .06);
  padding: clamp(1.6rem, 5vw, 3.2rem) clamp(1.1rem, 4.5vw, 3rem) clamp(1.6rem, 4vw, 2.4rem) clamp(1.5rem, 5.5vw, 3.6rem);
}

/* 笔记本左侧的红色页边线,贯穿整页 */
.page::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: clamp(.55rem, 2vw, 1.3rem);
  width: 1.5px;
  background: var(--margin-red);
}

/* ---- 首页页首 ---- */
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.6rem;
  padding-bottom: 1.4rem;
  border-bottom: 2px solid var(--ink);
}

h1 {
  flex: 1 1 auto;
  font-size: clamp(1.7rem, 5.2vw, 2.5rem);
  font-weight: 700;
  letter-spacing: .05em;
  line-height: 1.35;
  color: var(--ink);
}

.intro {
  flex: 1 1 100%;
  font-family: var(--kai);
  font-size: clamp(1.02rem, 2.6vw, 1.15rem);
  color: #3A4654;
  max-width: 36em;
}

/* 「学而时习」藏书印(仅首页) */
.seal {
  flex: none;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(2, 1fr);
  place-items: center;
  width: 5rem;
  height: 5rem;
  padding: .35rem;
  background: var(--seal-red);
  color: var(--sheet);
  font-family: var(--kai);
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1;
  border-radius: 5px;
  transform: rotate(-5deg);
  box-shadow: inset 0 0 0 2px rgba(250, 250, 246, .28);
  user-select: none;
}

@media (prefers-reduced-motion: no-preference) {
  .seal { animation: stamp .3s cubic-bezier(.2, .9, .3, 1.2) .45s both; }
  @keyframes stamp {
    from { opacity: 0; transform: rotate(-5deg) scale(1.7); }
    to   { opacity: 1; transform: rotate(-5deg) scale(1); }
  }
}

@media (max-width: 420px) {
  .seal { width: 4rem; height: 4rem; font-size: 1.2rem; }
}

/* ---- 小节标题(首页) ---- */
h2 {
  margin: 2.6rem 0 .4rem;
  font-family: var(--sans);
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: .5em;
  color: var(--muted);
}

/* ---- 分类 ---- */
.cats ul { list-style: none; }
.cats li {
  display: grid;
  grid-template-columns: 6.5em 1fr;
  gap: .2em 1.2em;
  align-items: baseline;
  padding: .8rem 0;
  border-bottom: 1px solid var(--rule-blue);
}
.cats strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .04em;
}
.cats span { color: var(--muted); font-size: .95rem; }

@media (max-width: 480px) {
  .cats li { grid-template-columns: 1fr; }
}

/* ---- 最近存下的 ---- */
.recent ul { list-style: none; }
.recent li {
  display: grid;
  grid-template-columns: 6.4em 5.4em 1fr;
  gap: .2em 1.2em;
  align-items: baseline;
  padding: .8rem 0;
  border-bottom: 1px solid var(--rule-blue);
}
.recent time {
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.recent em {
  font-style: normal;
  font-family: var(--sans);
  font-size: .82rem;
  color: var(--seal-red);
  letter-spacing: .06em;
}
.recent a.t {
  font-size: 1rem;
  color: var(--body-ink);
  text-decoration: none;
}
.recent a.t:hover {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--seal-red);
  text-underline-offset: 5px;
}

@media (max-width: 560px) {
  .recent li { display: block; padding: .75rem 0; }
  .recent time, .recent em { margin-right: 1.1em; }
  .recent a.t { display: inline-block; margin-top: .15em; }
}

.more {
  margin-top: 1.2rem;
  font-family: var(--kai);
  font-size: .98rem;
  color: var(--muted);
}

/* ---- 页脚 ---- */
footer {
  margin-top: 3rem;
  padding-top: 1.1rem;
  border-top: 2px solid var(--ink);
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .3em 2em;
}
footer a { color: var(--muted); text-decoration-color: rgba(102, 114, 127, .5); }
footer a:hover { color: var(--ink); }

/* ---- 顶部导航 ---- */
.sitenav {
  display: flex;
  justify-content: flex-end;
  gap: 2em;
  margin-bottom: 1.6rem;
  font-family: var(--sans);
  font-size: .88rem;
}
.sitenav a {
  color: var(--muted);
  text-decoration: none;
  letter-spacing: .25em;
  padding-bottom: .15em;
}
.sitenav a:hover { color: var(--ink); }
.sitenav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 2px solid var(--seal-red);
}

.posthead { padding-bottom: 1.2rem; border-bottom: 2px solid var(--ink); }
.posthead h1 {
  flex: none;
  font-size: clamp(1.4rem, 4.2vw, 1.9rem);
  letter-spacing: .02em;
  line-height: 1.5;
  margin-top: .5rem;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: .2em 1.4em;
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--muted);
}
.meta em {
  font-style: normal;
  color: var(--seal-red);
  letter-spacing: .06em;
}

.article-body { margin-top: 1.4rem; }
.article-body h2 {
  margin: 2.1rem 0 .5rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--ink);
}
.article-body p { margin: .9em 0; }
.article-body ul, .article-body ol { margin: .6em 0; padding-left: 1.5em; }
.article-body li { margin: .35em 0; }
.article-body strong { color: var(--ink); }
.article-body code {
  font-family: Consolas, "Courier New", monospace;
  font-size: .92em;
  background: rgba(31, 58, 92, .06);
  padding: .1em .4em;
  border-radius: 3px;
}

/* 红笔批注 */
.note {
  margin: 1.3rem 0;
  padding: .1rem 0 .1rem 1rem;
  border-left: 2px solid var(--seal-red);
  font-family: var(--kai);
  font-size: 1rem;
  color: #6B4438;
}

/* 公式行 */
.formula {
  margin: .8rem 0;
  padding-left: 1.4rem;
  line-height: 2.1;
  font-size: 1.02rem;
  color: var(--ink);
}

.article-body table {
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: .95rem;
}
.article-body th, .article-body td {
  border: 1px solid var(--rule-blue);
  padding: .45em .9em;
  text-align: left;
}
.article-body th {
  font-family: var(--sans);
  font-weight: 500;
  font-size: .86rem;
  color: var(--muted);
  background: rgba(215, 224, 233, .25);
}

/* 上一篇 / 下一篇 */
.postnav {
  margin-top: 2.8rem;
  padding-top: 1.1rem;
  border-top: 2px solid var(--ink);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: .8rem 1.4rem;
}
.postnav .lbl {
  display: block;
  font-family: var(--sans);
  font-size: .75rem;
  letter-spacing: .35em;
  color: var(--muted);
  margin-bottom: .1em;
}
.postnav a { color: var(--ink); text-decoration: none; }
.postnav a:hover {
  text-decoration: underline;
  text-decoration-color: var(--seal-red);
  text-underline-offset: 5px;
}
.postnav .home {
  align-self: center;
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--muted);
}
.postnav .home:hover { color: var(--ink); }
.postnav .next { text-align: right; }

/* ---- 关于页 ---- */
.sig {
  margin-top: 2.2rem;
  font-family: var(--kai);
  font-size: 1.05rem;
  color: #3A4654;
}

/* 落款处的小印 */
.seal.small {
  display: inline-grid;
  width: 3.2rem;
  height: 3.2rem;
  font-size: .95rem;
  vertical-align: -.9rem;
  margin-left: .8em;
}
