/* === Markdown Components === */

/* ==================== 自定义组件样式 ==================== */

/* Callout 提示框 */
.callout {
  display: flex;
  gap: 12px;
  padding: 16px;
  margin: 16px 0;
  border-radius: 8px;
  border-left: 4px solid;
}

.callout-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.callout-icon svg {
  width: 20px;
  height: 20px;
}

.callout-content {
  flex: 1;
  min-width: 0;
}

.callout-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.callout-body p:last-child {
  margin-bottom: 0;
}

.callout-info {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}
.callout-info .callout-icon { color: #3b82f6; }

.callout-tip {
  background: #f0fdf4;
  border-color: #22c55e;
  color: #166534;
}
.callout-tip .callout-icon { color: #22c55e; }

.callout-warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}
.callout-warning .callout-icon { color: #f59e0b; }

.callout-danger {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}
.callout-danger .callout-icon { color: #ef4444; }

/* 折叠块 */
.custom-details {
  margin: 16px 0;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  overflow: hidden;
}

.custom-details summary {
  padding: 12px 16px;
  background: var(--neutral-50);
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.custom-details summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 6px solid var(--neutral-500);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s;
}

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

.custom-details summary:hover {
  background: var(--neutral-100);
}

.details-content {
  padding: 16px;
  border-top: 1px solid var(--neutral-200);
}

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

/* 标签页 */
.custom-tabs {
  margin: 16px 0;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  overflow: hidden;
}

.tabs-header {
  display: flex;
  background: var(--neutral-50);
  border-bottom: 1px solid var(--neutral-200);
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-500);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--neutral-700);
  background: var(--neutral-100);
}

.tab-btn.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-500);
  background: #fff;
}

.tabs-body {
  padding: 16px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel p:last-child {
  margin-bottom: 0;
}

/* 快捷键 */
.kbd-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-block;
  padding: 3px 8px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
  color: var(--neutral-700);
  background: linear-gradient(180deg, #fff 0%, #f5f5f5 100%);
  border: 1px solid var(--neutral-300);
  border-radius: 5px;
  box-shadow: 0 2px 0 var(--neutral-200), inset 0 -1px 0 var(--neutral-200);
}

.kbd-plus {
  font-size: 11px;
  color: var(--neutral-400);
}

/* ==================== 代码高亮 - JetBrains Darcula 官方配色 ==================== */

/* orphaned fragment */
  color: #6a8759;
  background: rgba(106, 135, 89, 0.1);
}

.markdown-body pre {
  position: relative;
  background: #2B2B2B;
}

.markdown-body pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, Consolas, monospace;
  line-height: 1.5;
  color: #A9B7C6;
}

/* 语言标签 */
.markdown-body pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 10px;
  font-size: 11px;
  color: #606366;
  background: rgba(255,255,255,0.03);
  border-radius: 0 8px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Darcula 官方配色 */
.hljs {
  background: #2B2B2B;
  color: #A9B7C6;
}

/* 关键字 - 橙色 */
.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in {
  color: #CC7832;
}

/* 字符串 - 绿色 */
.hljs-string,
.hljs-attr {
  color: #6A8759;
}

/* 数字 - 蓝色 */
.hljs-number,
.hljs-literal {
  color: #6897BB;
}

/* 注释 - 灰色斜体 */
.hljs-comment,
.hljs-quote {
  color: #808080;
  font-style: italic;
}

/* 函数名 - 黄色 */
.hljs-function,
.hljs-title,
.hljs-title.function_ {
  color: #FFC66D;
}

/* 类型/类名 - 浅蓝 */
.hljs-type,
.hljs-class .hljs-title,
.hljs-title.class_ {
  color: #A9B7C6;
}

/* 变量/参数 - 紫色 */
.hljs-variable,
.hljs-template-variable,
.hljs-params {
  color: #A9B7C6;
}

/* 属性名 */
.hljs-attribute,
.hljs-property {
  color: #9876AA;
}

/* 标签 - 黄色 */
.hljs-tag {
  color: #E8BF6A;
}

.hljs-name {
  color: #E8BF6A;
}

/* 元信息/注解 - 黄绿色 */
.hljs-meta,
.hljs-meta .hljs-keyword {
  color: #BBB529;
}

/* 正则表达式 */
.hljs-regexp {
  color: #6A8759;
}

/* 符号 */
.hljs-symbol,
.hljs-bullet {
  color: #6897BB;
}

/* 内置 - 紫色 */
.hljs-built_in {
  color: #8888C6;
}

/* 选择器 - 黄色 */
.hljs-selector-id,
.hljs-selector-class {
  color: #FFC66D;
}

/* 删除/新增 */
.hljs-deletion {
  color: #CC7832;
  background: rgba(204, 120, 50, 0.1);
}

.hljs-addition {
  color: #6A8759;
  background: rgba(106, 135, 89, 0.1);
}

/* 强调 */
.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}

/* ==================== 代码块复制按钮 ==================== */
.code-block-wrapper { position: relative; margin: 16px 0; }
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #1e1e1e;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid #333;
}
.code-lang { font-size: 11px; color: #888; text-transform: uppercase; }
.code-copy-btn {
  font-size: 12px;
  color: #999;
  background: transparent;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.code-copy-btn:hover { color: #fff; border-color: #888; }
.code-block-wrapper pre { margin: 0; border-radius: 0 0 8px 8px; }

/* ==================== Wiki 链接卡片 ==================== */
.wiki-link-card {
  display: flex;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wiki-link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wiki-link-body {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wiki-link-body svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}

.wiki-link-name {
  color: var(--neutral-700);
  font-weight: 500;
}

.wiki-link-card:hover .wiki-link-name {
  color: var(--primary-600);
}


/* ==================== ASCII 图表卡片 ==================== */
.ascii-diagram {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--neutral-200);
  border-radius: 12px;
  padding: 24px 32px;
  margin: 20px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow-x: auto;
  display: inline-block;
  max-width: 100%;
}

.markdown-body .ascii-diagram {
  display: block;
  width: fit-content;
  margin-left: 0;
  margin-right: 0;
}

.ascii-diagram code {
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", "Monaco", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--neutral-600);
  background: none;
  white-space: pre;
  display: block;
  text-align: left;
}

.ascii-diagram:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--neutral-300);
}

/* ==================== HTML 嵌入块 ==================== */
.html-embed {
  margin: 16px 0;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.html-embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--neutral-100);
  border-bottom: 1px solid var(--neutral-200);
}

.html-embed-header-mini {
  justify-content: flex-end;
  padding: 4px 8px;
  background: transparent;
  border-bottom: none;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
}

.html-embed-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--neutral-700);
}

.html-embed-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--neutral-500);
  cursor: pointer;
  transition: all 0.15s;
}

.html-embed-toggle:hover {
  background: var(--neutral-200);
  color: var(--neutral-700);
}

.html-embed-code {
  display: none;
  max-height: 300px;
  overflow: auto;
  background: var(--neutral-900);
  border-bottom: 1px solid var(--neutral-200);
}

.html-embed-code pre {
  margin: 0;
  padding: 12px;
  background: transparent;
}

.html-embed-code code {
  font-size: 12px;
  line-height: 1.5;
  color: var(--neutral-300);
}

.html-embed.show-code .html-embed-code {
  display: block;
}

.html-embed-frame {
  display: block;
  width: 100%;
  border: none;
  background: #fff;
}

/* 无标题时的相对定位 */
.html-embed:not(:has(.html-embed-title)) {
  position: relative;
}

.html-embed:not(:has(.html-embed-title)) .html-embed-header-mini {
  opacity: 0;
  transition: opacity 0.15s;
}

.html-embed:not(:has(.html-embed-title)):hover .html-embed-header-mini {
  opacity: 1;
}
