/**
 * 增强的Markdown渲染样式 - 与网站整体风格保持一致
 */

/* 基础文本样式 */
.article-content {
  font-size: 1.05rem;
  line-height: 1.7;
  color: #374151;
}

.dark .article-content {
  color: #e5e7eb;
}

/* 标题样式 */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.75em;
  position: relative;
}

.article-content h1 {
  font-size: 2.25rem;
  margin-top: 1em;
  margin-bottom: 1em;
  color: #111827;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.dark .article-content h1 {
  color: #f9fafb;
  border-color: #374151;
}

.article-content h2 {
  font-size: 1.875rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.375rem;
  color: #1f2937;
  margin-top: 2.5rem;
}

.dark .article-content h2 {
  border-color: #374151;
  color: #f3f4f6;
}

.article-content h2::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.5rem;
  background: linear-gradient(to right, #3b82f6, #4f46e5);
  border-radius: 50%;
}

.article-content h3 {
  font-size: 1.5rem;
  color: #1f2937;
  margin-top: 2rem;
}

.dark .article-content h3 {
  color: #f3f4f6;
}

.article-content h3::before {
  content: "#";
  color: #3b82f6;
  margin-right: 0.5rem;
  opacity: 0.7;
  font-weight: 400;
}

.article-content h4 {
  font-size: 1.25rem;
  color: #1f2937;
}

.dark .article-content h4 {
  color: #f3f4f6;
}

.article-content h5 {
  font-size: 1.125rem;
  color: #1f2937;
}

.dark .article-content h5 {
  color: #f3f4f6;
}

.article-content h6 {
  font-size: 1rem;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dark .article-content h6 {
  color: #d1d5db;
}

/* 段落样式 */
.article-content p {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* 强调和加粗 */
.article-content strong,
.article-content b {
  font-weight: 700;
  color: #111827;
}

.dark .article-content strong,
.dark .article-content b {
  color: #f9fafb;
}

.article-content em,
.article-content i {
  font-style: italic;
}

/* 引用块 */
.article-content blockquote {
  border-left: 4px solid;
  border-image: linear-gradient(to bottom, #3b82f6, #4f46e5) 1;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background-color: #f0f7ff;
  border-radius: 0 0.5rem 0.5rem 0;
  color: #4b5563;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.dark .article-content blockquote {
  background-color: rgba(59, 130, 246, 0.1);
  color: #d1d5db;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.article-content blockquote p:first-of-type {
  margin-top: 0;
}

.article-content blockquote p:last-of-type {
  margin-bottom: 0;
}

/* 列表样式 */
.article-content ul,
.article-content ol {
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.article-content ul {
  list-style-type: none;
}

.article-content ul li {
  position: relative;
  padding-left: 0.5rem;
}

.article-content ul li::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 0.6rem;
  width: 0.375rem;
  height: 0.375rem;
  background: linear-gradient(to right, #3b82f6, #4f46e5);
  border-radius: 50%;
}

.article-content ol {
  list-style-type: decimal;
  counter-reset: item;
}

.article-content ol li {
  counter-increment: item;
}

.article-content li {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.article-content li > ul,
.article-content li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

/* 任务列表 */
.article-content ul.task-list {
  list-style-type: none;
  padding-left: 0;
}

.article-content ul.task-list li {
  display: flex;
  align-items: flex-start;
  margin: 0.5rem 0;
  padding-left: 0;
}

.article-content ul.task-list li::before {
  display: none;
}

.article-content ul.task-list li input[type="checkbox"] {
  margin-right: 0.5rem;
  margin-top: 0.25rem;
}

/* 表格样式 */
.article-content table {
  width: 100%;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.article-content thead {
  background: linear-gradient(to right, #3b82f6, #4f46e5);
}

.article-content th {
  color: white;
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
}

.dark .article-content th {
  color: #f9fafb;
}

.article-content td {
  padding: 0.75rem 1rem;
  border-top: 1px solid #e5e7eb;
}

.dark .article-content td {
  border-color: #4b5563;
}

.article-content tr:nth-child(even) {
  background-color: #f9fafb;
}

.dark .article-content tr:nth-child(even) {
  background-color: #283141;
}

.article-content table tr:hover {
  background-color: #f0f7ff;
}

.dark .article-content table tr:hover {
  background-color: rgba(59, 130, 246, 0.1);
}

/* 水平线 */
.article-content hr {
  margin: 2rem 0;
  border: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, #3b82f6, transparent);
}

.dark .article-content hr {
  background: linear-gradient(to right, transparent, #4f46e5, transparent);
}

/* 图片 */
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
  margin: 1.5rem auto;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.article-content img:hover {
  transform: scale(1.01);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* 链接样式 */
.article-content a {
  color: #3b82f6;
  text-decoration: none;
  border-bottom: 1px dashed #3b82f6;
  transition: color 0.2s, border-color 0.2s;
}

.article-content a:hover {
  color: #4f46e5;
  border-bottom: 1px solid #4f46e5;
}

.dark .article-content a {
  color: #60a5fa;
  border-bottom-color: #60a5fa;
}

.dark .article-content a:hover {
  color: #93c5fd;
  border-bottom-color: #93c5fd;
}

/* 脚注 */
.article-content .footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.875rem;
  color: #6b7280;
}

.dark .article-content .footnotes {
  border-color: #4b5563;
  color: #9ca3af;
}

.article-content .footnote-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  background: linear-gradient(to right, #3b82f6, #4f46e5);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  text-decoration: none;
  margin: 0 0.125rem;
  vertical-align: super;
  line-height: 1;
}

.dark .article-content .footnote-ref {
  background: linear-gradient(to right, #60a5fa, #818cf8);
}

.article-content .footnote-backref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #3b82f6;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.article-content .footnote-backref:hover {
  color: #4f46e5;
}

/* 定义列表 */
.article-content dl {
  margin: 1.5rem 0;
  padding: 0 1rem;
}

.article-content dt {
  font-weight: 700;
  color: #111827;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.dark .article-content dt {
  color: #f9fafb;
}

.article-content dd {
  margin-left: 1.5rem;
  color: #4b5563;
}

/* KBD 样式 */
.article-content kbd {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  color: #1f2937;
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  box-shadow: 
    0 1px 0 rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  vertical-align: middle;
  margin: 0 0.25rem;
}

.dark .article-content kbd {
  color: #f9fafb;
  background-color: #374151;
  border-color: #4b5563;
  box-shadow: 
    0 1px 0 rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 删除线和标记 */
.article-content del,
.article-content s {
  text-decoration: line-through;
  color: #6b7280;
}

.dark .article-content del,
.dark .article-content s {
  color: #9ca3af;
}

.article-content mark {
  background: linear-gradient(120deg, rgba(255, 226, 89, 0.5) 0%, rgba(255, 167, 81, 0.5) 100%);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
}

.dark .article-content mark {
  background: linear-gradient(120deg, rgba(255, 226, 89, 0.2) 0%, rgba(255, 167, 81, 0.2) 100%);
  color: #f3f4f6;
}

/* 代码块样式 */
.article-content pre {
  border-radius: 0.75rem;
  margin: 1.5rem 0;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.article-content pre code {
  display: block;
  padding: 1rem;
  overflow-x: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.6;
}

.article-content code:not([class*="language-"]) {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.875rem;
  background-color: #f3f4f6;
  color: #3b82f6;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
}

.dark .article-content code:not([class*="language-"]) {
  background-color: #1f2937;
  color: #60a5fa;
}

/* Mermaid 图表样式 */
.article-content .mermaid {
  margin: 2rem auto;
  overflow-x: auto;
  text-align: center;
  max-width: 100%;
  background-color: #f9fafb;
  padding: 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.dark .article-content .mermaid {
  background-color: #1f2937;
  filter: brightness(0.9);
}

.article-content .mermaid svg {
  max-width: 100%;
  height: auto !important;
  margin: 0 auto;
}

/* KaTeX 数学公式样式 */
.article-content .katex-display {
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  background-color: #f9fafb;
  border-radius: 0.75rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dark .article-content .katex-display {
  background-color: #1f2937;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.article-content .katex {
  font-size: 1.1em;
}

.article-content .katex-display > .katex {
  display: block;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

/* 确保行内公式适当显示 */
.article-content .katex-inline {
  display: inline-block;
  vertical-align: middle;
}

/* 目录样式 */
nav#TableOfContents {
  font-size: 0.875rem;
  line-height: 1.6;
  overflow: visible;
}

nav#TableOfContents ul {
  list-style-type: none;
  padding-left: 1rem;
  margin: 0.5rem 0;
}

nav#TableOfContents > ul {
  padding-left: 0;
}

nav#TableOfContents li {
  margin: 0.25rem 0;
  position: relative;
}

nav#TableOfContents a {
  display: block;
  padding: 0.375rem 0.75rem;
  color: #4b5563;
  text-decoration: none;
  border-radius: 0.375rem;
  transition: all 0.2s;
  border-left: 2px solid transparent;
  word-break: break-word;
  overflow-wrap: break-word;
}

.dark nav#TableOfContents a {
  color: #9ca3af;
}

nav#TableOfContents a:hover {
  background-color: #f3f4f6;
  color: #3b82f6;
  border-left-color: #3b82f6;
}

.dark nav#TableOfContents a:hover {
  background-color: #1f2937;
  color: #60a5fa;
  border-left-color: #60a5fa;
}

nav#TableOfContents a.active {
  background: linear-gradient(to right, #3b82f6, #4f46e5);
  color: white;
  font-weight: 500;
}

.dark nav#TableOfContents a.active {
  background: linear-gradient(to right, #60a5fa, #818cf8);
}

/* 添加目录层级缩进样式 */
nav#TableOfContents ul ul {
  margin-left: 0.25rem;
  border-left: 1px dashed #e5e7eb;
}

.dark nav#TableOfContents ul ul {
  border-left: 1px dashed #374151;
}

/* 移动端目录优化 */
@media (max-width: 1023px) {
  nav#TableOfContents {
    padding-bottom: 20px;
    font-size: 0.9rem;
  }
  
  nav#TableOfContents ul {
    padding-left: 0.75rem;
  }
  
  nav#TableOfContents a {
    padding: 0.6rem 0.5rem;
  }
  
  /* 确保最后一个项目有足够的底部间距 */
  nav#TableOfContents ul:last-child {
    margin-bottom: 1rem;
  }

  /* 增强移动端上的可点击区域 */
  nav#TableOfContents a {
    margin-bottom: 0.25rem;
  }

  /* 使最后一个链接和底部有足够的距离 */
  nav#TableOfContents li:last-child {
    margin-bottom: 1rem;
  }
} 