/* 真实等待状态的动效层：不移动正文或控件，不改变尺寸，不模拟完成比例。
   静态状态先成立；仅在系统允许动效时启动循环，状态移除后立即结束。 */
:root {
  --polish-spin-time: 1s;
  --polish-wait-time: 2.6s;
  --polish-sweep-time: 3.2s;
  --polish-wait-ease: cubic-bezier(.45, 0, .55, 1);
}

/* 新旧按钮加载标记共用一个稳定的转速，边框宽度与占位沿用原组件。 */
.busy-spinner, .spin {
  border-color: color-mix(in srgb, currentColor 24%, transparent);
  border-top-color: currentColor;
  border-right-color: currentColor;
  animation: none;
}
.launch-live {
  border-color: color-mix(in srgb, var(--brand) 24%, transparent);
  border-top-color: var(--brand);
  animation: none;
}
.launch-live::after { background: var(--brand); }

/* 加载图形只转动一圈主环，其余环保持静止，避免多层反向旋转。 */
.ai-loading-orbit > span { animation: none; }
.ai-loading-orbit > span:nth-child(1) {
  border-color: color-mix(in srgb, var(--brand) 18%, var(--border));
  border-top-color: var(--brand);
  animation: none;
}
.ai-loading-orbit > span:nth-child(2) {
  border-color: color-mix(in srgb, var(--brand) 18%, var(--border));
  border-bottom-color: color-mix(in srgb, var(--brand) 55%, var(--border));
  animation: none;
}
.ai-loading-orbit > span:nth-child(3) { opacity: .22; animation: none; }
.ai-skeleton-card > span { background: var(--sunk); animation: none; }

/* 只给正在执行的卡片加材质反馈；排队、失败、完成卡片没有循环。 */
.batch-work .pc.running {
  border-color: color-mix(in srgb, var(--brand) 58%, var(--border));
}
.pc.running .pc-img::after { background: none; animation: none; }
.pc.running .steps span.now { background: var(--brand); animation: none; }
.steps span.now { animation: none; }
#view .design-review-stage .ditem.wait:has(.spin),
#view .design-review-stage .ditem:has(.dbusy) {
  border-color: color-mix(in srgb, var(--brand) 48%, var(--border));
}
#view .design-review-stage .ditem.wait:has(.spin) .dimg { background: var(--surface-2); }
.dbusy { background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--brand); }

/* 思考、日志与重做用小标记轻呼吸，状态文字始终清晰静止。 */
.spin-dot .i, .live.on, .crow-regen.pill > i,
[data-rc-processing] > .i,
.auth-experience[data-submitting="true"] .auth-form-link .i {
  animation: none;
}
.live.on { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.loading span, .typing .bubble span { animation: none; transform: none; opacity: .7; }
.intake-color-scan > i { animation: none; box-shadow: none; }

@media (prefers-reduced-motion: no-preference) {
  .busy-spinner, .spin, .launch-live { animation: polish-wait-spin var(--polish-spin-time) linear infinite; }
  .ai-loading-orbit > span:nth-child(1) { animation: polish-wait-spin 2.4s linear infinite; }

  /* 扫光仅经过占位条，不遮住文字；小面积背景更新不触发布局。 */
  .ai-skeleton-card > span {
    background: linear-gradient(100deg, var(--sunk) 22%, color-mix(in srgb, var(--sunk) 55%, var(--surface)) 48%, var(--sunk) 74%);
    background-size: 240% 100%;
    animation: polish-wait-sweep var(--polish-sweep-time) linear infinite;
  }
  .ai-skeleton-card > span:nth-child(2) { animation-delay: 80ms; }
  .ai-skeleton-card > span:nth-child(3) { animation-delay: 160ms; }

  .pc.running .pc-img::after {
    background: linear-gradient(110deg, transparent 32%, #ffffff1c 49%, transparent 66%);
    background-size: 240% 100%;
    animation: polish-wait-sweep 4s linear infinite;
  }
  .pc.running .steps span.now { animation: polish-wait-breathe var(--polish-wait-time) var(--polish-wait-ease) infinite; }
  #view .design-review-stage .ditem.wait:has(.spin) .dimg {
    background: linear-gradient(110deg, var(--surface-2) 28%, var(--surface) 49%, var(--surface-2) 70%);
    background-size: 240% 100%;
    animation: polish-wait-sweep 4s linear infinite;
  }
  .spin-dot .i, .live.on, .crow-regen.pill > i,
  [data-rc-processing] > .i,
  .auth-experience[data-submitting="true"] .auth-form-link .i {
    animation: polish-wait-breathe var(--polish-wait-time) var(--polish-wait-ease) infinite;
  }
  .loading span, .typing .bubble span { animation: polish-wait-dots 1.6s var(--polish-wait-ease) infinite; }
  .loading span:nth-child(2), .typing .bubble span:nth-child(2) { animation-delay: 140ms; }
  .loading span:nth-child(3), .typing .bubble span:nth-child(3) { animation-delay: 280ms; }
  [data-intake-color-resolution][aria-busy="true"] .intake-color-scan > i {
    animation: polish-wait-scan 2.8s var(--polish-wait-ease) infinite;
  }
}

@keyframes polish-wait-spin { to { transform: rotate(1turn); } }
@keyframes polish-wait-sweep {
  0%, 12% { background-position: 140% 0; }
  72%, 100% { background-position: -140% 0; }
}
@keyframes polish-wait-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: .58; }
}
@keyframes polish-wait-dots {
  0%, 80%, 100% { opacity: .4; }
  36% { opacity: 1; }
}
@keyframes polish-wait-scan {
  0%, 100% { transform: translateY(4px); opacity: .4; }
  50% { transform: translateY(29px); opacity: .85; }
}

/* motion.js 用同一属性表示离屏容器或隐藏的文档，不改任务本身的状态。 */
[data-motion-paused="true"],
[data-motion-paused="true"]::before, [data-motion-paused="true"]::after,
[data-motion-paused="true"] *,
[data-motion-paused="true"] *::before, [data-motion-paused="true"] *::after {
  animation-play-state: paused !important;
}

/* 减少动画时保留全部任务文字和静态进度，连原有动画也确实停止。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .busy-spinner, .spin, .launch-live,
  .ai-loading-orbit > span,
  .loading span, .typing .bubble span { transform: none; opacity: 1; }
  .ai-loading-orbit > span:nth-child(3) { opacity: .22; }
  .ai-skeleton-card > span { background: var(--sunk); }
  .pc.running .pc-img::after { background: none; }
  .pc.running .steps span.now { background: var(--brand); opacity: 1; }
  #view .design-review-stage .ditem.wait:has(.spin) .dimg { background: var(--surface-2); }
  .spin-dot .i, .live.on, .crow-regen.pill > i,
  [data-rc-processing] > .i,
  .auth-experience[data-submitting="true"] .auth-form-link .i { opacity: 1; }
  .intake-color-scan > i { transform: translateY(16px); opacity: .7; }
}
