/* =========================================================
   Gold Monster AI — chat interface styles
   Uses CSS variables from styles.css (dark rugged brand).
   ========================================================= */

/* ----- Thread (scrollable message column) ----- */
.gm-ai-thread {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 60vh;
  min-height: 16rem;
  overflow-y: auto;
  padding: 0.5rem 0;
  scroll-behavior: smooth;
}

/* Nothing said yet: don't reserve 16rem of empty black above the composer —
   the first-run panel below fills that space with something useful instead. */
.gm-ai-thread:empty { min-height: 0; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  .gm-ai-thread { scroll-behavior: auto; }
}

/* ----- First run (hidden by js/gm-ai.js once the thread has messages) ----- */
.gm-ai-firstrun {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.gm-ai-firstrun-lead {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 62ch;
  margin-bottom: 1.1rem;
}
.gm-ai-firstrun .dash-chip { cursor: pointer; }

/* ----- Message bubbles ----- */
.gm-ai-msg {
  max-width: 46rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  line-height: 1.6;
  font-size: 1rem;
  animation: gmAiFadeIn 0.25s ease-out;
}

.gm-ai-msg p + p {
  margin-top: 0.6rem;
}

/* Member: gold-tinted, right-aligned */
.gm-ai-msg.from-member {
  background: linear-gradient(135deg, #2a2218, #1f1a12);
  border: 1px solid rgba(224, 166, 60, 0.18);
  align-self: flex-end;
  margin-left: auto;
}

/* AI: surface-2, left-aligned, thin border */
.gm-ai-msg.from-ai {
  background: var(--surface-2);
  border: 1px solid var(--line);
  align-self: flex-start;
  margin-right: auto;
}

/* ----- Citation links (superscript gold) ----- */
a.gm-ai-cite {
  display: inline;
  font-size: 0.72rem;
  vertical-align: super;
  line-height: 1;
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  padding: 0 0.15rem;
  border-radius: 2px;
  transition: background 0.15s;
}

a.gm-ai-cite:hover,
a.gm-ai-cite:focus-visible {
  background: rgba(224, 166, 60, 0.15);
  text-decoration: underline;
  color: var(--gold-hi);
}

/* ----- Chip row (wrapped flex of "go there" nav links) ----- */
.gm-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

a.gm-ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.4rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gold);
  border: 1px solid var(--gold-lo);
  border-radius: var(--radius);
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

a.gm-ai-chip::after {
  content: "→";
  font-size: 0.85rem;
  line-height: 1;
}

a.gm-ai-chip:hover,
a.gm-ai-chip:focus-visible {
  background: rgba(224, 166, 60, 0.12);
  border-color: var(--gold);
  color: var(--gold-hi);
}

/* ----- Typing indicator (three pulsing dots) ----- */
.gm-ai-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 2.5rem;
}

.gm-ai-typing span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-lo);
  animation: gmAiBounce 1.2s ease-in-out infinite;
}

.gm-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.gm-ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes gmAiBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-6px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .gm-ai-typing span { animation: none; opacity: 0.7; }
  .gm-ai-msg { animation: none; }
}

/* ----- Composer (textarea + send button) ----- */
.gm-ai-composer {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: flex-end;
}

.gm-ai-composer textarea {
  flex: 1;
  min-height: 44px;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.gm-ai-composer textarea:focus {
  border-color: var(--gold);
}

.gm-ai-composer textarea::placeholder {
  color: var(--text-dim);
}

.gm-ai-composer textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gm-ai-composer .btn {
  flex-shrink: 0;
  min-height: 44px;
}

/* Stack vertically on small screens */
@media (max-width: 639px) {
  .gm-ai-composer {
    flex-direction: column;
    align-items: stretch;
  }

  .gm-ai-composer .btn {
    width: 100%;
  }
}

/* ----- Status strip ----- */
.gm-ai-status {
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.75rem;
  background: var(--surface-2);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* ----- Meter and note text ----- */
.gm-ai-meter,
.gm-ai-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.gm-ai-meter + .gm-ai-note {
  margin-top: 0.35rem;
}

/* ----- Message fade-in ----- */
@keyframes gmAiFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
