/* ═══════════════════════════════════════════════════════════════
   S_DevLabs — project demos & animation
   ───────────────────────────────────────────────────────────────
   Every demo is honest about what it is:
     · the voice orb mirrors the REAL states of ai_agent_chat's UI
       (listening / thinking / speaking / idle — taken from its README)
     · the XRPL terminal shows REAL captured values from the public
       XRPL testnet (ledger seq + hash pulled 2026-10-29) with the
       sequence continuing live from that point
   Nothing fakes a transaction, a signature, or a credential.
   ═══════════════════════════════════════════════════════════════ */

.demo {
  position: relative;
  margin-top: 1.1rem;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #04060b;
  overflow: hidden;
}

.demo-bar {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem .8rem;
  background: rgba(255, 255, 255, .028);
  border-bottom: 1px solid var(--line);
}
.demo-dots { display: flex; gap: .3rem; }
.demo-dots i {
  width: 8px; height: 8px; border-radius: 50%; display: block;
  background: #2a3242;
}
.demo-dots i:nth-child(1) { background: #3a4356; }
.demo-dots i:nth-child(2) { background: #2f3849; }
.demo-dots i:nth-child(3) { background: #27303f; }

.demo-title {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--text-faint);
  letter-spacing: .02em;
}

/* Speaker toggle — shows the sound-on icon, or the muted one */
.demo-tag {
  margin-left: .6rem;
  font-size: .56rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--cyan);
  border: 1px solid rgba(62, 200, 240, .3);
  background: rgba(62, 200, 240, .08);
  padding: .12rem .45rem;
  border-radius: 999px;
}

.demo-body { padding: .95rem; }

/* ────────────────────────── VOICE ORB ───────────────────────── */

.orb-stage {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.orb {
  position: relative;
  width: 104px;
  height: 104px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #17263a 0%, #0a1220 55%, #060a12 100%);
  border: 1px solid rgba(62, 200, 240, .26);
  display: grid;
  place-items: center;
  transition: border-color .35s ease, box-shadow .35s ease;
}

/* the pulsing ring */
.orb::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid rgba(62, 200, 240, .32);
  opacity: 0;
}
.orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(62,200,240,.30), transparent 68%);
  opacity: 0;
}

.orb-core {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-grad);
  box-shadow: 0 0 18px rgba(62, 200, 240, .5);
  transition: transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s ease;
}

/* state: listening  — steady halo + slow breathe */
.orb[data-state="listening"] { border-color: rgba(62,200,240,.55); }
.orb[data-state="listening"]::before { opacity: 1; animation: ring 2.4s ease-out infinite; }
.orb[data-state="listening"]::after  { opacity: .5; }
.orb[data-state="listening"] .orb-core { animation: breathe 2.4s ease-in-out infinite; }

/* state: thinking — fast flicker, dimmer */
.orb[data-state="thinking"] { border-color: rgba(43,111,212,.6); }
.orb[data-state="thinking"]::before { opacity: 1; animation: ring 1.1s ease-out infinite; }
.orb[data-state="thinking"] .orb-core { animation: flicker 1.1s ease-in-out infinite; }

/* state: speaking — active waveform */
.orb[data-state="speaking"] { border-color: rgba(62,200,240,.85); box-shadow: 0 0 34px rgba(62,200,240,.34); }
.orb[data-state="speaking"]::before { opacity: 1; animation: ring .9s ease-out infinite; }
.orb[data-state="speaking"]::after  { opacity: .85; }
.orb[data-state="speaking"] .orb-core { animation: pulse .55s ease-in-out infinite; }

/* state: idle — dim */
.orb[data-state="idle"] { border-color: var(--line); }
.orb[data-state="idle"] .orb-core {
  background: #263041;
  box-shadow: none;
  transform: scale(.62);
}

@keyframes ring {
  0%   { transform: scale(.92); opacity: .85; }
  100% { transform: scale(1.28); opacity: 0; }
}
@keyframes breathe {
  0%, 100% { transform: scale(.94); }
  50%      { transform: scale(1.1); }
}
@keyframes flicker {
  0%, 100% { transform: scale(.86); opacity: .65; }
  50%      { transform: scale(1.02); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(.92); box-shadow: 0 0 16px rgba(62,200,240,.45); }
  50%      { transform: scale(1.16); box-shadow: 0 0 30px rgba(62,200,240,.75); }
}

/* waveform bars beside the orb */
.wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 46px;
  flex: 1 1 auto;
  min-width: 0;
}
.wave i {
  flex: 1 1 auto;
  min-width: 2px;
  max-width: 5px;
  height: 12%;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
  opacity: .35;
  transition: height .09s linear, opacity .09s linear;
}

/* the transcript beside the orb */
.orb-side { flex: 1 1 auto; min-width: 0; }

.orb-state {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .06em;
  color: var(--cyan);
  margin-bottom: .35rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.orb-state::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.transcript {
  font-size: .84rem;
  color: var(--text-dim);
  min-height: 3.6em;
  line-height: 1.5;
}
.transcript .you { color: var(--text); font-weight: 600; }
.transcript .agent { color: var(--cyan); }
.transcript .caret {
  display: inline-block;
  width: 7px; height: 1em;
  background: var(--cyan);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ──────────────────────────── TERMINAL ───────────────────────── */

.term {
  font-family: var(--font-mono);
  font-size: .735rem;
  line-height: 1.62;
  color: #9fb3c8;
  white-space: pre-wrap;
  word-break: break-word;
  /* Fixed height so every demo panel on the page is the same size and
     the cards line up. */
  height: 214px;
  overflow: hidden;
}
/* Scrollbar only if it is genuinely needed, and then quietly. */
.term::-webkit-scrollbar { width: 4px; }
.term::-webkit-scrollbar-track { background: transparent; }
.term::-webkit-scrollbar-thumb {
  background: rgba(62, 200, 240, .22);
  border-radius: 2px;
}
.term::-webkit-scrollbar-thumb:hover { background: rgba(62, 200, 240, .4); }
.term .p  { color: var(--cyan); }
.term .d  { color: #5f7085; }
.term .ok { color: #57d98a; }
.term .w  { color: #ffc46b; }
.term .b  { color: #6fb3ff; }
.term .hash { color: #c3a6ff; }
.term .cur {
  display: inline-block;
  width: 7px; height: 1em;
  background: var(--cyan);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}

/* ─────────────────────── GROUPING / LAYOUT ────────────────────── */

.group { margin-top: 2.4rem; }
.group-head {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  margin-bottom: .85rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--line-soft);
}
.group-head h3 {
  font-size: .78rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-dim);
}
.group-head .group-note {
  font-size: .78rem;
  color: var(--text-faint);
}
.group-head .group-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--text-faint);
}

/* group tinting */
.group-xrpl .group-head h3 { color: var(--cyan); }
.group-agent .group-head h3 { color: #a78bfa; }
.group-agent .demo-tag { color: #a78bfa; border-color: rgba(167,139,250,.3); background: rgba(167,139,250,.08); }
.group-agent .wave i { background: linear-gradient(180deg, #a78bfa, #6d5bd6); }

/* ═════════════════════ HASH CHAIN (xrpl_agent_log) ═════════════ */

.chain-stage { display: flex; flex-direction: column; gap: .35rem; }

.chain-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .35s ease, transform .35s ease;
}
.chain-row.on { opacity: 1; transform: none; }

.chain-n {
  width: 1.5rem;
  flex: 0 0 auto;
  color: var(--text-faint);
  text-align: right;
}

.chain-link {
  width: 14px;
  flex: 0 0 auto;
  text-align: center;
  color: #4a5a70;
  font-size: .85rem;
}
.chain-row.on .chain-link { color: var(--cyan); }

.chain-node {
  width: 26px; height: 26px;
  flex: 0 0 auto;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #080c14;
  display: grid;
  place-items: center;
  font-size: .58rem;
  font-weight: 700;
  color: var(--text-faint);
  transition: border-color .35s ease, background .35s ease, color .35s ease, box-shadow .35s ease;
}
.chain-row.on .chain-node {
  border-color: rgba(62, 200, 240, .5);
  background: rgba(62, 200, 240, .1);
  color: var(--cyan);
}
.chain-row.anchor .chain-node {
  border-color: rgba(87, 217, 138, .6);
  background: rgba(87, 217, 138, .12);
  color: #57d98a;
  box-shadow: 0 0 14px rgba(87, 217, 138, .35);
}

.chain-h { color: #c3a6ff; flex: 0 0 auto; letter-spacing: -.02em; }
.chain-label {
  color: var(--text-faint);
  margin-left: auto;
  white-space: nowrap;
  font-size: .66rem;
}
.chain-label.ok { color: #57d98a; }
.chain-label.w { color: #ffc46b; }

/* ═════════════════════ MCP HANDSHAKE (xrpl_did_mcp) ═══════════════ */

.mcp-stage { display: flex; flex-direction: column; gap: .5rem; }

.mcp-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--font-mono);
  font-size: .705rem;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity .3s ease, transform .3s ease;
}
.mcp-row.on { opacity: 1; transform: none; }

/* role label — makes the direction unambiguous */
.mcp-who {
  flex: 0 0 auto;
  width: 3.6rem;
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 700;
}
.mcp-row.client .mcp-who { color: var(--cyan); }
.mcp-row.server .mcp-who { color: #a78bfa; }

.mcp-dir {
  flex: 0 0 auto;
  width: 1rem;
  text-align: center;
  color: var(--text-faint);
}
.mcp-row.client .mcp-dir { color: var(--cyan); }
.mcp-row.server .mcp-dir { color: #a78bfa; }

.mcp-tool {
  color: #bfe9fb;
  background: rgba(62, 200, 240, .08);
  border: 1px solid rgba(62, 200, 240, .18);
  border-radius: 5px;
  padding: .08rem .42rem;
  flex: 0 0 auto;
}
.mcp-arg {
  color: var(--text-faint);
  font-size: .67rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.mcp-reply { color: #57d98a; }

/* ═════════════════════ MEMORY LAYERS (ai_agent_memory) ═════════ */

.mem-stage { display: flex; flex-direction: column; gap: .42rem; }

.mem-layer {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .48rem .65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #080c14;
  font-family: var(--font-mono);
  font-size: .705rem;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .34s ease, transform .34s ease, border-color .34s ease, background .34s ease;
}
.mem-layer.on { opacity: 1; transform: none; }
.mem-layer.loaded {
  border-color: rgba(62, 200, 240, .45);
  background: rgba(62, 200, 240, .08);
}

.mem-n {
  width: 1.4rem; height: 1.4rem;
  flex: 0 0 auto;
  border-radius: 5px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.05);
  color: var(--text-faint);
  font-size: .62rem; font-weight: 700;
}
.mem-layer.loaded .mem-n { background: rgba(62,200,240,.16); color: var(--cyan); }

.mem-name { color: var(--text); }
.mem-path { color: var(--text-faint); margin-left: auto; white-space: nowrap; font-size: .66rem; }
.mem-size {
  color: var(--cyan);
  font-size: .64rem;
  border: 1px solid rgba(62,200,240,.25);
  background: rgba(62,200,240,.07);
  border-radius: 999px;
  padding: .06rem .42rem;
  white-space: nowrap;
}

/* ────────────────────────── MOTION GUARDS ────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .orb::before, .orb::after { animation: none !important; opacity: .2 !important; }
  .orb-core { animation: none !important; }
  .transcript .caret, .term .cur { animation: none !important; }
  .wave i { transition: none !important; }
  .chain-row, .mcp-row, .mem-layer { transition: none !important; }
}

.demo-paused .wave i { transition: none; }
