/* ==========================================================================
   Vanta BIRDS 动态背景层
   来源：目标站 /assets/css/motion.css（只摘取 ambient 相关规则，不引入其
   卡片/弹窗动效体系，避免和 ng-target.css 的像素层打架）
   ========================================================================== */

/* ng-ui.css 有 body.ng-skin > * {position:relative;z-index:1}（0,1,1），
   比单个类选择器权重高，必须带 !important 才能压回 fixed/-1 */
body.ng-skin > .ng-motion-ambient {
  position: fixed !important;
  inset: 0 !important;
  z-index: -1 !important;
  width: auto !important;
  height: auto !important;
  overflow: hidden;
  contain: strict;
  pointer-events: none;
  opacity: .2;
  /* 目标站此处是 --ng-page-deep 实色；本项目页面底色在 body 上，
     让 Vanta 场景底色贴近页面底色，避免整层盖成灰白 */
  background: transparent;
}

/* Vanta 取色与场景底色。
   控制器把探针 span 挂到 <html> 上读色，变量必须定义在根元素，
   挂在 body 上读不到（会取到 0 变成黑色鸟） */
html {
  --ng-motion-primary: #6a4693;
  --ng-motion-secondary: #a06a3f;
  --ng-page-deep: #f8f3fb;
  --ng-page: #f8f3fb;
}

/* 暗色：场景底色必须跟着 body 的 #0b1326 走，否则 0.2 的浅色画布会把暗夜页洗灰 */
html[data-theme="dark"] {
  --ng-motion-primary: #c9a8ed;
  --ng-motion-secondary: #d8a05f;
  --ng-page-deep: #0b1326;
  --ng-page: #0b1326;
}

.ng-motion-ambient::before,
.ng-motion-ambient::after {
  content: none;
}

.ng-motion-ambient canvas {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  transform: scale(1.015);
}

.ng-motion-ambient canvas,
.ng-vanta-fallback {
  filter: blur(2px);
  opacity: .55;
}

/* WebGL 不可用时的同族 SVG 兜底（目标站原样保留） */
.ng-vanta-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: var(--ng-motion-primary, #6a4693);
  stroke: none;
  animation: ng-vanta-drift 16s ease-in-out -4s infinite alternate;
}

.ng-vanta-bird {
  animation: ng-vanta-flight 9s ease-in-out var(--bird-delay) infinite alternate;
}

.ng-vanta-wing {
  fill: var(--ng-motion-secondary, #a06a3f);
}

.ng-vanta-bird:nth-child(even) {
  display: none;
}

@keyframes ng-vanta-drift {
  from { transform: translate3d(-2%, 2%, 0) scale(1); }
  to   { transform: translate3d(2%, -2%, 0) scale(1.08); }
}

@keyframes ng-vanta-flight {
  from { transform: translate3d(-18px, 12px, 0); }
  to   { transform: translate3d(24px, -18px, 0); }
}

/* 关闭动效时整层不渲染（目标站 motion.css 同款降级） */
html[data-motion="off"] .ng-motion-ambient,
html.ng-motion-reduced .ng-motion-ambient {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .ng-motion-ambient { display: none; }
}

/* 目标站靠 html.ng-motion-ready body{isolation:isolate} 让 z-index:-1 的
   ambient 落在 body 自己的背景之上、正文之下；这里等价实现，
   body 的紫金渐变保持不动 */
body.ng-skin {
  isolation: isolate;
}
