/* ============================================================
   chat.css — scripted decision-tree chat UI
   Consumes the design tokens defined in desktop.css :root.
   Emitted by chat.js (+ .chat-host wrapper from main.js).
   ============================================================ */

/* the chat window's body is padding-free so the chat fills it exactly
   (its own sub-elements carry the padding) — fixes the dead gap above the dock */
.win__body--chat {
  padding: 0;
  overflow: hidden;
}

/* host wrapper fills the window body so the log scrolls internally */
.chat-host {
  height: 100%;
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* ---- scrolling message log ---- */
.chat__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 8px;
  background: var(--glass);
  scrollbar-width: thin;
  scrollbar-color: rgba(58, 44, 34, 0.35) transparent;
}
.chat__log::-webkit-scrollbar { width: 9px; }
.chat__log::-webkit-scrollbar-thumb {
  background: rgba(58, 44, 34, 0.3);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---- message rows ---- */
.chat__msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: chat-pop 0.26s var(--ease) both;
}
.chat__msg--bot { justify-content: flex-start; }
.chat__msg--user { justify-content: flex-end; }

@keyframes chat-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* bot avatar (🤖) — only on the first bot bubble of a turn */
.chat__avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: 50%;
  background: var(--cyan);
  border: 1.5px solid var(--ink);
  box-shadow: 1px 1px 0 rgba(58, 44, 34, 0.4);
}

/* ---- bubbles ---- */
.chat__bubble {
  max-width: 82%;
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 15px;
  word-wrap: break-word;
}

/* bot bubble: glass, left-accent. Indent bubbles that have no avatar so a
   multi-bubble bot turn stays visually aligned under the avatar. */
.chat__msg--bot .chat__bubble {
  margin-left: 34px;
  color: var(--ink);
  background: #f3e7ce;
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.chat__msg--bot .chat__avatar + .chat__bubble {
  margin-left: 0;
}

/* user bubble: solid coral, right-aligned, cream ink */
.chat__msg--user .chat__bubble {
  color: #faf3e2;
  font-weight: 600;
  background: var(--pink);
  border: 1.5px solid var(--ink);
  border-bottom-right-radius: 5px;
  box-shadow: 2px 2px 0 rgba(58, 44, 34, 0.4);
}

/* ---- typing indicator (3 bouncing dots) ---- */
.chat__typing-row { align-items: flex-end; }
.chat__typing {
  margin-left: 34px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 11px 14px;
  background: #f3e7ce;
  border: 1px solid var(--line);
  border-radius: 15px;
  border-bottom-left-radius: 5px;
}
.chat__typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: chat-bounce 1.1s infinite ease-in-out both;
}
.chat__typing-dot:nth-child(2) { animation-delay: 0.16s; }
.chat__typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* ---- in-log link buttons (.chat__links > a.btn.chat__link) ---- */
.chat__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 34px;
  margin-top: 2px;
}
.chat__link {
  font-size: 12.5px;
  padding: 8px 13px;
}

/* ---- quick-reply chips (pinned below the log) ---- */
.chat__replies {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 16px;
  border-top: 1.5px solid var(--ink);
  background: var(--glass-bar);
}

.chip {
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cyan);
  padding: 7px 13px;
  border: 1.5px solid var(--ink);
  border-radius: 7px;
  background: var(--glass-strong);
  box-shadow: 2px 2px 0 rgba(58, 44, 34, 0.7);
  transition: background 0.16s var(--ease), color 0.16s var(--ease),
    transform 0.12s var(--ease), box-shadow 0.16s var(--ease);
}
.chip:hover:not(:disabled) {
  background: #fff7e4;
}
.chip:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(58, 44, 34, 0.7);
}
.chip:disabled { opacity: 0.4; cursor: default; }

/* ---- live-AI composer (free-text input) ---- */
.chat__compose {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1.5px solid var(--ink);
  background: var(--glass-bar);
}
.chat__input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink);
  padding: 9px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #fffdf6;
  box-shadow: inset 1px 1px 0 rgba(58, 44, 34, 0.12);
}
.chat__input::placeholder { color: var(--faint); }
.chat__input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.chat__input:disabled { opacity: 0.6; }

.chat__send {
  flex: 0 0 auto;
  width: 40px;
  font-size: 15px;
  color: #faf3e2;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--pink);
  box-shadow: 2px 2px 0 rgba(58, 44, 34, 0.9);
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease), filter 0.16s var(--ease);
}
.chat__send:hover:not(:disabled) { filter: brightness(1.05); }
.chat__send:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(58, 44, 34, 0.9);
}
.chat__send:disabled { opacity: 0.45; cursor: default; }

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .chat__msg { animation: none; }
  .chat__typing-dot { animation: none; opacity: 0.7; }
  .chip { transition: none; }
  .chat__send { transition: none; }
}
