/* ============================================================
   ysd-blog — 友链卡片样式（Phase 2.5: 头像 + 卡片布局）

   注入点：.cat friends/<slug>/card.md → FriendCard.html()
   触发条件：card.md 的 frontmatter 中包含 avatar 字段（外部 URL）。
   未填写 avatar 时走纯文本 summary，本文件内的样式完全不生效。

   设计原则：
   - 配色与终端 CSS 变量（--fg, --accent, --border, --bg-alt）一致，暗/亮主题自动适配；
   - 卡片为行内-flex 容器，不破坏终端原生的行流式布局；
   - 头像固定 64px，信息区自适应，文本溢出自动截断。
   ============================================================ */

/* 卡片整体：轻描边 + 背景色与普通 output-line 一致 */
.friend-card {
  display: inline-flex;
  gap: 14px;
  align-items: flex-start;
  max-width: 560px;
  margin: 6px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  font-family: var(--font-mono);
  line-height: 1.45;
}

/* 头像：圆角方形，object-fit 防止变形；前景用 CSS filter 做轻微提亮 */
.friend-card-avatar {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: calc(var(--radius) - 2px);
  object-fit: cover;
  background: var(--border);
  /* 头像一般来自第三方源，无法控制其调色板；不做 filter 以保证真实色彩 */
  image-rendering: auto;
}

/* 信息区：撑满剩余空间 */
.friend-card-info {
  flex: 1 1 auto;
  min-width: 0;          /* 允许子项在 flex 容器中收缩、配合 text-overflow */
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 首行：名字 + 外链箭头 */
.friend-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.friend-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}

.friend-card-link {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--accent-dim);
  text-decoration: none;
  transition: color 0.15s ease;
}
.friend-card-link:hover {
  color: var(--accent);
}

/* URL、描述、标签、since 的共用轻样式 */
.friend-card-url {
  font-size: 12px;
  color: var(--accent-dim);
  /* 单行截断，避免超长 URL 撑破卡片 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-card-desc {
  font-size: 13px;
  color: var(--fg);
  /* 多行截断（最多 3 行） */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.friend-card-tags,
.friend-card-since {
  font-size: 12px;
  color: var(--fg-dim);
}

/* 正文段落（卡片下方的 markdown 渲染结果） */
.friend-card-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  color: var(--fg-dim);
}
.friend-card-body p:first-child { margin-top: 0; }
.friend-card-body p:last-child  { margin-bottom: 0; }

/* 兜底：output-html 容器自身不引入额外 padding/border（由 .friend-card 决定） */
.output-html {
  padding: 0;
  border: none;
  background: transparent;
}

/* ── friends 命令：多卡片分隔 ── */
.friend-card-sep {
  height: 1px;
  margin: 10px 0;
  background: var(--border);
  opacity: 0.6;
}

/* 无 avatar 的纯文本退避卡片 */
.friend-card-text {
  padding: 8px 12px;
}
.friend-card-summary {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 小屏幕/窄终端：头像固定，文字区域自然换行 */
@media (max-width: 480px) {
  .friend-card {
    flex-direction: column;
    align-items: stretch;
  }
  .friend-card-avatar {
    width: 48px;
    height: 48px;
  }
}
