/* ============================================================
   目录页 · 古籍风
   ============================================================ */

/* ---------- 封面 ---------- */
.toc-cover {
  padding: 36px 20px 28px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  position: relative;
}

.toc-cover::before,
.toc-cover::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent) 20%,
    var(--accent) 80%,
    transparent
  );
}

.toc-cover::before {
  top: 16px;
}
.toc-cover::after {
  bottom: 16px;
}

.toc-mark {
  font-size: 12px;
  letter-spacing: 6px;
  color: var(--text-mute);
  margin-bottom: 12px;
  text-indent: 6px; /* 抵消字间距让视觉居中 */
}

.toc-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 8px;
  text-indent: 8px;
  margin: 0 0 14px;
  color: var(--text);
  background: linear-gradient(135deg, var(--accent) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.toc-subtitle {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: 3px;
  margin: 0 0 16px;
  font-style: italic;
}

.toc-epigraph {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.9;
  max-width: 280px;
  margin: 0 auto;
  padding: 12px 0;
  border-top: 1px dashed var(--border-strong);
  border-bottom: 1px dashed var(--border-strong);
}

.toc-epigraph-author {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 2px;
}

/* ---------- 整体进度 ---------- */
.toc-progress {
  margin: 0 0 28px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
}

.toc-progress-emoji {
  font-size: 28px;
  flex-shrink: 0;
}

.toc-progress-text {
  flex: 1;
  min-width: 0;
}

.toc-progress-label {
  font-size: 12px;
  color: var(--text-mute);
  margin: 0 0 4px;
  letter-spacing: 1px;
}

.toc-progress-value {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.toc-progress-value strong {
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
}

.toc-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.toc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--secondary));
  border-radius: 2px;
  transition: width 0.6s var(--ease);
  width: 0%;
}

/* ---------- 卷 ---------- */
.volume {
  margin-bottom: 32px;
}

.volume-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--border-strong);
  margin-bottom: 4px;
}

.volume-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  letter-spacing: 1px;
}

.volume-count {
  font-size: 12px;
  color: var(--text-mute);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.volume-count strong {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- 目录项 ---------- */
.toc-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 8px;
  border-bottom: 1px dashed var(--border);
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
  transition: background 0.2s var(--ease), padding-left 0.2s var(--ease);
  position: relative;
}

.toc-item:last-child {
  border-bottom: none;
}

.toc-item:hover {
  background: var(--accent-soft);
  padding-left: 14px;
}

.toc-item:active {
  background: var(--accent-soft);
}

.toc-num {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--text-mute);
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

/* 中文数字 */
.toc-num-zh {
  font-feature-settings: "halt";
}

.toc-item-main {
  min-width: 0;
}

.toc-item-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 4px;
  line-height: 1.4;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-mute);
}

.toc-item-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.toc-item-tag.cat-nature {
  color: var(--category-nature);
}
.toc-item-tag.cat-life {
  color: var(--category-life);
}
.toc-item-tag.cat-poetry {
  color: var(--category-poetry);
}

/* 已读标记 */
.toc-status {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 1.5px solid var(--border-strong);
  color: var(--text-mute);
  background: var(--bg-elevated);
  transition: all 0.3s var(--ease);
}

.toc-item.is-read .toc-status {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

[data-theme="dark"] .toc-item.is-read .toc-status,
:root:not([data-theme]) .toc-item.is-read .toc-status {
  color: #2a1820;
}

.toc-item.is-read .toc-item-title {
  color: var(--text-mute);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
  text-decoration-thickness: 1px;
}

.toc-item.is-read .toc-num {
  color: var(--text-mute);
}

/* 卷末装饰 */
.volume-tail {
  text-align: center;
  margin-top: 12px;
  color: var(--text-mute);
  font-size: 14px;
  letter-spacing: 8px;
  font-family: var(--font-serif);
}

/* ---------- 工具栏（新） ---------- */
.toc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 24px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toc-toolbar-info {
  font-size: 13px;
  color: var(--text-soft);
}

.toc-toolbar-info strong {
  color: var(--accent);
}

.toc-toolbar-actions {
  display: flex;
  gap: 6px;
}

/* ---------- 设置面板（Drawer） ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 86%;
  max-width: 360px;
  background: var(--bg-elevated);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.35s var(--ease);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.2);
  padding-top: env(safe-area-inset-top);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 2px;
}

.drawer-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-soft);
}

.drawer-close:hover {
  background: var(--accent-soft);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 40px;
}

.drawer-section {
  padding: 16px 20px;
}

.drawer-section + .drawer-section {
  border-top: 1px solid var(--border);
}

.drawer-section-title {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 2px;
  margin: 0 0 12px;
  text-transform: uppercase;
}

.drawer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.drawer-row:last-child {
  border-bottom: none;
}

.drawer-row-label {
  font-size: 14px;
  color: var(--text);
}

.drawer-row-hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 2px;
}

.drawer-btn {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid transparent;
  transition: all 0.2s var(--ease);
}

.drawer-btn:hover {
  border-color: var(--accent);
}

.drawer-btn:active {
  transform: scale(0.95);
}

.drawer-btn.danger {
  background: transparent;
  color: var(--text-mute);
  border: 1px solid var(--border-strong);
}

.drawer-btn.danger:hover {
  color: #e88a8a;
  border-color: #e88a8a;
}

/* ---------- 阅读庆祝印章 ---------- */
.read-stamp {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0) rotate(-15deg);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  z-index: 60;
  box-shadow: 0 8px 32px rgba(245, 184, 200, 0.3);
}

.read-stamp-text {
  font-size: 26px;
  letter-spacing: 4px;
  line-height: 1.2;
}

.read-stamp-sub {
  font-size: 11px;
  letter-spacing: 2px;
  margin-top: 4px;
  color: var(--text-soft);
}

.read-stamp.show {
  animation: stampShow 1.6s var(--ease) forwards;
}

@keyframes stampShow {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0) rotate(-15deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2) rotate(-8deg);
  }
  35% {
    transform: translate(-50%, -50%) scale(0.95) rotate(-12deg);
  }
  50%,
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-12deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.4) rotate(-12deg);
  }
}

/* 印章纸张背景 */
.read-stamp::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px dashed var(--accent);
  border-radius: 50%;
  opacity: 0.4;
}

/* ---------- 阅读页位置徽章 ---------- */
.position-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.position-badge strong {
  color: var(--accent);
  font-weight: 600;
}

/* 阅读页：已读标识 */
.reader.is-read .reader-title::before {
  content: "✓";
  display: inline-block;
  color: var(--accent);
  margin-right: 8px;
  font-size: 0.85em;
}
