/* ==========================================================================
   XFM Theme · plugins.css
   标签插件：提示块 / 折叠 / 选项卡 / 时间轴 / 栅格 / 按钮 / 徽标 / 链接卡片
   以及目录树
   ========================================================================== */

/* --------------------------------------------------------------------------
   目录树
   -------------------------------------------------------------------------- */
.toc-body {
  --toc-accent: var(--xfm-primary);
}

.toc-child {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
}

.toc-child.depth-2 { padding-left: 12px; }
.toc-child.depth-3 { padding-left: 12px; }
.toc-child.depth-4 { padding-left: 12px; }

.toc-item {
  position: relative;
}

.toc-link {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--c-text-muted);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.toc-link:hover {
  color: var(--c-text);
  background: var(--c-surface-hover);
}

.toc-number {
  display: none;
}

.toc-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

body.mode-notes .toc-link,
body.mode-docs .toc-link {
  font-size: 12.5px;
  padding: 5px 9px;
}

.toc-link.is-active {
  color: var(--toc-accent);
  background: var(--c-primary-bg);
  font-weight: 700;
}

.toc-child.depth-1 > .toc-item > .toc-link.is-active::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 50%;
  width: 3px;
  height: 15px;
  border-radius: 3px;
  background: var(--toc-accent);
  transform: translateY(-50%);
}

/* --------------------------------------------------------------------------
   提示块 note
   -------------------------------------------------------------------------- */
.xfm-note {
  --note-color: var(--xfm-primary);
  --note-bg: var(--c-primary-bg);
  margin: 1.5em 0;
  padding: 14px 16px;
  background: var(--note-bg);
  border: 1px solid color-mix(in srgb, var(--note-color) 24%, transparent);
  border-left: 3px solid var(--note-color);
  border-radius: var(--xfm-radius);
}

.note-inner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.note-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  color: #fff;
  background: var(--note-color);
  border-radius: 8px;
  box-shadow: 0 3px 9px color-mix(in srgb, var(--note-color) 34%, transparent);
}

.note-icon .xfm-icon {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.note-main {
  flex: 1 1 auto;
  min-width: 0;
}

.note-title {
  margin-bottom: 4px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--note-color);
}

.note-body {
  font-size: 14px;
  line-height: 1.75;
  color: var(--c-text-soft);
}

.note-body > :last-child { margin-bottom: 0; }
.note-body > :first-child { margin-top: 0; }

.note-primary { --note-color: var(--xfm-primary); --note-bg: var(--c-primary-bg); }
.note-info { --note-color: var(--c-info); --note-bg: var(--c-info-bg); }
.note-success { --note-color: var(--c-success); --note-bg: var(--c-success-bg); }
.note-warning { --note-color: var(--c-warning); --note-bg: var(--c-warning-bg); }
.note-danger { --note-color: var(--c-danger); --note-bg: var(--c-danger-bg); }
.note-tip { --note-color: #8b5cf6; --note-bg: rgba(139, 92, 246, 0.10); }
.note-quote { --note-color: #64748b; --note-bg: rgba(100, 116, 139, 0.10); }

/* --------------------------------------------------------------------------
   折叠块
   -------------------------------------------------------------------------- */
.xfm-fold {
  margin: 1.5em 0;
  overflow: hidden;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--xfm-radius);
}

.fold-summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

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

.fold-summary:hover {
  color: var(--xfm-primary);
  background: var(--c-surface-hover);
}

.fold-arrow {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--xfm-primary);
  transition: transform var(--t-base) var(--ease);
}

.xfm-fold[open] .fold-arrow {
  transform: rotate(90deg);
}

.fold-content {
  padding: 4px 16px 16px;
  font-size: 14.5px;
  color: var(--c-text-soft);
  border-top: 1px solid var(--c-border);
  animation: xfm-fade-up var(--t-base) var(--ease-out) both;
}

.fold-content > :first-child { margin-top: 12px; }
.fold-content > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   选项卡
   -------------------------------------------------------------------------- */
.xfm-tabs {
  margin: 1.5em 0;
  overflow: hidden;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--xfm-radius);
}

.xfm-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px;
  background: var(--c-surface-alt);
  border-bottom: 1px solid var(--c-border);
}

.xfm-tab-btn {
  position: relative;
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--c-text-muted);
  border-radius: calc(var(--xfm-radius-sm) + 1px);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.xfm-tab-btn:hover {
  color: var(--c-text);
  background: var(--c-surface-hover);
}

.xfm-tab-btn.is-active {
  color: var(--xfm-primary);
  background: var(--c-surface);
  box-shadow: var(--shadow-xs);
}

.xfm-tab-btn.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--xfm-primary);
  transform: translateX(-50%);
}

.xfm-tabs-panels {
  padding: 4px 0 0;
}

.xfm-tab-panel {
  display: none;
  padding: 14px 18px 18px;
  animation: xfm-fade-up var(--t-base) var(--ease-out) both;
}

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

.xfm-tab-panel > :first-child { margin-top: 0; }
.xfm-tab-panel > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   时间轴
   -------------------------------------------------------------------------- */
.xfm-timeline {
  --tl-color: var(--xfm-primary);
  position: relative;
  margin: 1.6em 0;
  padding-left: 26px;
}

.xfm-timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--xfm-primary), transparent);
  opacity: 0.35;
}

.timeline-item {
  position: relative;
  padding-bottom: 18px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-node {
  position: absolute;
  left: -26px;
  top: 4px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c-surface);
  border: 2px solid var(--tl-color);
}

.timeline-node i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tl-color);
}

.timeline-card {
  padding: 12px 16px;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--xfm-radius);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}

.timeline-item:hover .timeline-card {
  transform: translateX(3px);
  border-color: color-mix(in srgb, var(--tl-color) 34%, transparent);
  box-shadow: var(--shadow-sm);
}

.timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--tl-color);
}

.timeline-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-text);
}

.timeline-body {
  font-size: 14px;
  line-height: 1.72;
  color: var(--c-text-soft);
}

.timeline-body > :first-child { margin-top: 0; }
.timeline-body > :last-child { margin-bottom: 0; }

.timeline-primary { --tl-color: var(--xfm-primary); }
.timeline-success { --tl-color: var(--c-success); }
.timeline-warning { --tl-color: var(--c-warning); }
.timeline-danger { --tl-color: var(--c-danger); }
.timeline-info { --tl-color: var(--c-info); }
.timeline-default { --tl-color: var(--c-text-muted); }
.timeline-gray { --tl-color: var(--c-text-faint); }

/* --------------------------------------------------------------------------
   栅格
   -------------------------------------------------------------------------- */
.xfm-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin: 1.5em 0;
}

.xfm-col {
  grid-column: span var(--col-span, 6);
  min-width: 0;
}

.xfm-col > :first-child { margin-top: 0; }
.xfm-col > :last-child { margin-bottom: 0; }

.xfm-col:empty { display: none; }

.xfm-row:has(> .xfm-col:only-child) .xfm-col {
  grid-column: span 12;
}

/* 未指定宽度时均分 */
.xfm-row > .xfm-col:not([style]) {
  grid-column: span 6;
}

/* --------------------------------------------------------------------------
   按钮（正文中）
   -------------------------------------------------------------------------- */
.xfm-content > .xfm-btn,
.xfm-content p > .xfm-btn {
  margin: 0 8px 0 0;
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   徽标
   -------------------------------------------------------------------------- */
.xfm-label {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  margin: 0 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--c-text-muted);
  border-radius: 6px;
  vertical-align: 0.1em;
}

.label-primary { background: var(--xfm-primary); }
.label-success { background: var(--c-success); }
.label-warning { background: var(--c-warning); }
.label-danger { background: var(--c-danger); }
.label-info { background: var(--c-info); }
.label-purple { background: #8b5cf6; }
.label-gray { background: var(--c-text-faint); }

/* --------------------------------------------------------------------------
   链接卡片
   -------------------------------------------------------------------------- */
.xfm-link-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  color: inherit;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--xfm-radius);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
}

.xfm-link-card:hover {
  transform: translateY(-3px);
  border-color: var(--c-primary-soft);
  box-shadow: var(--shadow-md);
}

.link-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: 12px;
  color: var(--c-text-faint);
  background: var(--c-surface-hover);
}

.link-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.link-avatar .xfm-icon {
  width: 21px;
  height: 21px;
  opacity: 0.6;
}

.link-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.link-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xfm-link-card:hover .link-title {
  color: var(--xfm-primary);
}

.link-desc {
  font-size: 12.5px;
  color: var(--c-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-host {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text-faint);
}

.link-arrow {
  flex: none;
  width: 17px;
  height: 17px;
  color: var(--c-text-faint);
  transition: transform var(--t-base) var(--ease-out), color var(--t-base) var(--ease);
}

.xfm-link-card:hover .link-arrow {
  color: var(--xfm-primary);
  transform: translateX(4px);
}

/* --------------------------------------------------------------------------
   Mermaid
   -------------------------------------------------------------------------- */
.mermaid {
  display: block;
  margin: 1.6em 0;
  padding: 16px;
  text-align: center;
  overflow-x: auto;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--xfm-radius);
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

.mermaid:not([data-processed]) {
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
  text-align: left;
  color: var(--c-text-muted);
}
