/* ============================================================
   classics-philosophy.css
   三语版（四把尺子理论·儒家 / 法家 / 佛家）共享样式
   主题、字号与工具栏仍由 main.css 提供；本文件只补三语版
   独立长文阅读所需的版式、目录与组件样式。
   ============================================================ */

:root {
  --phil-content-max: 880px;
  --phil-sidebar-w: 280px;
  --phil-gutter: 24px;
  --phil-radius: 10px;
  --phil-border-w: 1px;
  --phil-pill-bg: var(--pill-bg, #eef2ff);
  --phil-pill-text: var(--pill-text, #3754b5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC",
    "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: calc(16px * var(--font-scale, 1.08));
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

main { display: block; padding: 0; }

.layout-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  display: grid;
  grid-template-columns: var(--phil-sidebar-w) 1fr;
  gap: var(--phil-gutter);
  align-items: start;
}

@media (max-width: 980px) {
  .layout-container {
    grid-template-columns: 1fr;
    padding: 16px 14px 56px;
  }
  .sidebar { position: static !important; max-height: none !important; }
}

/* ============= 侧边栏（目录） ============= */
.sidebar {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel-bg);
  border: var(--phil-border-w) solid var(--panel-border);
  border-radius: var(--phil-radius);
  padding: 14px 14px 12px;
  font-size: 0.92em;
  box-shadow: var(--shadow);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

.sidebar-title {
  margin: 0;
  font-size: 1.02em;
  letter-spacing: 0.04em;
  color: var(--text);
}

.sidebar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sidebar-actions button,
.sidebar-actions a {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.82em;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.6;
}

.sidebar-actions button:hover,
.sidebar-actions a:hover { color: var(--text); border-color: var(--link); }

.sidebar-note {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.82em;
  line-height: 1.5;
}

.toc-mode-status {
  color: var(--muted);
  font-size: 0.8em;
  margin-bottom: 8px;
}

.toc-tree, .toc-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-tree li { line-height: 1.7; }

.toc-item-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toc-spacer { display: inline-block; width: 18px; }

.toc-toggle {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: monospace;
  width: 18px;
  height: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  border-radius: 4px;
}

.toc-toggle:hover { background: var(--panel-border); color: var(--text); }

.toc-tree a {
  display: block;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.94em;
  word-break: break-word;
}

.toc-tree a:hover { color: var(--link); background: var(--code-bg); }

.toc-tree a.is-active { color: var(--link); font-weight: 600; }

.toc-h1 { font-weight: 600; }
.toc-h2 { padding-left: 8px; }
.toc-h3 { padding-left: 16px; }
.toc-h4 { padding-left: 24px; font-size: 0.9em; }

.toc-children[hidden] { display: none; }

.toc-current > .toc-item-row > a { color: var(--link); }
.toc-ancestor > .toc-item-row > a { color: var(--text); }

/* ============= 内容区 ============= */
.content-area {
  background: var(--panel-bg);
  border: var(--phil-border-w) solid var(--panel-border);
  border-radius: var(--phil-radius);
  padding: 28px 36px 40px;
  box-shadow: var(--shadow);
  min-width: 0;
}

@media (max-width: 720px) {
  .content-area { padding: 20px 18px 30px; }
}

.content-area header {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.content-area header h1 {
  font-size: 1.8em;
  line-height: 1.35;
  margin: 6px 0 8px;
  letter-spacing: 0.02em;
}

.content-area header .small {
  color: var(--muted);
  font-size: 0.85em;
}

.content-area header .note {
  color: var(--muted);
  font-size: 0.95em;
  margin: 6px 0 0;
}

.content-area header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 14px;
  font-size: 0.92em;
}

.content-area header nav a,
.content-area header nav button {
  display: inline-block;
  background: var(--code-bg);
  color: var(--link);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 4px 10px;
  text-decoration: none;
  font-size: 0.9em;
  cursor: pointer;
}

.content-area header nav a:hover,
.content-area header nav button:hover {
  background: var(--bg);
  border-color: var(--link);
}

.content-area .panel {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 24px;
}

.content-area .panel h2 {
  margin: 0 0 10px;
  font-size: 1.05em;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.content-area .panel .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.content-area .panel .card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92em;
  line-height: 1.6;
}

.content-area .panel .eyebrow {
  display: block;
  color: var(--link);
  font-size: 0.85em;
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ============= 文章正文 ============= */
article { font-size: 1em; }

article h1, article h2, article h3, article h4, article h5, article h6 {
  color: var(--text);
  line-height: 1.4;
  letter-spacing: 0.01em;
  scroll-margin-top: 16px;
}

article h1 {
  font-size: 1.7em;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
  margin: 36px 0 18px;
}

article h2 {
  font-size: 1.42em;
  margin: 32px 0 14px;
  padding-left: 10px;
  border-left: 4px solid var(--link);
}

article h3 {
  font-size: 1.18em;
  margin: 26px 0 10px;
  color: var(--text);
}

article h4 {
  font-size: 1.05em;
  margin: 22px 0 8px;
  color: var(--muted);
}

article h5 {
  font-size: 1em;
  margin: 18px 0 6px;
  color: var(--muted);
}

article p {
  margin: 12px 0;
  text-align: justify;
  text-justify: inter-character;
}

article strong { color: var(--text); font-weight: 700; }
article em { color: var(--text); font-style: italic; }

article blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  background: var(--bg);
  border-left: 4px solid var(--link);
  color: var(--muted);
  border-radius: 0 6px 6px 0;
}

article blockquote p { margin: 6px 0; }

article ul, article ol {
  margin: 12px 0;
  padding-left: 28px;
}

article li { margin: 4px 0; }

article code {
  background: var(--code-bg);
  color: var(--pill-text);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", "Menlo", monospace;
  font-size: 0.9em;
}

article pre {
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow: auto;
  font-size: 0.92em;
  line-height: 1.6;
}

article pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
}

article table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.94em;
  background: var(--panel-bg);
}

article th, article td {
  border: 1px solid var(--panel-border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

article th { background: var(--bg); color: var(--text); font-weight: 600; }

article hr {
  border: 0;
  border-top: 1px dashed var(--panel-border);
  margin: 24px 0;
}

article a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}

article a:hover { border-bottom-color: var(--link); }

/* ============= 复制提示 ============= */
.copy-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--toast-bg);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.9em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  z-index: 9999;
}

.copy-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============= 回到顶部 ============= */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99;
  font-size: 18px;
  line-height: 1;
}

.to-top.is-visible { display: flex; }
.to-top:hover { color: var(--link); border-color: var(--link); }

/* ============= 字号/主题工具栏（在 main.css 中定义基础，这里微调） ============= */
.font-zoom {
  position: fixed;
  right: 16px;
  bottom: 76px;
  z-index: 98;
  background: var(--tool-bg);
  color: var(--text);
  border: 1px solid var(--tool-border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.88em;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 168px;
}

.font-zoom .tool-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.font-zoom-label {
  font-weight: 600;
  font-size: 0.92em;
  letter-spacing: 0.04em;
}

.panel-toggle {
  background: transparent;
  border: 1px solid var(--tool-border);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.82em;
  cursor: pointer;
}

.panel-toggle:hover { color: var(--text); border-color: var(--link); }

.tool-panel-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.font-zoom[data-collapsed="true"] .tool-panel-body { display: none; }

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0;
  border-top: 1px solid var(--panel-border);
}

.tool-group:first-of-type { border-top: 0; padding-top: 0; }

.tool-group-title {
  color: var(--muted);
  font-size: 0.82em;
  letter-spacing: 0.04em;
}

.tool-button-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tool-button-row.two-column { display: grid; grid-template-columns: 1fr 1fr; }

.tool-button-row button,
.tool-group select,
.tool-group button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.86em;
  cursor: pointer;
  text-align: center;
}

.tool-button-row button:hover,
.tool-group select:hover,
.tool-group button:hover { border-color: var(--link); color: var(--link); }

.tool-group select { width: 100%; }

.tool-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86em;
  color: var(--text);
  cursor: pointer;
}

.tool-check input { accent-color: var(--link); }

.tool-group-note {
  color: var(--muted);
  font-size: 0.8em;
  line-height: 1.5;
}

/* 收起到极简图标 */
.font-zoom[data-collapsed="true"] {
  min-width: 0;
  padding: 6px 10px;
}
.font-zoom[data-collapsed="true"] .tool-panel-head { gap: 4px; }

/* ============= 标签 / 卡片 ============= */
.eyebrow {
  display: inline-block;
  background: var(--phil-pill-bg);
  color: var(--phil-pill-text);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78em;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 12px;
}

/* ============= 打印 ============= */
@media print {
  .sidebar, .font-zoom, .to-top, .copy-toast, .content-area header nav { display: none !important; }
  .layout-container { grid-template-columns: 1fr; padding: 0; }
  .content-area { border: 0; box-shadow: none; padding: 0; }
  body { font-size: 12pt; }
  article h2 { page-break-after: avoid; }
}
