@import "./articles-table.css";
@import "./articles-mermaid.css";
@import "./articles-code.css";

/* 增强列表样式 */
.prose ul {
  list-style-type: disc;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  padding-left: 1.625em;
}

.prose ul li {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  padding-left: 0.375em;
}

.prose ul li::marker {
  color: #6b7280;
}

.prose ul li ul {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.prose ol {
  list-style-type: decimal;
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  padding-left: 1.625em;
}

.prose ol li {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  padding-left: 0.375em;
}

.prose ol li::marker {
  color: #6b7280;
}

/* 标题样式 */
.prose h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--color-secondary-900);
  border-bottom: 1px solid var(--color-secondary-200);
  padding-bottom: 0.5rem;
  position: relative;
}

.prose h1::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100px;
  height: 3px;
  background: linear-gradient(to right, var(--color-primary-600), var(--color-primary-400));
  border-radius: 3px;
}

.prose h2 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1.25rem;
  color: var(--color-secondary-900);
  border-bottom: 1px solid var(--color-secondary-200);
  padding-bottom: 0.25rem;
  position: relative;
}

.prose h2::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 75px;
  height: 2px;
  background: linear-gradient(to right, var(--color-primary-500), var(--color-primary-300));
  border-radius: 2px;
}

.prose h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 1rem;
  color: var(--color-secondary-900);
  position: relative;
  padding-left: 1rem;
}

.prose h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.25em;
  height: 1em;
  width: 4px;
  background: linear-gradient(to bottom, var(--color-primary-500), var(--color-primary-300));
  border-radius: 2px;
}

.prose h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-secondary-900);
}

.prose h5 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--color-secondary-900);
}

.prose h6 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--color-secondary-700);
}

/* 标题锚点样式 */
.prose h1 .anchor,
.prose h2 .anchor,
.prose h3 .anchor,
.prose h4 .anchor,
.prose h5 .anchor,
.prose h6 .anchor {
  visibility: hidden;
  margin-left: 0.5rem;
  color: #a0aec0;
  text-decoration: none;
}

.prose h1:hover .anchor,
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose h4:hover .anchor,
.prose h5:hover .anchor,
.prose h6:hover .anchor {
  visibility: visible;
}

/* 暗色模式 */
[data-theme="dark"] .prose {
  color: var(--color-secondary-300);
}

[data-theme="dark"] .prose h1,
[data-theme="dark"] .prose h2,
[data-theme="dark"] .prose h3,
[data-theme="dark"] .prose h4,
[data-theme="dark"] .prose h5 {
  color: var(--color-secondary-100);
}

[data-theme="dark"] .prose h6 {
  color: var(--color-secondary-300);
}

/* 引用样式 */
.prose blockquote {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  border-left: 4px solid var(--color-primary-500);
  background-color: var(--color-gray-100);
  border-radius: 0.5rem;
  font-style: italic;
  color: var(--color-secondary-700);
}

.prose blockquote p {
  margin: 0;
}

.prose blockquote p + p {
  margin-top: 1em;
}

/* 链接样式 */
.prose a {
  color: var(--color-primary-600);
  text-decoration: none;
  border-bottom: 1px solid var(--color-primary-300);
  transition: border-bottom-color 0.2s ease;
}

.prose a:hover {
  color: var(--color-primary-800);
  border-bottom-color: var(--color-primary-600);
}

/* 暗色模式适配 */
[data-theme="dark"] .prose blockquote {
  background-color: var(--color-dark-surface);
  border-left-color: var(--color-primary-400);
  color: var(--color-secondary-300);
}

[data-theme="dark"] .prose a {
  color: var(--color-primary-400);
  border-bottom-color: var(--color-primary-600);
}

[data-theme="dark"] .prose a:hover {
  color: var(--color-primary-300);
  border-bottom-color: var(--color-primary-400);
}

/* 收纳内容样式 */
.details-content {
  margin-left: 1.5em;
  padding: 1em;
  background-color: var(--color-gray-100);
  border-left: 4px solid var(--color-primary-500);
  margin-bottom: 1em;
  border-radius: 0.5rem;
}

[data-theme="dark"] .details-content {
  background-color: var(--color-dark-surface);
  border-left-color: var(--color-primary-400);
}

/* 收纳标题样式 */
.prose details {
  margin: 1.5em 0;
  border-radius: 0.5rem;
  border: 1px solid var(--color-secondary-200);
  background-color: var(--color-gray-50);
  transition: box-shadow 0.2s ease;
  overflow: hidden;
}

/* 添加 details 内部内容的内边距 */
.prose details > *:not(summary) {
  padding: 1.5em;
  margin: 0;
}

.prose details > p,
.prose details > ul,
.prose details > ol,
.prose details > div {
  margin-top: 0;
  margin-bottom: 1em;
}

.prose details > *:last-child {
  margin-bottom: 0;
}

.prose details summary {
  padding: 1em;
  cursor: pointer;
  position: relative;
  font-weight: 500;
  color: var(--color-secondary-900);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75em;
  transition: background 0.2s ease;
  background: linear-gradient(to right, var(--color-primary-50), var(--color-gray-50));
  border-left: 4px solid var(--color-primary-100);
}

.prose details summary::-webkit-details-marker {
  display: none;
}

.prose details summary::before {
  content: "";
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234b6bff'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5l7 7-7 7'%3E%3C/path%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.prose details[open] summary {
  border-left: 4px solid var(--color-primary-500);
  background: linear-gradient(to right, var(--color-primary-100), var(--color-gray-50));
  border-bottom: 1px solid var(--color-secondary-200);
}

.prose details[open] summary::before {
  transform: rotate(90deg);
}

.prose details summary:hover {
  background: linear-gradient(to right, var(--color-primary-100), var(--color-gray-100));
  color: var(--color-primary-700);
}

.prose details > blockquote {
  margin: 0;
  padding: 1.5em;
  border-radius: 0;
  border-left: 4px solid var(--color-primary-500);
  background: linear-gradient(to right, var(--color-primary-50/50), var(--color-gray-50));
}

.prose details > blockquote p:first-child {
  margin-top: 0;
}

.prose details > blockquote p:last-child {
  margin-bottom: 0;
}

/* 暗色模式适配 */
[data-theme="dark"] .prose details {
  border-color: var(--color-dark-border);
  background-color: var(--color-dark-surface);
}

[data-theme="dark"] .prose details summary {
  color: var(--color-secondary-100);
  background: linear-gradient(to right, var(--color-dark-surface), var(--color-dark-card));
  border-left-color: var(--color-primary-800);
}

[data-theme="dark"] .prose details[open] summary {
  border-bottom-color: var(--color-dark-border);
}

[data-theme="dark"] .prose details summary::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23839dff'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5l7 7-7 7'%3E%3C/path%3E%3C/svg%3E");
}

[data-theme="dark"] .prose details[open] summary {
  background: linear-gradient(to right, var(--color-dark-card), var(--color-dark-surface));
  border-left-color: var(--color-primary-400);
}

[data-theme="dark"] .prose details summary:hover {
  background: linear-gradient(to right, var(--color-primary-900/30), var(--color-dark-card));
  color: var(--color-primary-400);
}

[data-theme="dark"] .prose details > blockquote {
  background: linear-gradient(to right, var(--color-primary-900/10), var(--color-dark-surface));
  border-left-color: var(--color-primary-400);
}

/* 目录组件样式 */
/* 目录项基础样式 */
.toc-item {
  position: relative;
}

.toc-item-container {
  display: flex;
  align-items: center;
}

/* 目录链接基础样式 */
.toc-link {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.25rem 0;
  border-radius: 0.25rem;
  transition: background-color 0.3s ease;
  position: relative;
}

/* 目录链接高亮指示器 */
.toc-link-active::before {
  content: '';
  position: absolute;
  left: -0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1rem;
  background: linear-gradient(to bottom, var(--color-primary-600), var(--color-primary-400));
  border-radius: 0 2px 2px 0;
  opacity: 1;
}

[data-theme="dark"] .toc-link-active::before {
  background: linear-gradient(to bottom, var(--color-primary-400), var(--color-primary-600));
}

/* 目录链接悬停样式 */
.toc-link:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .toc-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* 目录切换按钮样式 */
.toc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  min-width: 1.5rem;
  min-height: 1.5rem;
}

/* 展开/折叠图标动画 */
.toc-toggle svg {
  transition: transform 0.3s ease;
}

.toc-toggle[aria-expanded="true"] svg {
  transform: rotate(-180deg);
}

/* 目录切换按钮悬停样式 */
.toc-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .toc-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 子目录列表样式 */
.toc-list {
  list-style-type: none;
  transition: padding 0.3s ease;
}

/* 子目录展开/收起动画 */
.toc-sublist {
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* 目录面板样式 */
#toc-panel {
  position: fixed;
  right: calc(50% - 44rem);
  top: 5rem;
  width: 16rem;
  z-index: 30;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@media (max-width: 1535px) {
  #toc-panel.hidden {
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
  }
}

/* 目录内容容器样式 */
#toc-content {
  font-size: 0.875rem;
  padding: 1rem;
  padding-top: 0.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 8rem - 42px);
  scroll-behavior: smooth;
}

/* 目录内容滚动条样式 */
#toc-content::-webkit-scrollbar {
  width: 4px;
}

#toc-content::-webkit-scrollbar-track {
  background: transparent;
}

#toc-content::-webkit-scrollbar-thumb {
  background-color: var(--color-primary-200);
  border-radius: 4px;
}

[data-theme="dark"] #toc-content::-webkit-scrollbar-thumb {
  background-color: var(--color-primary-800);
}
