/* =========================================================
   FAQ — chat-style Q&A, restyled onto the site's dark theme
   ========================================================= */

.faq-chat-wrap {
  max-width: 640px;
  margin: 0 auto;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* --- Question bubble (right-aligned, "from you") --- */
.msg.from-you {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.q-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: right;
}

.q-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.q-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 20px;
  border-bottom-right-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 420px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.msg.from-you.active .q-toggle {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}
.msg.from-you.active .q-bubble {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.q-btn:focus-visible .q-toggle {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* --- Answer row (left-aligned, collapsible via grid-rows trick) --- */
.ans-row {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.ans-row.open {
  grid-template-rows: 1fr;
}

.ans-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
  /* The fixed-size avatar circle can fight the grid row's shrink-to-zero
     in some browsers, leaking a sliver of it through when collapsed —
     opacity:0 guarantees nothing is visible regardless of any leftover
     height, independent of the grid-rows animation above. */
  opacity: 0;
  transition: opacity 0.25s ease;
}
.ans-row.open .ans-inner {
  opacity: 1;
}

.ava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
}
.ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ans-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.typing {
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  padding: 14px 16px;
  width: fit-content;
}
.ans-row.typing-active .typing { display: flex; }
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: faqTypingBounce 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes faqTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.ans-bubble {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 14px 18px;
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  line-height: 1.6;
  max-width: 480px;
}
.ans-row.open:not(.typing-active) .ans-bubble { display: block; }
.ans-bubble em {
  color: var(--text);
  font-style: normal;
  font-weight: 600;
}
.ans-bubble a { color: var(--accent-ink); }

/* --- Compose bar / CTA --- */
.chat-compose {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding: 10px 10px 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  text-decoration: none;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.chat-compose:hover {
  background: rgba(20, 10, 45, 0.04);
  border-color: var(--border-2);
}
.cc-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.cc-ava {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-solid);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-2);
  flex-shrink: 0;
}
.cc-ava svg { width: 16px; height: 16px; }
.cc-text {
  color: var(--text-muted);
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-text em { color: var(--text); font-style: normal; font-weight: 600; }
.cc-send {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: 100px;
  flex-shrink: 0;
  white-space: nowrap;
}
.cc-send svg { width: 16px; height: 16px; }

@media (max-width: 640px) {
  .q-bubble, .ans-bubble { max-width: 74vw; font-size: 0.9rem; }
  .cc-text { display: none; }
  .chat-compose { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .ans-row { transition: none; }
  .typing span { animation: none; }
}
