/* Original WYz Lab waiting scene. Visibility follows the existing request state;
   no timers, request hooks, fake stages or progress estimates are introduced. */
#canvas {
  display: grid;
  isolation: isolate;
}
#canvas > #empty,
#canvas > #results,
#canvas > #loading-scene {
  grid-area: 1 / 1;
  min-width: 0;
}
.loading-scene {
  display: none;
  min-height: inherit;
  padding: 36px 20px 28px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
#canvas[aria-busy="true"] > #loading-scene { display: flex; }
#canvas[aria-busy="true"] > #empty,
#canvas[aria-busy="true"] > #results {
  visibility: hidden;
  pointer-events: none;
}
/* The previous result retains its height and Blob URLs while waiting. */
.loading-art {
  position: relative;
  width: 260px;
  height: 230px;
  max-width: 100%;
  flex: 0 0 auto;
  margin-bottom: 20px;
}
.loading-halo {
  position: absolute;
  inset: 12px -6px;
  border-radius: 50%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--color-primary) 13%, transparent), transparent 68%);
}
.loading-paper {
  position: absolute;
  width: 148px;
  height: 178px;
  left: calc(50% - 74px);
  top: 25px;
  border: 1px solid var(--color-surface-cream-strong);
  border-radius: 12px;
}
.loading-paper-back {
  background: var(--color-surface-card);
  transform: translate(-14px, 3px) rotate(-10deg);
}
.loading-paper-mid {
  background: var(--color-canvas);
  transform: translate(13px, 3px) rotate(8deg);
}
.loading-paper-front {
  background: var(--surface);
  padding: 11px;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--color-ink) 7%, transparent);
  transform: translateY(0) rotate(-2deg);
}
.loading-drawing {
  height: 128px;
  border: 1px solid var(--color-hairline-soft);
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--color-canvas);
}
.loading-drawing svg { width: 100%; height: auto; overflow: visible; }
.loading-guide {
  stroke: var(--color-hairline);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.loading-ink {
  stroke: var(--color-primary-active);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
}
.loading-ink-sun { stroke: var(--color-primary); }
.loading-ground { stroke: var(--color-hairline); stroke-width: 1.4; stroke-linecap: round; }
.loading-paper-caption { display: flex; gap: 5px; align-items: center; margin-top: 13px; }
.loading-paper-caption i { width: 22px; height: 3px; border-radius: 2px; background: var(--color-hairline); }
.loading-paper-caption i:first-child { width: 36px; background: var(--color-surface-cream-strong); }
.loading-paper-caption i:last-child { width: 10px; margin-left: auto; }
.loading-spark { position: absolute; color: var(--color-primary); line-height: 1; font-weight: 300; }
.loading-spark-one { left: 17px; top: 46px; font-size: 22px; }
.loading-spark-two { right: 16px; bottom: 43px; font-size: 15px; }
.loading-speck { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--color-primary); opacity: .45; }
.loading-speck-one { right: 30px; top: 37px; }
.loading-speck-two { left: 26px; bottom: 49px; width: 3px; height: 3px; }
.loading-eyebrow { color: var(--muted); font-size: 10px; letter-spacing: 2px; margin-bottom: 9px; }
.loading-scene h3 { font-family: var(--display-font); font-size: clamp(21px, 2vw, 25px); font-weight: 400; letter-spacing: -.4px; }
.loading-scene p { font-size: 12px; color: var(--muted); margin-top: 10px; }
.loading-breath { display: flex; gap: 7px; margin-top: 20px; height: 9px; align-items: center; }
.loading-breath span { width: 4px; height: 4px; border-radius: 50%; background: var(--color-primary-active); opacity: .55; }
.loading-note { font-size: 9px; color: var(--muted); margin-top: 14px; }

@keyframes loading-paper-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-5px) rotate(0deg); }
}
@keyframes loading-draw {
  0%, 8% { stroke-dashoffset: 100; opacity: .4; }
  55%, 73% { stroke-dashoffset: 0; opacity: 1; }
  94%, 100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes loading-halo-breathe {
  0%, 100% { transform: scale(.92); opacity: .55; }
  50% { transform: scale(1.04); opacity: .9; }
}
@keyframes loading-spark-breathe {
  0%, 100% { transform: translateY(0); opacity: .3; }
  50% { transform: translateY(-4px); opacity: .8; }
}
@keyframes loading-dot-breathe {
  0%, 100% { transform: scale(.8); opacity: .3; }
  50% { transform: scale(1.2); opacity: .85; }
}

/* Animate only during the real request; loops are gentle, local, and independent. */
@media (prefers-reduced-motion: no-preference) {
  #canvas[aria-busy="true"] .loading-paper-front { animation: loading-paper-float 4.8s ease-in-out infinite; }
  #canvas[aria-busy="true"] .loading-halo { animation: loading-halo-breathe 5.6s ease-in-out infinite; }
  #canvas[aria-busy="true"] .loading-ink { animation: loading-draw 5.4s ease-in-out infinite; }
  #canvas[aria-busy="true"] .loading-ink-sun { animation-delay: -.9s; }
  #canvas[aria-busy="true"] .loading-spark { animation: loading-spark-breathe 4s ease-in-out infinite; }
  #canvas[aria-busy="true"] .loading-spark-two { animation-delay: -2s; }
  #canvas[aria-busy="true"] .loading-breath span { animation: loading-dot-breathe 2s ease-in-out infinite; }
  #canvas[aria-busy="true"] .loading-breath span:nth-child(2) { animation-delay: -.4s; }
  #canvas[aria-busy="true"] .loading-breath span:nth-child(3) { animation-delay: -.8s; }
}
.page-hidden #canvas[aria-busy="true"] .loading-art *,
.page-hidden #canvas[aria-busy="true"] .loading-breath span { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  #loading-scene * { animation: none !important; }
  .loading-ink { stroke-dashoffset: 0; opacity: 1; }
}
@media (max-width: 800px) {
  .loading-scene { padding: 28px 16px; }
  .loading-art { width: 220px; height: 185px; margin-bottom: 14px; }
  .loading-paper { width: 126px; height: 151px; left: calc(50% - 63px); top: 17px; }
  .loading-paper-front { padding: 9px; }
  .loading-drawing { height: 105px; }
  .loading-paper-caption { margin-top: 12px; }
  .loading-spark-one { left: 9px; top: 30px; }
  .loading-spark-two { right: 5px; bottom: 31px; }
  .loading-breath { margin-top: 16px; }
}
@media (forced-colors: active) {
  .loading-halo { display: none; }
  .loading-paper, .loading-drawing { background: Canvas; border-color: CanvasText; box-shadow: none; }
  .loading-guide, .loading-ground, .loading-ink { stroke: CanvasText; }
}
