/* Motion layer for running mock flows and working chat state. */

.demo-motion-signal {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  margin: 0 0 12px;
  padding: 10px 0 11px;
  border-bottom: 1px solid var(--border, #dedbd3);
}
.demo-motion-signal.compact { margin-top: 2px; }
.demo-motion-signal strong,
.demo-motion-signal small { display: block; }
.demo-motion-signal strong { font-size: 12px; }
.demo-motion-signal small { margin-top: 2px; color: var(--muted, #77746d); font-size: 11px; }
.demo-motion-signal small.swap { animation: demo-motion-copy-in .32s ease-out; }

.demo-motion-core {
  width: 30px;
  height: 30px;
  position: relative;
  display: grid;
  place-items: center;
}
.demo-motion-core::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2f7d5b;
  box-shadow: 0 0 0 5px rgba(47, 125, 91, .08);
}
.demo-motion-core > i {
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(47, 125, 91, .24);
  border-radius: 50%;
  animation: demo-motion-orbit 2.4s linear infinite;
}
.demo-motion-core > i:nth-child(2) {
  inset: 7px;
  border-style: dashed;
  animation-duration: 1.65s;
  animation-direction: reverse;
}

.demo-motion-bars {
  height: 24px;
  display: flex;
  gap: 3px;
  align-items: center;
}
.demo-motion-bars i {
  width: 3px;
  height: 7px;
  border-radius: 999px;
  background: #5f8d77;
  transform-origin: center;
  animation: demo-motion-bars 1s ease-in-out infinite;
}
.demo-motion-bars i:nth-child(2) { animation-delay: .12s; }
.demo-motion-bars i:nth-child(3) { animation-delay: .24s; }
.demo-motion-bars i:nth-child(4) { animation-delay: .36s; }

.demo-flow-steps.demo-motion-running li.active::after {
  content: '';
  position: absolute;
  left: 11px;
  top: 28px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #2f7d5b;
  box-shadow: 0 0 0 4px rgba(47, 125, 91, .08);
  animation: demo-motion-step-travel 1.8s ease-in-out infinite;
  z-index: 2;
}
.demo-flow-steps.demo-motion-running li.active:last-child::after { display: none; }
.demo-motion-packet { display: none; }
.demo-flow-steps.demo-motion-running li.active > span {
  position: relative;
}
.demo-flow-steps.demo-motion-running li.active > span::after {
  content: '';
  position: absolute;
  left: 0;
  right: 10%;
  bottom: -7px;
  height: 1px;
  background: linear-gradient(90deg, rgba(47, 125, 91, .32), rgba(47, 125, 91, 0));
  transform-origin: left;
  animation: demo-motion-active-line 1.9s ease-in-out infinite;
}

.demo-motion-card-running {
  position: relative;
  overflow: hidden;
}
.demo-motion-card-running::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(47, 125, 91, .72), transparent);
  animation: demo-motion-card-scan 2.5s linear infinite;
}

.demo-motion-vibe-running {
  position: relative;
  overflow: hidden;
}
.demo-motion-rail {
  height: 2px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  overflow: hidden;
  pointer-events: none;
}
.demo-motion-rail i {
  position: absolute;
  top: 0;
  width: 34px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #4d876d, transparent);
  animation: demo-motion-rail-run 3s linear infinite;
}
.demo-motion-rail i:nth-child(2) { animation-delay: 1s; }
.demo-motion-rail i:nth-child(3) { animation-delay: 2s; }

.demo-motion-chat-strip-running {
  position: relative;
  overflow: hidden;
}
.demo-motion-chat-strip-running::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(47, 125, 91, .68), transparent);
  animation: demo-motion-strip-scan 2.8s linear infinite;
}

.demo-chat-worker {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  margin: 0 24px 14px;
  max-width: 760px;
  animation: demo-motion-worker-in .3s ease-out both;
}
.demo-chat-worker-avatar {
  width: 34px;
  height: 34px;
  position: relative;
  display: grid;
  place-items: center;
}
.demo-chat-worker-avatar > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2, #f0eee8);
  font-size: 11px;
  font-weight: 700;
  z-index: 1;
}
.demo-chat-worker-avatar > i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  border-top-color: rgba(47, 125, 91, .78);
  border-right-color: rgba(47, 125, 91, .2);
  animation: demo-motion-spin 1.35s linear infinite;
}
.demo-chat-worker-body {
  min-width: 0;
  padding: 10px 12px 9px;
  border: 1px solid var(--border, #dedbd3);
  border-radius: 13px;
  background: var(--surface, #fff);
}
.demo-chat-worker-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.demo-chat-worker-head strong { font-size: 12px; }
.demo-chat-worker-head > span {
  font-size: 10px;
  color: var(--muted, #77746d);
  white-space: nowrap;
}
.demo-chat-worker-head > span i {
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 3px;
  border-radius: 50%;
  background: #2f7d5b;
  animation: demo-live-pulse 1.8s ease-in-out infinite;
}
.demo-chat-worker p {
  margin: 7px 0 9px;
  color: var(--muted, #66635d);
  font-size: 12px;
  line-height: 1.45;
}
.demo-chat-worker p::after {
  content: '';
  width: 5px;
  height: 12px;
  display: inline-block;
  vertical-align: -2px;
  margin-left: 4px;
  border-radius: 1px;
  background: rgba(47, 125, 91, .58);
  animation: demo-motion-caret .85s steps(1) infinite;
}
.demo-chat-worker p.swap { animation: demo-motion-copy-in .32s ease-out; }
.demo-chat-worker-line {
  display: grid;
  grid-template-columns: 1.1fr .8fr 1.4fr .65fr 1fr;
  gap: 4px;
  height: 3px;
  overflow: hidden;
}
.demo-chat-worker-line i {
  border-radius: 999px;
  background: rgba(47, 125, 91, .16);
  position: relative;
  overflow: hidden;
}
.demo-chat-worker-line i::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(47, 125, 91, .72), transparent);
  transform: translateX(-120%);
  animation: demo-motion-worker-line 1.9s linear infinite;
}
.demo-chat-worker-line i:nth-child(2)::after { animation-delay: .12s; }
.demo-chat-worker-line i:nth-child(3)::after { animation-delay: .24s; }
.demo-chat-worker-line i:nth-child(4)::after { animation-delay: .36s; }
.demo-chat-worker-line i:nth-child(5)::after { animation-delay: .48s; }

@keyframes demo-motion-copy-in {
  from { opacity: .35; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes demo-motion-orbit { to { transform: rotate(360deg); } }
@keyframes demo-motion-bars {
  0%, 100% { transform: scaleY(.55); opacity: .4; }
  50% { transform: scaleY(1.7); opacity: 1; }
}
@keyframes demo-motion-step-travel {
  0% { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  78% { opacity: 1; }
  100% { transform: translateY(31px); opacity: 0; }
}
@keyframes demo-motion-active-line {
  0%, 100% { transform: scaleX(.2); opacity: .25; }
  50% { transform: scaleX(1); opacity: .9; }
}
@keyframes demo-motion-card-scan {
  from { transform: translateX(-120%); }
  to { transform: translateX(320%); }
}
@keyframes demo-motion-rail-run {
  from { transform: translateX(-48px); }
  to { transform: translateX(calc(100vw + 48px)); }
}
@keyframes demo-motion-strip-scan {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
@keyframes demo-motion-worker-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes demo-motion-spin { to { transform: rotate(360deg); } }
@keyframes demo-motion-caret { 0%, 48% { opacity: 1; } 49%, 100% { opacity: 0; } }
@keyframes demo-motion-worker-line { to { transform: translateX(120%); } }

@media (max-width: 760px) {
  .demo-motion-signal { grid-template-columns: 30px minmax(0, 1fr); }
  .demo-motion-bars { display: none; }
  .demo-chat-worker { margin-inline: 12px; grid-template-columns: 32px minmax(0,1fr); }
  .demo-chat-worker-avatar { width: 30px; height: 30px; }
  .demo-chat-worker-avatar > span { width: 25px; height: 25px; }
  .demo-chat-worker-head { align-items: flex-start; }
  .demo-chat-worker-head > span { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .demo-motion-core > i,
  .demo-motion-bars i,
  .demo-flow-steps.demo-motion-running li.active::after,
  .demo-flow-steps.demo-motion-running li.active > span::after,
  .demo-motion-card-running::after,
  .demo-motion-rail i,
  .demo-motion-chat-strip-running::after,
  .demo-chat-worker,
  .demo-chat-worker-avatar > i,
  .demo-chat-worker-head > span i,
  .demo-chat-worker p::after,
  .demo-chat-worker-line i::after,
  .demo-motion-signal small.swap,
  .demo-chat-worker p.swap {
    animation: none !important;
  }
}