/* ============================================================
   首页动态背景板 · 星云主题（v2.9.0 新增 / v2.11.0 主题联动）
   5 套可选主题：calm / flow / particles / aurora / abyss
   ------------------------------------------------------------
   性能策略：
   - 仅使用 transform / opacity 动画（合成层，主线程零重绘）；
   - 云层以柔和径向渐变模拟辉光，不依赖 filter:blur（避免昂贵滤镜，
     仅在极光帷幕用 6px 轻模糊，移动端再降到 3px）；
   - mix-blend-mode:screen 让光晕在深色底上叠加发光；
   - 粒子由 assets/js/nebula.js 统一驱动（按面积计算密度、DPR≤2、
     30fps 上限、离屏/标签页隐藏暂停、reduced-motion 关闭）。
   响应式：粒子密度由 JS 按视口面积自适应；此处仅做必要降级。
   联动：body.nebula-on 时 hero 透明、入场遮罩透出星云，形成统一过渡；
        云层颜色由 color-mix(var(--blue*)…) 从当前家族/明暗派生，
        切换主题或日/夜时自动更新（旧浏览器回退 rgba 原色）。
   ============================================================ */

.nebula{
  position:absolute; inset:0; overflow:hidden; pointer-events:none; z-index:0;
  opacity:0;
  filter:hue-rotate(var(--nebula-hue, 0deg));
  transition:filter .45s ease;
}
body.nebula-on .nebula{ opacity:1; animation:nbReveal 1.2s ease both; }
@keyframes nbReveal{ from{opacity:.5;} to{opacity:1;} }

/* 云层基元（柔和辉光团） */
.nebula .nb{
  position:absolute; border-radius:48% 52% 60% 40% / 55% 45% 55% 45%;
  opacity:0; mix-blend-mode:screen; will-change:transform,opacity;
}
.n1{ width:62vmax; height:62vmax; left:-12vmax; top:-18vmax; }
.n2{ width:52vmax; height:52vmax; right:-14vmax; top:2vmax; }
.n3{ width:46vmax; height:46vmax; left:18vmax;  bottom:-22vmax; }
.n4{ width:40vmax; height:40vmax; right:8vmax;  bottom:-12vmax; }

/* 粒子画布（统一引擎驱动） */
.nebula-fx{ position:absolute; inset:0; width:100%; height:100%; z-index:3; }

/* 流光带（flow 专用） */
.nb-ribbon{
  position:absolute; left:-30%; top:30%; width:160%; height:24vmax;
  background:linear-gradient(100deg,transparent,rgba(15,181,201,0) 20%,rgba(120,200,255,.35) 50%,rgba(15,181,201,0) 80%,transparent);
  background:linear-gradient(100deg,transparent,color-mix(in srgb, var(--accent) 0%, transparent) 20%,color-mix(in srgb, var(--blue-l) 35%, transparent) 50%,color-mix(in srgb, var(--accent) 0%, transparent) 80%,transparent);
  transform:rotate(-12deg) translateX(-20%); opacity:0; mix-blend-mode:screen;
  will-change:transform,opacity;
}
/* 极光帷幕（aurora 专用） */
.nb-curtain{
  position:absolute; inset:-10% -10% 30% -10%;
  background:
    linear-gradient(100deg,transparent 0%,rgba(80,255,200,0) 25%,rgba(120,255,210,.30) 45%,rgba(90,200,255,.22) 60%,transparent 80%),
    linear-gradient(80deg,transparent 10%,rgba(120,160,255,.18) 50%,transparent 70%);
  background:
    linear-gradient(100deg,transparent 0%,color-mix(in srgb, var(--accent) 0%, transparent) 25%,color-mix(in srgb, var(--accent) 30%, transparent) 45%,color-mix(in srgb, var(--blue) 22%, transparent) 60%,transparent 80%),
    linear-gradient(80deg,transparent 10%,color-mix(in srgb, var(--blue) 18%, transparent) 50%,transparent 70%);
  opacity:0; mix-blend-mode:screen; transform-origin:top center; will-change:transform,opacity;
  filter:blur(6px);
}

/* ---------- 主题：none（保持现状，仅粒子，无云层，底透明） ---------- */
.nebula[data-nebula="none"]{ background:transparent; }
.nebula[data-nebula="none"] .nb,
.nebula[data-nebula="none"] .nb-ribbon,
.nebula[data-nebula="none"] .nb-curtain{ display:none; }

/* ---------- 通用：激活主题给基底（替换 hero 原渐变，颜色随家族/明暗联动） ---------- */
.nebula[data-nebula^="nebula-"]{
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(15,181,201,.16), transparent 55%),
    linear-gradient(135deg, var(--blue-d), var(--blue) 60%, var(--blue-l));
  background:
    radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%),
    linear-gradient(135deg, var(--blue-d), var(--blue) 60%, var(--blue-l));
}

/* ---------- 1. calm 静谧：极慢柔和云团飘移，极低粒子 ---------- */
.nebula[data-nebula="nebula-calm"] .n1{ background:radial-gradient(circle at 50% 50%,rgba(20,86,176,.55),transparent 62%); animation:nbDrift1 46s ease-in-out infinite; }
.nebula[data-nebula="nebula-calm"] .n1{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-d) 55%, transparent),transparent 62%); }
.nebula[data-nebula="nebula-calm"] .n2{ background:radial-gradient(circle at 50% 50%,rgba(15,181,201,.50),transparent 60%); animation:nbDrift2 54s ease-in-out infinite; }
.nebula[data-nebula="nebula-calm"] .n2{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--accent) 50%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-calm"] .n3{ background:radial-gradient(circle at 50% 50%,rgba(60,120,220,.45),transparent 60%); animation:nbDrift3 60s ease-in-out infinite; }
.nebula[data-nebula="nebula-calm"] .n3{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue) 45%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-calm"] .n4{ background:radial-gradient(circle at 50% 50%,rgba(150,245,255,.40),transparent 58%); animation:nbDrift1 50s ease-in-out infinite reverse; }
.nebula[data-nebula="nebula-calm"] .n4{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-l) 40%, transparent),transparent 58%); }
.nebula[data-nebula="nebula-calm"] .nb{ opacity:.60; }

/* ---------- 2. flow 流光：较快流光带 + 多层渐变流动 ---------- */
.nebula[data-nebula="nebula-flow"] .n1{ background:radial-gradient(circle at 50% 50%,rgba(20,86,176,.60),transparent 60%); animation:nbDrift1 24s ease-in-out infinite; }
.nebula[data-nebula="nebula-flow"] .n1{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-d) 60%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-flow"] .n2{ background:radial-gradient(circle at 50% 50%,rgba(15,181,201,.55),transparent 58%); animation:nbDrift2 30s ease-in-out infinite; }
.nebula[data-nebula="nebula-flow"] .n2{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--accent) 55%, transparent),transparent 58%); }
.nebula[data-nebula="nebula-flow"] .n3{ background:radial-gradient(circle at 50% 50%,rgba(90,160,255,.50),transparent 58%); animation:nbDrift3 28s ease-in-out infinite; }
.nebula[data-nebula="nebula-flow"] .n3{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue) 50%, transparent),transparent 58%); }
.nebula[data-nebula="nebula-flow"] .n4{ background:radial-gradient(circle at 50% 50%,rgba(150,245,255,.50),transparent 56%); animation:nbDrift1 26s ease-in-out infinite reverse; }
.nebula[data-nebula="nebula-flow"] .n4{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-l) 50%, transparent),transparent 56%); }
.nebula[data-nebula="nebula-flow"] .nb{ opacity:.70; }
.nebula[data-nebula="nebula-flow"] .nb-ribbon{ opacity:.90; animation:nbRibbon 16s linear infinite; }

/* ---------- 3. particles 粒子：云团极淡，星点闪烁 + 连线网络为主 ---------- */
.nebula[data-nebula="nebula-particles"] .n1{ background:radial-gradient(circle at 50% 50%,rgba(20,86,176,.35),transparent 60%); animation:nbDrift1 40s ease-in-out infinite; }
.nebula[data-nebula="nebula-particles"] .n1{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-d) 35%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-particles"] .n2{ background:radial-gradient(circle at 50% 50%,rgba(15,181,201,.30),transparent 60%); animation:nbDrift2 46s ease-in-out infinite; }
.nebula[data-nebula="nebula-particles"] .n2{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--accent) 30%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-particles"] .n3,
.nebula[data-nebula="nebula-particles"] .n4{ display:none; }
.nebula[data-nebula="nebula-particles"] .nb{ opacity:.32; }

/* ---------- 4. aurora 极光：多色光帷幕纵向摆动（色相随家族主色派生） ---------- */
.nebula[data-nebula="nebula-aurora"] .n1{ background:radial-gradient(circle at 50% 50%,rgba(20,86,176,.50),transparent 60%); animation:nbDrift1 34s ease-in-out infinite; }
.nebula[data-nebula="nebula-aurora"] .n1{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-d) 50%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-aurora"] .n2{ background:radial-gradient(circle at 50% 50%,rgba(15,181,201,.45),transparent 58%); animation:nbDrift2 40s ease-in-out infinite; }
.nebula[data-nebula="nebula-aurora"] .n2{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--accent) 45%, transparent),transparent 58%); }
.nebula[data-nebula="nebula-aurora"] .n3,
.nebula[data-nebula="nebula-aurora"] .n4{ display:none; }
.nebula[data-nebula="nebula-aurora"] .nb{ opacity:.55; }
.nebula[data-nebula="nebula-aurora"] .nb-curtain{
  top:-12%; right:auto; bottom:22%; left:-100%; width:300%;
  background:linear-gradient(100deg,
      rgba(80,255,170,.40) 0%,
      rgba(170,90,255,.36) 16%,
      rgba(70,150,255,.40) 33%,
      rgba(255,110,200,.34) 50%,
      rgba(170,90,255,.36) 66%,
      rgba(70,150,255,.40) 83%,
      rgba(80,255,170,.40) 100%) repeat-x;
  background:linear-gradient(100deg,
      color-mix(in srgb, var(--accent) 40%, transparent) 0%,
      color-mix(in srgb, var(--blue-d) 36%, transparent) 16%,
      color-mix(in srgb, var(--blue) 40%, transparent) 33%,
      color-mix(in srgb, var(--blue-l) 34%, transparent) 50%,
      color-mix(in srgb, var(--blue-d) 36%, transparent) 66%,
      color-mix(in srgb, var(--blue) 40%, transparent) 83%,
      color-mix(in srgb, var(--accent) 40%, transparent) 100%) repeat-x;
  background-size:33.333% 100%;
  opacity:.95; filter:blur(7px);
  animation:nbAurora 7s ease-in-out infinite;
}

/* ---------- 5. abyss 深海：大绽放 + 上升气泡 ---------- */
.nebula[data-nebula="nebula-abyss"] .n1{ background:radial-gradient(circle at 50% 50%,rgba(13,50,110,.70),transparent 64%); animation:nbBloom1 30s ease-in-out infinite; }
.nebula[data-nebula="nebula-abyss"] .n1{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-d) 70%, transparent),transparent 64%); }
.nebula[data-nebula="nebula-abyss"] .n2{ background:radial-gradient(circle at 50% 50%,rgba(20,86,176,.60),transparent 62%); animation:nbBloom2 38s ease-in-out infinite; }
.nebula[data-nebula="nebula-abyss"] .n2{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue-d) 60%, transparent),transparent 62%); }
.nebula[data-nebula="nebula-abyss"] .n3{ background:radial-gradient(circle at 50% 50%,rgba(15,181,201,.50),transparent 60%); animation:nbBloom1 44s ease-in-out infinite reverse; }
.nebula[data-nebula="nebula-abyss"] .n3{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--accent) 50%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-abyss"] .n4{ background:radial-gradient(circle at 50% 50%,rgba(60,140,230,.50),transparent 60%); animation:nbBloom2 34s ease-in-out infinite; }
.nebula[data-nebula="nebula-abyss"] .n4{ background:radial-gradient(circle at 50% 50%,color-mix(in srgb, var(--blue) 50%, transparent),transparent 60%); }
.nebula[data-nebula="nebula-abyss"] .nb{ opacity:.70; }

/* ---------- 关键帧 ---------- */
@keyframes nbDrift1{ 0%{transform:translate3d(0,0,0) scale(1);} 50%{transform:translate3d(6vmax,4vmax,0) scale(1.12);} 100%{transform:translate3d(0,0,0) scale(1);} }
@keyframes nbDrift2{ 0%{transform:translate3d(0,0,0) scale(1.05);} 50%{transform:translate3d(-7vmax,5vmax,0) scale(.92);} 100%{transform:translate3d(0,0,0) scale(1.05);} }
@keyframes nbDrift3{ 0%{transform:translate3d(0,0,0) scale(1);} 50%{transform:translate3d(4vmax,-6vmax,0) scale(1.15);} 100%{transform:translate3d(0,0,0) scale(1);} }
@keyframes nbBloom1{ 0%{transform:scale(.85);opacity:.50;} 50%{transform:scale(1.18);opacity:.85;} 100%{transform:scale(.85);opacity:.50;} }
@keyframes nbBloom2{ 0%{transform:scale(1.10);opacity:.45;} 50%{transform:scale(.90);opacity:.80;} 100%{transform:scale(1.10);opacity:.45;} }
@keyframes nbRibbon{ 0%{transform:rotate(-12deg) translateX(-20%);} 100%{transform:rotate(-12deg) translateX(20%);} }
@keyframes nbAurora{ 0%{transform:translateX(0) skewX(-5deg) scaleY(1);} 50%{transform:translateX(-33.333%) skewX(5deg) scaleY(1.14);} 100%{transform:translateX(0) skewX(-5deg) scaleY(1);} }

/* ---------- 入场遮罩联动：激活主题时仍保持不透明页面转场（不直接透出星云，
   遮罩淡出后自然揭示已就位的首页与星云背景，形成干净的「不透明转场进入首页」 ---------- */
body.nebula-on .brand-intro{
  background:
    radial-gradient(120% 120% at 50% 38%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%),
    linear-gradient(135deg, var(--blue-d), var(--blue) 55%, var(--blue-l));
}

/* ---------- Hero 基底：激活主题时透明，交由星云层承载背景 ---------- */
body.nebula-on .hero{ background:transparent; }
body.nebula-on .hero::after{ opacity:.10; }

/* ---------- 响应式降级 ---------- */
@media (max-width:768px){
  .nebula .nb{ opacity:.55 !important; }
  .nb-curtain{ filter:blur(3px); }
  .nebula[data-nebula="nebula-aurora"] .nb-curtain{ filter:blur(4px); }
}

/* ---------- reduced-motion：全部静止，保留静态深色底与可读背景 ---------- */
@media (prefers-reduced-motion: reduce){
  .nebula{ opacity:1 !important; }
  .nebula *{ animation:none !important; }
  .nb-ribbon,.nb-curtain{ display:none !important; }
  .nebula-fx{ display:none !important; }
  body.nebula-on .brand-intro{
    background:
      radial-gradient(120% 120% at 50% 38%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%),
      linear-gradient(135deg, var(--blue-d), var(--blue) 55%, var(--blue-l));
  }
}
