/*
 * Waiting / processing states.
 *
 * The signature is the split diagram: one mixed signal on the left fanning out
 * into separate stems on the right — the thing the site actually does, used as
 * the status graphic. Colour encodes separation: periwinkle = still mixed,
 * mint = separated. Stems only light up once the job is genuinely being
 * separated, so the graphic never implies progress we do not have.
 */

.wait {
  --w-ink: #000637;
  --w-haze: #bbbbf2;
  --w-mint: #5ed6b3;
  --w-amber: #ffad00;
  --w-blue: #1998ff;
  --w-surface: #fff;
  --w-line: rgba(0, 6, 55, .12);
  --w-muted: rgba(0, 6, 55, .55);

  max-width: 33rem;
  /* States carry different amounts of readout (the queue has an estimate and a
     position, separating has one line). Hold a floor so the card does not jump
     as the job moves between them. */
  min-height: 20rem;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 1.5rem;
  border: 1px solid var(--w-line);
  border-radius: 14px;
  background: var(--w-surface);
  color: var(--w-ink);
  text-align: center;
}

[data-theme="dark"] .wait {
  --w-surface: #11142b;
  --w-ink: #eef0ff;
  --w-line: rgba(187, 187, 242, .18);
  --w-muted: rgba(238, 240, 255, .6);
}

/* --- signature: the split diagram --- */
.wait-split {
  display: block;
  width: 100%;
  max-width: 20rem;
  height: auto;
  margin: 0 auto .25rem;
  overflow: visible;
}

.wait-split path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.wait-split__mix {
  stroke: var(--w-haze);
  stroke-dasharray: 10 8;
  animation: wait-flow 1.6s linear infinite;
}

.wait-split__stem {
  stroke: var(--w-haze);
  opacity: .25;
  transition: opacity .5s ease, stroke .5s ease;
}

.wait-split__node {
  fill: var(--w-haze);
  transition: fill .5s ease;
}

@keyframes wait-flow {
  to { stroke-dashoffset: -18; }
}

/* Stems separate only once the audio is really being worked on. */
.wait[data-stage="separate"] .wait-split__stem,
.wait[data-stage="assemble"] .wait-split__stem {
  stroke: var(--w-mint);
  opacity: 1;
}

.wait[data-stage="separate"] .wait-split__stem { animation: wait-breathe 2.4s ease-in-out infinite; }
.wait[data-stage="separate"] .wait-split__stem:nth-of-type(2) { animation-delay: .2s; }
.wait[data-stage="separate"] .wait-split__stem:nth-of-type(3) { animation-delay: .4s; }
.wait[data-stage="separate"] .wait-split__stem:nth-of-type(4) { animation-delay: .6s; }

.wait[data-stage="separate"] .wait-split__node,
.wait[data-stage="assemble"] .wait-split__node { fill: var(--w-mint); }

/* Assembling runs the flow backwards: stems coming back together. */
.wait[data-stage="assemble"] .wait-split__mix {
  stroke: var(--w-mint);
  animation-direction: reverse;
}

@keyframes wait-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

/* --- pipeline: a real sequence, so it earns its numbering --- */
.wait-steps {
  display: flex;
  justify-content: center;
  gap: .35rem;
  margin: 1rem 0 1.25rem;
  padding: 0;
  list-style: none;
  font-size: .625rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.wait-steps li {
  flex: 1 1 0;
  max-width: 6rem;
  padding-top: .5rem;
  border-top: 2px solid var(--w-line);
  color: var(--w-muted);
  opacity: .6;
}

.wait-steps li.is-done {
  border-top-color: var(--w-mint);
  opacity: .85;
}

.wait-steps li.is-active {
  border-top-color: var(--w-blue);
  color: var(--w-ink);
  opacity: 1;
  font-weight: 600;
}

/* --- readout --- */
.wait-eta {
  margin: 0;
  font-size: 2.5rem;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.wait-eta__label {
  display: block;
  margin-bottom: .3rem;
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--w-muted);
}

.wait-state {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
}

.wait-sub {
  margin: .4rem 0 0;
  font-size: .875rem;
  color: var(--w-muted);
}

.wait-sub b { font-variant-numeric: tabular-nums; }

/* Queue depth, drawn as ticks so position reads at a glance. */
.wait-queue {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin: .9rem 0 0;
}

.wait-queue i {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--w-line);
}

.wait-queue i.is-you {
  background: var(--w-amber);
  height: 20px;
  margin-top: -3px;
}

.wait-foot {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--w-line);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .5rem 1rem;
  font-size: .8125rem;
}

.wait-foot a { color: var(--w-blue); }

.wait-notify {
  border: 1px solid var(--w-line);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  padding: .3rem .85rem;
  font: inherit;
  font-size: .8125rem;
  cursor: pointer;
}

.wait-notify:hover:not([disabled]) { border-color: var(--w-blue); color: var(--w-blue); }
.wait-notify:focus-visible { outline: 2px solid var(--w-blue); outline-offset: 2px; }
.wait-notify[disabled] { opacity: .55; cursor: default; }

.wait-hint {
  margin: .9rem 0 0;
  font-size: .75rem;
  color: var(--w-muted);
}

@media (max-width: 420px) {
  .wait { padding: 1.25rem 1rem; min-height: 18rem; }
  .wait-eta { font-size: 2rem; }
  .wait-steps { font-size: .5625rem; letter-spacing: .08em; }
}

@media (prefers-reduced-motion: reduce) {
  .wait-split__mix,
  .wait[data-stage="separate"] .wait-split__stem { animation: none; }
  .wait-split__mix { stroke-dasharray: none; }
}
