/* ============================================================
   CL-indexi 样式
   配色：背景 #f5f4f1 / 卡片 #ffffff / 主文字 #2b2b2b / 强调色 #3d5a5e
   ============================================================ */

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #f5f4f1;
  color: #2b2b2b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  line-height: 1.6;
}

img { display: block; max-width: 100%; }

/* ---------- 页头 ---------- */
.site-header { padding: 1rem 2rem; }

.site-name {
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #3d5a5e;
}

/* ---------- Hero 区 ---------- */
.hero { padding: 4rem 2rem 3rem; text-align: center; }

.hero-title { font-size: 2.5rem; letter-spacing: 0.1em; }

.hero-subtitle { margin-top: 0.75rem; color: #777; }

/* ---------- 画廊：CSS columns 瀑布流 ---------- */
.gallery {
  columns: 1;
  column-gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

@media (min-width: 640px)  { .gallery { columns: 2; } }
@media (min-width: 1024px) { .gallery { columns: 3; } }
@media (min-width: 1600px) { .gallery { columns: 4; } }

/* ---------- 作品卡片 ---------- */
.card {
  position: relative;
  width: 100%;
  break-inside: avoid;              /* 防止卡片被列打断 */
  margin: 0 0 1.5rem;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  outline: none;
  /* 入场动画初始态：卡片生成时透明下移，.visible 后恢复 */
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease,
    box-shadow 0.3s ease;
}

.card-img {
  width: 100%;
  height: auto;
  background: #e8e6e2;              /* 加载中的浅灰底 */
}

/* 入场动画完成态（由 script.js 添加，注意本规则须在 :hover 之前） */
.card.visible { opacity: 1; transform: none; }

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.card:focus-visible {
  outline: 2px solid #3d5a5e;
  outline-offset: 2px;
}

/* 图片加载失败：显示灰色占位 + 标题（Review Focus #1） */
.card.img-failed .card-img { display: none; }

.card.img-failed::before {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e3e1dc;
  color: #999;
}

/* ---------- 悬停信息浮层（纯 CSS） ---------- */
.card-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2.5rem 1rem 1rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.card:hover .card-info,
.card:focus-visible .card-info {
  opacity: 1;
  transform: none;
}

.card-info h2 { font-size: 1.05rem; font-weight: 600; }

.card-info p {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  display: -webkit-box;             /* 简介只显示前两行 */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 页脚 ---------- */
.site-footer {
  padding: 2rem;
  text-align: center;
  color: #999;
  font-size: 0.9rem;
}

/* ---------- Lightbox 大图预览 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;  /* 顶部对齐：内容溢出时可滚动，避免居中裁切 */
  gap: 1rem;
  padding: 1.5rem;
  background: rgba(20, 20, 20, 0.94);
  animation: lb-fade 0.25s ease;
  overflow-y: auto;             /* 矮视口（如横屏手机）下滚动查看完整内容 */
}

/* 必须覆盖 .lightbox 的 display:flex，否则 hidden 属性不生效 */
.lightbox[hidden] { display: none; }

@keyframes lb-fade { from { opacity: 0; } }

.lb-img {
  max-width: 92vw;
  max-height: 78vh;
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.5);
  margin: auto 0;               /* 空间充足时垂直居中；不足时归零、随容器滚动 */
}

.lb-info { color: #fff; text-align: center; max-width: 60ch; }

.lb-title { font-size: 1.2rem; }

.lb-desc { margin-top: 0.4rem; color: #ccc; }

/* Lightbox 按钮：关闭（右上角）、上一张/下一张（左右居中） */
.lb-close,
.lb-prev,
.lb-next {
  position: absolute;
  border: none;
  background: none;
  color: #fff;
  font-size: 2.2rem;
  line-height: 1;
  padding: 0.5rem 1rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.lb-close { top: 1rem; right: 1rem; }

.lb-prev { left: 0.5rem; top: 50%; transform: translateY(-50%); }

.lb-next { right: 0.5rem; top: 50%; transform: translateY(-50%); }

.lb-close:hover,
.lb-prev:hover,
.lb-next:hover,
.lb-close:focus-visible,
.lb-prev:focus-visible,
.lb-next:focus-visible { opacity: 1; }

/* 小屏：箭头与关闭按钮缩小，留出图片空间 */
@media (max-width: 640px) {
  .lb-close, .lb-prev, .lb-next { font-size: 1.6rem; padding: 0.5rem; }
}
