/*=== 破损图片占位样式 ===*/
/* 当图片加载失败时,用 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;
}
