/* ============================
   doc.css - 教程文档页样式
   ============================ */

.doc-layout {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--page-pad-top) 20px 24px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

/* 侧栏 */
.doc-sidebar {
  position: sticky;
  top: calc(var(--navbar-height) + 24px);
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-sidebar-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  padding: 8px 14px 12px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 6px;
}

.doc-sidebar-item {
  display: block;
  padding: 10px 14px;
  font-size: .85rem;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.5;
}

.doc-sidebar-item:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.doc-sidebar-item.active {
  background: var(--bg-elevated);
  color: var(--accent);
  font-weight: 600;
}

/* 侧栏二级目录（当前页章节） */
.doc-sidebar-sub {
  display: block;
  padding: 7px 14px 7px 28px;
  font-size: .8rem;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.45;
}

.doc-sidebar-sub.lvl-3 {
  padding-left: 42px;
  font-size: .76rem;
}

.doc-sidebar-sub:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.doc-sidebar-sub.active {
  background: var(--bg-elevated);
  color: var(--accent);
  font-weight: 600;
}

/* 标题锚点定位时补偿吸顶导航高度 */
.doc-article h1,
.doc-article h2,
.doc-article h3,
.doc-article h4 {
  scroll-margin-top: calc(var(--navbar-height) + 20px);
}

/* 内容区 */
.doc-content {
  flex: 1;
  min-width: 0;
}

.doc-loading,
.doc-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: .95rem;
}

/* Markdown 渲染 */
.doc-article {
  color: var(--text);
  font-size: .92rem;
  line-height: 1.8;
}

.doc-article h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.doc-article h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 32px 0 16px;
  color: var(--text);
}

.doc-article h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 24px 0 12px;
}

.doc-article p {
  margin: 12px 0;
}

.doc-article a {
  color: var(--accent);
  text-decoration: none;
}

.doc-article a:hover {
  text-decoration: underline;
}

.doc-article blockquote {
  margin: 16px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--accent);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--text-secondary);
}

.doc-article blockquote p {
  margin: 6px 0;
}

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

.doc-article li {
  margin: 6px 0;
}

.doc-article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 16px 0;
  display: block;
}

.doc-article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.doc-article strong {
  font-weight: 700;
  color: var(--text);
}

.doc-article code {
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: .85em;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border-radius: 4px;
}

.doc-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

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

.doc-article th {
  background: var(--bg-elevated);
  font-weight: 700;
}

/* 响应式 */
@media (max-width: 768px) {
  .doc-layout {
    flex-direction: column;
    padding: 16px;
  }

  .doc-sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .doc-sidebar-title {
    width: 100%;
    border-bottom: none;
    margin-bottom: 0;
  }

  .doc-sidebar-item {
    width: auto;
  }
}
