/* ==========================================================
   云间书店 · 编程语言的故事 —— 网站样式
   主题：书卷气 / 暖纸色 / 墨绿 / 砖红
   ========================================================== */

:root {
  --paper: #f6f1e7;          /* 暖纸底色 */
  --paper-deep: #ede4d2;     /* 深一档纸色 */
  --ink: #2c2a26;            /* 墨色正文 */
  --ink-soft: #57534a;       /* 次级文字 */
  --ink-faint: #8a8375;      /* 弱文字 */
  --green: #2f5d4e;          /* 墨绿主色 */
  --green-deep: #234639;     /* 深墨绿 */
  --green-pale: #e2ebe3;     /* 浅绿底 */
  --brick: #b0562e;          /* 砖红点缀 */
  --brick-pale: #f5e6dc;     /* 浅砖红底 */
  --gold: #c9a24b;           /* 金棕 */
  --code-bg: #2b2f36;        /* 代码块深底 */
  --code-ink: #e8e6df;       /* 代码块文字 */
  --line: #d9cfba;           /* 分隔线 */
  --shadow: 0 2px 14px rgba(60, 50, 30, 0.10);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(201,162,75,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(47,93,78,0.06), transparent 55%),
    var(--paper);
  line-height: 1.85;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold); color: #fff; }

a { color: var(--green); text-decoration: none; transition: color .2s; }
a:hover { color: var(--brick); }

img { max-width: 100%; }

/* ============ 顶部导航 ============ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(246, 241, 231, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 980px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 700; }
.brand .brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green); color: #f6f1e7;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 15px; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: var(--ink-faint); letter-spacing: 2px; }

.site-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.site-nav a {
  padding: 6px 12px; border-radius: 999px; font-size: 13.5px;
  color: var(--ink-soft); border: 1px solid transparent;
}
.site-nav a:hover { color: var(--brick); background: var(--brick-pale); }
.site-nav a.current { color: #fff; background: var(--green); border-color: var(--green); }

/* ============ 通用容器 ============ */
.container { max-width: 980px; margin: 0 auto; padding: 0 24px; }
.wide { max-width: 1080px; }

/* ============ 首页 Hero ============ */
.hero {
  text-align: center; padding: 84px 24px 56px;
  position: relative;
}
.hero .kicker {
  display: inline-block; font-size: 13px; letter-spacing: 5px; color: var(--brick);
  border: 1px solid var(--brick); border-radius: 999px; padding: 6px 18px; margin-bottom: 26px;
  text-transform: uppercase;
}
.hero h1 {
  font-family: var(--serif); font-size: clamp(34px, 6vw, 56px); font-weight: 800;
  letter-spacing: 2px; color: var(--green-deep); line-height: 1.25;
}
.hero h1 em { font-style: normal; color: var(--brick); }
.hero .subtitle {
  margin-top: 18px; font-size: clamp(15px, 2.4vw, 18px); color: var(--ink-soft);
  max-width: 640px; margin-left: auto; margin-right: auto;
}
.hero .motto {
  margin-top: 34px; font-family: var(--serif); font-size: 16px; color: var(--ink-faint);
}
.hero .motto b { color: var(--green); }

.hero-rule {
  max-width: 200px; height: 3px; margin: 0 auto; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ============ 章节总览卡片 ============ */
.section-title {
  font-family: var(--serif); font-size: 26px; color: var(--green-deep);
  display: flex; align-items: center; gap: 14px; margin: 64px 0 26px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-title .no {
  font-size: 13px; color: var(--brick); border: 1px solid var(--brick);
  border-radius: 6px; padding: 3px 9px; letter-spacing: 2px;
}

.chapter-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px;
}

.chapter-card {
  position: relative; display: block;
  background: #fffdf8; border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 22px 18px; box-shadow: var(--shadow);
  transition: transform .25s, box-shadow .25s, border-color .25s;
  overflow: hidden;
}
.chapter-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--green), var(--gold));
  opacity: 0; transition: opacity .25s;
}
.chapter-card:hover { transform: translateY(-5px); box-shadow: 0 10px 26px rgba(60,50,30,.16); border-color: var(--gold); }
.chapter-card:hover::before { opacity: 1; }

.chapter-card .card-no {
  font-family: var(--serif); font-size: 13px; color: var(--brick); letter-spacing: 2px; margin-bottom: 6px;
}
.chapter-card .card-title {
  font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--green-deep);
  margin-bottom: 8px; line-height: 1.4;
}
.chapter-card .card-desc { font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; }
.chapter-card .card-layer {
  margin-top: 12px; display: inline-block; font-size: 11.5px; color: var(--green);
  background: var(--green-pale); padding: 3px 10px; border-radius: 999px; letter-spacing: .5px;
}

/* ============ 家族树 ============ */
.tree-wrap {
  background: #fffdf8; border: 1px solid var(--line); border-radius: 16px;
  padding: 30px 26px; box-shadow: var(--shadow);
}
.tree { display: flex; flex-direction: column; align-items: center; gap: 0; }
.tree .tree-root {
  background: var(--green-deep); color: #f2ead8; font-family: var(--serif);
  font-weight: 700; font-size: 17px; letter-spacing: 1px;
  padding: 10px 26px; border-radius: 999px; box-shadow: var(--shadow);
}
.tree .tree-line-v { width: 2px; height: 22px; background: var(--gold); }
.tree .tree-level {
  width: 100%; display: flex; align-items: stretch; gap: 0;
  background: #fffdf8; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 10px; overflow: hidden; transition: box-shadow .2s, transform .2s;
}
.tree .tree-level:hover { box-shadow: var(--shadow); transform: translateX(3px); }
.tree .tree-badge {
  flex: none; width: 150px; display: flex; flex-direction: column; justify-content: center;
  background: var(--green); color: #f6f1e7; padding: 12px 16px;
  font-family: var(--serif); font-weight: 700; font-size: 14.5px; letter-spacing: .5px; line-height: 1.5;
}
.tree .tree-badge small { font-family: var(--sans); font-weight: 400; font-size: 11px; opacity: .85; margin-top: 3px; }
.tree .tree-concepts {
  flex: 1; display: flex; flex-wrap: wrap; align-content: center; gap: 8px; padding: 12px 16px;
}
.tree .chip {
  font-size: 12.5px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
  transition: background .2s, border-color .2s;
}
.tree .chip:hover { background: var(--brick-pale); border-color: var(--brick); color: var(--brick); }
.tree .chip .sc { color: var(--ink-faint); margin-left: 4px; font-size: 11px; }

@media (max-width: 640px) {
  .tree .tree-level { flex-direction: column; }
  .tree .tree-badge { width: 100%; }
}

/* ============ 对照表 ============ */
.mapping-table { width: 100%; border-collapse: collapse; background: #fffdf8; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.mapping-table th, .mapping-table td { padding: 13px 16px; text-align: left; vertical-align: top; }
.mapping-table thead th {
  background: var(--green); color: #f6f1e7; font-family: var(--serif); font-size: 14.5px; letter-spacing: 1px;
}
.mapping-table tbody tr { border-bottom: 1px solid var(--line); }
.mapping-table tbody tr:last-child { border-bottom: none; }
.mapping-table tbody tr:nth-child(even) { background: #faf6ec; }
.mapping-table tbody tr:hover { background: var(--green-pale); }
.mapping-table td:first-child { font-weight: 600; color: var(--brick); white-space: nowrap; }
.mapping-table code { font-size: 12.5px; }

/* ============ 章节页 ============ */
.chapter-hero {
  padding: 56px 24px 34px; text-align: center;
  border-bottom: 1px dashed var(--line);
}
.chapter-hero .ch-no {
  font-size: 13px; letter-spacing: 4px; color: var(--brick);
  border: 1px solid var(--brick); display: inline-block; padding: 4px 16px; border-radius: 999px; margin-bottom: 18px;
}
.chapter-hero h1 {
  font-family: var(--serif); font-size: clamp(26px, 4.5vw, 40px); font-weight: 800;
  color: var(--green-deep); letter-spacing: 1px; line-height: 1.35;
}
.chapter-hero .ch-meta {
  margin-top: 16px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.chapter-hero .ch-meta .pill {
  font-size: 12px; padding: 5px 14px; border-radius: 999px;
}
.pill-layer { background: var(--green-pale); color: var(--green-deep); }
.pill-story { background: var(--brick-pale); color: var(--brick); }

/* 章节正文 */
.chapter-body { padding: 40px 0 30px; }
.article { max-width: 860px; margin: 0 auto; }

.article h2 {
  font-family: var(--serif); font-size: 24px; color: var(--green-deep);
  margin: 46px 0 16px; padding-left: 14px; border-left: 4px solid var(--gold);
  line-height: 1.4;
}
.article h3 {
  font-family: var(--serif); font-size: 19px; color: var(--ink);
  margin: 34px 0 12px; line-height: 1.4;
}
.article h4 { font-size: 16px; color: var(--ink); margin: 26px 0 10px; }

.article p { margin: 14px 0; color: var(--ink); }
.article strong { color: var(--green-deep); font-weight: 700; }
.article em { color: var(--brick); font-style: normal; }

.article ul, .article ol { margin: 14px 0 14px 26px; }
.article li { margin: 7px 0; }
.article li::marker { color: var(--brick); }

.article blockquote {
  margin: 20px 0; padding: 16px 20px;
  background: #fffdf8; border-left: 4px solid var(--gold);
  border-radius: 0 10px 10px 0; color: var(--ink-soft);
  font-size: 15px;
}
.article blockquote p { margin: 6px 0; }
.article blockquote strong { color: var(--brick); }

.article hr { border: none; height: 1px; background: var(--line); margin: 40px 0; position: relative; }
.article hr::after {
  content: "❦"; position: absolute; left: 50%; top: -11px; transform: translateX(-50%);
  background: var(--paper); padding: 0 14px; color: var(--gold); font-size: 16px;
}

/* 行内代码 */
.article code:not(pre code) {
  font-family: var(--mono); font-size: 13.5px; color: var(--brick);
  background: var(--brick-pale); padding: 2px 7px; border-radius: 5px;
}

/* 代码块 */
.article pre {
  background: var(--code-bg); color: var(--code-ink);
  border-radius: 12px; padding: 18px 20px; margin: 20px 0;
  overflow-x: auto; box-shadow: inset 0 1px 0 rgba(255,255,255,.06), var(--shadow);
  position: relative;
  line-height: 1.7;
}
.article pre code {
  font-family: var(--mono); font-size: 13.5px; color: var(--code-ink);
  background: none; padding: 0; border-radius: 0;
}
.article pre::before {
  content: attr(data-lang); position: absolute; top: 0; right: 0;
  font-size: 11px; letter-spacing: 1.5px; color: rgba(232,230,223,.55);
  background: rgba(255,255,255,.08); padding: 5px 14px;
  border-radius: 0 12px 0 10px; font-family: var(--mono);
}

/* 表格（正文内） */
.article table {
  width: 100%; border-collapse: collapse; margin: 20px 0;
  background: #fffdf8; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
  font-size: 14px;
}
.article table th { background: var(--green); color: #f6f1e7; padding: 10px 14px; font-weight: 600; text-align: left; }
.article table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.article table tr:last-child td { border-bottom: none; }
.article table tr:nth-child(even) td { background: #faf6ec; }

/* ============ 章节导航（前后章） ============ */
.chapter-nav {
  max-width: 860px; margin: 34px auto 60px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.chapter-nav a {
  display: block; background: #fffdf8; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; box-shadow: var(--shadow); transition: transform .2s, border-color .2s;
}
.chapter-nav a:hover { transform: translateY(-3px); border-color: var(--gold); }
.chapter-nav a.next { text-align: right; }
.chapter-nav .nav-label { font-size: 11.5px; color: var(--ink-faint); letter-spacing: 2px; }
.chapter-nav .nav-title { font-family: var(--serif); font-weight: 700; color: var(--green-deep); font-size: 15px; margin-top: 3px; }

/* ============ 页脚 ============ */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 70px;
  background: var(--paper-deep);
}
.footer-inner {
  max-width: 980px; margin: 0 auto; padding: 34px 24px 40px; text-align: center;
}
.footer-inner .footer-brand { font-family: var(--serif); font-weight: 700; color: var(--green-deep); font-size: 17px; letter-spacing: 1px; }
.footer-inner p { font-size: 12.5px; color: var(--ink-faint); margin-top: 8px; }
.footer-inner .footer-motto { font-family: var(--serif); color: var(--brick); font-size: 14px; margin-top: 14px; }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .header-inner { flex-direction: column; gap: 10px; padding: 12px 16px; }
  .site-nav { justify-content: center; }
  .chapter-nav { grid-template-columns: 1fr; }
  .mapping-table { display: block; overflow-x: auto; white-space: nowrap; }
  .chapter-grid { grid-template-columns: 1fr; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* 平滑进入动画 */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .7s ease both; }
