/* ============================================================
   THE BRAIN — interactive demo widget
   Self-contained. Used on index.html (embedded) and
   brain.html (standalone, for screen-sharing on sales calls).
   Depends only on the CSS custom properties in brand.css.
============================================================ */

.brain-demo {
  background: linear-gradient(180deg, rgba(20, 22, 28, 0.9), rgba(12, 14, 18, 0.92));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 24px;
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  display: flex; flex-direction: column;
}

/* ---------- header ---------- */
.bd-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.bd-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.bd-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
  animation: bdPulse 2.4s ease-in-out infinite;
}
@keyframes bdPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.bd-demo-tag {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(255, 122, 26, 0.1);
  border: 1px solid rgba(255, 122, 26, 0.28);
  padding: 4px 8px; border-radius: 6px; white-space: nowrap;
}

/* ---------- source badges ---------- */
.bd-sources {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.bd-sources-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px; color: var(--text-dim); margin-right: 2px;
}
.bd-source {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px;
  font-size: 12px; font-weight: 500; color: var(--text);
}
.bd-source-mark {
  width: 16px; height: 16px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff; letter-spacing: -0.02em;
}
.bd-source.reading { border-color: rgba(255, 122, 26, 0.45); background: rgba(255, 122, 26, 0.08); }
.bd-source-lock {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px; color: var(--text-dim); letter-spacing: 0.04em;
  border: 1px dashed var(--border-strong); border-radius: 8px; padding: 5px 9px;
}
.bd-source-empty {
  border-style: dashed; color: var(--text-dim); font-weight: 400;
}

/* ---------- transcript ---------- */
.bd-thread {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  min-height: 260px;
  max-height: 420px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.bd-thread::-webkit-scrollbar { width: 8px; }
.bd-thread::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

.bd-empty { margin: auto; text-align: center; padding: 20px 10px; }
.bd-empty-icon {
  width: 42px; height: 42px; border-radius: 12px; margin: 0 auto 14px;
  background: rgba(255, 122, 26, 0.1); border: 1px solid rgba(255, 122, 26, 0.25);
  display: flex; align-items: center; justify-content: center;
}
.bd-empty-icon svg { width: 20px; height: 20px; color: var(--accent); }
.bd-empty p { font-size: 13.5px; color: var(--text-muted); max-width: 340px; margin: 0 auto; }
.bd-empty strong { color: var(--text); font-weight: 600; }

.bd-msg { animation: bdIn 0.35s ease-out both; }
@keyframes bdIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.bd-msg-user {
  align-self: flex-end; max-width: 88%;
  background: rgba(255, 122, 26, 0.12);
  border: 1px solid rgba(255, 122, 26, 0.28);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  font-size: 13.5px; color: var(--text);
}

.bd-msg-brain { align-self: stretch; }
.bd-answer-head {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px;
}
.bd-avatar {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
}
.bd-avatar svg { width: 14px; height: 14px; color: #08090C; }
.bd-headline { font-size: 14.5px; font-weight: 600; line-height: 1.45; color: var(--text); }

/* quote block (call transcript excerpts) */
.bd-quote {
  margin: 0 0 12px 36px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 0 10px 10px 0;
  font-size: 13.5px; line-height: 1.6; color: var(--text);
}
.bd-quote-attr {
  display: block; margin-top: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px; color: var(--text-dim);
}

/* data rows */
.bd-rows { margin-left: 36px; display: flex; flex-direction: column; gap: 6px; }
.bd-row {
  display: grid; grid-template-columns: minmax(120px, 1fr) auto;
  gap: 4px 14px; align-items: baseline;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px;
  animation: bdIn 0.3s ease-out both;
}
.bd-row-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.bd-row-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px; color: var(--accent-2); text-align: right; white-space: nowrap;
}
.bd-row-meta { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.bd-row.flag { border-color: rgba(239, 68, 68, 0.28); background: rgba(239, 68, 68, 0.05); }
.bd-row.flag .bd-row-value { color: #FCA5A5; }

.bd-note {
  margin: 12px 0 0 36px; font-size: 12.5px; color: var(--text-muted); line-height: 1.55;
}

/* citations */
.bd-cites { margin: 12px 0 0 36px; display: flex; flex-wrap: wrap; gap: 6px; }
.bd-cite {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px;
}
.bd-cite-mark { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* the read-only reminder — this is the whole sales mechanism, keep it visible */
.bd-readonly {
  margin: 14px 0 0 36px; padding: 9px 12px;
  display: flex; align-items: flex-start; gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  font-size: 12px; color: var(--text-dim); line-height: 1.5;
}
.bd-readonly svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 2px; }

/* thinking state */
.bd-thinking { display: flex; align-items: center; gap: 10px; }
.bd-thinking-text {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px; color: var(--text-dim);
}
.bd-thinking-dots { display: inline-flex; gap: 4px; }
.bd-thinking-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: bdBounce 1s ease-in-out infinite;
}
.bd-thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.bd-thinking-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bdBounce { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- chips + input ---------- */
.bd-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.bd-chip {
  font-family: inherit;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px; padding: 8px 14px;
  font-size: 12.5px; line-height: 1.3; text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.bd-chip:hover, .bd-chip:focus-visible {
  border-color: rgba(255, 122, 26, 0.5); color: var(--text);
  background: rgba(255, 122, 26, 0.07); outline: none;
}

.bd-composer { display: flex; gap: 8px; margin-top: 12px; }
.bd-input {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  color: var(--text); font-family: inherit; font-size: 13.5px;
  transition: border-color 0.2s;
}
.bd-input::placeholder { color: var(--text-dim); }
.bd-input:focus { outline: none; border-color: var(--accent); }
.bd-send {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent-grad); color: #08090C;
  border: none; border-radius: 10px; padding: 12px 18px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease, opacity 0.2s ease;
}
.bd-send:hover { filter: brightness(1.08); }
.bd-send:disabled { opacity: 0.45; cursor: not-allowed; }
.bd-send svg { width: 15px; height: 15px; }

/* ---------- caps footer ---------- */
.bd-caps {
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.bd-cap {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px;
}
.bd-cap-note { font-size: 11.5px; color: var(--text-dim); margin-left: auto; }

@media (max-width: 560px) {
  .brain-demo { padding: 18px; }
  .bd-quote, .bd-rows, .bd-note, .bd-cites, .bd-readonly { margin-left: 0; }
  .bd-row { grid-template-columns: 1fr; }
  .bd-row-value { text-align: left; }
  .bd-send span { display: none; }
  .bd-send { padding: 12px 14px; }
  .bd-cap-note { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .bd-msg, .bd-row { animation: none !important; }
  .bd-dot, .bd-thinking-dots i { animation: none !important; }
}
