/* Ledon 文档主题：在 docfx modern 模板之上的排版与导航微调。
   docfx 会把本文件合并到 public/main.css，并在 docfx.min.css 之后加载。 */

:root {
  --bs-body-font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --bs-body-font-size: 1.0625rem;
  --bs-body-line-height: 1.8;
  --bs-font-monospace: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, "SFMono-Regular", Menlo, monospace;
  --ledon-content-width: 50rem;
  --ledon-toc-width: 18rem;
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 正文 ---------- */

body[data-layout=""] > main > .content > article,
body[data-layout=conceptual] > main > .content > article,
body[data-layout=landing] > main > .content > article {
  width: 100%;
  max-width: var(--ledon-content-width);
}

article p,
article li {
  line-height: 1.85;
}

article h1,
article h2,
article h3,
article h4,
article h5 {
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--bs-heading-color);
}

article h1 {
  margin-bottom: 1.25rem;
  font-size: 2.1rem;
}

article h2 {
  margin-top: 2.6rem;
  margin-bottom: .9rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--bs-border-color);
  font-size: 1.55rem;
}

article h3 {
  margin-top: 1.9rem;
  margin-bottom: .65rem;
  font-size: 1.22rem;
}

article h4 {
  margin-top: 1.5rem;
  margin-bottom: .5rem;
  font-size: 1.06rem;
}

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

article a {
  text-underline-offset: .2em;
}

article ul,
article ol {
  padding-left: 1.5rem;
}

article li + li {
  margin-top: .3rem;
}

/* 行内代码 */
article :not(pre) > code {
  padding: .15em .4em;
  border: 1px solid var(--bs-border-color-translucent);
  border-radius: .3rem;
  background: var(--bs-tertiary-bg);
  color: var(--bs-emphasis-color);
  font-size: .86em;
  word-break: break-word;
}

/* 代码块 */
article pre {
  margin: 1.25rem 0;
  border: 1px solid var(--bs-border-color);
  border-radius: .55rem;
  overflow: hidden;
}

article pre code.hljs {
  padding: 1rem 1.15rem;
  font-size: .9rem;
  line-height: 1.65;
}

/* 表格 */
article table {
  width: 100%;
  margin: 1.3rem 0;
  font-size: .95rem;
}

article table th,
article table td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--bs-border-color);
  vertical-align: top;
}

article table thead th {
  border-bottom: 2px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  font-weight: 600;
  white-space: nowrap;
}

article table tbody tr:hover {
  background: var(--bs-tertiary-bg);
}

/* 引用与图片 */
article blockquote {
  margin: 1.25rem 0;
  padding: .8rem 1.1rem;
  border-left: .25rem solid var(--bs-primary);
  border-radius: 0 .4rem .4rem 0;
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
}

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

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

/* ---------- 左侧目录 ---------- */

@media (min-width: 768px) {
  .toc-offcanvas {
    flex: 0 0 var(--ledon-toc-width);
    max-width: var(--ledon-toc-width);
  }
}

.toc-offcanvas {
  padding-right: .5rem;
  border-right: 1px solid var(--bs-border-color);
}

#toc {
  font-size: .93rem;
}

#toc .filter {
  margin: .25rem 0 .75rem;
}

#toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#toc ul ul {
  padding-left: .85rem;
}

#toc li {
  margin: 0;
}

#toc a {
  display: block;
  padding: .38rem .6rem;
  border-left: 2px solid transparent;
  border-radius: .375rem;
  color: var(--bs-body-color);
  line-height: 1.5;
}

#toc a:hover {
  background: var(--bs-tertiary-bg);
  color: var(--bs-emphasis-color);
}

#toc li.active > a {
  border-left-color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  font-weight: 600;
}

/* 单层 toc.yml 同时被用作顶部导航，这里统一改为左侧目录，避免顶部堆满长标题。 */
#navbar > .navbar-nav {
  display: none !important;
}

/* ---------- 顶部导航与页脚 ---------- */

.navbar-brand {
  font-weight: 600;
  letter-spacing: .01em;
}

.navbar-brand img {
  width: auto;
  height: 1.6rem;
  margin-right: .4rem;
}

/* 右侧 “In this article” */
.affix {
  font-size: .875rem;
}

.affix h5 {
  margin-bottom: .5rem;
  color: var(--bs-secondary-color);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

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

.affix a {
  display: block;
  padding: .2rem 0 .2rem .75rem;
  border-left: 2px solid var(--bs-border-color);
  color: var(--bs-secondary-color);
  text-decoration: none;
}

.affix a:hover {
  border-left-color: var(--bs-primary);
  color: var(--bs-emphasis-color);
}

.contribution {
  margin-top: 2rem;
  font-size: .9rem;
}

footer {
  font-size: .875rem;
}

footer .flex-fill {
  padding: 1rem 0;
}

/* ---------- 可访问性与打印 ---------- */

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

@media (max-width: 767.98px) {
  .toc-offcanvas {
    padding-right: 0;
    border-right: 0;
  }

  article h1 {
    font-size: 1.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  header,
  .toc-offcanvas,
  .affix,
  .contribution,
  .next-article {
    display: none !important;
  }
}
