/* ============================================================
   延时摄影相册页 · 样式（复用 style.css 的设计变量）
   ============================================================ */

.page-gallery main.wrap { padding-top: 22px; }

/* ---------------- 概览 ---------------- */
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.gallery-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.gstat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 15px 9px 11px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.gstat-ico {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: #5ce0b4;
  background: rgba(56, 217, 169, 0.12);
}
.gstat-ico .ico { width: 18px; height: 18px; }
.gstat b {
  display: block;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.gstat span { font-size: 11.5px; color: var(--tx-3); }

.gallery-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 30px 0 12px;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--tx-3);
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 13px; top: 50%;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--tx-3);
  border-bottom: 1.6px solid var(--tx-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--tx-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  max-width: 190px;
}
.select-wrap select option { background: #0e1626; color: var(--tx); }

.btn.primary {
  background: rgba(56, 217, 169, 0.15);
  border-color: rgba(56, 217, 169, 0.3);
  color: #8ef7cf;
  height: 36px;
}
.btn.primary:hover { background: rgba(56, 217, 169, 0.24); color: #b6ffe4; }

/* ---------------- 网格 ---------------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 12px;
}
.tile {
  position: relative;
  margin: 0;                 /* figure 默认有 1em 40px 外边距，会把缩略图压窄 */
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: #0d1524;
  border: 1px solid var(--line-soft);
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.3s;
  opacity: 0;
}
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.045); }
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
.tile-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 26px 10px 8px;
  background: linear-gradient(to top, rgba(4, 8, 14, 0.88), rgba(4, 8, 14, 0));
  font-size: 11.5px;
  color: #d7e3f4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.tile-cap .cap-size { color: rgba(215, 227, 244, 0.6); }

.tile-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.tile-play i {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(6, 12, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(4px);
}
.tile-play .ico { width: 20px; height: 20px; color: #fff; fill: #fff; stroke: none; }

/* ---------------- 空状态 ---------------- */
.empty-state {
  margin: 30px auto 10px;
  max-width: 520px;
  padding: 34px 26px;
  text-align: center;
  border-radius: 18px;
  background: var(--panel);
  border: 1px dashed rgba(255, 255, 255, 0.14);
}
.empty-ico {
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: rgba(56, 217, 169, 0.1);
  color: #5ce0b4;
}
.empty-state h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.empty-state p { margin: 0 0 8px; font-size: 12.5px; color: var(--tx-3); line-height: 1.7; }
.empty-state .empty-hint { margin-top: 12px; font-size: 11.5px; }
.empty-state code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--tx-2);
  font-size: 11.5px;
}

.load-more-wrap { display: flex; justify-content: center; padding: 22px 0 6px; }

/* ---------------- 灯箱 ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
}
.lightbox.on { display: block; }
.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.94);
  backdrop-filter: blur(6px);
  animation: fade 0.16s ease;
}
.lb-stage {
  position: absolute;
  inset: 0 0 74px 0;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px 74px;
}
.lb-stage img,
.lb-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 30px 70px -30px #000;
  background: #000;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e9eef8;
  cursor: pointer;
  z-index: 2;
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.14); }
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 16px; }
.lb-nav[disabled] { opacity: 0.28; cursor: default; }
.lb-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 74px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: linear-gradient(to top, rgba(4, 8, 14, 0.96), rgba(4, 8, 14, 0.5));
  border-top: 1px solid var(--line-soft);
}
.lb-info { flex: 1 1 auto; min-width: 0; }
.lb-info b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.lb-info span {
  display: block;
  font-size: 11.5px;
  color: var(--tx-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- 延时播放 ---------------- */
.show {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: none;
  background: #04070d;
}
.show.on { display: block; }
.show-stage {
  position: absolute;
  inset: 0 0 78px 0;
  display: grid;
  place-items: center;
  padding: 16px;
}
.show-stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 24px 60px -28px #000;
}
.show-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 78px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px calc(env(safe-area-inset-bottom, 0px)) 18px;
  background: rgba(6, 10, 18, 0.96);
  border-top: 1px solid var(--line-soft);
}
.show-progress { flex: 1 1 auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.show-progress span {
  font-size: 12px;
  color: var(--tx-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.show-progress .bar {
  position: relative;
  flex: 1 1 auto;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.show-progress .bar b {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: linear-gradient(90deg, #34d3a4, #38bdf8);
  border-radius: 2px;
  transition: width 0.12s linear;
}
.seg.small { padding: 2px; border-radius: 9px; }
.seg.small button { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }
.show-unit { font-size: 11.5px; color: var(--tx-3); white-space: nowrap; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
}

@media (max-width: 720px) {
  .page-gallery main.wrap { padding-top: 14px; }
  .gallery-head { gap: 12px; margin-bottom: 12px; }
  .gallery-stats { width: 100%; gap: 8px; }
  .gstat { flex: 1 1 auto; padding: 8px 12px 8px 9px; gap: 8px; }
  .gstat-ico { width: 28px; height: 28px; border-radius: 9px; }
  .gstat-ico .ico { width: 15px; height: 15px; }
  .gstat b { font-size: 15px; }
  .gstat span { font-size: 10.5px; }
  .gallery-tools { width: 100%; }
  .select-wrap { flex: 1 1 auto; min-width: 0; }
  .select-wrap select { max-width: 100%; width: 100%; }
  .btn.primary { flex: 0 0 auto; }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 8px;
  }
  .tile { border-radius: 11px; }
  .tile-cap { padding: 20px 8px 6px; font-size: 10.5px; flex-wrap: wrap; gap: 0 6px; }
  .tile-cap > span:first-child { flex: 1 1 auto; }
  .tile-cap .cap-size { flex: 0 0 auto; }
  .tile-play i { width: 38px; height: 38px; }
  .tile-play .ico { width: 16px; height: 16px; }

  .lb-stage { inset: 0 0 82px 0; padding: 12px; }
  .lb-nav { width: 38px; height: 38px; top: auto; bottom: 96px; transform: none; }
  .lb-nav.prev { left: 12px; }
  .lb-nav.next { right: 12px; }
  .lb-bar { height: 82px; padding: 0 14px; gap: 10px; }
  .lb-info b { font-size: 12.5px; }

  /* 播放器控件改成两行：播放/进度/关闭 一行，帧率一行 */
  .show-bar {
    height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "toggle progress close"
      "fps    fps      fps";
    gap: 9px 12px;
    padding: 11px 14px calc(11px + env(safe-area-inset-bottom, 0px));
  }
  #showToggle { grid-area: toggle; }
  .show-progress { grid-area: progress; }
  .show-bar > [data-close] { grid-area: close; }
  #fpsSeg { grid-area: fps; justify-self: center; }
  .show-progress .bar { height: 3px; }
  .show-stage { inset: 0 0 128px 0; padding: 10px; }
  .show-unit { display: none; }
}

@media (max-width: 420px) {
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
}

/* 视频缩略（浏览器会渲染首帧） */
.tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a1020;
}

/* ---------------- 合成按钮 ---------------- */
#composeBtn {
  min-width: 108px;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
#composeBtn.busy { cursor: progress; opacity: 0.82; }
#composeBtn.busy .ico { animation: spin 1.3s linear infinite; }
.btn[disabled] { opacity: 0.42; cursor: default; }
.btn[disabled]:hover {
  color: var(--tx-2);
  background: var(--panel-2);
  border-color: var(--line);
}

/* ---------------- 轻提示 ---------------- */
.toast {
  position: fixed;
  /* left/right + margin:auto + fit-content 才能让气泡按文字宽度居中；
     只写 left:50% 的话可用宽度只剩一半，长文案会被硬折行 */
  left: 0;
  right: 0;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  z-index: 210;
  width: -moz-fit-content;
  width: fit-content;
  max-width: min(88vw, 460px);
  margin: 0 auto;
  transform: translateY(14px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 24, 40, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e8efff;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
  box-shadow: 0 20px 48px -18px #000, 0 0 0 1px rgba(0, 0, 0, 0.4) inset;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.toast.on { opacity: 1; transform: translateY(0); }

@media (max-width: 720px) {
  /* 别盖住底部标签栏 */
  .toast {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    font-size: 12.5px;
    padding: 9px 16px;
  }
}

@media (max-width: 470px) {
  /* 窄屏：场次选择占一行，两个按钮平分下一行 */
  .select-wrap { flex: 1 1 100%; }
  .gallery-tools .btn { flex: 1 1 0; min-width: 0; justify-content: center; padding: 0 8px; }
  #composeBtn { min-width: 0; }
}
