/* ==========================================================================
   base.css — 重置、排版基础、Markdown 内容样式（GitHub 风格）
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-default);
  background: var(--bg-default);
  word-wrap: break-word;
  transition: background-color 0.2s ease, color 0.2s ease;
}

::selection {
  background: var(--accent-subtle);
}

a {
  color: var(--accent-fg);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

hr {
  height: 1px;
  margin: 24px 0;
  border: 0;
  background: var(--border-default);
}

/* --------------------------------------------------------------------------
   标题（GitHub markdown 风格：h1/h2 带底部分隔线）
   -------------------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 24px 0 16px;
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  font-size: 2em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-muted);
}

h2 {
  font-size: 1.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-muted);
}

h3 {
  font-size: 1.25em;
}

h4 {
  font-size: 1em;
}

h5 {
  font-size: 0.875em;
}

h6 {
  font-size: 0.85em;
  color: var(--fg-muted);
}

p {
  margin: 0 0 16px;
}

ul,
ol {
  margin: 0 0 16px;
  padding-left: 2em;
}

li + li {
  margin-top: 0.25em;
}

li > ul,
li > ol {
  margin-top: 0.25em;
  margin-bottom: 0;
}

/* GitHub 风格任务列表 */
li.task-list-item {
  list-style: none;
  margin-left: -1.4em;
}

li.task-list-item input[type="checkbox"] {
  margin-right: 0.5em;
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   代码（行内 + 代码块）
   -------------------------------------------------------------------------- */

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

:not(pre) > code {
  padding: 0.2em 0.4em;
  margin: 0;
  background: var(--code-bg);
  border-radius: var(--radius);
  white-space: break-spaces;
}

kbd {
  display: inline-block;
  padding: 3px 5px;
  font-size: 11px;
  line-height: 10px;
  color: var(--fg-default);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius);
}

pre {
  margin: 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 85%;
  line-height: 1.55;
  tab-size: 2;
}

pre code {
  display: block;
  padding: 16px;
  overflow: visible;
  background: transparent;
  border: 0;
  white-space: pre;
}

/* --------------------------------------------------------------------------
   引用
   -------------------------------------------------------------------------- */

blockquote {
  margin: 0 0 16px;
  padding: 0 1em;
  color: var(--fg-muted);
  border-left: 0.25em solid var(--border-default);
}

blockquote > :first-child {
  margin-top: 0;
}

blockquote > :last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   表格（GitHub markdown 表格）
   -------------------------------------------------------------------------- */

.table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  border-spacing: 0;
  border-collapse: collapse;
  width: max-content;
  max-width: 100%;
  font-size: 14px;
}

th,
td {
  padding: 6px 13px;
  border: 1px solid var(--border-default);
}

th {
  font-weight: 600;
  background: var(--bg-subtle);
}

tr:nth-child(2n) td {
  background: var(--bg-subtle);
}

tr {
  background: transparent;
}

/* --------------------------------------------------------------------------
   文章内容区（文档页 / 主页正文）
   -------------------------------------------------------------------------- */

.markdown-body {
  font-size: 16px;
  line-height: 1.6;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1:first-child {
  margin-top: 0;
}

/* 标题滚动定位补偿（吸顶导航高度） */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.doc-sec {
  scroll-margin-top: calc(var(--header-height) + 16px);
}

/* 标题悬停锚点（GitHub 风格链图标） */
.heading-anchor {
  position: relative;
}

.heading-anchor .anchor {
  position: absolute;
  left: -0.85em;
  width: 0.85em;
  padding-right: 4px;
  color: var(--fg-muted);
  opacity: 0;
  text-decoration: none;
  font-weight: 400;
}

.heading-anchor:hover .anchor,
.heading-anchor .anchor:focus {
  opacity: 1;
}

.heading-anchor .anchor:hover {
  text-decoration: none;
  color: var(--accent-fg);
}

/* --------------------------------------------------------------------------
   滚动条（贴近 GitHub）
   -------------------------------------------------------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-muted) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--bg-muted);
  border-radius: 4px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}