/* ==========================================================================
 * 相册集惰性加载样式（独立文件，仅作用于 .gallery-lazy，不影响全局）
 * 一行 4 个固定方形网格，占位与图片尺寸一致（加载前后不跳动）
 * 流程：模糊渐变占位 + loading 旋转 → 图片 load 完成 → 加 .is-loaded 揭开遮罩
 * ========================================================================== */

/* 用 grid 做规整网格：桌面一行 4 个，窄屏逐级减少。
   （不用瀑布流 columns，避免占位高度不一导致位置乱跳） */
.gallery-lazy {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
@media screen and (max-width: 1200px) {
  .gallery-lazy { grid-template-columns: repeat(3, 1fr); }
}
@media screen and (max-width: 768px) {
  .gallery-lazy { grid-template-columns: repeat(2, 1fr); }
}
@media screen and (max-width: 480px) {
  .gallery-lazy { grid-template-columns: 1fr; }
}

.gallery-lazy-item {
  position: relative;
}

/* 用高优先级覆盖主题 .article-container a 的 border-bottom:2px dotted（蓝色虚线） */
.article-container .gallery-lazy-link {
  position: relative;
  display: block;
  overflow: hidden;
  /* 固定 1:1 方形：占位与成品同尺寸，加载过程位置不跳动 */
  aspect-ratio: 1 / 1;
  background: var(--efu-card-bg, #e9e9e9);
  /* 无边框、无圆角、无阴影、无下划线 */
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none;
  text-decoration: none !important;
  font-weight: normal;
  color: inherit;
}

/* 图片填满方格并裁切为方形；未加载时透明，由遮罩占位。
   用高优先级覆盖主题的 .article-container img:not(.post_bg) 的
   border-radius:12px / margin / max-width:90% / max-height:450px */
.article-container .gallery-lazy-link .gallery-lazy-img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: cover;
  border: 0;
  border-radius: 0 !important;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity .5s ease, transform .5s ease;
}

.gallery-lazy-item.is-loaded .gallery-lazy-img {
  opacity: 1;
  transform: scale(1);
}

/* 隐藏主题 addPhotoFigcaption() 为相册图片插入的文件名标题（仅相册内，不影响全局） */
.gallery-lazy .img-alt {
  display: none !important;
}

/* 遮罩：盖在图片上，加载完成后淡出 */
.gallery-lazy-mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none; /* 点击穿透到 <a>，随时可打开灯箱 */
  transition: opacity .5s ease, visibility .5s ease;
}

.gallery-lazy-item.is-loaded .gallery-lazy-mask {
  opacity: 0;
  visibility: hidden;
}

/* 模糊色块：渐变 + blur + 微动画，营造毛玻璃占位感 */
.gallery-lazy-blur {
  position: absolute;
  inset: -24px;
  background: linear-gradient(135deg, #dfe6f0 0%, #e9dfe8 45%, #dcebe6 100%);
  background-size: 200% 200%;
  filter: blur(18px);
  animation: gallery-lazy-shimmer 2.2s ease-in-out infinite alternate;
}

/* 用不同色相区分相邻占位，避免整片同色 */
.gallery-lazy-item:nth-child(3n + 2) .gallery-lazy-blur {
  background: linear-gradient(135deg, #e7e2d8 0%, #dde5ee 50%, #e8dfe4 100%);
}
.gallery-lazy-item:nth-child(3n + 3) .gallery-lazy-blur {
  background: linear-gradient(135deg, #dfeae4 0%, #e6e0ee 50%, #eee3d9 100%);
}

/* loading 旋转圈 */
.gallery-lazy-loading {
  position: relative;
  z-index: 1;
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, .55);
  border-top-color: #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, .12);
  animation: gallery-lazy-spin .85s linear infinite;
}

/* 加载失败：遮罩保留，隐藏旋转圈，显示友好提示（不露出 broken 图） */
.gallery-lazy-item.is-error .gallery-lazy-loading {
  display: none;
}
.gallery-lazy-item.is-error .gallery-lazy-mask::after {
  content: '图片加载失败';
  font-size: 13px;
  color: var(--efu-secondtext, #888);
  letter-spacing: 1px;
}

@keyframes gallery-lazy-shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

@keyframes gallery-lazy-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-lazy-blur,
  .gallery-lazy-loading { animation: none; }
}

/* ==========================================================================
 * 相册灯箱（Fancybox v5）专属覆盖
 * 灯箱容器挂在 body 下，但本样式仅相册详情页引用，故不影响其它页面
 * ========================================================================== */

/* 深色背景：覆盖任何浅色主题/默认白色，避免预览刺眼 */
.fancybox__container {
  --fancybox-bg: rgba(18, 18, 20, .96) !important;
}

/* 底部缩略图条：默认展开后的外观，贴合深色背景 */
.fancybox__thumbs {
  --f-thumbs-strip-bg: rgba(0, 0, 0, .35);
}
