/* ==========================================================================
   Matplotlib 数据可视化作品集 —— 清手绘笔记风样式表
   使用说明：
   1. 想换整体配色，只改下方 :root 和 .ch-N 里的变量；
   2. 想换某个章节的主题色，只改对应的 .ch-N；
   3. 所有卡片都使用 .sketch 类，圆角故意做成不规则形状，模拟手绘线条。
   ========================================================================== */

:root {
  --paper:        #faf7f0;   /* 纸张底色 */
  --paper-card:   #fffdf8;   /* 卡片底色 */
  --ink:          #3d4b45;   /* 主文字色 */
  --ink-soft:     #76847b;   /* 次要文字色 */
  --line:         #d8d4c7;   /* 分割线颜色 */
  --accent:       #8fb39b;   /* 默认强调色 */
  --shadow:       rgba(61, 75, 69, 0.13);
  --font-hand:    "Kaiti SC", "STKaiti", "楷体", "KaiTi", "Comic Sans MS", cursive;
  --font-body:    "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", sans-serif;
}

/* 八个章节的柔和主题色：改这里即可一键换色 */
.ch-2 { --accent: #8fb39b; }
.ch-3 { --accent: #e6a08f; }
.ch-4 { --accent: #93b7c9; }
.ch-5 { --accent: #e6cb8e; }
.ch-6 { --accent: #b6a8cf; }
.ch-7 { --accent: #9fc8b4; }
.ch-8 { --accent: #eab59a; }
.ch-9 { --accent: #a5c3dc; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.85;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(110, 130, 118, 0.17) 1px, transparent 1px);
  background-size: 22px 22px;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--font-hand); line-height: 1.35; margin: 0; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.wrap { width: min(1100px, 92%); margin: 0 auto; }

/* 手绘感边框：不规则圆角 + 轻微偏移阴影 */
.sketch {
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 255px 14px 225px 16px / 16px 225px 14px 255px;
  box-shadow: 4px 5px 0 var(--shadow);
}

/* ---------- 顶部导航 ---------- */
.site-head {
  border-bottom: 2px dashed var(--line);
  margin-bottom: 34px;
}
.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-hand);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.brand svg { color: var(--accent); flex: none; }
.back-home {
  font-size: .9rem;
  color: var(--ink-soft);
  border-bottom: 1px dashed var(--ink-soft);
  padding-bottom: 2px;
  transition: color .2s;
}
.back-home:hover { color: var(--ink); }

/* ---------- 标题与波浪下划线 ---------- */
.section-title {
  display: inline-block;
  font-size: 1.7rem;
  margin: 0 0 22px;
  position: relative;
}
.section-title small {
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 10px;
  letter-spacing: 1px;
}
.section-title::after {
  content: "";
  position: absolute;
  left: 2px;
  bottom: -8px;
  width: 78px;
  height: 6px;
  background: var(--accent);
  border-radius: 60% 40% 55% 45% / 50% 55% 45% 50%;
  transform: rotate(-1.5deg);
  opacity: .85;
}

/* ---------- 首页大标题区 ---------- */
.hero { padding: 46px 48px 42px; text-align: center; margin-bottom: 54px; }
.hero-kicker {
  display: inline-block;
  font-size: .78rem;
  letter-spacing: 3px;
  color: var(--ink-soft);
  border: 1px dashed var(--accent);
  border-radius: 20px 8px 20px 8px;
  padding: 3px 14px;
  margin-bottom: 20px;
}
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.2rem); letter-spacing: 1px; }
.hero h1 span { color: var(--accent); }
.hero .lead { margin: 18px auto 0; max-width: 680px; color: var(--ink-soft); }
.hero-tip { margin-top: 22px; font-size: .85rem; color: var(--ink-soft); }
.hero-tip::before { content: "✎ "; color: var(--accent); }

/* ---------- 首页章节卡片 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
  gap: 26px;
  margin-bottom: 60px;
}
.chapter-card {
  display: flex;
  flex-direction: column;
  padding: 26px 26px 22px;
  min-height: 272px;
  transition: transform .25s ease, box-shadow .25s ease;
}
.chapter-card:nth-child(even) {
  border-radius: 14px 255px 16px 225px / 225px 16px 255px 14px;
}
.chapter-card:hover {
  transform: translateY(-6px) rotate(-.8deg);
  box-shadow: 8px 10px 0 var(--shadow);
}
.chapter-no {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 48% 52% 55% 45% / 52% 45% 55% 48%;
  font-family: var(--font-hand);
  font-size: 1.35rem;
  font-weight: 700;
}
.card-kicker {
  font-size: .7rem;
  letter-spacing: 2px;
  color: var(--ink-soft);
}
.chapter-card h3 { font-size: 1.35rem; margin: 6px 0 10px; }
.chapter-card > p { font-size: .92rem; color: var(--ink-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; padding-top: 14px; }
.tags span {
  font-size: .74rem;
  padding: 1px 9px;
  border: 1px dashed var(--accent);
  border-radius: 14px 5px 14px 5px;
  color: var(--ink-soft);
}
.card-more {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: .86rem;
  color: var(--ink);
}
.card-more b { color: var(--accent); font-size: 1.1rem; margin-left: 5px; }

/* ---------- 章节页标题区 ---------- */
.chapter-hero { padding: 36px 42px; margin-bottom: 18px; }
.chapter-hero-top { display: flex; align-items: center; gap: 26px; }
.big-no {
  flex: none;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 47% 53% 45% 55% / 54% 46% 55% 45%;
  font-family: var(--font-hand);
  font-size: 2.5rem;
  font-weight: 700;
}
.chapter-hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); margin: 4px 0 8px; }
.chapter-hero .lead { color: var(--ink-soft); margin: 0; }
.chapter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 48px;
}
.chapter-pills a {
  font-size: .82rem;
  padding: 3px 13px;
  border: 1px dashed var(--line);
  border-radius: 16px 6px 16px 6px;
  color: var(--ink-soft);
  transition: .2s;
}
.chapter-pills a:hover { border-color: var(--ink); color: var(--ink); }
.chapter-pills a.current {
  background: var(--accent);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-weight: 700;
}

/* ---------- 内容区块 ---------- */
.block { margin-bottom: 54px; }
.note { padding: 28px 34px; color: var(--ink); }
.note p { text-indent: 2em; }
.point-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 20px;
}
.point-list li {
  position: relative;
  padding: 10px 0 10px 30px;
  border-bottom: 1px dashed var(--line);
  color: var(--ink);
}
.point-list li:last-child { border-bottom: 0; }
.point-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 10px;
  color: var(--accent);
  font-family: var(--font-hand);
  font-weight: 700;
}
.point-list code {
  font-family: Consolas, "Courier New", monospace;
  font-size: .88em;
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink);
}

/* ---------- 图表作品 ---------- */
.figure-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px; }
.figure-card { margin: 0; padding: 22px 22px 24px; }
.figure-card figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-hand);
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.fig-tag {
  font-family: var(--font-body);
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--ink);
  background: var(--accent);
  border-radius: 12px 4px 12px 4px;
  padding: 2px 9px;
}
.img-frame {
  position: relative;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 12px 4px 14px 5px / 5px 14px 4px 12px;
  background: #fff;
  overflow: hidden;
}
.img-frame img { width: 100%; height: auto; }
.img-fallback {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  color: var(--ink-soft);
  background: repeating-linear-gradient(45deg, #fffdf8, #fffdf8 12px, #f7f4ec 12px, #f7f4ec 24px);
  border: 2px dashed var(--accent);
  border-radius: 12px 4px 14px 5px / 5px 14px 4px 12px;
}
.img-fallback strong {
  display: block;
  font-family: var(--font-hand);
  font-size: 1.35rem;
  color: var(--ink);
  margin-bottom: 6px;
}
.img-fallback code {
  font-family: Consolas, "Courier New", monospace;
  font-size: .95rem;
  color: var(--ink);
  background: #fff;
  border: 1px dashed var(--accent);
  border-radius: 5px;
  padding: 2px 8px;
}
.figure-desc {
  margin: 14px 2px 0;
  font-size: .88rem;
  color: var(--ink-soft);
}

/* ---------- 学习体会 ---------- */
.reflection {
  padding: 30px 38px 30px 66px;
  position: relative;
}
.quote-mark {
  position: absolute;
  left: 22px;
  top: 8px;
  font-family: var(--font-hand);
  font-size: 4rem;
  line-height: 1;
  color: var(--accent);
  opacity: .65;
}
.reflection p { text-indent: 0; }

/* ---------- 章节间跳转 ---------- */
.page-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 20px 0 42px;
  border-top: 2px dashed var(--line);
  margin-top: 10px;
}
.foot-link {
  font-size: .9rem;
  padding: 7px 16px;
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 200px 12px 190px 14px / 14px 190px 12px 200px;
  box-shadow: 2px 3px 0 var(--shadow);
  transition: transform .2s;
}
.foot-link:hover { transform: translateY(-2px); }
.foot-link.center { border-style: dashed; box-shadow: none; }
.foot-link.right { text-align: right; }

.site-foot {
  padding: 22px 0 36px;
  text-align: center;
  font-size: .8rem;
  color: var(--ink-soft);
  border-top: 1px dashed var(--line);
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .hero { padding: 34px 22px; }
  .chapter-hero { padding: 26px 22px; }
  .chapter-hero-top { flex-direction: column; align-items: flex-start; }
  .big-no { width: 72px; height: 72px; font-size: 2rem; }
  .figure-grid { grid-template-columns: 1fr; }
  .note, .point-list, .reflection { padding-left: 22px; padding-right: 22px; }
  .reflection { padding-left: 52px; }
  .quote-mark { left: 14px; }
  .page-foot { justify-content: center; }
}
