/* ===========================================================
   NeuroForest — Lu Xun Echo demo (chat UI)
   Uses the design tokens from styles.css.
   =========================================================== */

.demo {
  max-width: 860px;
}

.demo__chat {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(600px 300px at 0% 0%, var(--violet-bg), transparent 60%),
    var(--surface);
  box-shadow: 0 30px 70px -40px rgba(26, 11, 61, 0.22);
  overflow: hidden;
}

/* ---------- message log ---------- */
.chat__log {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(20px, 3vw, 32px);
  min-height: 320px;
  max-height: min(58vh, 560px);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 86%;
  animation: msg-in 0.3s var(--ease) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg__who {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
}

.msg__body {
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 15.5px;
  line-height: 1.62;
}
.msg__body p { margin: 0 0 0.7em; }
.msg__body p:last-child { margin-bottom: 0; }
.msg__body em { font-family: var(--serif); }

/* Echo (Lu Xun) — left aligned, warm surface with a violet spine */
.msg--echo {
  align-self: flex-start;
}
.msg--echo .msg__body {
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet);
  color: var(--ink-soft);
}
.msg--echo .msg__who { color: var(--violet); }

/* User — right aligned, violet tint */
.msg--user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg--user .msg__body {
  background: var(--violet);
  color: #fff;
  border: 1px solid var(--violet);
}
.msg--user .msg__who { color: var(--ink-dim); }

/* Error */
.msg--error { align-self: flex-start; }
.msg--error .msg__body {
  background: var(--pink-bg);
  border: 1px solid var(--pink-soft);
  border-left: 3px solid var(--pink);
  color: var(--ink-soft);
}
.msg--error .msg__who { color: var(--pink); }

/* ---------- typing indicator ---------- */
.msg--typing .msg__body {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--violet-soft);
  animation: typing 1.2s var(--ease) infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ---------- suggestions ---------- */
.chat__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 clamp(20px, 3vw, 32px) 4px;
}
.suggest__chip {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s var(--ease),
              background .2s var(--ease), color .2s var(--ease);
}
.suggest__chip:hover {
  transform: translateY(-1px);
  border-color: var(--violet);
  color: var(--violet);
  background: var(--violet-bg);
}

/* ---------- input form ---------- */
.chat__form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: clamp(16px, 2.5vw, 24px) clamp(20px, 3vw, 32px);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}
.chat__input {
  flex: 1;
  resize: none;
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-height: 180px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.chat__input:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-bg);
}
.chat__input::placeholder { color: var(--ink-dimmer); }

.chat__send { flex-shrink: 0; }
.chat__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.chat__send svg { transition: transform .2s var(--ease); }
.chat__send:not(:disabled):hover svg { transform: translateX(3px); }

/* ---------- note ---------- */
.demo__note {
  margin: 22px 2px 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-dim);
}
.demo__note strong { color: var(--ink-soft); }

@media (max-width: 560px) {
  .msg { max-width: 94%; }
  .chat__send-label { display: none; }
  .chat__send { padding: 13px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; }
  .typing-dot { animation: none; opacity: 0.6; }
}
