/* ==========================================================================
   发布出来的只读站点  —  样式
   --------------------------------------------------------------------------
   功能模块：只读站点（/s/<短码>/）的结构与语义层，定义读者侧观感——
   浅色纸感、衬线标题、顶部导航 Home / 分区、卡片网格、正文行宽收窄。
   加载顺序（依据 DESIGN.md §4 的契约，顺序不能改）：站点页依次加载
   site → apple → terminal → polish → experience。本文件排在最前，负责定
   结构与本页语义 token（--paper / --ink / --site-primary 等）；后面的
   apple / terminal 换肤层再据此覆盖。选用暖纸白 + 深墨的浅色取值，是为了
   面向读者的纸面观感，而不是工作区的深色终端配色。
   ========================================================================== */

:root {
  --paper: #f6f3ec;
  --paper-2: #fffdf8;
  --ink: #23201a;
  --ink-soft: #5f594e;
  --ink-dim: #8d867a;
  --line: rgba(35, 32, 26, 0.12);
  --site-primary: #3f3416;
  --site-heading: "EB Garamond", Georgia, serif;
  --site-body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--site-body);
  font-size: 16px;
  line-height: 1.65;
}

h1, h2, h3 { font-family: var(--site-heading); font-weight: 400; letter-spacing: 0.01em; }
a { color: var(--site-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------- 导航 */
.nav {
  display: flex; align-items: center; gap: 22px;
  padding: 14px 28px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.nav-brand {
  font-family: var(--site-heading); font-size: 21px; font-style: italic; color: var(--ink);
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-links { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; }
.nav-links a { color: var(--ink-soft); white-space: nowrap; }
.nav-search { margin-left: auto; min-width: 0; }
.nav-search input, .search-inline input {
  font: inherit; font-size: 14px;
  background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; min-width: 220px; outline: 0;
}
.nav-search input:focus, .search-inline input:focus { border-color: var(--site-primary); }

/* 平板（721–1024）：品牌 + 分区链接 + 筛选 chip + 搜索框挤在一排会横向溢出
   （2026-10-18 体检：1024 溢出 74px、768 溢出 49px，品牌被压成三行、中文导航项竖排）。
   拆成两行：第一行品牌 / 筛选 / 搜索，第二行分区链接整行铺开。 */
@media (max-width: 1024px) {
  .nav { flex-wrap: wrap; gap: 10px 16px; padding: 12px 20px; }
  .nav-brand { order: 1; max-width: 46%; font-size: 19px; }
  .filter-chip { order: 2; margin-left: auto; margin-right: 0; }
  .nav-search { order: 2; flex: 1 1 250px; margin-left: 0; }
  .nav-search input { min-width: 0; width: 100%; }
  .nav-links { order: 3; flex: 1 1 100%; gap: 6px 16px; }
  body.site .nav-links a { font-size: 13px; }
}

/* 手机（≤720）：品牌与筛选同排，分区链接、搜索框各占一行。
   （2026-10-15 体检：390px 下原布局横向溢出近一个屏幕宽。） */
@media (max-width: 720px) {
  .nav { flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px; }
  .nav-brand { order: 1; max-width: 100%; margin-right: auto; font-size: 18px; }
  .nav-links { order: 3; flex-wrap: wrap; gap: 8px 14px; }
  .filter-chip { order: 2; margin-left: 0; margin-right: 0; }
  .nav-search { order: 4; flex: 1 1 100%; margin-left: 0; }
  .nav-search input { min-width: 0; width: 100%; }
}

/* 页头装饰网格横向外扩 10vw（experience.css: inset:-40px -10vw auto），
   平板区间会把文档撑宽 49–74px。只裁横向，纵向浮层不受影响（clip 不会把另一轴变成 auto）。 */
@media (max-width: 1024px) {
  body.site .hero,
  body.site .era-head,
  body.site .page-head { overflow-x: clip; }
}

/* 手机正文：收紧留白、标题降级、属性表与时间线条目改为纵向堆叠
   （放在本文件末尾，确保能覆盖前面同特异性的基础规则） */

.wrap { max-width: 1040px; margin: 0 auto; padding: 34px 28px 60px; }

/* ------------------------------------------------------------------- 首页 */
.hero { padding: 26px 0 10px; border-bottom: 1px solid var(--line); }
.hero h1 { font-size: 46px; font-style: italic; margin: 0 0 8px; }
.hero-sub { color: var(--ink-soft); margin: 0 0 6px; max-width: 62ch; }
.hero-stats { color: var(--ink-dim); font-size: 13px; margin: 0 0 18px; }

.search-inline { display: flex; gap: 8px; margin: 20px 0 6px; }
.search-inline button {
  font: inherit; font-size: 13px; padding: 6px 16px; cursor: pointer;
  background: var(--site-primary); color: #fff; border: 0; border-radius: 999px;
}

.section { margin-top: 34px; }
.section h2 { font-size: 24px; margin: 0 0 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; color: var(--ink);
}
.tile:hover { text-decoration: none; border-color: var(--site-primary); transform: translateY(-1px); }
.tile-cover { display: block; height: 96px; border-radius: 8px; background: center/cover no-repeat; margin-bottom: 6px; }
.tile-kind { font-size: 11.5px; color: var(--ink-dim); letter-spacing: 0.04em; }
.tile-name { font-family: var(--site-heading); font-size: 20px; }
.tile-era { font-size: 12px; color: var(--ink-dim); }

/* ----------------------------------------------------------------- 页面 */
.crumbs { font-size: 13px; color: var(--ink-dim); margin-bottom: 14px; }
.page { max-width: 720px; }
.page-head { display: flex; gap: 22px; align-items: flex-start; justify-content: space-between; }
.page-head h1 { font-size: 40px; font-style: italic; margin: 0 0 6px; }
.page-kind { color: var(--ink-dim); font-size: 13px; margin: 0; }
.page-aka { color: var(--ink-soft); font-size: 13.5px; margin: 6px 0 0; }
.page-cover { width: 168px; height: 168px; border-radius: 12px; background: center/cover no-repeat; border: 1px solid var(--line); flex: 0 0 auto; }

.props { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: 14.5px; }
.props th { text-align: left; width: 150px; color: var(--ink-dim); font-weight: 400; padding: 6px 10px 6px 0; vertical-align: top; }
.props td { padding: 6px 0; border-bottom: 1px solid var(--line); }

.page h2 { font-size: 22px; margin: 30px 0 8px; }
.page p { margin: 0 0 14px; }
.page blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 2px solid var(--line); color: var(--ink-soft); font-style: italic; }
.page hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.callout { background: var(--paper-2); border: 1px solid var(--line); border-left: 3px solid var(--site-primary); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; }

.timeline-read ol { list-style: none; padding: 0; margin: 0; }
.timeline-read li { display: flex; gap: 14px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ev-date { flex: 0 0 190px; color: var(--ink-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.ev-title { font-family: var(--site-heading); font-size: 19px; }
.ev-links { color: var(--ink-dim); font-size: 13px; }

.related { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 18px; }
.related ul { list-style: none; padding: 0; margin: 0; }
.related li { padding: 5px 0; }
.rel-reason { color: var(--ink-dim); font-size: 12.5px; margin-left: 8px; }

.empty { color: var(--ink-dim); }

/* ------------------------------------------------------------------ 页脚 */
.foot {
  border-top: 1px solid var(--line); padding: 20px 28px 34px;
  color: var(--ink-dim); font-size: 12.5px; text-align: center;
}
.foot-meta { margin-top: 4px; }

/* ----------------------------------------------------------------- 密码页 */
.gate { max-width: 420px; margin: 16vh auto; text-align: center; }
.gate h1 { font-size: 34px; font-style: italic; margin-bottom: 6px; }
.gate p { color: var(--ink-soft); }
.gate form { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.gate input { font: inherit; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; outline: 0; }
.gate button { font: inherit; padding: 8px 18px; border: 0; border-radius: 999px; background: var(--site-primary); color: #fff; cursor: pointer; }
.gate-error { color: #b3261e; }


/* ------------------------------------------------- 嵌进页面的只读时间线 */
/* 时间线铺满浏览器宽度：相对父容器左移 50%，再按自身宽度回拉一半 —— 
   比 calc(50% - 50vw) 稳（后者在带外边距的窄栏里会算歪）。 */
.timeline-embed {
  /* 全宽由 JS 精确设置（见 base.html 的 bleed()）：量出内容列的位置再拉负外边距，
     不依赖百分比基准，窄栏 / 侧边距都不会算歪 */
  margin: 28px 0 8px;
  padding: 0 clamp(12px, 3vw, 40px);
  box-sizing: border-box;
}
body { overflow-x: hidden; }   /* 100vw 在带滚动条的浏览器里会多出一点点，别让它出横向滚动条 */

.te-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.te-bar h2 { margin: 0; flex: 1 1 auto; }
.te-actions { display: flex; gap: 8px; }
.te-btn {
  height: 30px; padding: 0 12px; cursor: pointer; font: inherit; font-size: 12.5px;
  background: var(--surface, #fff); color: var(--ink-dim, #6b6459);
  border: 1px solid var(--line, #e2ddd2); border-radius: 999px;
}
.te-btn:hover { color: var(--ink, #1b1710); border-color: var(--ink-dim, #6b6459); }
.te-frame-wrap {
  position: relative; overflow: hidden;
  border: 1px solid var(--line, #e2ddd2); border-radius: 18px;
  background: var(--surface, #fff);
}
.te-frame { display: block; width: 100%; height: 520px; border: 0; transition: height 200ms cubic-bezier(.22,1,.36,1); }
.te-dock {
  display: flex; align-items: center; gap: 4px;
  /* 悬浮在画布上，不参与排版：既不压住色带，也不会把下面的文字挤变形 */
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 3; width: max-content; margin: 0;
  padding: 5px; border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(27, 23, 16, .10);
  box-shadow: 0 8px 24px rgba(27, 23, 16, .12);
  backdrop-filter: blur(10px);
}
.te-dock-btn {
  min-width: 34px; height: 30px; padding: 0 12px; cursor: pointer;
  border: 0; border-radius: 999px; background: transparent;
  color: #4a4438; font: inherit; font-size: 12.5px;
}
.te-dock-btn:hover { background: rgba(27, 23, 16, .06); color: #1b1710; }
.te-dock-sep { width: 1px; height: 18px; background: rgba(27, 23, 16, .12); margin: 0 4px; }
.timeline-embed.is-full .te-frame { height: min(78vh, 760px); }
.timeline-embed.is-list .te-frame-wrap { display: none; }
.timeline-embed.is-list .te-list { display: block; }
.te-list { margin: 10px 0 6px; }
.te-frame-wrap { position: relative; }
.te-list summary { cursor: pointer; color: var(--ink-dim, #6b6459); font-size: 13px; }
.te-list[hidden] { display: none; }

@media (max-width: 720px) {
  .te-frame { height: 400px; }
  .te-dock { bottom: 10px; }
  .timeline-embed.is-full .te-frame { height: 70vh; }
}


/* 嵌进页面的只读画布（地图 / 关系树 / 图谱）：和时间线一样铺满窗口宽 */
.canvas-embed {
  margin: 20px 0 8px;
  padding: 0 clamp(12px, 3vw, 40px);
  box-sizing: border-box;
}
.canvas-embed iframe {
  display: block; width: 100%;
  height: clamp(420px, 68vh, 760px);        /* 跟着窗口长，别写死 */
  border: 1px solid var(--line, #e2ddd2);
  border-radius: 16px; background: var(--surface, #fff);
}
@media (max-width: 720px) { .canvas-embed iframe { height: clamp(320px, 58vh, 520px); } }

/* ------------------------------------------------------- 筛选 chip */
.filter-chip { position: relative; margin-right: 10px; }
.fc-btn {
  display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  cursor: pointer; font: inherit; font-size: 13px; color: var(--ink, #1b1710);
  background: var(--surface, #fff); border: 1px solid var(--line, #e2ddd2); border-radius: 999px;
}
.fc-btn:hover { border-color: var(--ink-dim, #6b6459); }
.fc-icon { opacity: .6; }
.fc-caret { opacity: .5; font-size: 10px; }
.fc-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  min-width: 200px; max-height: 60vh; overflow: auto; padding: 6px;
  background: var(--surface, #fff); border: 1px solid var(--line, #e2ddd2);
  border-radius: 14px; box-shadow: 0 12px 30px rgba(27, 23, 16, .14);
}
.fc-group { padding: 8px 10px 4px; font-size: 11.5px; color: var(--ink-dim, #857c6b); }
.fc-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 10px; border-radius: 9px; color: inherit; text-decoration: none; font-size: 13.5px;
}
.fc-item:hover { background: rgba(27, 23, 16, .05); }
.fc-item.is-on { background: rgba(27, 23, 16, .07); font-weight: 600; }
.fc-count { color: var(--ink-dim, #857c6b); font-size: 12px; }

/* ------------------------------------------------------- 搜索结果 */
.crumbs { color: var(--ink-dim, #857c6b); font-size: 13px; margin: 4px 0 14px; }
.search-count { color: var(--ink-dim, #857c6b); font-size: 13.5px; margin: 10px 0 18px; }
.hit-list { list-style: none; padding: 0; margin: 0; }
.hit { padding: 16px 0; border-bottom: 1px solid var(--line, #e2ddd2); }
.hit-name { font-family: var(--site-heading); font-size: 19px; }
.hit-meta { display: block; color: var(--ink-dim, #857c6b); font-size: 12.5px; margin-top: 4px; }
.hit-snippet { margin: 8px 0 0; color: var(--ink-soft, #4a4438); font-size: 14px; line-height: 1.6; }
.hit-events { margin: 6px 0 0; color: var(--ink-dim, #857c6b); font-size: 12.5px; }
.hit-event { padding: 2px 8px; border: 1px solid var(--line, #e2ddd2); border-radius: 999px; }

@media (max-width: 720px) {
  .filter-chip { margin-right: 6px; }
  .fc-menu { right: auto; left: 0; }
}

/* ------------------------------------------------- 纪元页与纪元胶囊 */
.era-head { margin: 10px 0 18px; }
.era-span { color: var(--ink-dim, #857c6b); font-size: 13px; margin: 6px 0 0; }
.era-desc { color: var(--ink-soft, #4a4438); font-size: 15px; line-height: 1.7; margin: 10px 0 0; max-width: 62ch; }
.era-switch, .era-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 26px; }
.era-pill {
  padding: 6px 14px; border-radius: 999px; text-decoration: none; font-size: 13.5px;
  border: 1px solid var(--line, #e2ddd2); color: inherit; background: var(--surface, #fff);
}
.era-pill.is-on { font-weight: 600; }
.era-t-blue { background: #cee2f5; border-color: #b2c7e8; color: #2f4a7a; }
.era-t-sky { background: #cae6f2; border-color: #a8d0e4; color: #28566e; }
.era-t-violet { background: #d8d5f4; border-color: #c2bde8; color: #4b447f; }
.era-t-red { background: #f9d8d2; border-color: #ecbfb8; color: #7d3a33; }
.era-t-teal { background: #cdeada; border-color: #b0dbc7; color: #245c46; }
.era-t-gold { background: #f6e7c2; border-color: #e8d098; color: #7a5a1e; }
.era-head.era-t-blue, .era-head.era-t-sky, .era-head.era-t-violet,
.era-head.era-t-red, .era-head.era-t-teal, .era-head.era-t-gold {
  padding: 18px 20px; border-radius: 16px;
}
.era-timeline { list-style: none; padding: 0; margin: 8px 0 0; }
.era-event { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line, #e2ddd2); }
.ee-date { flex: 0 0 190px; color: var(--ink-dim, #857c6b); font-size: 13px; font-variant-numeric: tabular-nums; }
.ee-body { display: flex; flex-direction: column; gap: 4px; }
.ee-title { font-family: var(--site-heading); font-size: 18px; }
.ee-desc { color: var(--ink-soft, #4a4438); font-size: 14px; line-height: 1.6; }
.ee-cards { color: var(--ink-dim, #857c6b); font-size: 12.5px; }

/* ------------------------------------------------- 搜索：高亮与分页 */
.hit-snippet mark { background: #f6e7a8; color: inherit; padding: 0 2px; border-radius: 3px; }
.pager { display: flex; align-items: center; gap: 14px; margin: 22px 0 8px; }
.pager-btn {
  padding: 7px 14px; border-radius: 999px; text-decoration: none; font-size: 13.5px;
  border: 1px solid var(--line, #e2ddd2); color: inherit;
}
.pager-btn:hover { border-color: var(--ink-dim, #6b6459); }
.pager-info { color: var(--ink-dim, #857c6b); font-size: 13px; }

@media (max-width: 720px) {
  .era-event { flex-direction: column; gap: 4px; }
  .ee-date { flex: none; }
}

/* 搜不到时的"你是不是想找" */
.similar { display: block; margin-top: 8px; color: var(--ink-dim, #857c6b); font-size: 13.5px; }
.similar a { color: var(--ink, #1b1710); }

/* 纪元页顶部的两个跳转按钮 */
.era-actions { display: flex; gap: 8px; margin: 4px 0 16px; }
.era-actions .te-btn { text-decoration: none; display: inline-flex; align-items: center; height: 30px; }


/* 画布里的轻提示（例如成员没有关联卡片） */
.canvas-hint {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  background: rgba(27, 23, 16, .9); color: #faf7f0;
  opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease;
  z-index: 40;
}
.canvas-hint.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ----------------------------------------------------------------- 手机正文 */
@media (max-width: 640px) {
  .wrap { padding: 24px 16px 48px; }
  .hero { padding: 18px 0 8px; }
  body.site .hero h1 { font-size: clamp(30px, 8.5vw, 40px); }
  .page-head { flex-direction: column; gap: 14px; }
  body.site .page-head h1 { font-size: 30px; }
  .page-cover { inline-size: 100%; block-size: 172px; }
  .props th { width: 96px; padding-right: 8px; }
  .timeline-read li { flex-direction: column; gap: 2px; }
  .ev-date { flex: none; }
  .search-inline { flex-wrap: wrap; }
  .search-inline input { flex: 1 1 100%; min-width: 0; }
  .te-bar { flex-wrap: wrap; }
  .gate { margin: 10vh auto; }
  .gate form { flex-wrap: wrap; }
  .gate input { flex: 1 1 160px; min-width: 0; }
}
