/*=== 破损图片占位样式 ===*/
/* 当图片加载失败时,用 JS 给 img 的父容器加 .img-broken,
   并把 img 隐藏,显示设计感占位 */

/* 1. 正文里的破损图片:替换成带渐变 + 图标的占位块 */
.img-broken-wrapper {
  position: relative;
  display: block;
  margin: 1.5rem auto;
  min-height: 180px;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(135deg,
      rgba(124, 122, 223, 0.08) 0%,
      rgba(91, 192, 235, 0.08) 50%,
      rgba(255, 184, 107, 0.08) 100%),
    repeating-linear-gradient(45deg,
      rgba(148, 163, 184, 0.06) 0,
      rgba(148, 163, 184, 0.06) 12px,
      transparent 12px,
      transparent 24px);
  border: 1px dashed rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
  transition: all 0.3s ease;
}

.img-broken-wrapper:hover {
  border-color: rgba(124, 122, 223, 0.5);
  background:
    linear-gradient(135deg,
      rgba(124, 122, 223, 0.12) 0%,
      rgba(91, 192, 235, 0.12) 50%,
      rgba(255, 184, 107, 0.12) 100%),
    repeating-linear-gradient(45deg,
      rgba(148, 163, 184, 0.08) 0,
      rgba(148, 163, 184, 0.08) 12px,
      transparent 12px,
      transparent 24px);
}

.img-broken-wrapper .img-broken-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 0.75rem;
  opacity: 0.55;
  color: #6b7280;
}

.img-broken-wrapper .img-broken-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.img-broken-wrapper .img-broken-hint {
  font-size: 0.8rem;
  color: #9ca3af;
  font-style: italic;
}

.img-broken-wrapper .img-broken-url {
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: #9ca3af;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.2rem 0.6rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
}

/* 2. 封面图(列表页/文章顶部)破损:占位更紧凑 */
.post-preview .img-broken-wrapper,
.post-meta .img-broken-wrapper {
  min-height: 140px;
  padding: 1.25rem;
}

/* 3. 列表页卡片里的破损封面:
   Chirpy 的 .preview-img 用 aspect-ratio: 40/21 固定宽高比,
   占位块必须填满父容器,否则会偏移+留白 */
.preview-img > .img-broken-wrapper,
.col-md-5 .img-broken-wrapper,
.card .img-broken-wrapper {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 40 / 21;
  padding: 0.75rem;
  margin: 0;
  border-radius: inherit; /* 继承 .preview-img 的圆角 */
  box-sizing: border-box;
}

/* 列表页缩略图里:icon 更小,只显示标题,隐藏 hint 和 url */
.preview-img > .img-broken-wrapper .img-broken-icon,
.col-md-5 .img-broken-wrapper .img-broken-icon,
.card .img-broken-wrapper .img-broken-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 0.4rem;
}

.preview-img > .img-broken-wrapper .img-broken-title,
.col-md-5 .img-broken-wrapper .img-broken-title,
.card .img-broken-wrapper .img-broken-title {
  font-size: 0.85rem;
  /* 标题最多 2 行,超出省略 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 90%;
}

/* 列表页缩略图空间小,隐藏 hint 和 url,只保留 icon+title */
.preview-img > .img-broken-wrapper .img-broken-hint,
.col-md-5 .img-broken-wrapper .img-broken-hint,
.card .img-broken-wrapper .img-broken-hint,
.preview-img > .img-broken-wrapper .img-broken-url,
.col-md-5 .img-broken-wrapper .img-broken-url,
.card .img-broken-wrapper .img-broken-url {
  display: none;
}

/* 3. 破损图外层链接:禁用 glightbox 弹窗(点开也是 404) */
a.img-broken-link {
  cursor: not-allowed;
  pointer-events: none;
  display: block;
}

a.img-broken-link:focus {
  outline: none;
}

/* 暗黑模式适配 */
[data-mode="dark"] .img-broken-wrapper {
  background:
    linear-gradient(135deg,
      rgba(124, 122, 223, 0.12) 0%,
      rgba(91, 192, 235, 0.12) 50%,
      rgba(255, 184, 107, 0.12) 100%),
    repeating-linear-gradient(45deg,
      rgba(148, 163, 184, 0.08) 0,
      rgba(148, 163, 184, 0.08) 12px,
      transparent 12px,
      transparent 24px);
  border-color: rgba(148, 163, 184, 0.25);
}

[data-mode="dark"] .img-broken-wrapper:hover {
  border-color: rgba(124, 122, 223, 0.6);
}

[data-mode="dark"] .img-broken-wrapper .img-broken-icon {
  color: #9ca3af;
}

[data-mode="dark"] .img-broken-wrapper .img-broken-title {
  color: #d1d5db;
}

[data-mode="dark"] .img-broken-wrapper .img-broken-hint {
  color: #6b7280;
}

[data-mode="dark"] .img-broken-wrapper .img-broken-url {
  background: rgba(255, 255, 255, 0.06);
  color: #9ca3af;
}

/* ============================================
 * Chirpy 精致微调 v1 (2026-07-11)
 * 1. 字体升级:正文思源宋体,标题 Inter,代码 JetBrains Mono
 * 2. 阅读进度条:顶部渐变细条
 * 3. 卡片与列表:悬停微动效
 * 4. 代码块:Mac 风格圆点窗口栏
 * 5. 引用块:强调色边框 + 浅色背景
 * ============================================ */

:root {
  --custom-font-serif: 'Noto Serif SC', 'Source Serif Pro', Georgia, 'Songti SC', 'STSong', 'SimSun', serif;
  --custom-font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft Yahei', sans-serif;
  --custom-font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --custom-accent: #7c7adf;
  --custom-accent-rgb: 124, 122, 223;
}

/* === 1. 字体升级 === */
/* 正文用衬线体(杂志/书籍感),只作用于文章阅读区,不影响 UI */
.post-content p,
.post-content li,
.post-content dd,
.post-content dt {
  font-family: var(--custom-font-serif);
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
}

/* 标题用无衬线,更现代 */
h1, h2, h3, h4, h5, h6,
.post-title, .post-header h1 {
  font-family: var(--custom-font-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* 等宽字体升级 */
code, pre, kbd, samp {
  font-family: var(--custom-font-mono) !important;
}

/* === 2. 阅读进度条 === */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  z-index: 1031; /* 高于 Chirpy 顶部导航 */
  background: linear-gradient(90deg, #7c7adf 0%, #5bc0eb 50%, #ffb86b 100%);
  box-shadow: 0 0 8px rgba(124, 122, 223, 0.5);
  transition: width 0.1s ease-out, opacity 0.3s ease;
  pointer-events: none;
  opacity: 0;
}

/* === 3. 卡片与列表美化 === */
.post-preview .card {
  border: 1px solid var(--card-border-color, rgba(0, 0, 0, 0.08));
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.post-preview .card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--custom-accent-rgb), 0.3);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.post-preview .preview-img {
  overflow: hidden;
}

.post-preview .preview-img img {
  transition: transform 0.4s ease;
}

.post-preview .card:hover .preview-img img {
  transform: scale(1.04);
}

.post-preview .card-title a {
  transition: color 0.2s ease;
}

.post-preview .card:hover .card-title a {
  color: var(--custom-accent);
}

[data-mode="dark"] .post-preview .card:hover {
  border-color: rgba(var(--custom-accent-rgb), 0.5);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* === 4. 代码块:Mac 风格圆点窗口栏 === */
.post-content .highlight {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* 顶部圆点栏背景 */
.post-content .highlight::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.04) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* 三个红黄绿圆点 */
.post-content .highlight::after {
  content: '';
  position: absolute;
  top: 11px;
  left: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f56;
  box-shadow:
    20px 0 0 #ffbd2e,
    40px 0 0 #27c93f;
  pointer-events: none;
  z-index: 2;
}

/* 代码内容下移,给圆点栏留空间 */
.post-content .highlight pre {
  padding-top: 2.5rem !important;
  position: relative;
  z-index: 0;
}

[data-mode="dark"] .post-content .highlight::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 100%);
}

/* 行内代码 */
.post-content :not(pre) > code {
  padding: 0.15em 0.4em !important;
  border-radius: 4px;
  background: rgba(var(--custom-accent-rgb), 0.08);
  color: var(--custom-accent);
  font-size: 0.9em;
  border: 1px solid rgba(var(--custom-accent-rgb), 0.12);
}

[data-mode="dark"] .post-content :not(pre) > code {
  background: rgba(var(--custom-accent-rgb), 0.15);
  color: #a5a3e8;
  border-color: rgba(var(--custom-accent-rgb), 0.25);
}

/* === 5. 引用块美化 === */
.post-content blockquote {
  position: relative;
  padding: 0.8rem 1.2rem 0.8rem 1.5rem !important;
  margin: 1.5rem 0;
  border-left: 4px solid var(--custom-accent) !important;
  border-radius: 0 6px 6px 0;
  background: linear-gradient(90deg, rgba(var(--custom-accent-rgb), 0.06) 0%, transparent 100%);
  color: inherit;
}

[data-mode="dark"] .post-content blockquote {
  background: linear-gradient(90deg, rgba(var(--custom-accent-rgb), 0.12) 0%, transparent 100%);
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}
