/* Agent demo reel — "See it in action" on the per-agent storefront detail
 * (public, dark). Dark glass treatment.
 *
 * DESIGN RULE: the DEFAULT state is the fully readable, static transcript of
 * EVERY example, stacked — what no-JS, crawlers, screen readers and
 * prefers-reduced-motion get. The one-at-a-time animated reel is opt-IN: the JS
 * layer adds `.is-animating` only when motion is allowed. */

.kw-demo {
  position: relative;
  border: 1px solid var(--kw-glass-stroke);
  border-radius: var(--kw-radius-xl);
  background: var(--kw-glass-fill);
  box-shadow: var(--kw-glow-glass);
  -webkit-backdrop-filter: blur(34px);
  backdrop-filter: blur(34px);
  padding: 1.375rem;
  overflow: hidden;
}

/* --- header: eyebrow + (JS-only) dots + (JS-only) controls --------------- */
.kw-demo__head {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.125rem;
}
.kw-demo__eyebrow {
  font-family: var(--kw-font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--kw-muted-lavender);
  margin: 0 auto 0 0;
}
.kw-demo__dots,
.kw-demo__controls { display: none; }
.kw-demo.is-animating .kw-demo__dots { display: inline-flex; gap: 0.5rem; }
.kw-demo.is-animating .kw-demo__controls { display: inline-flex; gap: 0.375rem; }

.kw-demo__dot {
  width: 22px; height: 5px;
  padding: 0;
  border: none;
  border-radius: var(--kw-radius-pill);
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: 200ms;
}
.kw-demo__dot[aria-current="true"] {
  width: 30px;
  background: var(--kw-electric-indigo);
  box-shadow: 0 0 10px rgba(77, 96, 251, 0.6);
}
.kw-demo__dot:hover { background: rgba(255, 255, 255, 0.3); }
.kw-demo__ctrl {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--kw-radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--kw-muted-lavender);
  cursor: pointer;
  transition: 150ms;
}
.kw-demo__ctrl:hover { color: #fff; border-color: rgba(255, 255, 255, 0.34); }

/* --- stage + examples ---------------------------------------------------- */
.kw-demo__example + .kw-demo__example {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--kw-glass-stroke);
}
.kw-demo.is-animating .kw-demo__example {
  display: none;
  margin-top: 0; padding-top: 0; border-top: none;
}
.kw-demo.is-animating .kw-demo__example.is-active { display: block; }
.kw-demo.is-animating .kw-demo__stage { min-height: 22rem; }
.kw-demo__example { margin: 0; }

/* --- chat turns + bubbles ------------------------------------------------ */
.kw-demo__turn { display: flex; flex-direction: column; gap: 0.4375rem; margin-bottom: 1rem; }
.kw-demo__turn--user { align-items: flex-end; }
.kw-demo__turn--agent { align-items: flex-start; }
.kw-demo__role {
  display: inline-flex; align-items: center; gap: 0.4375rem;
  font-family: var(--kw-font-mono);
  font-size: 0.6875rem; color: var(--kw-fg-subtle);
}
.kw-demo__bubble {
  max-width: 88%;
  border-radius: var(--kw-radius-lg);
  padding: 0.75rem 0.9375rem;
  font-size: 0.875rem;
  line-height: 1.55;
}
.kw-demo__turn--user .kw-demo__bubble {
  background: rgba(77, 96, 251, 0.18);
  border: 1px solid rgba(77, 96, 251, 0.4);
  color: #fff;
  border-end-end-radius: var(--kw-radius-sm);
  box-shadow: inset 0 0 20px rgba(77, 96, 251, 0.18);
}
.kw-demo__turn--agent .kw-demo__bubble {
  width: 100%;
  background: rgba(13, 15, 49, 0.55);
  border: 1px solid var(--kw-glass-stroke);
  border-end-start-radius: var(--kw-radius-sm);
  box-shadow: inset 0 0 30px rgba(197, 185, 246, 0.08);
}
.kw-demo__prompt { margin: 0; }
.kw-demo__blocks { display: flex; flex-direction: column; gap: 0.6875rem; }

/* --- response blocks ----------------------------------------------------- */
.kw-demo__say { margin: 0; color: #fff; }

.kw-demo__tool {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--kw-font-mono);
  font-size: 0.78125rem;
  color: var(--kw-muted-lavender);
  background: rgba(77, 96, 251, 0.10);
  border: 1px solid rgba(77, 96, 251, 0.18);
  padding: 0.4375rem 0.6875rem;
  border-radius: var(--kw-radius-sm);
}
.kw-demo__tool .kw-ico { color: var(--kw-electric-indigo); }
.kw-demo__tool-arrow { color: var(--kw-electric-indigo); font-weight: 700; }

.kw-demo__metrics { display: flex; flex-wrap: wrap; gap: 0.625rem; }
.kw-demo__metric {
  display: flex; flex-direction: column; gap: 0.1875rem;
  padding: 0.6875rem 0.9375rem;
  border: 1px solid var(--kw-glass-stroke);
  border-radius: var(--kw-radius-md);
  background: rgba(77, 96, 251, 0.08);
  min-width: 5.75rem;
}
.kw-demo__metric-value { font-family: var(--kw-font-mono-num); font-size: 1.5rem; font-weight: 400; color: #fff; line-height: 1; }
.kw-demo__metric-label { font-family: var(--kw-font-mono); font-size: 0.625rem; color: var(--kw-fg-subtle); text-transform: uppercase; letter-spacing: 0.04em; }
/* Headline metric gets the indigo accent. */
.kw-demo__metric:first-child {
  background: rgba(77, 96, 251, 0.16);
  border-color: rgba(77, 96, 251, 0.5);
  box-shadow: inset 0 0 22px rgba(197, 185, 246, 0.14);
}
.kw-demo__metric:first-child .kw-demo__metric-value { color: var(--kw-soft-lavender); text-shadow: var(--kw-glow-text); }

.kw-demo__table-wrap { overflow-x: auto; }
.kw-demo__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.kw-demo__table th,
.kw-demo__table td {
  text-align: start;
  padding: 0.5rem 0.625rem;
  white-space: nowrap;
}
.kw-demo__table th {
  font-family: var(--kw-font-mono);
  font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--kw-fg-subtle); font-weight: 500;
  border-bottom: 1px solid var(--kw-glass-stroke);
}
.kw-demo__table td { color: var(--kw-fg-muted); border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.kw-demo__table tbody tr:last-child td { border-bottom: none; }

.kw-demo__code {
  margin: 0;
  font-family: var(--kw-font-mono);
  font-size: 0.78125rem;
  line-height: 1.7;
  background: var(--kw-deep-space);
  border: 1px solid var(--kw-glass-stroke);
  color: var(--kw-soft-lavender);
  padding: 1rem;
  border-radius: var(--kw-radius-md);
  overflow-x: auto;
}

.kw-demo__callout {
  display: flex; align-items: center; gap: 0.5625rem;
  padding: 0.625rem 0.8125rem;
  border-radius: var(--kw-radius-md);
  font-size: 0.84375rem;
  border: 1px solid;
}
.kw-demo__callout--success {
  background: rgba(43, 182, 115, 0.12);
  border-color: rgba(43, 182, 115, 0.35);
  color: #7DE0B0;
}
.kw-demo__callout--success .kw-ico { color: #36C588; }
.kw-demo__callout--info {
  background: rgba(77, 96, 251, 0.10);
  border-color: rgba(77, 96, 251, 0.30);
  color: var(--kw-muted-lavender);
}
.kw-demo__callout--warn {
  background: rgba(253, 202, 19, 0.10);
  border-color: rgba(253, 202, 19, 0.30);
  color: var(--kw-signal-gold);
}
.kw-demo__callout--warn .kw-ico { color: var(--kw-signal-gold); }

.kw-demo__provenance {
  display: flex; align-items: center; gap: 0.25rem;
  margin-top: 0.875rem;
  font-family: var(--kw-font-mono);
  font-size: 0.6875rem;
  color: var(--kw-fg-subtle);
}

/* --- animated reveal states (scoped under .kw-demo.is-animating) ---------- */
.kw-demo.is-animating .kw-demo__prompt { white-space: nowrap; overflow: hidden; }
.kw-demo.is-animating .kw-demo__turn--agent { opacity: 0; transition: opacity 0.3s ease; }
.kw-demo.is-animating .kw-demo__example.show-agent .kw-demo__turn--agent { opacity: 1; }
.kw-demo.is-animating .kw-demo__blocks > [data-demo-block] {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.kw-demo.is-animating .kw-demo__blocks > [data-demo-block].is-shown {
  opacity: 1;
  transform: none;
}
.kw-demo.is-animating [data-demo-block="table"] tbody tr { opacity: 0; transition: opacity 0.3s ease; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr { opacity: 1; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(1) { transition-delay: 0.04s; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(2) { transition-delay: 0.12s; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(3) { transition-delay: 0.20s; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(4) { transition-delay: 0.28s; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(5) { transition-delay: 0.36s; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(6) { transition-delay: 0.44s; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(7) { transition-delay: 0.52s; }
.kw-demo.is-animating [data-demo-block="table"].is-shown tbody tr:nth-child(8) { transition-delay: 0.60s; }

/* "Thinking" dots — injected by JS (aria-hidden) during the response pause. */
.kw-demo__thinking { display: inline-flex; gap: 5px; align-items: center; height: 1rem; }
.kw-demo__thinking i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--kw-muted-lavender);
  animation: kw-demo-think 1.2s ease-in-out infinite;
}
.kw-demo__thinking i:nth-child(2) { animation-delay: 0.15s; }
.kw-demo__thinking i:nth-child(3) { animation-delay: 0.30s; }
@keyframes kw-demo-think {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50%      { opacity: 1;   transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .kw-demo, .kw-demo * { animation: none !important; transition: none !important; }
  .kw-demo .kw-demo__turn--agent,
  .kw-demo .kw-demo__blocks > [data-demo-block],
  .kw-demo [data-demo-block="table"] tbody tr { opacity: 1 !important; transform: none !important; }
  .kw-demo .kw-demo__prompt { white-space: normal !important; overflow: visible !important; clip-path: none !important; }
}

/* ============================================================
   Home synced-hero variant (.kw-demo--hero) — the LIVE DEMO console on the
   right of the .kw-shero grid (handoff-home-hero). Same component + same
   brand recipe (glass panel on dark navy, mono numerals, white/gold icons);
   the variant only changes the BASELINE: the hero shows ONE scenario
   statically (no-JS / reduced-motion = the first scenario, fully revealed,
   content for all scenarios still present in markup for SEO), where the
   storefront detail page stacks every example.
   ============================================================ */
.kw-demo--hero .kw-demo__example:not(.is-active) { display: none; }
.kw-demo--hero .kw-demo__example + .kw-demo__example { margin-top: 0; padding-top: 0; border-top: none; }
.kw-demo--hero .kw-demo__stage { min-height: 22.5rem; }

/* Pulsing "live" dot in the console eyebrow — Electric Indigo glow. */
.kw-demo__live {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--kw-electric-indigo);
  box-shadow: 0 0 10px var(--kw-electric-indigo);
  animation: kw-demo-pulse 2s ease-in-out infinite;
}
.kw-demo--hero .kw-demo__eyebrow { display: inline-flex; align-items: center; gap: 0.5rem; }
@keyframes kw-demo-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* Metric tile accents: the headline tile (first) already carries the lavender
   glow; the ATTENTION tile takes Signal Gold. The schema has no per-metric
   tone, so the hero applies gold to the second tile (the mockup's "Gaps" /
   "Exceptions" position); .kw-demo__metric--gold is the explicit hook. */
.kw-demo__metric--gold .kw-demo__metric-value,
.kw-demo--hero .kw-demo__metric:nth-child(2) .kw-demo__metric-value { color: var(--kw-signal-gold); }

/* Stacked hero (≤920px): the console sits below the copy — shorter stage. */
@media (max-width: 920px) {
  .kw-demo--hero .kw-demo__stage,
  .kw-demo--hero.is-animating .kw-demo__stage { min-height: 16.25rem; }
}
