/* ============================================================
   光流 · Undertow —— 页面界面层（画布之外的 Chrome）
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: #04050c;
  color: #cfd3e4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#stream {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  cursor: crosshair;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#error {
  position: fixed;
  inset: auto 16px 16px;
  max-width: 30rem;
  margin: 0 auto;
  padding: 14px 18px;
  border: 1px solid rgba(255, 120, 120, 0.4);
  border-radius: 8px;
  background: rgba(40, 8, 12, 0.85);
  color: #ffd9d9;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------------- 顶栏 ---------------- */

.chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(4, 5, 12, 0.7), transparent);
}

.chrome > * { pointer-events: auto; }

.chrome .back {
  color: #aab0c8;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.1em;
  border-bottom: 1px solid rgba(170, 176, 200, 0.35);
  padding-bottom: 2px;
}

.chrome .back:hover { color: #fff; }

.chrome .crumb {
  font-size: 12px;
  letter-spacing: 0.22em;
  color: #e8eaf6;
}

.chrome .hint {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(170, 176, 200, 0.65);
}

body.ready #loader { opacity: 0; }

/* ---------------- 加载进度 ---------------- */

#loader {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: 2px;
  background: rgba(120, 130, 180, 0.15);
  transition: opacity 0.8s;
}

#loader i {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  background: linear-gradient(90deg, #5560c8, #9aa6ff);
  box-shadow: 0 0 12px rgba(122, 134, 255, 0.8);
}

/* ---------------- 缩放刻度 ---------------- */

#meter {
  position: fixed;
  right: 22px;
  top: 50%;
  z-index: 25;
  width: 2px;
  height: 120px;
  margin-top: -60px;
  background: rgba(150, 158, 200, 0.18);
  opacity: 0;
  transition: opacity 0.4s;
}

body.zooming #meter { opacity: 1; }

#meter i {
  position: absolute;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aab4ff;
  box-shadow: 0 0 10px #7a86ff;
  top: calc((1 - var(--z, 0)) * 112px);
}

/* ---------------- 指针 ---------------- */

#cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  border: 1px solid rgba(200, 208, 255, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.18s;
}

body.pointer #cursor { opacity: 0.9; }

body.over-line #cursor {
  transform: scale(2.1);
  border-color: #fff;
  box-shadow: 0 0 14px rgba(160, 172, 255, 0.9);
}

#label {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  margin: 18px 0 0 14px;
  padding: 5px 10px;
  border-radius: 4px;
  background: rgba(8, 10, 22, 0.72);
  color: #dfe3f8;
  font-size: 11px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

body.over-line #label { opacity: 1; }

/* ---------------- 故事面板 ---------------- */

#story {
  position: fixed;
  inset: 0;
  z-index: 50;
}

#story[hidden] { display: none; }

#story .veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(4, 5, 12, 0.82), rgba(4, 5, 12, 0.94));
  opacity: 0;
  transition: opacity 0.5s;
}

#story.show .veil { opacity: 1; }

.story-title {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: #eceefb;
  font-size: 13px;
  letter-spacing: 0.3em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s 0.1s;
}

#story.show .story-title { opacity: 1; }

.story-flow {
  position: absolute;
  inset: 0;
  top: 72px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(140, 148, 200, 0.35) transparent;
  opacity: 0;
  transition: opacity 0.5s 0.05s;
}

#story.show .story-flow { opacity: 1; }

.story-flow .strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 42px;
  width: min(84vw, 400px);
  margin: 0 auto;
  padding: 30px 0 46vh;
}

.strip figure {
  margin: 0;
  position: relative;
  cursor: zoom-in;
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.6s, opacity 0.6s;
}

#story.show .strip figure {
  transform: translateY(0);
  opacity: 1;
}

/* 逐张错落浮现 */
#story.show .strip figure:nth-child(1) { transition-delay: 0.05s; }
#story.show .strip figure:nth-child(2) { transition-delay: 0.12s; }
#story.show .strip figure:nth-child(3) { transition-delay: 0.19s; }
#story.show .strip figure:nth-child(4) { transition-delay: 0.26s; }
#story.show .strip figure:nth-child(5) { transition-delay: 0.33s; }
#story.show .strip figure:nth-child(6) { transition-delay: 0.40s; }
#story.show .strip figure:nth-child(7) { transition-delay: 0.47s; }
#story.show .strip figure:nth-child(8) { transition-delay: 0.54s; }

.strip img {
  display: block;
  width: 100%;
  border-radius: 3px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.strip figcaption {
  margin: 10px 2px 0;
  color: #9aa2c4;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.strip figcaption b {
  color: #dfe3f8;
  font-weight: 500;
}

/* 面板两侧 / 返回按钮 */

.side {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(20, 24, 44, 0.5);
  color: #dfe3f8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.side svg { width: 20px; height: 20px; }

.side:hover { background: rgba(60, 68, 120, 0.55); }

.side.prev { left: 20px; }
.side.next { right: 20px; }

.story-back {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(20, 24, 44, 0.5);
  color: #dfe3f8;
  font-size: 12px;
  letter-spacing: 0.14em;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.story-back svg { width: 15px; height: 15px; }

.story-back:hover { background: rgba(60, 68, 120, 0.55); }

/* 灯箱 */

.lb {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(3, 4, 10, 0.92);
  cursor: zoom-out;
}

/* 自定义了 display，必须显式恢复 hidden 的隐藏效果 */
.lb[hidden] { display: none; }

.lb img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 4px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
}

.lb-cap {
  margin: 0;
  color: #9aa2c4;
  font-size: 12px;
  letter-spacing: 0.16em;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 640px) {
  .chrome .hint { display: none; }
  .side { display: none; }
  .story-flow .strip { width: 78vw; }
}
