/* Markdown 扩展组件（服务端渲染与后台预览共用）
   - 提醒框 .alert（GitHub 五种类型）
   - GitHub 仓库卡片 .repo-card
   - 图片网格 .image-grid
   - 剧透 .spoiler
   - 公式 .math-block / .math-inline（排版主体来自 KaTeX 自带样式）

   这些类可能出现在前台文章正文（article.css 的 .body）、首页关于卡
   （home.css 的 .about-card）和后台预览，所以组件本身只依赖全局主题变量，
   不绑定某一个页面容器；页面样式可以覆盖它们的布局。 */

/* ---------- 提醒框 ---------- */
.alert {
  margin: 0 0 24px;
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink-80);
  box-shadow: 6px 6px 0 var(--shade);
}
.alert-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 2px solid var(--ink);
  background: var(--pink-soft);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 1.4;
  color: var(--ink);
}
.alert-kind {
  font-weight: 700;
}
.alert-label {
  color: var(--ink-62);
}
.alert-body {
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.9;
}
.alert-body > :first-child {
  margin-top: 0;
}
.alert-body > :last-child {
  margin-bottom: 0;
}
.alert-body p {
  margin: 0 0 12px;
}
.alert-body ul,
.alert-body ol {
  margin: 0 0 12px;
  padding-left: 0;
}
.alert--note .alert-head {
  background: var(--pink-soft);
}
.alert--tip .alert-head {
  background: var(--pink-wash);
}
.alert--important .alert-head {
  background: var(--ink);
  color: var(--paper);
}
.alert--important .alert-label {
  color: var(--paper);
}
.alert--warning .alert-head {
  background: var(--pink);
  color: var(--on-pink);
}
.alert--warning .alert-label {
  color: var(--on-pink);
}
.alert--caution .alert-head {
  background: var(--pink-deep);
  color: var(--paper);
}
.alert--caution .alert-label {
  color: var(--paper);
}

/* ---------- GitHub 仓库卡片 ---------- */
.repo-card,
.body a.repo-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 24px;
  padding: 14px 16px;
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 6px 6px 0 var(--shade);
  font-weight: 400;
  text-decoration: none;
  transition:
    background 0.15s var(--ease),
    box-shadow 0.15s var(--ease),
    transform 0.15s var(--ease);
}
.repo-card:hover,
.body a.repo-card:hover {
  background: var(--pink-wash);
  color: var(--ink);
  box-shadow: 8px 8px 0 var(--shade);
  transform: translate(-1px, -1px);
}
.repo-card:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}
.repo-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.repo-card-kind {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-62);
}
.repo-card-name {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.3;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.repo-card-slash {
  color: var(--ink-25);
}
.repo-card-repo {
  color: var(--pink-deep);
}
.repo-card-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--ink-62);
}
.repo-card-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.repo-card-stat b {
  color: var(--ink);
  font-weight: 700;
}
.repo-card-go {
  flex: none;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  white-space: nowrap;
}
.repo-card:hover .repo-card-go {
  background: var(--pink);
  color: var(--on-pink);
}

/* ---------- 图片网格 ---------- */
.image-grid {
  display: grid;
  gap: 14px;
  margin: 0 0 24px;
}
.image-grid--1 {
  grid-template-columns: minmax(0, 1fr);
}
.image-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.image-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.image-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.image-grid-item {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-width: 0;
}
.image-grid .image-grid-item img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  object-fit: cover;
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shade);
}
/* 多图并排时统一画幅（按 4:3 中心裁剪），保证同一行与图注对齐 */
.image-grid--2 .image-grid-item img,
.image-grid--3 .image-grid-item img,
.image-grid--4 .image-grid-item img {
  aspect-ratio: 4 / 3;
}
.image-grid-item figcaption {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: var(--ink-62);
}
@media (max-width: 1100px) {
  .image-grid--3,
  .image-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .image-grid--2,
  .image-grid--3,
  .image-grid--4 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- 剧透 ---------- */
.spoiler {
  padding: 0 2px;
  background: var(--ink);
  color: transparent;
  border-bottom: 2px solid var(--ink);
  cursor: pointer;
  user-select: none;
  transition:
    background 0.15s var(--ease),
    color 0.15s var(--ease);
}
.spoiler:hover,
.spoiler:focus,
.spoiler:focus-visible,
.spoiler.is-open {
  background: var(--pink-wash);
  color: inherit;
  user-select: text;
}
.spoiler:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}

/* ---------- 公式 ---------- */
.math-block {
  margin: 0 0 24px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.math-block .katex-display {
  margin: 0;
}
.math-inline .katex {
  font-size: 1.02em;
}
.math-src {
  display: block;
  margin: 0;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-x: auto;
}
