/* ============================================================
 * 开场动画外壳（内容为开源项目 Roxy-Antigravity-Boot-Animation）
 * 仅负责：全屏承载、跳过、播放策略、结束后淡出为页面背景
 * ============================================================ */

html.opening-pending body { opacity: 0; }
html.opening-lock { overflow: hidden !important; }
html.opening-lock body { overflow: hidden !important; }

.opening {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: #000;
  overflow: hidden;
  contain: layout paint style;
  opacity: 1;
  transition: opacity 0.9s ease;
  -webkit-tap-highlight-color: transparent;
}

.opening-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.opening-skip {
  position: absolute;
  z-index: 5;
  top: max(16px, calc(env(safe-area-inset-top) + 10px));
  right: max(16px, calc(env(safe-area-inset-right) + 10px));
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(6, 10, 22, 0.55);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  color: rgba(255, 255, 255, 0.82);
  font: 12px/1.4 "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.25s, color 0.25s, border-color 0.25s, background 0.25s;
}
.opening-skip:hover,
.opening-skip:focus-visible {
  opacity: 1;
  color: #fff;
  border-color: rgba(0, 229, 255, 0.55);
  background: rgba(14, 20, 40, 0.62);
  outline: none;
}
.opening-skip:focus-visible { box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.5); }

.opening.is-leaving { opacity: 0; }

/* 播放结束后替换成的 Roxy 背景 */
.opening-ambient-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 42%;
  filter: saturate(1.02) brightness(0.86);
  transform-origin: 62% 44%;
  -webkit-mask-image: radial-gradient(ellipse 82% 86% at 62% 44%, #000 32%, rgba(0, 0, 0, 0.5) 66%, transparent 92%);
  mask-image: radial-gradient(ellipse 82% 86% at 62% 44%, #000 32%, rgba(0, 0, 0, 0.5) 66%, transparent 92%);
  animation: opening-ambient-drift 28s ease-in-out infinite alternate;
}
@keyframes opening-ambient-drift {
  from { transform: scale(1.02); }
  to { transform: scale(1.07) translateY(-1.2%); }
}

/* 播放结束后保留为页面背景 */
.opening.is-ambient {
  z-index: 0;
  pointer-events: none;
  opacity: 0.42;
  background: transparent;
  transition: opacity 3s ease;
}
.opening.is-ambient .opening-frame { pointer-events: none; }
.opening.is-ambient .opening-skip { display: none; }

/* 背景态的柔光压暗层，保证正文可读 */
.opening.is-ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 60% 40%, rgba(4, 7, 18, 0.18), rgba(4, 7, 18, 0.55) 78%),
    linear-gradient(180deg, rgba(3, 5, 14, 0.25), rgba(3, 5, 14, 0.5));
}

html.has-opening-ambient .workspace,
html.has-opening-ambient .container {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .opening { transition-duration: 0.2s; }
  .opening-ambient-img { animation: none; }
}
