/* ============================================================
   gallery.css — 浏览端：顶栏 / 筛选 / 瀑布流 / 灯箱
   ============================================================ */

.app-header {
  padding: calc(var(--sp-4) + env(safe-area-inset-top)) var(--sp-4) 0;
  max-width: 1200px;
  margin: 0 auto;
}

.app-header h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.app-header .sub {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* 筛选栏：吸顶 */
.filter-wrap {
  position: sticky;
  top: 0;
  padding-top: env(safe-area-inset-top);
  z-index: 20;
  background: hsl(36 44% 96% / 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.filter-inner { max-width: 1200px; margin: 0 auto; }

.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 0 var(--sp-4) var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.result-line .link-clear {
  color: var(--primary-deep);
  font-size: var(--fs-sm);
  padding: var(--sp-1) var(--sp-2);
}

/* 瀑布流（CSS 多列） */
.masonry {
  columns: 2;
  column-gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-8);
  max-width: 1200px;
  margin: 0 auto;
}

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

.card {
  break-inside: avoid;
  margin: 0 0 var(--sp-3);
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:active { transform: scale(0.98); }

.card img {
  display: block;
  width: 100%;
  min-height: 140px;
  background: var(--surface-2);
}

.card img.loaded { min-height: 0; }

.card .broken {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 140px;
  padding: var(--sp-3);
  color: var(--text-2);
  font-size: var(--fs-sm);
  word-break: break-all;
  text-align: center;
}

/* 骨架卡片 */
.card.sk { height: 220px; box-shadow: none; }
.card.sk:nth-child(2n) { height: 170px; }
.card.sk:nth-child(3n) { height: 260px; }

#sentinel { height: 1px; }

.app-footer {
  padding: var(--sp-6) var(--sp-4) calc(var(--sp-8) + env(safe-area-inset-bottom));
  text-align: center;
}

.app-footer a {
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 2px;
}

/* ============ 灯箱 ============ */

.lb {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  background: var(--overlay);
}

.lb.open { display: block; }

.lb-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.lb-stage img {
  max-width: 100vw;
  max-height: 100vh;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.lb-stage img.switching { transition: opacity 0.12s ease; opacity: 0.25; }

.lb-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: calc(var(--sp-2) + env(safe-area-inset-top)) var(--sp-2) var(--sp-2);
  background: linear-gradient(hsl(28 22% 8% / 0.7), transparent);
  color: hsl(36 40% 96%);
  transition: opacity 0.2s ease;
}

.lb-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm);
}

.lb-count { font-size: var(--fs-sm); opacity: 0.85; }

.lb-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
  background: linear-gradient(transparent, hsl(28 22% 8% / 0.7));
  transition: opacity 0.2s ease;
}

.lb-bottom .chip {
  background: hsl(36 30% 96% / 0.14);
  border-color: hsl(36 30% 96% / 0.3);
  color: hsl(36 40% 96%);
  min-height: 30px;
  pointer-events: none;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  color: hsl(36 40% 96% / 0.85);
  width: 48px;
  height: 72px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.lb-nav.prev { left: 0; }
.lb-nav.next { right: 0; }

@media (hover: hover) and (pointer: fine) {
  .lb-nav { display: flex; }
}

.lb.hide-ui .lb-top,
.lb.hide-ui .lb-bottom,
.lb.hide-ui .lb-nav { opacity: 0; pointer-events: none; }
