/* ==========================================================================
   电影级视觉层 CINEMATIC LAYER
   --------------------------------------------------------------------------
   · .cine        固定叠层：遮幅 / 闪光 / 横向扫光 / 颗粒 / 暗角 / 形态刻度轨
   · #fx-canvas   three.js 粒子层（随模组切换形变）
   · .stage-num   舞台内的大号模组编号水印
   本文件只加层，不改任何原有元素的结构与文案。
   ========================================================================== */

/* ---- three.js 粒子层 ---- */
#fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1500ms ease;
  pointer-events: none;
}
#fx-canvas.is-live { opacity: 1; }

/* ---- 固定电影叠层 ---- */
.cine {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  overflow: hidden;
}

/* 三个混合模式层：直接在 body 下，固定定位并盖在内容之上 */
.cine-streak,
.cine-flash,
.cine-grain {
  position: fixed;
  inset: 0;
  z-index: 72;
  pointer-events: none;
  opacity: 0;
}
.cine-flash { z-index: 74; }
.cine-grain { z-index: 76; }

/* 上下遮幅：切换瞬间收窄画幅 */
.cine-mask {
  position: absolute;
  left: 0;
  right: 0;
  height: 10vh;
  background: #04050a;
  transform: scaleY(0);
  opacity: 0;
  transition: transform 520ms cubic-bezier(0.7, 0, 0.2, 1), opacity 400ms ease;
}
.cine-mask.top { top: 0; transform-origin: top; }
.cine-mask.bottom { bottom: 0; transform-origin: bottom; }
.cine.is-cut .cine-mask {
  transform: scaleY(1);
  opacity: 1;
}

/* 曝光闪光 */
.cine-flash {
  background:
    radial-gradient(68% 58% at 50% 46%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 62%),
    radial-gradient(120% 90% at 50% 50%, rgba(var(--accent-rgb), 0.4), transparent 70%);
  mix-blend-mode: screen;
}

/* 变形宽银幕横向光扫 */
.cine-streak {
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 32%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 32%,
    rgba(255, 255, 255, 0.34) 50%,
    rgba(var(--accent-rgb), 0.28) 62%,
    transparent 100%
  );
  filter: blur(16px);
  mix-blend-mode: screen;
}

/* 胶片颗粒 */
.cine-grain {
  inset: -20%;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23g)'/%3E%3C/svg%3E");
  animation: grainShift 900ms steps(4) infinite;
}
@keyframes grainShift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-2%, 1.5%, 0); }
  50% { transform: translate3d(1.5%, -1%, 0); }
  75% { transform: translate3d(-1%, -2%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* 暗角 */
.cine-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(122% 98% at 50% 46%, transparent 40%, rgba(0, 0, 0, 0.62) 100%);
}

/* 右侧形态刻度轨 */
.cine-rail {
  position: absolute;
  right: max(0.5rem, calc(var(--gutter) * 0.3));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-end;
}
.cine-rail i {
  display: block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  opacity: 0.3;
  transform: scaleX(0.55);
  transform-origin: right;
  transition: opacity 420ms ease, transform 420ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 420ms ease, width 420ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cine-rail i.on {
  opacity: 1;
  transform: scaleX(1);
  width: 30px;
  box-shadow: 0 0 14px currentColor;
}

/* 开场帷幕 */
.cine-curtain {
  position: absolute;
  inset: 0;
  background: #04050a;
  opacity: 1;
  z-index: 3;
}

/* ---- 舞台内的编号水印 ---- */
.stage { position: relative; }
.stage-num {
  position: absolute;
  right: clamp(0.5rem, 3vw, 2rem);
  top: clamp(0.1rem, 0.8vw, 0.7rem);
  z-index: 0;
  font-family: var(--font-display);
  font-size: clamp(6rem, 21vw, 14rem);
  line-height: 0.82;
  letter-spacing: -0.06em;
  color: rgba(255, 255, 255, 0.05);
  pointer-events: none;
  user-select: none;
  text-shadow: 0 0 70px rgba(var(--accent-rgb), 0.18);
}
.stage-inner,
.detail-tabs,
.dpanel { position: relative; z-index: 1; }

/* ---- 标题逐字进场 ---- */
.mod-title { perspective: 800px; }

/* 拆分后的标题：父级不再用 background-clip，改为每个字符自带渐变，
   否则子 span 会继承 color:transparent 而整段标题变成空白。 */
.mod-title.is-split {
  background-image: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
}
.mod-title.is-split .w {
  display: inline-block;
  white-space: nowrap;
}
.mod-title.is-split .ch {
  display: inline-block;
  white-space: pre;
  background-image: linear-gradient(180deg, #fff 42%, rgba(var(--accent-rgb), 0.85));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stage[data-cine="in"] .mod-title.is-split .ch {
  animation: charIn 780ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
@keyframes charIn {
  from {
    opacity: 0;
    transform: translate3d(0, 0.5em, 0) rotateX(-68deg);
    filter: blur(8px);
  }
}

/* ---- 色卡的扫描光 ---- */
.chip .chip-scan {
  position: absolute;
  inset: -40% auto -40% -30%;
  width: 30%;
  opacity: 0;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
}
.chip[aria-selected="true"] .chip-scan {
  animation: chipScan 2800ms cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes chipScan {
  0% { opacity: 0; transform: translateX(0) skewX(-18deg); }
  12% { opacity: 0.8; }
  60% { opacity: 0; }
  100% { opacity: 0; transform: translateX(640%) skewX(-18deg); }
}

/* ---- 取景框：四角括号 + 中心十字，切换瞬间收紧 ---- */
.cine-frame {
  position: absolute;
  /* 垂直方向要让开 10vh 的遮幅条，取景框才不会被黑边盖住 */
  inset: calc(10vh + 16px) clamp(12px, 2.4vw, 34px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 320ms ease;
}
.cine-frame .fc {
  position: absolute;
  display: block;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.55);
}
.cine-frame .fc.tl,
.cine-frame .fc.tr,
.cine-frame .fc.bl,
.cine-frame .fc.br {
  width: 22px;
  height: 22px;
  background: none;
  border: 0;
}
.cine-frame .fc.tl { top: 0; left: 0; border-top: 1.5px solid rgba(255, 255, 255, 0.6); border-left: 1.5px solid rgba(255, 255, 255, 0.6); }
.cine-frame .fc.tr { top: 0; right: 0; border-top: 1.5px solid rgba(255, 255, 255, 0.6); border-right: 1.5px solid rgba(255, 255, 255, 0.6); }
.cine-frame .fc.bl { bottom: 0; left: 0; border-bottom: 1.5px solid rgba(255, 255, 255, 0.6); border-left: 1.5px solid rgba(255, 255, 255, 0.6); }
.cine-frame .fc.br { bottom: 0; right: 0; border-bottom: 1.5px solid rgba(255, 255, 255, 0.6); border-right: 1.5px solid rgba(255, 255, 255, 0.6); }
.cine-frame .fc.cross { opacity: 0; }
.cine-frame .fc.cross.h { left: 50%; top: 50%; width: 26px; height: 1px; transform: translate(-50%, -50%); }
.cine-frame .fc.cross.v { left: 50%; top: 50%; width: 1px; height: 26px; transform: translate(-50%, -50%); }
.cine.is-cut .cine-frame { opacity: 1; }
.cine.is-cut .cine-frame .fc.tl,
.cine.is-cut .cine-frame .fc.tr,
.cine.is-cut .cine-frame .fc.bl,
.cine.is-cut .cine-frame .fc.br {
  animation: frameLock 620ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes frameLock {
  0% { transform: scale(1.9); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.cine.is-cut .cine-frame .fc.cross { opacity: 0.55; }

/* ---- 胶片时码条 ---- */
.cine-tc {
  position: absolute;
  left: clamp(10px, 2.2vw, 30px);
  bottom: clamp(8px, 2vh, 22px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 300ms ease, transform 300ms ease;
  pointer-events: none;
}
.cine.is-cut .cine-tc { opacity: 1; transform: translateY(0); }
.cine-tc .tc-label { opacity: 0.85; }
.cine-tc .tc-time {
  font-variant-numeric: tabular-nums;
  padding: 0.1rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.28);
}
.cine-tc .tc-bar {
  display: block;
  width: clamp(70px, 13vw, 180px);
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.cine-tc .tc-bar i {
  display: block;
  height: 100%;
  width: 38%;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.35), var(--accent));
}
.cine.is-cut .cine-tc .tc-bar i { animation: tcSweep 620ms cubic-bezier(0.33, 0, 0.2, 1); }
@keyframes tcSweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(265%); }
}
.cine-tc .tc-shot { color: var(--accent); font-weight: 700; }

/* ---- 冲击瞬间的整屏色偏：像换了一卷胶片 ---- */
.cine-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(var(--accent-rgb), 0.16);
  mix-blend-mode: multiply;
  opacity: 0;
}
.cine.is-cut .cine-flash::after { animation: filmShift 620ms ease-out; }
@keyframes filmShift {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- 变形宽银幕光晕：切换瞬间镜头前的蓝色横条炫光 ---- */
.cine-flare {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0;
}
.cine-flare i {
  display: block;
  width: 130%;
  height: clamp(2px, 0.32vh, 4px);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(120, 196, 255, 0.5) 26%,
    rgba(214, 240, 255, 0.95) 48%,
    rgba(255, 255, 255, 0.98) 50%,
    rgba(214, 240, 255, 0.95) 52%,
    rgba(120, 196, 255, 0.5) 74%,
    transparent 100%
  );
  box-shadow:
    0 0 22px rgba(120, 196, 255, 0.7),
    0 0 70px rgba(80, 150, 255, 0.42),
    0 0 160px rgba(50, 110, 255, 0.24);
  transform: scaleX(0);
  transform-origin: center;
  mix-blend-mode: screen;
}
.cine.is-cut .cine-flare { opacity: 1; }
.cine.is-cut .cine-flare i { animation: flareStrike 700ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes flareStrike {
  0% { transform: scaleX(0) scaleY(0.4); opacity: 0; filter: blur(0px); }
  22% { transform: scaleX(1.04) scaleY(1.6); opacity: 1; filter: blur(2px); }
  46% { transform: scaleX(1) scaleY(1); opacity: 0.9; filter: blur(0px); }
  100% { transform: scaleX(1) scaleY(0.18); opacity: 0; filter: blur(1px); }
}
/* 光晕的垂直辉光核心 */
.cine-flare::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(46vw, 620px);
  height: min(46vw, 620px);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(150, 205, 255, 0.22), transparent 72%);
  opacity: 0;
  mix-blend-mode: screen;
}
.cine.is-cut .cine-flare::after { animation: flareBloom 700ms ease-out; }
@keyframes flareBloom {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.18); }
}

/* ---- 标题色散：切入瞬间红/青分离，落定后合拢 ---- */
.stage[data-cine="in"] .mod-title.is-split .ch {
  animation:
    charIn 780ms cubic-bezier(0.16, 1, 0.3, 1) both,
    chroma 620ms cubic-bezier(0.2, 0, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 26ms), 0ms;
}
@keyframes chroma {
  0% {
    text-shadow:
      -0.055em 0 rgba(255, 44, 76, 0.95),
      0.055em 0 rgba(0, 226, 255, 0.95);
  }
  45% {
    text-shadow:
      -0.024em 0 rgba(255, 44, 76, 0.6),
      0.024em 0 rgba(0, 226, 255, 0.6);
  }
  100% {
    text-shadow:
      0 0 rgba(255, 44, 76, 0),
      0 0 rgba(0, 226, 255, 0);
  }
}

/* ---- 减少动态时全部静止 ---- */
@media (prefers-reduced-motion: reduce) {
  .cine-grain { animation: none; }
  .chip[aria-selected="true"] .chip-scan { animation: none; opacity: 0; }
  .stage[data-cine="in"] .mod-title.is-split .ch { animation: none; }
  .cine-frame, .cine-tc, .cine-flare { display: none; }
  .stage[data-cine="in"] .mod-title.is-split .ch { text-shadow: none; }
  .cine-flash::after { display: none; }
  #fx-canvas { opacity: 1; transition: none; }
}

/* ---- 合成提示：动效层尽量走 GPU ---- */
.cine-flash,
.cine-streak,
.cine-grain,
.cine-frame,
.cine-tc,
.cine-flare,
.cine-flare i { will-change: transform, opacity; }
.chip .chip-scan { will-change: transform, opacity; }

.cine-grain,
.bg-noise,
.cine-flash,
.cine-streak,
.cine-tc { display: none; }

#fx-canvas.is-live { opacity: 0.4; }
