/* ============================================================
   图廊 TTGallery · 图版（masonry，按原图比例）+ 空态 + 灯箱
   布局由 js/grid.js 计算（尺寸来自 js/data.js 的 w/h），
   本文件只给外观；图版一律 absolute，位置由 transform 写入
   ============================================================ */

/* ══ 图版容器 ══ */
.grid {
  position: relative;
  width: 100%;
  contain: layout paint;
}

.tile {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  padding: 0;
  overflow: hidden;
  background: var(--plate);
  border: 0;
  border-radius: var(--r-md);
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
.tile:hover { box-shadow: 0 0 0 1px var(--line-2); filter: brightness(0.97); }
[data-theme="dark"] .tile:hover { filter: brightness(1.08); }
.tile:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.tile-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.tile-img.is-loaded { opacity: 1; }

/* loading 骨架 / error 态（诚实三态） */
.ph {
  position: absolute;
  inset: 0;
  background: var(--surface);
  animation: ph-pulse 1.2s var(--ease) infinite;
}
.ph.is-hidden { display: none; }
.tile-fail {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: var(--fs-2xs);
  color: var(--error);
  background: var(--surface);
}
.tile.is-error .tile-img,
.tile.is-error .ph { display: none; }
.tile.is-error .tile-fail { display: grid; }
@keyframes ph-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* 名称：悬停 / 键盘聚焦时浮出，其余时候画面归图片 */
.tile-veil {
  position: absolute;
  inset: auto 0 0 0;
  display: block;
  padding: 22px 8px 6px;
  text-align: left;
  background: linear-gradient(to top, var(--veil-to), var(--veil-from));
  color: var(--veil-ink);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.tile:hover .tile-veil,
.tile:focus-visible .tile-veil { opacity: 1; }
.tile-name {
  display: block;
  overflow: hidden;
  font-size: var(--fs-2xs);
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 分批渲染的"继续下滑"提示 */
.grid-sentinel {
  padding: var(--sp-5) 0 var(--sp-6);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-align: center;
}

/* ══ 空态（诚实三态） ══ */
.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: var(--sp-7) var(--sp-4);
  text-align: center;
}
.empty-mark {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  color: var(--text-dim);
}
.empty-title { margin: 0; font-size: var(--fs-md); font-weight: 500; }
.empty-sub { margin: 0; max-width: 40ch; font-size: var(--fs-sm); color: var(--text-dim); }

/* ══ 灯箱：左图右签 ══ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--scrim);
  backdrop-filter: blur(6px);
  animation: lb-in var(--t-med) var(--ease);
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

.lb-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: var(--sp-3);
}
.lb-plate {
  display: grid;
  place-items: center;
  max-width: 100%;
  overflow: hidden;
  background: var(--plate);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.lb-plate img {
  display: block;
  max-width: 100%;
  max-height: min(78vh, 940px);
}
.lb-nav {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  color: var(--veil-ink);
  background: var(--media-btn);
  border: 1px solid var(--media-btn-line);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.lb-nav:hover { background: var(--media-btn-hover); }

/* —— 展签面板 —— */
.lb-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  flex: 0 0 280px;
  max-height: 78vh;
  padding: var(--sp-4);
  overflow-y: auto;
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.lb-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.lb-index {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.lb-name {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.lb-spec { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.lb-spec > div { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.lb-spec dt { font-size: var(--fs-xs); color: var(--text-dim); }
.lb-spec dd {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-mid);
  text-align: right;
}
.lb-spec dd.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.lb-download {
  display: grid;
  place-items: center;
  margin-top: auto;
  padding: 9px var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-ink);
  background: var(--ink);
  border-radius: var(--r-md);
  text-decoration: none;
  transition: opacity var(--t-fast) var(--ease);
}
.lb-download:hover { opacity: 0.86; }
.lb-hint {
  margin: 0;
  font-size: var(--fs-2xs);
  color: var(--text-dim);
  text-align: center;
}

/* ══ 触屏：名称常显（无悬停） ══ */
@media (hover: none) {
  .tile-veil { opacity: 1; padding-top: 18px; }
}

/* ══ 灯箱竖屏：上下堆叠 ══ */
@media (max-width: 900px) {
  .lightbox { flex-direction: column; align-items: stretch; gap: var(--sp-3); padding: var(--sp-3); }
  .lb-stage { flex: 0 1 auto; }
  .lb-plate img { max-height: 52vh; }
  .lb-panel { flex: 1 1 auto; max-height: none; }
  .lb-hint { display: none; }
}
