/* ==========================================================================
   GKD 视觉组完整教程页样式
   复用 site.css 的 :root 变量，保证与站点其它页面同一套画风。
   ========================================================================== */

/* 只调整教程正文区块的间距，页面上的导览段落沿用 site.css 的统一节奏 */
#vt-tutorial {
  padding: 52px 0 84px;
}

/* ---------------------------------------------------------------- 来源声明 */
.vt-attrib {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 34px;
  padding: 16px 20px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.vt-attrib b {
  color: var(--text);
  font-size: 14px;
}

.vt-attrib a {
  color: var(--orange);
  text-decoration: none;
}

.vt-attrib a:hover {
  color: var(--yellow);
}

/* ------------------------------------------------------------ 侧栏 + 正文 */
.vt-layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 46px;
  align-items: start;
}

.vt-sidebar {
  position: sticky;
  top: 22px;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}

.vt-sidebar::-webkit-scrollbar {
  width: 7px;
}

.vt-sidebar::-webkit-scrollbar-track {
  background: #120d20;
}

.vt-sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--blue), var(--orange));
  border-radius: 8px;
}

.vt-toc-title {
  font: 700 13px 'Barlow Condensed';
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 12px;
}

.vt-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}

.vt-toc-list li {
  margin: 0;
}

.vt-toc-list a {
  display: block;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color .15s, border-color .15s, background .15s;
}

.vt-toc-list a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .03);
}

.vt-toc-list li.lvl-2 > a {
  font-weight: 700;
  color: var(--text);
  font-size: 13.5px;
  margin-top: 9px;
}

.vt-toc-list li.lvl-3 > a {
  padding-left: 20px;
}

.vt-toc-list li.lvl-4 > a {
  padding-left: 32px;
  font-size: 12.5px;
  color: #8f87a3;
}

.vt-toc-list a.is-active {
  color: var(--orange);
  border-left-color: var(--orange);
  background: rgba(255, 40, 117, .07);
}

.vt-to-top {
  display: inline-block;
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.vt-to-top:hover {
  color: var(--orange);
}

/* ---------------------------------------------------------------- 正文排版 */
.vt-content {
  min-width: 0;
  font-size: 16px;
  line-height: 1.9;
  color: var(--muted);
}

.vt-content > *:first-child {
  margin-top: 0;
}

.vt-content h2,
.vt-content h3,
.vt-content h4,
.vt-content h5,
.vt-content h6 {
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -.02em;
  scroll-margin-top: 26px;
}

.vt-content h2 {
  font-size: clamp(27px, 3.4vw, 40px);
  margin: 74px 0 20px;
  padding-top: 26px;
  border-top: 1px solid rgba(255, 255, 255, .09);
}

.vt-content h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.vt-content h3 {
  font-size: clamp(21px, 2.3vw, 27px);
  margin: 50px 0 16px;
  padding-left: 14px;
  border-left: 3px solid var(--orange);
}

.vt-content h4 {
  font-size: 19px;
  margin: 36px 0 12px;
}

.vt-content h4:before {
  content: "▍";
  color: var(--blue);
  margin-right: 6px;
}

.vt-content h5 {
  font-size: 16.5px;
  margin: 28px 0 10px;
  color: #ded7ee;
}

.vt-content h6 {
  font-size: 15px;
  margin: 22px 0 8px;
  color: var(--muted);
}

.vt-content p {
  margin: 0 0 17px;
}

.vt-content strong {
  color: var(--text);
  font-weight: 700;
}

.vt-content em {
  color: #ded7ee;
}

.vt-content a {
  color: var(--orange);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 40, 117, .35);
  word-break: break-word;
}

.vt-content a:hover {
  color: var(--yellow);
  border-bottom-color: var(--yellow);
}

.vt-content del {
  color: #6f6880;
}

.vt-content mark {
  background: rgba(255, 228, 94, .16);
  color: var(--yellow);
  padding: 0 3px;
}

.vt-content hr {
  border: 0;
  height: 1px;
  margin: 48px 0;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

/* -------------------------------------------------------------- 列表 */
.vt-content ul,
.vt-content ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.vt-content li {
  margin: 7px 0;
}

.vt-content li::marker {
  color: var(--orange);
}

.vt-content ul ul,
.vt-content ol ol,
.vt-content ul ol,
.vt-content ol ul {
  margin: 7px 0 4px;
}

/* -------------------------------------------------------------- 引用块 */
.vt-content blockquote {
  margin: 20px 0;
  padding: 14px 20px;
  background: rgba(123, 92, 255, .07);
  border-left: 3px solid var(--blue);
  color: #c6bfd8;
}

.vt-content blockquote p:last-child {
  margin-bottom: 0;
}

.vt-content blockquote blockquote {
  margin: 12px 0 0;
  background: rgba(123, 92, 255, .06);
}

/* -------------------------------------------------------------- 完成清单 */
.vt-content .task-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
}

.vt-content .task-list-item {
  display: block;
  position: relative;
  margin: 8px 0;
  padding: 12px 16px 12px 44px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.65;
  transition: border-color .15s, color .15s;
}

.vt-content .task-list-item:hover {
  border-color: var(--orange);
  color: var(--text);
}

.vt-content .task-list-item input[type="checkbox"] {
  position: absolute;
  left: 16px;
  top: 15px;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--orange);
  cursor: default;
}

/* -------------------------------------------------------------- 图片 */
.vt-fig {
  margin: 26px 0;
}

.vt-content img.vt-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #08060d;
  border: 1px solid var(--line);
}

.vt-fig-bare {
  margin: 24px 0;
}

.vt-content figcaption,
.vt-content .vt-cap {
  margin: 10px auto 0;
  max-width: 760px;
  text-align: center;
  font-size: 13px;
  line-height: 1.75;
  color: #8f87a3;
}

.vt-content .vt-cap {
  margin: 10px 0 20px;
}

/* -------------------------------------------------------------- 表格 */
.vt-content table {
  width: 100%;
  margin: 22px 0;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

.vt-content th,
.vt-content td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.vt-content th {
  color: var(--yellow);
  font-size: 13px;
}

.vt-content td {
  color: var(--muted);
}

/* -------------------------------------------------------------- 代码 */
.vt-content pre.vt-code {
  margin: 22px 0;
  padding: 16px 18px;
  background: #0a0812;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
}

.vt-content pre.vt-code code {
  font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
  color: #b9f3ea;
  background: none;
  padding: 0;
}

.vt-content code {
  padding: 2px 6px;
  background: #17111f;
  border: 1px solid var(--line);
  font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
  font-size: 13.5px;
  color: var(--green);
}

/* -------------------------------------------------------------- 公式 */
.vt-math-block {
  margin: 22px 0;
  padding: 14px 10px;
  background: rgba(123, 92, 255, .05);
  border: 1px solid rgba(123, 92, 255, .18);
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  color: var(--text);
}

.vt-math {
  color: var(--text);
}

.vt-content .katex {
  font-size: 1.04em;
}

.vt-content .katex-display {
  margin: 0;
}

/* -------------------------------------------------------------- 响应式 */
@media (max-width: 1040px) {
  .vt-layout {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .vt-sidebar {
    position: static;
    max-height: none;
    padding: 0;
  }

  .vt-toc-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 14px 18px;
  }

  .vt-toc-wrap > summary {
    cursor: pointer;
    font: 700 13px 'Barlow Condensed';
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--orange);
    list-style: none;
  }

  .vt-toc-wrap > summary::-webkit-details-marker {
    display: none;
  }

  .vt-toc-wrap > summary:after {
    content: " ▾";
  }

  .vt-toc-wrap[open] > summary:after {
    content: " ▴";
  }

  /* 窄屏用 <summary> 当标题，桌面端那行标题就隐藏 */
  .vt-toc-wrap > .vt-toc-title {
    display: none;
  }

  .vt-toc-list {
    margin-top: 12px;
    max-height: 46vh;
    overflow-y: auto;
  }
}

@media (min-width: 1041px) {
  .vt-toc-wrap > summary {
    display: none;
  }
}

@media (max-width: 800px) {
  #vt-tutorial {
    padding: 34px 0 58px;
  }

  .vt-content {
    font-size: 15.5px;
  }

  .vt-content h2 {
    margin-top: 56px;
    padding-top: 20px;
  }

  .vt-content h3 {
    margin-top: 38px;
  }

  .vt-attrib {
    font-size: 12.5px;
  }
}

/* ------------------------------------------------- 窄屏：公式横向可滚 */
.vt-content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 2px;
  -webkit-overflow-scrolling: touch;
}

.vt-content .katex-display > .katex {
  white-space: nowrap;
}

.vt-content .katex-display::-webkit-scrollbar {
  height: 6px;
}

.vt-content .katex-display::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 6px;
}

/* 窄屏表格：允许横向滑动而不是撑破布局 */
@media (max-width: 800px) {
  .vt-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 800px) {
  /* 代码块：字号收一档，长命令尽量少横滑 */
  .vt-content pre.vt-code {
    font-size: 12px;
    padding: 13px 14px;
    line-height: 1.6;
  }
  .vt-content code { font-size: 12.5px; }

  /* 公式：整体缩一档，宽公式仍可横滑 */
  .vt-content .katex { font-size: .93em; }
  .vt-math-block { padding: 12px 8px; margin: 18px 0; }

  /* 目录与正文的间距 */
  .vt-content h2 { margin-top: 34px; }
  .vt-content h3 { margin-top: 26px; }

  /* 图片不再溢出 */
  .vt-fig img, .vt-img { max-width: 100%; height: auto; }
}

/* ------------------------------------------------- 长 token 不撑破正文 */
/* 内联代码、文件路径、渲染失败的 TeX 都是不可断长串，窄屏会顶宽整页 */
.vt-content {
  overflow-wrap: break-word;
}

.vt-content code,
.vt-content a,
.vt-content .katex-error,
.vt-content .vt-math {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 渲染失败的公式（原样 TeX）单独给个可横滑的框，别拖累版面 */
.vt-content .katex-error {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: bottom;
  color: #ff8aa8;
}

/* 正文里的裸长链接 */
.vt-content p a,
.vt-content li a {
  word-break: break-all;
}
