/* AI chat widget — ported from the static site
 * ---------------------------------------------------------------------
 * Loaded after figtree-cream.css.
 *
 * The original CSS is almost entirely token-driven -- var(--green),
 * var(--surface), var(--bg), var(--text) -- so it picks up the cream palette
 * on its own with no changes. Only the values written against a dark
 * background needed touching, and they are marked below.
 */

.chat-bubble {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 5000;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--green); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  box-shadow: 0 4px 20px rgba(90,158,47,0.4);
  transition: transform 0.2s, background 0.2s;
}
.chat-bubble:hover { transform: scale(1.07); background: var(--green-dark); }
.chat-bubble.open  { background: var(--green-dark); }

.chat-panel {
  position: fixed; bottom: 5.25rem; right: 2rem; z-index: 4999;
  width: 370px; max-height: 540px;
  background: var(--surface); border: 1px solid rgba(90,158,47,0.18);
  display: flex; flex-direction: column;
  /* CHANGED: was rgba(0,0,0,0.55). A shadow that heavy was tuned to separate
     the panel from a near-black page; on cream it reads as a smudge. */
  box-shadow: 0 16px 48px rgba(26,46,13,0.18);
  transform: scale(0.95) translateY(8px); opacity: 0; pointer-events: none;
  transition: all 0.26s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom right;
}
.chat-panel.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* The header stays dark green against the cream panel. That contrast is
   deliberate -- it is what makes the panel read as a distinct surface rather
   than a cream box on a cream page. */
.chat-header {
  padding: 1rem 1.2rem; background: var(--green-deep);
  border-bottom: 1px solid rgba(90,158,47,0.14);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 0.7rem; }
.chat-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green); display: flex; align-items: center; justify-content: center; font-size: 0.95rem; }
/* CHANGED: the header sits on --green-deep, so its text cannot use --text,
   which is now near-black. These are fixed light values on purpose. */
.chat-name strong { display: block; font-size: 0.85rem; color: #f3ecdf; }
.chat-name span   { font-size: 0.68rem; color: rgba(243,236,223,0.65); }
.chat-online { display: flex; align-items: center; gap: 0.35rem; font-size: 0.63rem; color: #9ed46f; font-family: 'Courier Prime', monospace; }
.chat-online::before { content: ''; width: 5px; height: 5px; background: #9ed46f; border-radius: 50%; }

.chat-msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; min-height: 0; }
.chat-msgs::-webkit-scrollbar { width: 3px; }
.chat-msgs::-webkit-scrollbar-thumb { background: rgba(90,158,47,0.2); border-radius: 2px; }

.chat-msg { max-width: 88%; display: flex; flex-direction: column; gap: 0.18rem; }
.chat-msg.bot  { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }
.chat-bubble-msg { padding: 0.62rem 0.85rem; font-size: 0.83rem; line-height: 1.55; border-radius: 2px; }
.chat-msg.bot .chat-bubble-msg  { background: var(--bg); color: var(--text); border: 1px solid rgba(90,158,47,0.18); }
.chat-msg.user .chat-bubble-msg { background: var(--green); color: #fff; }
.chat-msg-time { font-size: 0.6rem; color: var(--text-muted); font-family: 'Courier Prime', monospace; }
.chat-msg.user .chat-msg-time { text-align: right; }

.chat-typing { align-self: flex-start; padding: 0.62rem 0.85rem; background: var(--bg); border: 1px solid rgba(90,158,47,0.18); display: none; gap: 4px; align-items: center; }
.chat-typing.show { display: flex; }
.dot { width: 5px; height: 5px; background: var(--green); border-radius: 50%; animation: ft-chat-bounce 1.2s infinite; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
/* Renamed from `bounce` -- a keyframe name that generic in a shared stylesheet
   is asking to be redefined by something else later. */
@keyframes ft-chat-bounce {
  0%,60%,100% { transform: translateY(0);    opacity: 0.35; }
  30%         { transform: translateY(-5px); opacity: 1; }
}

.chat-turnstile { padding: 0.55rem 0.9rem 0; display: flex; justify-content: center; }

.chat-input-row { padding: 0.7rem 0.9rem; border-top: 1px solid rgba(90,158,47,0.18); display: flex; gap: 0.5rem; flex-shrink: 0; }
.chat-input { flex: 1; background: var(--bg); border: 1px solid rgba(90,158,47,0.25); color: var(--text); padding: 0.55rem 0.75rem; font-family: 'DM Sans', sans-serif; font-size: 0.83rem; outline: none; border-radius: 2px; resize: none; transition: border-color 0.2s; line-height: 1.4; }
.chat-input:focus { border-color: var(--green); }
.chat-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.chat-send { background: var(--green); border: none; color: #fff; width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.95rem; border-radius: 2px; transition: background 0.2s; flex-shrink: 0; align-self: flex-end; }
.chat-send:hover:not(:disabled) { background: var(--green-dark); }
.chat-send:disabled { opacity: 0.5; cursor: default; }

/* The panel is 370px wide and pinned 2rem from the right. Below ~420px that
   overflows the viewport, which the static site never had to handle because
   the widget sat on one page. Now it is on every page. */
@media (max-width: 600px) {
  .chat-panel {
    right: 1rem; left: 1rem; width: auto;
    bottom: 4.75rem; max-height: 70vh;
  }
  .chat-bubble { right: 1rem; bottom: 1rem; }
}
