/* 图书室的资料夹（js/shelf.js）：目录一列，点开在窗口里读。正文是 Markdown 排出来的（标题、段落、列表、引用、表格） */
/* 护眼：不用窗口那张带颗粒的羊皮纸，换一块素净的米黄纸，字是暖深灰（不用纯黑，对比别太硬） */
.shelf {
  --ink-soft: #7a7064;
  height: 100%;
  overflow-y: auto;
  padding: 10px 18px 16px;
  box-sizing: border-box;
  background: #f5edd9;
  color: #3d3830;
}

.shelf-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ink-soft);
  font-size: 1.15em;
  font-weight: normal;
  letter-spacing: 2px;
}

.shelf-h small,
.shelf-empty,
.shelf-list small,
.shelf-date {
  color: var(--ink-soft);
}

.shelf-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf-list li + li {
  border-top: 1px dotted #00000030;
}

.shelf-list button {
  all: unset;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 2px;
  box-sizing: border-box;
  cursor: pointer;
}

.shelf-list button:hover b {
  text-decoration: underline dotted;
}

.shelf-list b {
  font-weight: normal;
}

/* 读的那一页：一栏不太宽，行距放开 */
.shelf-doc {
  max-width: 42em;
  margin: 0 auto;
  line-height: 1.8;
}

/* 目录：分类一节一节，最上面一排分类小签（两类以上才有），点了跳到那一节 */
.shelf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 4px;
}

.shelf-cat {
  margin: 14px 0 2px;
  color: var(--rust);
  font-size: 1em;
  font-weight: normal;
  letter-spacing: 2px;
}

/* 读的时候钉在顶上的一条：回目录、所在分类、分类菜单。往下翻也一直在 */
.shelf-bar {
  position: sticky;
  top: -10px; /* 盖住 .shelf 上面那截内边距，滚动时不露缝 */
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -10px 0 6px;
  padding: 8px 0 6px;
  border-bottom: 1px solid #00000020;
  background: #f5edd9;
}

.shelf-where {
  flex: 1;
  color: var(--ink-soft);
}

.shelf-menu {
  position: relative;
}

.shelf-menu summary {
  cursor: pointer;
  list-style: none;
  padding: 2px 6px;
  border: 1px solid #00000030;
}

.shelf-menu summary::-webkit-details-marker {
  display: none;
}

.shelf-menu-box {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  width: min(320px, 70vw);
  max-height: 360px;
  overflow-y: auto;
  padding: 6px 0;
  border: 1px solid #00000040;
  background: #fbf6ea;
  box-shadow: 2px 3px 0 #00000030;
  line-height: 1.5;
}

.shelf-menu-box button {
  all: unset;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 3px 12px;
  cursor: pointer;
}

.shelf-menu-box button:hover,
.shelf-menu-box button:focus-visible {
  background: #0000000d;
}

.shelf-menu-cat {
  margin-top: 4px;
  color: var(--rust);
}

.shelf-menu-doc {
  padding-left: 24px !important;
}

.shelf-menu-doc[aria-current] {
  color: var(--ink-soft);
}

.shelf-menu-doc[aria-current]::after {
  content: ' ·在读';
}

.shelf-doc h1 {
  margin: 4px 0 0;
  font-size: 1.4em;
  font-weight: normal;
  line-height: 1.4;
}

.shelf-date {
  margin: 2px 0 14px;
}

.shelf-doc h2 {
  margin: 1.6em 0 0.4em;
  padding-bottom: 2px;
  border-bottom: 1px solid #00000030;
  font-size: 1.15em;
  font-weight: normal;
}

.shelf-doc h3 {
  margin: 1.2em 0 0.3em;
  font-size: 1em;
}

.shelf-doc p {
  margin: 0.5em 0;
}

.shelf-doc ul,
.shelf-doc ol {
  margin: 0.5em 0;
  padding-left: 1.6em;
}

.shelf-doc blockquote {
  margin: 0.8em 0;
  padding: 2px 10px;
  border-left: 3px solid var(--rust);
  background: #00000008;
}

.shelf-doc table {
  width: 100%;
  margin: 0.8em 0;
  border-collapse: collapse;
  font-size: 0.95em;
  line-height: 1.5;
}

.shelf-doc th,
.shelf-doc td {
  padding: 3px 6px;
  border: 1px solid #00000030;
  text-align: left;
  vertical-align: top;
}

/* 表头不折行：窄的那几栏（文体、章节）至少有表头那么宽，「小说」不会断成两行 */
.shelf-doc th {
  background: #0000000d;
  font-weight: normal;
  white-space: nowrap;
}

.shelf-doc hr {
  border: 0;
  border-top: 1px dashed #00000040;
}

/* ── 从科算中心搬来的文章（2026-11）：标签、要点、提示框、图解、公式、录像 ── */
.shelf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: -8px 0 12px;
}

.shelf-tags span {
  padding: 0 6px;
  border: 1px solid #00000025;
  color: var(--ink-soft);
  font-size: 0.85em;
}

.shelf-sum {
  margin: 0 0 16px;
  padding: 8px 14px;
  background: #00000008;
  border-left: 3px solid var(--ink-soft);
}

.shelf-doc .shelf-sum h2 {
  margin: 0 0 4px;
  border: 0;
  font-size: 1em;
  color: var(--ink-soft);
  letter-spacing: 2px;
}

.shelf-sum ul {
  margin: 0;
}

.shelf-sum li + li {
  margin-top: 4px;
}

/* > [!NOTE] —— 提示框 */
.shelf-doc blockquote.shelf-callout {
  border-left-color: #5d7a9a;
  background: #5d7a9a14;
  padding: 6px 12px;
}

/* 手画的 SVG 图解：照原样铺满一栏，太宽的横着滚 */
.shelf-text svg:not(.katex svg) {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px auto;
}

.shelf-text a {
  color: #3d5fa8;
}

.shelf-link {
  text-decoration: underline dotted;
}

/* 公式：整行的那种太长就横着滚，不撑破窗口 */
.shelf-text .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

.shelf-text .katex {
  font-size: 1.05em;
}

.shelf-text pre {
  overflow-x: auto;
  padding: 8px 10px;
  background: #00000008;
  line-height: 1.5;
}

.shelf-video {
  margin: 12px 0;
}

.shelf-video video {
  display: block;
  width: 100%;
}

.shelf-video figcaption {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.9em;
}
