/* ---------------------------------------------------------------------------
 * 站点自定义样式
 * 由 _config.stellar.yml 的 inject.head_end 以 /assets/custom.css 加载。
 *
 * 目前只有一块内容：引用（citation）的排版。
 * 正文 `[^key]` 由 scripts/citation.js 渲染为：
 *   <sup class="cite-ref">[<a class="cite-mark" href="#reference-1">1</a>]</sup>
 * 参考资料（front matter 的 footer.references）里的条目会被加上
 *   id="reference-1" 以及回跳箭头 <a class="cite-backref">↩</a>。
 * 主题本身没有这套样式，所以这里补齐。
 * ------------------------------------------------------------------------- */

/* 正文中的引用标记：[1] */
.md-text .cite-ref {
  font-size: .78em;
  font-weight: 600;
  line-height: 0;
  white-space: nowrap;
}

.md-text .cite-ref .cite-mark {
  color: var(--accent);
  text-decoration: none;
  padding: 0 .05em;
}

.md-text .cite-ref .cite-mark:hover,
.md-text .cite-ref .cite-mark:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* 跳回正文时不要被顶栏挡住 */
.md-text .cite-mark {
  scroll-margin-top: calc(var(--shell-sticky-offset, 5rem) + 1rem);
}

/* 参考资料：编号 + 回跳 */
.article-footer #references .body ul {
  counter-reset: reference;
  list-style: none;
  padding-left: 0;
}

.article-footer #references .body li.post-title {
  counter-increment: reference;
  display: flex;
  align-items: baseline;
  gap: .4rem;
}

/* 参考资料里的空条目（front matter 写了 `- ''`）不显示也不占编号 */
.article-footer #references .body li.post-title:empty {
  display: none;
  counter-increment: none;
}

.article-footer #references .body li.post-title::before {
  content: '[' counter(reference) ']';
  flex: none;
  color: var(--text-p3);
  font-variant-numeric: tabular-nums;
}

.article-footer #references .body li.post-title p {
  margin: 0;
  min-width: 0;
}

.article-footer #references .body li.post-title .cite-backref {
  flex: none;
  color: var(--text-p4);
  font-size: .9em;
  text-decoration: none;
}

.article-footer #references .body li.post-title .cite-backref:hover,
.article-footer #references .body li.post-title .cite-backref:focus-visible {
  color: var(--link);
}

/* 从正文跳到参考资料时高亮目标条目 */
.article-footer #references .body li {
  scroll-margin-top: var(--shell-sticky-offset, 5rem);
  border-radius: 6px;
}

.article-footer #references .body li:target {
  background: var(--bg-a100);
  box-shadow: 0 0 0 .35rem var(--bg-a100);
}
