/* ================= KudoAI, the second hero (#kudoai) =================
   Its chat on the left; the write page (the .pm kit, Sepia) on the right,
   lit at its edges while KudoAI has the screen, its glowing pointer doing
   each step the chat names. Played by /kudoai-demo.js. */
.kx { position: relative; padding: 110px 0 90px; overflow: hidden; isolation: isolate; }
.kx-ground {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 520px at 50% 62%, rgba(139, 92, 246, 0.22), transparent 70%),
    radial-gradient(700px 400px at 85% 15%, rgba(240, 106, 155, 0.1), transparent 70%),
    linear-gradient(180deg, transparent, rgba(22, 16, 34, 0.7) 30%, rgba(22, 16, 34, 0.7) 70%, transparent);
}
.kx-ground::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(196, 181, 253, 0.16) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask: radial-gradient(70% 60% at 50% 60%, #000, transparent);
  mask: radial-gradient(70% 60% at 50% 60%, #000, transparent);
}
.kx-head { text-align: center; margin: 0 auto 48px; max-width: 760px; }
.kx-head h2 { font-size: calc(clamp(32px, 4.6vw, 56px) / var(--tz, 1)); line-height: 1.06; letter-spacing: -0.02em; text-wrap: balance; }
.kx-head h2 em {
  display: block;
  background: linear-gradient(100deg, #e9e2ff, #c4b5fd 30%, #a78bfa 55%, #f0a3e8 85%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: hx-shine 8s ease-in-out infinite;
}
.kx-head p { margin-inline: auto; max-width: 60ch; }

.kx-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 56px;
  align-items: center;
  max-width: 1040px;
  margin: 0 auto;
  user-select: none;
}

/* ---- the chat ---- */
.kx-chat {
  position: relative; z-index: 3;
  display: flex; flex-direction: column;
  height: 470px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(34, 28, 46, 0.92), rgba(20, 17, 27, 0.94));
  border: 1px solid rgba(167, 139, 250, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 40px 90px -40px rgba(0, 0, 0, 0.95), 0 0 70px -30px rgba(139, 92, 246, 0.8);
  overflow: hidden;
}
.kx-chat-head { display: flex; align-items: center; gap: 9px; padding: 13px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.kx-chat-head b { font-size: calc(14px / var(--tz, 1)); }
.kx-chat-head .kx-orb { width: 20px; height: 20px; margin: 0; }
.kx-state { margin-left: auto; font-size: calc(11px / var(--tz, 1)); color: var(--fg-3); transition: color 0.3s; }
.kx-stage.acting .kx-state { color: var(--spark-text); animation: hb-pulse 1.2s ease-in-out infinite; }
.kx-msgs { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; padding: 14px; overflow: hidden; }
.kx-input {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 12px;
  padding: 8px 8px 8px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: calc(13px / var(--tz, 1));
  color: var(--fg-3);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.kx-input.typing { color: var(--fg); border-color: rgba(167, 139, 250, 0.55); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }
.kx-input-text { flex: 1; min-width: 0; line-height: 1.4; max-height: 4.2em; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.kx-send { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; background: linear-gradient(135deg, #8b5cf6, #a855f7); box-shadow: 0 6px 16px -6px rgba(139, 92, 246, 0.9); transition: transform 0.2s; }
.kx-send svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.kx-send.press { transform: scale(0.85); }
.kx-caret { display: inline-block; width: 2px; height: 1em; margin-left: 1px; vertical-align: -2px; background: var(--spark-text); animation: hb-blink 0.9s steps(1) infinite; }
.kx-msg {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: calc(13.5px / var(--tz, 1));
  line-height: 1.45;
  transition: opacity 0.5s, transform 0.5s cubic-bezier(.16, 1, .3, 1);
}
.kx-msg.me {
  align-self: flex-end;
  max-width: 92%;
  border-bottom-right-radius: 6px;
  color: #fff;
  background: linear-gradient(135deg, #d93a75, #ea5a8b 60%, #f07a86);
  box-shadow: 0 16px 40px -18px rgba(240, 106, 155, 0.9);
}
.kx-msg.ai {
  display: flex; gap: 10px; align-items: flex-start;
  border-bottom-left-radius: 6px;
  color: var(--fg-soft, #e2dbe6);
  background: linear-gradient(180deg, rgba(44, 35, 66, 0.92), rgba(28, 23, 40, 0.92));
  border: 1px solid rgba(167, 139, 250, 0.28);
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.9), 0 0 50px -24px rgba(139, 92, 246, 0.9);
}
.kx-done { display: block !important; }
.kx-orb {
  width: 22px; height: 22px; flex: none; border-radius: 50%; margin-top: 1px;
  background: radial-gradient(circle at 34% 30%, #fff 0 8%, #d9ccff 22%, var(--spark) 52%, var(--spark-strong, #7c3aed) 100%);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.8);
  animation: hx-orb 1.8s ease-in-out infinite;
}
.kx-chips { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kx-chip {
  display: inline-flex; align-items: center; gap: 8px;
  align-self: flex-start;
  padding: 6px 11px 6px 8px;
  border-radius: 999px;
  font-size: calc(12px / var(--tz, 1)); font-weight: 700;
  color: var(--spark-text);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.22);
  transition: all 0.35s cubic-bezier(.16, 1, .3, 1);
  max-height: 40px;
}
.kx-chip svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kx-chip.on { color: #fff; background: linear-gradient(135deg, #8b5cf6, #a855f7); border-color: transparent; box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2), 0 0 26px rgba(139, 92, 246, 0.8); transform: translateX(4px); }
.kx-chip.done { color: #b9e7c4; background: rgba(134, 210, 154, 0.1); border-color: rgba(134, 210, 154, 0.25); }
.kx-chip.hide { opacity: 0; transform: translateY(6px) scale(0.9); max-height: 0; padding-block: 0; margin-top: -6px; border-width: 0; }
.kx-msg.hide { opacity: 0; transform: translateY(10px) scale(0.96); }
.kx-msg.gone { display: none !important; }
.kx-dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.kx-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--spark-text); animation: kx-dot 1s ease-in-out infinite; }
.kx-dots i:nth-child(2) { animation-delay: 0.15s; }
.kx-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes kx-dot { 50% { transform: translateY(-4px); opacity: 0.4; } }

/* ---- the page KudoAI works on ---- */
.kx-app { position: relative; z-index: 2; }
.kx-app .pm { min-height: 430px; }
.kx-app .pm-paras { position: relative; }
/* Take-over: the page lit at its edges, violet and rose, breathing. */
.kx-aura {
  position: absolute; inset: -3px;
  z-index: 4;
  border-radius: 25px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.8), 0 0 60px -6px rgba(139, 92, 246, 0.85), inset 0 0 50px -16px rgba(139, 92, 246, 0.55);
  animation: kx-aura 2.4s ease-in-out infinite;
}
.kx-stage.acting .kx-aura { opacity: 1; }
@keyframes kx-aura { 50% { box-shadow: 0 0 0 2px rgba(240, 163, 232, 0.85), 0 0 90px -4px rgba(139, 92, 246, 0.95), inset 0 0 60px -16px rgba(240, 106, 155, 0.5); } }
.kx-app .pm-btn.is-press { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.25), 0 0 22px rgba(139, 92, 246, 0.7); }
.kx-app .pm-go.is-press { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.28); }
.kx-app .pm-para.is-entering { animation: kx-in 0.55s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes kx-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }

/* KudoAI's pointer: a glowing orb with a pointer and its name, as the
   agent's take-over draws it in the app. */
.kx-cursor { position: absolute; left: 0; top: 0; z-index: 9; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
.kx-stage.acting .kx-cursor { opacity: 1; }
.kx-cursor .o {
  position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 14%, rgba(196, 181, 253, 0.9) 30%, rgba(139, 92, 246, 0.45) 55%, transparent 72%);
  filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.95));
  animation: kx-breathe 1.4s ease-in-out infinite;
}
@keyframes kx-breathe { 50% { transform: scale(1.25); } }
.kx-cursor svg { position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); }
.kx-cursor .n {
  position: absolute; left: 22px; top: 18px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: calc(11px / var(--tz, 1)); font-weight: 800; letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
  background: linear-gradient(135deg, #8b5cf6, #c05bd0);
  box-shadow: 0 6px 16px -6px rgba(139, 92, 246, 0.9);
}
.kx-ripple { position: absolute; z-index: 8; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none; border: 2px solid #c4b5fd; animation: kx-ripple 0.7s ease-out forwards; }
.kx-ripple.r2 { animation-delay: 0.12s; border-color: #f0a3e8; }
@keyframes kx-ripple { from { opacity: 1; } to { transform: scale(5.5); opacity: 0; } }
.kx-stage.resetting .kx-msgs, .kx-stage.resetting .pm-paras { opacity: 0; transition: opacity 0.5s; }

@media (max-width: 860px) {
  .kx { padding: 80px 0 64px; }
  .kx-stage { grid-template-columns: 1fr; gap: 28px; max-width: 480px; }
  .kx-chat { width: 100%; height: 300px; }
  .kx-msg { font-size: calc(13px / var(--tz, 1)); padding: 10px 13px; }
  .kx-app .pm { min-height: 380px; }
}
@media (max-width: 720px) {
  .kx-chat { height: 280px; }
  .kx-chip { font-size: calc(11.5px / var(--tz, 1)); padding: 5px 10px 5px 7px; }
  .kx-cursor .n { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .kx-orb, .kx-aura, .kx-head h2 em, .kx-cursor .o { animation: none !important; }
}

/* The light from the step in the chat to where KudoAI's pointer is working. */
.kx-beam { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 8; pointer-events: none; overflow: visible; }
.kx-beam path { fill: none; stroke-linecap: round; transition: opacity 0.3s; }
.kx-beam-glow { stroke: rgba(167, 139, 250, 0.35); stroke-width: 9; filter: blur(5px); }
.kx-beam-line { stroke: url(#kx-beam-g); stroke-width: 2.2; stroke-dasharray: 3 9; animation: kx-flow 0.6s linear infinite; }
@keyframes kx-flow { to { stroke-dashoffset: -12; } }
.kx-beam.off path { opacity: 0; }
