/* ============================================================
   自由能原理读书站 · 全站样式
   视觉方向：预测之流 · 靛紫 × 烧橙 × 斜线流纹
   ============================================================ */

:root {
  --paper: #f7f6f2;
  --paper-deep: #eeece5;
  --ink: #201f24;
  --muted: #6b6871;
  --accent: #4a3d8f;        /* 靛紫（自上而下的预测） */
  --accent-deep: #362c6b;
  --accent-wash: #eae7f4;
  --red: #b45536;           /* 烧橙（自下而上的误差） */
  --line: #ddd9cf;
  --serif: "Songti SC", "Noto Serif SC", "STSong", serif;
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --latin: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.85;
  font-size: 16px;
}

/* ---------- 导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247, 246, 242, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--ink);
}
.nav-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 28px; height: 58px;
}
.nav-brand {
  font-family: var(--latin);
  font-size: 13px; letter-spacing: 0.22em;
  color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap;
}
.nav-brand .mk { color: var(--red); }
.nav-links { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.nav-links a {
  font-size: 14px; color: var(--muted); text-decoration: none;
  padding: 6px 12px; border-radius: 2px; white-space: nowrap;
}
.nav-links a:hover { color: var(--accent-deep); background: var(--accent-wash); }
.nav-links a.active { color: #fff; background: var(--accent); }

/* ---------- 版面骨架 ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.prose { max-width: 760px; }
section { padding: 72px 0; }
section + section { border-top: 1px solid var(--line); }

.eyebrow {
  font-family: var(--latin);
  font-size: 12px; letter-spacing: 0.3em;
  color: var(--accent); text-transform: uppercase; margin-bottom: 14px;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 900; line-height: 1.3; }
h1 { font-size: clamp(34px, 5.5vw, 56px); letter-spacing: 0.02em; }
h2 { font-size: clamp(26px, 3.6vw, 36px); margin-bottom: 20px; }
h3 { font-size: 20px; margin: 28px 0 10px; }
p { margin: 14px 0; }
.lede { font-size: 18px; color: var(--muted); max-width: 680px; }
strong { color: var(--accent-deep); }
em { font-style: normal; border-bottom: 2px solid var(--red); }
a.text-link { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }
code { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 0.92em; background: var(--paper-deep); padding: 1px 6px; border-radius: 3px; }

blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-wash);
  padding: 18px 24px; margin: 22px 0;
  font-family: var(--serif); font-size: 17px;
}
blockquote cite {
  display: block; font-family: var(--latin);
  font-size: 12px; letter-spacing: 0.12em;
  color: var(--muted); margin-top: 8px; font-style: normal;
}

.inscription {
  text-align: center; font-family: var(--latin);
  font-size: 13px; letter-spacing: 0.45em;
  color: var(--red); text-transform: uppercase; margin: 8px 0 0;
}

/* ---------- 图框（斜线流纹底） ---------- */
.figure {
  border: 1.5px solid var(--ink);
  background:
    repeating-linear-gradient(135deg, rgba(74, 61, 143, 0.06) 0 1px, transparent 1px 20px),
    #fdfcf9;
  padding: 28px 24px 18px; margin: 28px 0;
}
.figure svg { display: block; width: 100%; height: auto; }
.figcap {
  font-family: var(--latin); font-size: 12px; color: var(--muted);
  letter-spacing: 0.06em; margin-top: 14px;
  border-top: 1px solid var(--line); padding-top: 10px;
}
.figcap b { color: var(--accent); font-weight: 700; }

/* ---------- 卡片 ---------- */
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.card {
  border: 1.5px solid var(--ink);
  background: #fdfcf9;
  padding: 24px; position: relative;
  box-shadow: 4px 4px 0 var(--accent-wash);
}
.card h3 { margin-top: 0; }
.card .tag {
  display: inline-block; font-family: var(--latin);
  font-size: 11px; letter-spacing: 0.16em;
  color: #fff; background: var(--accent);
  padding: 2px 9px; margin-bottom: 12px; text-transform: uppercase;
}
.card .tag.red { background: var(--red); }
.card p { font-size: 15px; color: #454251; }
a.card { display: block; text-decoration: none; color: inherit; transition: transform 0.15s ease, box-shadow 0.15s ease; }
a.card:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--accent-wash); }

/* ---------- 时间线 ---------- */
.timeline { position: relative; margin: 36px 0; padding-left: 34px; }
.timeline::before {
  content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--accent);
}
.t-item { position: relative; padding: 0 0 34px; }
.t-item::before {
  content: ""; position: absolute; left: -32px; top: 8px;
  width: 12px; height: 12px; background: var(--paper);
  border: 3px solid var(--accent); border-radius: 50%;
}
.t-item.milestone::before { background: var(--red); border-color: var(--red); }
.t-year { font-family: var(--latin); font-weight: 700; font-size: 15px; color: var(--accent-deep); letter-spacing: 0.06em; }
.t-item h3 { margin: 4px 0 6px; font-size: 18px; }
.t-item p { margin: 0; font-size: 15px; color: #454251; max-width: 640px; }

/* ---------- 精读块 ---------- */
.chapter { border-left: 4px solid var(--accent); padding: 8px 0 8px 26px; margin: 44px 0; }
.chapter .ch-no { font-family: var(--latin); font-size: 12px; letter-spacing: 0.24em; color: var(--accent); text-transform: uppercase; }
.chapter h3 { margin-top: 6px; font-size: 24px; }
.chapter ul { margin: 12px 0 12px 22px; }
.chapter li { margin: 8px 0; font-size: 15.5px; }
.keybox { background: var(--paper-deep); border: 1px solid var(--line); padding: 14px 18px; margin: 16px 0; font-size: 15px; }
.keybox b { font-family: var(--latin); font-size: 12px; letter-spacing: 0.2em; color: var(--red); display: block; margin-bottom: 6px; text-transform: uppercase; }

.difficulty { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 10px; }
.difficulty i { width: 9px; height: 9px; border: 1.5px solid var(--accent); border-radius: 50%; display: inline-block; }
.difficulty i.on { background: var(--accent); }
.difficulty.hard i { border-color: var(--red); }
.difficulty.hard i.on { background: var(--red); }

/* ---------- Hero（斜线流纹底） ---------- */
.hero {
  padding: 84px 0 64px;
  border-bottom: 2px solid var(--ink);
  background:
    repeating-linear-gradient(135deg, rgba(74, 61, 143, 0.05) 0 1px, transparent 1px 24px),
    var(--paper);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
.hero .lede { margin-top: 20px; }

/* ---------- 受控幻觉实验台 ---------- */
.lab {
  border: 2px solid var(--ink);
  background: #fdfcf9;
  padding: 26px; margin: 30px 0;
  box-shadow: 6px 6px 0 var(--accent-wash);
}
.lab-title { font-family: var(--latin); font-size: 13px; letter-spacing: 0.22em; color: var(--accent); margin-bottom: 18px; text-transform: uppercase; }
.lab .controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 16px; }
@media (max-width: 720px) { .lab .controls { grid-template-columns: 1fr; } }
.lab .ctl label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.lab .ctl .val { font-family: var(--latin); color: var(--accent-deep); font-weight: 700; }
.lab .ctl input[type="range"] { width: 100%; accent-color: #4a3d8f; }
.lab .fmt { display: flex; gap: 10px; flex-wrap: wrap; }
.lab .fmt button {
  font-family: var(--sans); font-size: 14px; font-weight: 700;
  padding: 8px 16px; cursor: pointer;
  border: 2px solid var(--ink); background: #fff;
}
.lab .fmt button.on { background: var(--red); color: #fff; border-color: var(--red); }
.lab canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); background: #fff; }
.lab .legend { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.lab .legend i { display: inline-block; width: 16px; height: 3px; margin-right: 6px; vertical-align: middle; }
.lab .readout { font-size: 15.5px; margin-top: 14px; text-align: center; min-height: 56px; }
.lab .readout b { color: var(--accent-deep); }

/* ---------- 页脚 ---------- */
footer {
  border-top: 2px solid var(--ink); margin-top: 40px;
  padding: 36px 0 48px; background: var(--paper-deep);
}
footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 32px; justify-content: space-between; align-items: baseline; }
footer p, footer a { font-family: var(--latin); font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
footer a { text-decoration: none; }
footer a:hover { color: var(--accent); }

.page-head { padding: 64px 0 48px; border-bottom: 2px solid var(--ink); }
.page-head .lede { margin-top: 16px; }
.concept { margin: 56px 0; }

table.terms { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 15px; }
table.terms th, table.terms td { border: 1px solid var(--line); padding: 10px 14px; text-align: left; }
table.terms th { background: var(--accent-wash); font-family: var(--latin); font-size: 12px; letter-spacing: 0.15em; color: var(--accent-deep); text-transform: uppercase; }
table.terms td:first-child { font-weight: 700; }

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