/*!
 * bl8ds 站点级 UI：代码块 / 首页卡片流 / 置顶
 * 通过 Hexo injector 注入，位于主题 CSS 之后。
 * 颜色全部跟随主题的 --color-* 变量；代码高亮单独定义亮 / 暗两套 token 配色。
 * 高特异性前缀 body[data-color-scheme] 用于覆盖主题自带的 code-highlighting.css。
 */

/* ================================================================== *
 * A. 代码块
 * ================================================================== */

body[data-color-scheme] figure.highlight.bl8ds-code {
  /* GitHub Light */
  --cb-bg: #f6f8fa;
  --cb-bar: #eaeef2;
  --cb-fg: #24292f;
  --cb-gutter: #8c959f;
  --cb-border: #d8dee4;
  --cb-btn: #ffffff;
  --cb-btn-hover: #f3f5f7;
  --cb-accent: #0969da;
  --cb-success: #1a7f37;
  --cb-comment: #6e7781;
  --cb-keyword: #cf222e;
  --cb-string: #0a3069;
  --cb-number: #0550ae;
  --cb-title: #8250df;
  --cb-type: #953800;
  --cb-meta: #0550ae;
  --cb-name: #116329;
  --cb-builtin: #8250df;
  --cb-variable: #953800;
  --cb-addition-bg: #dafbe1;
  --cb-deletion-bg: #ffebe9;

  display: block;
  margin: 26px 0;
  padding: 0;
  /* 主题把 overflow 放在 figure 上，会让工具栏跟着横向滚走；这里把滚动交给 body */
  overflow: visible;
  background: var(--cb-bg);
  color: var(--cb-fg);
  border: 1px solid var(--cb-border);
  border-radius: var(--radius-medium, 12px);
  box-shadow: 0 1px 2px rgba(27, 31, 36, .06);
}

body[data-color-scheme='dark'] figure.highlight.bl8ds-code {
  /* GitHub Dark */
  --cb-bg: #0d1117;
  --cb-bar: #161b22;
  --cb-fg: #c9d1d9;
  --cb-gutter: #6e7681;
  --cb-border: #30363d;
  --cb-btn: #21262d;
  --cb-btn-hover: #30363d;
  --cb-accent: #58a6ff;
  --cb-success: #3fb950;
  --cb-comment: #8b949e;
  --cb-keyword: #ff7b72;
  --cb-string: #a5d6ff;
  --cb-number: #79c0ff;
  --cb-title: #d2a8ff;
  --cb-type: #ffa657;
  --cb-meta: #79c0ff;
  --cb-name: #7ee787;
  --cb-builtin: #d2a8ff;
  --cb-variable: #ffa657;
  --cb-addition-bg: #1b3725;
  --cb-deletion-bg: #3d1a1a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

@media (prefers-color-scheme: dark) {
  body[data-color-scheme='auto'] figure.highlight.bl8ds-code {
    --cb-bg: #0d1117;
    --cb-bar: #161b22;
    --cb-fg: #c9d1d9;
    --cb-gutter: #6e7681;
    --cb-border: #30363d;
    --cb-btn: #21262d;
    --cb-btn-hover: #30363d;
    --cb-accent: #58a6ff;
    --cb-success: #3fb950;
    --cb-comment: #8b949e;
    --cb-keyword: #ff7b72;
    --cb-string: #a5d6ff;
    --cb-number: #79c0ff;
    --cb-title: #d2a8ff;
    --cb-type: #ffa657;
    --cb-meta: #79c0ff;
    --cb-name: #7ee787;
    --cb-builtin: #d2a8ff;
    --cb-variable: #ffa657;
    --cb-addition-bg: #1b3725;
    --cb-deletion-bg: #3d1a1a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

/* 顶部工具栏 */
body[data-color-scheme] figure.highlight.bl8ds-code .code-block__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px 0 14px;
  background: var(--cb-bar);
  border-bottom: 1px solid var(--cb-border);
  border-radius: calc(var(--radius-medium, 12px) - 1px) calc(var(--radius-medium, 12px) - 1px) 0 0;
  font-family: var(--font-sans-serif, system-ui, sans-serif);
  font-size: 12px;
  line-height: 1;
  color: var(--cb-gutter);
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--cb-fg);
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cb-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cb-accent) 18%, transparent);
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__meta {
  font-variant-numeric: tabular-nums;
  opacity: .8;
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__copy {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  background: var(--cb-btn);
  color: var(--cb-fg);
  font: 600 12px/1 var(--font-sans-serif, system-ui, sans-serif);
  cursor: pointer;
  transition:
    transform .28s cubic-bezier(.2, .8, .2, 1),
    background-color .28s ease,
    border-color .28s ease,
    box-shadow .28s ease,
    color .28s ease;
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__copy:hover {
  transform: translateY(-1px) scale(1.07);
  background: var(--cb-btn-hover);
  border-color: var(--cb-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .13);
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__copy:active {
  transform: scale(.97);
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__copy:focus-visible {
  outline: 2px solid var(--cb-accent);
  outline-offset: 2px;
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__copy.is-done {
  color: var(--cb-success);
  border-color: var(--cb-success);
}

body[data-color-scheme] figure.highlight.bl8ds-code .code-block__copy.is-failed {
  color: var(--cb-keyword);
  border-color: var(--cb-keyword);
}

/* 代码区：横向滚动只发生在这一层，行号列用 sticky 固定 */
body[data-color-scheme] figure.highlight.bl8ds-code .code-block__body {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 0 0 calc(var(--radius-medium, 12px) - 1px) calc(var(--radius-medium, 12px) - 1px);
  scrollbar-width: thin;
}

body[data-color-scheme] figure.highlight.bl8ds-code table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  border-spacing: 0;
}

body[data-color-scheme] figure.highlight.bl8ds-code td {
  padding: 0;
  border: 0;
  vertical-align: top;
}

body[data-color-scheme] figure.highlight.bl8ds-code pre {
  margin: 0;
  background: transparent;
  font-size: 13.5px;
  line-height: 1.7;
  -moz-tab-size: 2;
    -o-tab-size: 2;
       tab-size: 2;
}

body[data-color-scheme] figure.highlight.bl8ds-code .gutter {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 1%;
  min-width: 46px;
  padding: 14px 12px;
  text-align: right;
  white-space: nowrap;
  color: var(--cb-gutter);
  background: var(--cb-bg);
  border-right: 1px solid var(--cb-border);
  font-variant-numeric: tabular-nums;
  -moz-user-select: none;
       user-select: none;
  -webkit-user-select: none;
}

body[data-color-scheme] figure.highlight.bl8ds-code .gutter pre {
  padding: 0;
  color: inherit;
}

body[data-color-scheme] figure.highlight.bl8ds-code .code pre {
  padding: 14px 18px;
  color: var(--cb-fg);
  white-space: pre;
}

body[data-color-scheme] figure.highlight.bl8ds-code .line {
  min-height: 1.7em;
}

/* 没有 gutter 时用 CSS counter 补行号（例如关闭了 line_number 的代码块） */
body[data-color-scheme] figure.highlight.bl8ds-code--no-gutter .code pre {
  counter-reset: cb-line;
}

body[data-color-scheme] figure.highlight.bl8ds-code--no-gutter .code .line {
  counter-increment: cb-line;
}

body[data-color-scheme] figure.highlight.bl8ds-code--no-gutter .code .line::before {
  content: counter(cb-line);
  display: inline-block;
  width: 2.6em;
  margin-right: 1.4em;
  text-align: right;
  color: var(--cb-gutter);
  -moz-user-select: none;
       user-select: none;
  -webkit-user-select: none;
}

/* token 配色：完整覆盖主题那份只定义了 12 个类的 GitHub 主题 */
body[data-color-scheme] figure.highlight.bl8ds-code .comment,
body[data-color-scheme] figure.highlight.bl8ds-code .quote {
  color: var(--cb-comment);
  font-style: italic;
}

body[data-color-scheme] figure.highlight.bl8ds-code .keyword,
body[data-color-scheme] figure.highlight.bl8ds-code .selector-tag,
body[data-color-scheme] figure.highlight.bl8ds-code .literal,
body[data-color-scheme] figure.highlight.bl8ds-code .doctag {
  color: var(--cb-keyword);
}

body[data-color-scheme] figure.highlight.bl8ds-code .string,
body[data-color-scheme] figure.highlight.bl8ds-code .symbol,
body[data-color-scheme] figure.highlight.bl8ds-code .bullet,
body[data-color-scheme] figure.highlight.bl8ds-code .link,
body[data-color-scheme] figure.highlight.bl8ds-code .regexp {
  color: var(--cb-string);
}

body[data-color-scheme] figure.highlight.bl8ds-code .number,
body[data-color-scheme] figure.highlight.bl8ds-code .attr,
body[data-color-scheme] figure.highlight.bl8ds-code .attribute,
body[data-color-scheme] figure.highlight.bl8ds-code .selector-class,
body[data-color-scheme] figure.highlight.bl8ds-code .selector-id,
body[data-color-scheme] figure.highlight.bl8ds-code .meta-keyword {
  color: var(--cb-number);
}

body[data-color-scheme] figure.highlight.bl8ds-code .title,
body[data-color-scheme] figure.highlight.bl8ds-code .section,
body[data-color-scheme] figure.highlight.bl8ds-code .function .title,
body[data-color-scheme] figure.highlight.bl8ds-code .built_in,
body[data-color-scheme] figure.highlight.bl8ds-code .builtin-name {
  color: var(--cb-title);
}

body[data-color-scheme] figure.highlight.bl8ds-code .type,
body[data-color-scheme] figure.highlight.bl8ds-code .class .title,
body[data-color-scheme] figure.highlight.bl8ds-code .params,
body[data-color-scheme] figure.highlight.bl8ds-code .variable,
body[data-color-scheme] figure.highlight.bl8ds-code .template-variable,
body[data-color-scheme] figure.highlight.bl8ds-code .subst {
  color: var(--cb-type);
}

body[data-color-scheme] figure.highlight.bl8ds-code .meta,
body[data-color-scheme] figure.highlight.bl8ds-code .meta-string {
  color: var(--cb-meta);
}

body[data-color-scheme] figure.highlight.bl8ds-code .name,
body[data-color-scheme] figure.highlight.bl8ds-code .selector-pseudo,
body[data-color-scheme] figure.highlight.bl8ds-code .selector-attr {
  color: var(--cb-name);
}

body[data-color-scheme] figure.highlight.bl8ds-code .addition {
  background: var(--cb-addition-bg);
}

body[data-color-scheme] figure.highlight.bl8ds-code .deletion {
  background: var(--cb-deletion-bg);
}

body[data-color-scheme] figure.highlight.bl8ds-code .emphasis { font-style: italic; }
body[data-color-scheme] figure.highlight.bl8ds-code .strong { font-weight: 700; }

/* ================================================================== *
 * B. 首页卡片流
 * ================================================================== */

.bl8ds-feed {
  gap: 18px;
  -webkit-user-select: text;
     -moz-user-select: text;
          user-select: text;
}

.feed-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-large, 24px);
  isolation: isolate;
}

.feed-card > a {
  display: block;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.feed-card > a:focus-visible {
  outline: 3px solid var(--color-text-accent);
  outline-offset: 3px;
}

/* 六种稳定的封面配色 */
.feed-card[data-tone='0'] { --art-a: #3b6fe0; --art-b: #7b5cf0; }
.feed-card[data-tone='1'] { --art-a: #0e8f86; --art-b: #37b39b; }
.feed-card[data-tone='2'] { --art-a: #d2694a; --art-b: #efab5c; }
.feed-card[data-tone='3'] { --art-a: #5a4bb6; --art-b: #b061c9; }
.feed-card[data-tone='4'] { --art-a: #1f6f9e; --art-b: #51a8d8; }
.feed-card[data-tone='5'] { --art-a: #a3466d; --art-b: #e2839a; }

.feed-card__art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, .38), transparent 45%),
    radial-gradient(circle at 82% 82%, rgba(0, 0, 0, .28), transparent 50%),
    linear-gradient(135deg, var(--art-a), var(--art-b));
}

.feed-card__art::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .12) 1px, transparent 1px);
  background-size: 30px 30px;
  -webkit-mask-image: linear-gradient(120deg, #000, transparent 78%);
  mask-image: linear-gradient(120deg, #000, transparent 78%);
}

.feed-card__art-glyph {
  position: relative;
  z-index: 1;
  font-size: clamp(72px, 11vw, 148px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.08em;
  color: rgba(255, 255, 255, .26);
  text-shadow: 0 10px 34px rgba(0, 0, 0, .18);
}

/* 大图卡片的字形放到右上方：居中时会和左下角的标题笔画叠在一起 */
.feed-card--hero .feed-card__art { display: block; }

.feed-card--hero .feed-card__art-glyph {
  position: absolute;
  top: -4%;
  right: 7%;
  font-size: clamp(148px, 19vw, 250px);
  color: rgba(255, 255, 255, .17);
}

.feed-card__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  transition: transform .65s cubic-bezier(.2, .8, .2, 1), filter .65s ease;
}

/* ---- B1. 大图封面卡片（第一页首篇） ---- */

.feed-card--hero {
  grid-column: 1 / -1;
  min-height: 372px;
  background: var(--color-background-secondary);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .10);
  transition: transform .45s cubic-bezier(.2, .8, .2, 1), box-shadow .45s ease;
}

.feed-card--hero:hover {
  transform: translateY(-5px) scale(1.006);
  box-shadow: 0 22px 54px rgba(0, 0, 0, .20);
}

.feed-card--hero > a { color: #fff; }

.feed-card__media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.feed-card__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(4, 8, 18, .04) 0%,
    rgba(4, 8, 18, .22) 38%,
    rgba(4, 8, 18, .78) 76%,
    rgba(4, 8, 18, .92) 100%
  );
}

.feed-card--hero:hover .feed-card__img {
  transform: scale(1.06);
  filter: brightness(.92);
}

.feed-card__overlay {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 372px;
  padding: 34px 38px 32px;
}

.feed-card--hero .feed-card__flags { color: rgba(255, 255, 255, .9); }
.feed-card--hero .feed-card__cat { color: #fff; }

.feed-card--hero .feed-card__title {
  max-width: 22em;
  margin: 12px 0 0;
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.02em;
}

.feed-card--hero .feed-card__desc {
  max-width: 38em;
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.65;
  color: rgba(255, 255, 255, .82);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-card--hero .feed-card__foot {
  margin-top: 20px;
  color: rgba(255, 255, 255, .74);
  font-size: 13px;
}

.feed-card__more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #fff;
  transition: gap .3s cubic-bezier(.2, .8, .2, 1);
}

.feed-card--hero:hover .feed-card__more { gap: 12px; }

/* ---- B2. 紧凑图文混排卡片 ---- */

.feed-card--compact {
  background: var(--color-background-secondary);
  border: 1px solid var(--color-border-primary);
  transition:
    transform .4s cubic-bezier(.2, .8, .2, 1),
    box-shadow .4s ease,
    border-color .4s ease;
}

.feed-card--compact:hover {
  transform: translateY(-6px) scale(1.014);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .15);
  border-color: var(--color-text-accent);
}

.feed-card--compact.is-pinned {
  border-color: color-mix(in srgb, var(--color-text-accent) 55%, transparent);
}

.feed-card--compact > a {
  display: flex;
  align-items: stretch;
  color: var(--color-text-primary);
}

.feed-card__thumb {
  position: relative;
  flex: 0 0 132px;
  width: 132px;
  align-self: stretch;
  overflow: hidden;
  background: var(--color-background-primary);
  border-right: 1px solid var(--color-border-primary);
}

.feed-card__thumb .feed-card__art-glyph { font-size: 62px; }

.feed-card--compact:hover .feed-card__img { transform: scale(1.08); }

.feed-card__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 16px;
}

.feed-card__flags {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
}

.feed-card__cat { color: var(--color-text-accent); }

.feed-card__pin {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--color-background-accent-lite);
  color: var(--color-text-accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
}

.feed-card--hero .feed-card__pin {
  background: rgba(255, 255, 255, .18);
  color: #fff;
  backdrop-filter: blur(8px);
}

.feed-card__feature {
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .08em;
}

.feed-card--compact .feed-card__title {
  margin: 9px 0 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-card__desc {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-tertiary);
  font-weight: 400;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.feed-card__arrow {
  font-size: 17px;
  color: var(--color-text-accent);
  transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}

.feed-card--compact:hover .feed-card__arrow { transform: translateX(5px); }

/* ---- B3. 响应式 ---- */

@media (max-width: 800px) {
  .feed-card__thumb { flex-basis: 108px; width: 108px; }
  .feed-card__body { padding: 15px 16px 14px; }
  .feed-card--compact .feed-card__title { font-size: 16px; }
  .feed-card__overlay { padding: 28px 26px 26px; }
}

@media (max-width: 600px) {
  .bl8ds-feed { gap: 14px; }
  .feed-card--hero,
  .feed-card__overlay { min-height: 300px; }
  .feed-card__overlay { padding: 24px 20px 22px; }
  .feed-card--hero .feed-card__title { font-size: 25px; }
  .feed-card--hero .feed-card__desc { -webkit-line-clamp: 2; }
  .feed-card--hero .feed-card__art-glyph { top: 0; right: 3%; font-size: 128px; }
  .feed-card__thumb { flex-basis: 92px; width: 92px; }
  .feed-card__thumb .feed-card__art-glyph { font-size: 46px; }
  .feed-card--compact .feed-card__title { font-size: 15px; -webkit-line-clamp: 2; }
  .feed-card__desc { font-size: 12px; -webkit-line-clamp: 1; }
}

/* ================================================================== *
 * C. 无障碍：尊重系统的「减少动态效果」
 * ================================================================== */

@media (prefers-reduced-motion: reduce) {
  .feed-card,
  .feed-card__img,
  .code-block__copy,
  .feed-card__arrow,
  .feed-card__more {
    transition-duration: .01ms !important;
  }
  .feed-card:hover { transform: none; }
}
