/* 琴心画布 · 生成中状态高级动画 v9
   纯 CSS，不改动生成 / 积分 / 上传逻辑。
   视觉语言：精密仪器 / HUD —— 细网格、微幅刻度弧、四角角标、细扫描线。
   已移除上一版过大的中心圆环。 */

@keyframes qxga-breathe {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255,255,255,.055), inset 0 0 64px rgba(0,0,0,.55), 0 0 12px rgba(110,152,246,.04); }
  50%      { box-shadow: inset 0 0 0 1px rgba(255,255,255,.115), inset 0 0 78px rgba(0,0,0,.62), 0 0 26px rgba(110,152,246,.12); }
}

@keyframes qxga-spin {
  from { transform: translate(-50%,-50%) rotate(0deg); }
  to   { transform: translate(-50%,-50%) rotate(360deg); }
}

@keyframes qxga-scanline {
  0%   { background-position-y: -12%; opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { background-position-y: 112%; opacity: 0; }
}

@keyframes qxga-title-pulse {
  0%, 100% { opacity: .88; }
  50%      { opacity: 1; }
}

@keyframes qxga-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200,215,242,.5); opacity: .8; }
  50%      { box-shadow: 0 0 0 4px rgba(215,221,217,0); opacity: 1; }
}

@keyframes qxga-dot-saving {
  0%, 100% { box-shadow: 0 0 0 0 rgba(110,152,246,.6); opacity: .8; }
  50%      { box-shadow: 0 0 0 5px rgba(110,152,246,0); opacity: 1; }
}

@keyframes qxga-sheen {
  0%   { background-position: -60% 0; }
  100% { background-position: 160% 0; }
}

/* ========== 1. 卡片底：细网格 + 四角角标 + 中心十字准星 ========== */
.canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface {
  isolation: isolate;
  border-radius: 14px;
  background-color: #151b26;
  background-image:
    linear-gradient(rgba(255,255,255,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    linear-gradient(180deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    linear-gradient(90deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    linear-gradient(180deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    linear-gradient(90deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    linear-gradient(180deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    linear-gradient(90deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    linear-gradient(180deg, rgba(110,152,246,.5), rgba(110,152,246,.5)),
    radial-gradient(40% 36% at 50% 50%, rgba(110,152,246,.13), rgba(110,152,246,.03) 52%, transparent 76%),
    radial-gradient(44% 38% at 22% 12%, rgba(190,215,255,.10), transparent 70%),
    radial-gradient(48% 42% at 82% 90%, rgba(110,160,245,.10), transparent 72%),
    linear-gradient(158deg, #151b26 0%, #1d2534 52%, #121822 100%);
  background-size:
    28px 28px, 28px 28px,
    16px 1px, 1px 16px,
    16px 1px, 1px 16px,
    16px 1px, 1px 16px,
    16px 1px, 1px 16px,
    100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-position:
    0 0, 0 0,
    14px 14px, 14px 14px,
    right 14px top 14px, right 14px top 14px,
    left 14px bottom 14px, left 14px bottom 14px,
    right 14px bottom 14px, right 14px bottom 14px,
    center, center, center, center;
  background-repeat:
    repeat, repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat, no-repeat, no-repeat;
  animation: qxga-breathe 6.8s ease-in-out infinite;
}

/* ========== 2. 微幅刻度弧（尺寸约为上一版的 1/3） ========== */
.canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface:before {
  content: '';
  position: absolute;
  inset: auto;
  left: 50%;
  top: 50%;
  width: 30%;
  aspect-ratio: 1 / 1;
  max-width: 110px;
  max-height: 110px;
  border-radius: 50%;
  background-image:
    repeating-conic-gradient(from 0deg,
      rgba(110,152,246,.8) 0deg .7deg,
      rgba(110,152,246,0) .7deg 6deg),
    conic-gradient(from 200deg,
      rgba(110,152,246,0) 0deg,
      rgba(196,224,255,.16) 46deg,
      rgba(228,240,255,.95) 86deg,
      rgba(110,152,246,.5) 116deg,
      rgba(110,152,246,0) 160deg,
      rgba(110,152,246,0) 360deg),
    conic-gradient(from 20deg,
      rgba(178,158,255,0) 0deg,
      rgba(178,158,255,.62) 34deg,
      rgba(178,158,255,0) 78deg,
      rgba(178,158,255,0) 360deg);
  -webkit-mask: radial-gradient(closest-side, transparent 0 88%, #000 89.5% 97%, transparent 98%);
  mask: radial-gradient(closest-side, transparent 0 88%, #000 89.5% 97%, transparent 98%);
  filter: drop-shadow(0 0 4px rgba(110,152,246,.45));
  opacity: .85;
  transform: translate(-50%,-50%);
  animation: qxga-spin 22s linear infinite;
}

/* ========== 3. 细横向扫描线 ========== */
.canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface:after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(180deg,
    transparent 0%,
    rgba(110,152,246,.06) 40%,
    rgba(255,246,241,.42) 50%,
    rgba(110,152,246,.06) 60%,
    transparent 100%);
  background-size: 100% 12%;
  background-repeat: no-repeat;
  background-position-y: -12%;
  mix-blend-mode: screen;
  animation: qxga-scanline 4.6s cubic-bezier(.45,0,.55,1) infinite;
  pointer-events: none;
}

/* ========== 4. 左上角『视频生成中』标签：与边框留出间距 ========== */
.canvas-node:is(.image-canvas-node,.video-canvas-node) .generation-state-title {
  top: 14px;
  left: 14px;
  max-width: calc(100% - 28px);
  min-height: 26px;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border-radius: 8px;
  background: rgba(15,18,21,.8);
  border: 1px solid rgba(110,152,246,.34);
  box-shadow: 0 4px 16px rgba(0,0,0,.5), inset 0 0 14px rgba(110,152,246,.09);
}

.canvas-node:is(.image-canvas-node,.video-canvas-node) .generation-state-title:before {
  content: '';
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  margin: 0;
  border-radius: 50%;
  background: linear-gradient(90deg, #559ce9, #9c7bec);
  animation: qxga-dot-saving 2s ease-in-out infinite;
}

.canvas-node:is(.image-canvas-node,.video-canvas-node) .generation-state-title strong,
.text-canvas-node .node-head.generation-state-title strong {
  color: #eaf1ff;
  font-weight: 600;
  letter-spacing: .03em;
  animation: qxga-title-pulse 3.4s ease-in-out infinite;
}

.canvas-node:is(.image-canvas-node,.video-canvas-node) .generation-state-title button {
  margin-left: 2px;
  padding: 0 6px;
  min-height: 17px;
}

.text-canvas-node .node-head.generation-state-title {
  top: 14px;
  left: 14px;
  min-height: 26px;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border-radius: 8px;
  background: rgba(15,18,21,.8);
  border: 1px solid rgba(110,152,246,.34);
}

/* ========== 5. 计时条：站点统一进度条风格 ========== */
.qx-timing-phase.generating:before {
  animation: qxga-dot 1.8s ease-in-out infinite;
}

.qx-timing-phase.saving:before {
  animation: qxga-dot-saving 1.4s ease-in-out infinite;
}

.qx-timing-progress > span {
  width: 96px;
  height: 3px;
  border-radius: 3px;
  background: #e6eeff1a;
  overflow: hidden;
}

.qx-timing-progress > span > i {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--accent-strong, #d7ddd9);
  transition: width .8s ease;
  overflow: hidden;
}

.qx-timing-progress > span > i:after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background-image: linear-gradient(90deg,
    rgba(255,255,255,0), rgba(255,255,255,.42), rgba(255,255,255,0));
  background-size: 60% 100%;
  background-repeat: no-repeat;
  animation: qxga-sheen 1.6s linear infinite;
}

.qx-timing-progress.generating > span > i {
  background: linear-gradient(90deg, #559ce9, #9c7bec);
}

.qx-timing-progress.saving > span > i {
  background: linear-gradient(90deg, #559ce9, #9c7bec);
}

.qx-timing-progress.failed > span > i {
  background: #ee9292;
}

.qx-timing-progress.failed > span > i:after {
  animation: none;
  background-image: none;
}

/* ========== 6. 浅色主题 ========== */
body.light .canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface {
  background-color: #edf2fa;
  background-image:
    linear-gradient(rgba(40,52,86,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40,52,86,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    linear-gradient(180deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    linear-gradient(90deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    linear-gradient(180deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    linear-gradient(90deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    linear-gradient(180deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    linear-gradient(90deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    linear-gradient(180deg, rgba(92,128,232,.42), rgba(92,128,232,.42)),
    radial-gradient(40% 36% at 50% 50%, rgba(110,152,246,.14), transparent 76%),
    radial-gradient(44% 38% at 22% 12%, rgba(255,255,255,.9), transparent 70%),
    radial-gradient(48% 42% at 82% 90%, rgba(176,202,236,.4), transparent 72%),
    linear-gradient(158deg, #f2f6fc 0%, #e5ebf6 52%, #edf2fa 100%);
  background-size:
    28px 28px, 28px 28px,
    16px 1px, 1px 16px,
    16px 1px, 1px 16px,
    16px 1px, 1px 16px,
    16px 1px, 1px 16px,
    100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-position:
    0 0, 0 0,
    14px 14px, 14px 14px,
    right 14px top 14px, right 14px top 14px,
    left 14px bottom 14px, left 14px bottom 14px,
    right 14px bottom 14px, right 14px bottom 14px,
    center, center, center, center;
  background-repeat:
    repeat, repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat,
    no-repeat, no-repeat, no-repeat, no-repeat;
  box-shadow: inset 0 0 0 1px rgba(40,52,86,.09), inset 0 0 34px rgba(40,52,86,.05);
  animation: none;
}

body.light .canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface:after {
  mix-blend-mode: normal;
  background-image: linear-gradient(180deg,
    transparent 0%,
    rgba(92,128,232,.06) 40%,
    rgba(235,244,255,.9) 50%,
    rgba(92,128,232,.06) 60%,
    transparent 100%);
}

body.light .canvas-node:is(.image-canvas-node,.video-canvas-node) .generation-state-title,
body.light .text-canvas-node .node-head.generation-state-title {
  background: rgba(255,255,255,.88);
  border-color: rgba(92,128,232,.3);
  box-shadow: 0 4px 14px rgba(40,52,86,.13);
}

body.light .canvas-node:is(.image-canvas-node,.video-canvas-node) .generation-state-title strong,
body.light .text-canvas-node .node-head.generation-state-title strong {
  color: #23262a;
}

body.light .qx-timing-progress > span {
  background: rgba(40,52,86,.1);
}

body.light .qx-timing-progress > span > i {
  background: #2a3350;
}

body.light .qx-timing-progress.generating > span > i {
  background: linear-gradient(90deg, rgba(92,128,232,.5), #5b7fe8);
}

body.light .qx-timing-progress.saving > span > i {
  background: #5b7fe8;
}

/* ========== 7. 无障碍降级 ========== */
@media (prefers-reduced-motion: reduce) {
  .canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface,
  .canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface:before,
  .canvas-node:is(.image-canvas-node,.video-canvas-node) .generation-state-title:before,
  .canvas-node .generation-state-title strong,
  .text-canvas-node .node-head.generation-state-title strong,
  .qx-timing-phase.generating:before,
  .qx-timing-phase.saving:before,
  .qx-timing-progress > span > i:after {
    animation: none !important;
  }
  .canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface:after {
    display: none;
  }
  .canvas-node:is(.image-canvas-node,.video-canvas-node,.text-canvas-node) .generation-running-surface:before {
    opacity: .55;
  }
}
