/* ===== 变量 ===== */
:root{
  --toc-w: 300px;                 /* 侧栏宽度 */
  --navbar-h: 20px;                /* 顶栏高度 */
  --transition: .55s;             /* 动画时长（统一） */
  --slide-dist: calc(var(--toc-w) + 1px);
  --tab-width: 40px;
  --tab-height: 200px;
  --tab-purple: #6a0dad;
  --hover-zone-width: 20px;
  --brand-purple: #7c3aed;        /* 引导紫 */
  --brand-purple-weak: #ede9fe;
  --sidebar-gap: 16px;            /* 上下留白，避免顶天立地 */
  --sidebar-radius: 18px;
  --sidebar-offset: 20px;         /* sidebar 距窗口左侧的偏移 */
  --sidebar-hide-extra: 12px;     /* 额外位移，盖住阴影/圆角 */

  --ff-body: "InterLocal", sans-serif;
  --ff-serif: "SourceSerif4Local", serif;
}


/* ===== 布局容器 ===== */
.page-layout {
  display: flex;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
  position: relative;
  overflow: visible;
}
body.collapsed .page-layout {
  justify-content: center;     /* 让唯一的 .content 在全屏居中 */
}

/* ===== 侧边栏 ===== */
.sidebar{
  position: sticky;
  top: var(--navbar-h);
  left: var(--sidebar-offset);                 /* 不改它，只动画 transform */
  width: var(--toc-w);
  height: calc(100vh - var(--navbar-h) - (var(--sidebar-gap) * 2));
  margin: var(--sidebar-gap) 0;
  background: #fff;
  color: #111;
  padding: 14px 16px 16px 18px;
  border-radius: var(--sidebar-radius);
  border: 1px solid #eef2f7;
  box-shadow: 0 10px 30px rgba(17,24,39,.08);
  overflow: hidden;
  z-index: 1001;
  font-family: var(--ff-body);

  /* 关键：让 flex 参与占位，并能过渡宽度 */

  transition: transform var(--transition) cubic-bezier(.25,.8,.25,1);
  transform: translateX(0);
}

/* 左侧紫色引导条 */
.sidebar::before{
  content:"";
  position:absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--brand-purple), #a78bfa);
  border-top-left-radius: var(--sidebar-radius);
  border-bottom-left-radius: var(--sidebar-radius);
  transition: opacity .2s ease;
}

/* 折叠：只改 transform + flex-basis，同步让正文扩展 */
body.collapsed .sidebar {
  position: absolute;
  transform: translateX(calc(-100% - var(--sidebar-offset) - var(--sidebar-hide-extra)));
  pointer-events: none;
  box-shadow: none;                      /* 防止阴影露头 */
  border-color: transparent;             /* 防止 1px 边线露头 */
}
body.collapsed .sidebar::before { opacity: 0; }

/* ===== 目录容器 ===== */
.sidebar-toc {
  max-height: calc(100vh - var(--navbar-h) - 1.5rem);
  overflow-y: auto;
  padding-top: 1.5rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overflow-x: visible;
}
.sidebar-toc::-webkit-scrollbar { width: 0; height: 0; }
.sidebar-toc ul { list-style: none; margin: 0; padding: 0; }



/* ===== 正文 ===== */
.content {
  flex: 1 1 auto;
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem 2rem;
  box-sizing: border-box;
  font-family: var(--ff-body);
  transition:
    max-width var(--transition) cubic-bezier(.25,.8,.25,1),
    padding   var(--transition) cubic-bezier(.25,.8,.25,1);
}

/* 折叠态：正文同步变宽（与侧栏动画同速） */
body.collapsed .content {
  max-width: 1200px;
  padding: 1rem 10rem;
  margin: 0 auto;              /* 确保水平居中 */
}

/* ===== 按钮 ===== */
.toggle-btn {
  position: absolute;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #000;
  z-index: 1000;
}
.close-btn { top: 0.75rem; right: 1.25rem; }
body.collapsed .close-btn { display: none; }

/* ===== Hover 触发区（左侧） ===== */
.hover-zone {
  position: fixed;
  top: 0; left: 0;
  width: var(--hover-zone-width);
  height: 100vh;
  z-index: 1001;
  opacity: 0;
  pointer-events: auto;
}

/* ===== Sidebar Tab（细长条） ===== */
.sidebar-tab {
  position: sticky;
  top: calc(50vh - (var(--tab-height) / 2));
  left: 0;
  width: var(--tab-width);
  height: var(--tab-height);
  background: var(--tab-purple);
  color: #fff;
  display: none; /* 仅 collapsed 显示 */
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  font-weight: bold;
  font-size: 1.2rem;
  writing-mode: vertical-rl;
  transform: translateX(calc(-100% + 5px)) rotate(180deg);
  cursor: pointer;
  transition: transform var(--transition) ease;
  z-index: 1002;
  box-sizing: border-box;
}
.sidebar-tab.tab-intro { transform: translateX(0) rotate(180deg); }
body.collapsed .sidebar-tab { display: flex; }
body.collapsed .sidebar-tab:hover { transform: translateX(0) rotate(180deg); }
body.collapsed .hover-zone:hover ~ .sidebar-tab { transform: translateX(0) rotate(180deg); }

/* ===== TOC 链接效果 ===== */
.sidebar-toc a {
  color: #000;
  cursor: pointer;
  font-size: 16px;
  font-weight: 400;
  line-height: 45px;
  margin: 0 0 2em;
  position: relative;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  display: inline-block;
}
.sidebar-toc a:hover { color:#6a0dad; }


/* ===== 移动端（浮层侧栏） ===== */
@media (max-width: 1200px) {
  .page-layout { overflow: visible; }
  .content { transition: none; max-width: 700px; padding: 1rem 1.25rem; }

  .sidebar {
    position: fixed;
    top: var(--navbar-h);
    left: 0;
    width: var(--toc-w);
    height: calc(100vh - var(--navbar-h));
    margin: 0;
    transform: translateX(-100%);                 /* 初始隐藏 */
    pointer-events: none;
    flex-basis: auto;                              /* 不参与布局 */
    transition: transform var(--transition) cubic-bezier(.25,.8,.25,1);
  }
  body:not(.collapsed) .sidebar {
    transform: translateX(0);
    pointer-events: auto;
  }
  body.collapsed .sidebar { transform: translateX(-100%); }

  .close-btn { position: fixed; top: .75rem; right: 1.25rem; display: none; }
  body:not(.collapsed) .close-btn { display: block; }

  body.collapsed .sidebar-tab { display: flex !important; }
}





:root{
  --brand-purple: #7c3aed;
  --brand-purple-weak: #ede9fe;
  --text: #111;
  --muted: #6b7280;
  --rhythm: 1.1em;       /* 段落节奏 */
}

/* 正文容器：保留你已有 .content，只做排版增强 */
.content{
  color: var(--text);
  font-size: clamp(1rem, 0.2vw + 1rem, 1.06rem);
  text-align: justify;
  line-height: 1.6;
  letter-spacing: .01em;
  margin: 0 auto;
  padding: 1rem 2rem;
  box-sizing: border-box;
  transition: max-width .55s cubic-bezier(.25,.8,.25,1), padding .55s cubic-bezier(.25,.8,.25,1);
}

/* 折叠侧栏时，正文同步变宽（与你现有 collapsed 逻辑保持一致） */
body.collapsed .content{
  padding: 1rem 10rem;
}



/* 段落节奏 */
.content p{ margin: 0 0 var(--rhythm); }
.content .lead{
  font-size: clamp(1.05rem, .5vw + 1rem, 1.25rem);
  color: var(--muted);
  text-align: center;
}

/* 标题层级与滚动偏移（避免被顶栏/封面挡住） */
.content h1, .content h2, .content h3, .content h4{
  scroll-margin-top: calc(var(--navbar-h, 0px) + 16px);
  line-height: 1.25;
  font-weight: 700;
  color: #111;
  font-family: var(--ff-serif);
}
.content h1{ font-size: clamp(1.8rem, 1vw + 2rem, 3rem); margin: 1.2em 0 .6em; text-align:center; }
.content h2{ font-size: clamp(1.35rem, .6vw + 1.2rem, 2rem); margin: 2.2em 0 .6em; position:relative; }
.content h3{ font-size: clamp(1.15rem, .4vw + 1rem, 1.4rem); margin: 1.6em 0 .5em; }

/* 标题本身占满内容列 */
.content h2{
  position: relative;
  display: block;       /* 默认就是 block，写明更直观 */
  width: 100%;

}

/* 分割线 = 整列宽度 */
.content h2::after{
  content: "";
  position: absolute;
  left: 0;              /* 贴左 */
  right: 0;             /* 贴右 => 等于 width:100% */
  bottom: -.5em;        /* 与文字的间距 */
  height: 3px;
  background: linear-gradient(90deg, var(--brand-purple), #a78bfa);
  border-radius: 2px;
}

/* 标题锚点（如 Hugo 的 # 链接）：仅 hover 显示 */
.content .anchor, .content a.header-anchor{
  margin-left:.4em; opacity:0; text-decoration:none;
  color: var(--muted); transition: opacity .15s ease;
}
.content h1:hover .anchor,
.content h2:hover .anchor,
.content h3:hover .anchor{ opacity:1; }

/* 链接样式 */
.content a{ color: var(--brand-purple); text-decoration: none; }
.content a:hover{ text-decoration: underline; text-underline-offset: 2px; }

/* 列表：与正文对齐、子层级缩进 */
.content ul, .content ol{ padding-left: 1.2em; margin: .6em 0 var(--rhythm); }
.content li + li{ margin-top: .35em; }

/* 引用块：左侧紫条、浅灰底 */
.content blockquote{
  margin: 1.2em 0;
  padding: .9em 1.1em .9em 1em;
  background: #f9fafb;
  border-left: 4px solid var(--brand-purple);
  color: #111;
}
.content blockquote p{ margin: 0.4em 0; }

/* 信息/警示卡片（可把 > [!NOTE] 这类映射到这些类名） */
.content .admonition,
.content .note, .content .tip, .content .warn{
  border:1px solid #eef2f7; border-left: 6px solid var(--brand-purple);
  background:#fff; padding: .9em 1em; border-radius: 12px; margin: 1.2em 0;
  box-shadow: 0 4px 18px rgba(17,24,39,.05);
}
.content .admonition > strong{ color: var(--brand-purple); }

/* 图片 / 图注 */
.content figure{ margin: 1.2em 0; text-align:center; }
.content img{ max-width:100%; height:auto; border-radius: 10px; }
.content figcaption{ color: var(--muted); font-size:.9em; margin-top:.5em; }

/* 表格（如有） */
.content table{
  width:100%; border-collapse: collapse; margin: 1.2em 0;
  font-size: .98em;
}
.content th, .content td{ padding:.65em .75em; border-bottom:1px solid #eee; text-align:left;}
.content thead th{ text-align:left; border-bottom:2px solid #ddd; }

/* 参考文献：悬挂缩进 */
.content .references, .content ol.references{
  list-style: decimal;
  margin: 1.4em 0;
  padding-left: 1.2em;
}
.content .references li{
  padding-left: .4em;
  text-indent: -0.4em;     /* 悬挂缩进视觉上更整齐 */
  margin-bottom: .65em;
}
/* 参考文献：悬挂缩进 */
.content ol.references,
.content .references ol{               /* ← 新增这一行 */
  list-style: decimal;
  margin: 1.4em 0;
  padding-left: 1.2em;
}
.content .references li,
.content ol.references li{
  padding-left: .4em;
  text-indent: -0.4em;
  margin-bottom: .65em;
    text-align: left;
}


/* 脚注（Hugo 原生 footnotes） */
.footnotes{ font-size: .92em; color:#222; }
.footnotes ol{ padding-left: 1.1em; }
.footnotes li{ margin-bottom:.5em; }



/* 手写大纲的样式 */
.sidebar-toc .manual-outline { padding-top: .25rem; }

.manual-outline .group { margin: 0 0 1.8rem; }

.manual-outline .group-title{
  display:block;
  font-weight:700;
  font-size: 1.1rem;
  line-height: 1.1;
  margin: .2rem 0 .6rem;
  letter-spacing: .02em;
  text-transform: none;           /* 覆盖全大写 */
  color:#111;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}



.manual-outline .group-items a{
  display:block;
   margin: 0 0 .8em;
  line-height: 1.4;
  font-size: 1rem;
  font-weight: 400;
  text-transform: none;           /* 覆盖全大写 */
  white-space: normal;
  overflow-wrap: anywhere;     /* ← 单个超长词也能换行 */
  word-break: break-word;      /* ← 兼容旧浏览器的别名 */
  hyphens: auto;               /* ← 英文自动加连字符（可选） */
}

.manual-outline .group-items a:hover{ color:#6a0dad; }



/* ==== TOC：仅高亮命中的那条链接 ==== */
:root{
  --toc-accent: #7c3aed;      /* 高亮紫 */
  --toc-shift: 8px;           /* 标题右移距离 */
  --toc-line: 0px;            /* 默认竖线粗细 */
  --toc-line-thick: 4px;      /* 高亮竖线粗细 */
  --toc-line-shift: 5px;      /* 高亮时竖线整体右移量 */
  --toc-anim: .28s;
}

/* 每条链接成为独立高亮单元 */
.manual-outline .group-items > a{
  position: relative;
  display: block;
  padding-left: 14px;                 /* 给竖线留空间 */
  transform: translateX(0);
  color: inherit;
  transition: color var(--toc-anim) ease,
              transform var(--toc-anim) ease,
              font-weight var(--toc-anim) ease;
  text-decoration: none;
}

/* 每条链接自己的竖线（默认黑色、较细、贴左） */
.manual-outline .group-items > a::before{
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--toc-line);
  background: #000;
  transform: translateX(0);
  transition: background var(--toc-anim) ease,
              width var(--toc-anim) ease,
              transform var(--toc-anim) ease;
  border-radius: 999px;
}

/* 命中时：只有这一条链接右滑、变紫、加粗；它自己的竖线也右移并变粗变紫 */
.manual-outline .group-items > a.is-inview-link{
  transform: translateX(var(--toc-shift));
  color: var(--toc-accent);
  font-weight: 700;
}

.manual-outline .group-items > a.is-inview-link::before{
  background: var(--toc-accent);
  width: var(--toc-line-thick);
  transform: translateX(var(--toc-line-shift));
}

/* ===== TroGen 标题区（主标题 + 副标题）===== */

/* 主标题：只作用于 <h1 id="trogen"> */
.content h1{
  /* 更大的字号与更紧凑的行高 */
  font-size: clamp(2.6rem, 2vw + 2rem, 4rem);
  line-height: 1.1;
  font-weight: 800;
  color: #111; /* 深灰黑 */
  /* 居中 + 单独限宽（避免副标题太长）*/
  max-width: min(90vw, 820px);
  margin: 1.2em auto .4em;   /* 上下间距你可再调 */
  text-align: center;
  font-family: var(--ff-serif);
}


.content strong {
  color: #4c1d95;   /* 深紫色，比原来的 #7c3aed 更稳重 */
  font-weight: 700; /* 保持加粗 */
}
.hero-title {
  text-align: center;
  padding-top: 3em;  /* 仅上间距 */
}
.hero-title .logo-title {
  max-width: 480px;   /* 控制图片宽度，避免太大 */
  width: 100%;
  height: auto;
}

.hero-subtitle {
  font-size: clamp(1.05rem, .6vw + 1rem, 1.6rem);
  font-weight: 400;
  line-height: 1.4;
  color: color-mix(in srgb, var(--brand-purple) 35%, #000);
  font-family: var(--ff-body);
  text-align: center;     /* 强制居中 */
      max-width: min(92vw, 900px);
  margin: 0 auto 0.8em;
}

/* 侧栏里的 TOC、手写大纲、侧栏细长 Tab：Inter */
.sidebar-toc,
.manual-outline,
.sidebar-tab{
  font-family: var(--ff-body);
}

/* 手写大纲的分组标题：Source Serif 4 */
.manual-outline .group-title{
  /* 你已有的粗细等 ... */
  font-family: var(--ff-serif);
}

/* TOC 链接本体（保留你原尺寸/行高/大写等设定，只指定字体） */
.sidebar-toc a{
  /* 你已有的属性（color/size/line-height/...） */
  font-family: var(--ff-body);
}

.parts li { margin-bottom: 10px; }
.parts .overview { display: block; margin-left: 24px; }