/* ============================================================
   "CHAT WITH HER" (DEMO): the chat panel drawn by site/chat.js.
   Uses site/app.css's tokens when they are there, with the same values as fallbacks, so it also
   works on its own (tools/chat-test.html). Fits a 320-380px panel; the log scrolls, the box stays.
   Her bubbles are the surface grey; mine are her pack colours (--chat-p1/--chat-p2, set by chat.js).
   ============================================================ */
.chat {
  --chat-p1: var(--pink, #FF4DAE);
  --chat-p2: var(--magenta, #FC0187);
  display: flex; flex-direction: column; gap: 8px;
  height: 100%; min-height: 360px; max-height: 100%;
  color: var(--text, #fff); font-family: var(--font, system-ui, sans-serif); font-size: 14px; line-height: 1.45;
  text-align: left;
}

/* ---- heading: her avatar and name (the one AI line is .chat__note under it) ---- */
.chat__head { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.chat__av { position: relative; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2, #2F3135); }
.chat__av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.chat__titles { flex: 1 1 auto; min-width: 0; }
.chat__name { margin: 0; font-weight: 800; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.chat__clear {
  flex: 0 0 auto; display: inline-grid; place-items: center; width: 44px; height: 44px; margin-right: -8px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted, rgba(255, 255, 255, .66)); cursor: pointer;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.chat__clear[hidden] { display: none; }
.chat__clear:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.chat__clear[data-armed] { color: #fff; background: rgba(255, 83, 128, .22); }

/* ---- the not-her note: hidden unless a real reply has arrived (site/chat.js paintLog; Luke, 13 Nov) ---- */
.chat__note[hidden] { display: none; }
.chat__note {
  margin: 0; padding: 7px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px var(--line, rgba(255, 255, 255, .10));
  color: var(--muted, rgba(255, 255, 255, .66)); font-size: 12px; line-height: 1.4;
}

/* ---- the messages ---- */
.chat__log {
  flex: 1 1 auto; min-height: 120px; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 6px; padding: 4px 2px;
  scrollbar-width: thin;
}
.chat__log:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 8px; }
.chat__msg {
  max-width: 85%; padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat__msg--in { animation: chat-in 180ms var(--ease-out, ease-out) both; }   /* new bubbles only (site/chat.js) */
.chat__msg--her { align-self: flex-start; background: var(--surface-2, #2F3135); border-bottom-left-radius: 6px; }
.chat__msg--me {
  align-self: flex-end; color: #fff; border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--chat-p1), var(--chat-p2));
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);   /* white on the lighter pack colours (#1ACFFF) */
}
@keyframes chat-in { from { opacity: 0; transform: translateY(6px); } }
.chat__vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* typing: three dots */
.chat__typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.chat__typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted, rgba(255, 255, 255, .66)); animation: chat-dot 1s ease-in-out infinite; }
.chat__typing i:nth-child(2) { animation-delay: 150ms; }
.chat__typing i:nth-child(3) { animation-delay: 300ms; }
@keyframes chat-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---- the box ---- */
.chat__foot { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.chat__form {
  display: flex; align-items: flex-end; gap: 6px; padding: 4px 4px 4px 12px; border-radius: 22px;
  background: var(--chip-bg, rgba(35, 35, 38, .5)); box-shadow: inset 0 0 0 1px var(--chip-ring, rgba(255, 255, 255, .28));
}
.chat__form:focus-within { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .7); }
.chat__input {
  flex: 1 1 auto; min-width: 0; min-height: 36px; max-height: 112px; margin: 0; padding: 8px 0; resize: none;
  border: 0; outline: 0; background: transparent; color: inherit;
  font: inherit; font-size: 16px; line-height: 1.25;   /* 16px: iOS does not zoom into the box */
}
.chat__input::placeholder { color: var(--faint, rgba(255, 255, 255, .42)); }
.chat__send {
  flex: 0 0 auto; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--go, #FF2D9B); color: #121314; cursor: pointer;
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}
.chat__send:active:not(:disabled) { transform: scale(.94); }
.chat__send:disabled { opacity: .38; cursor: default; }
.chat__send:focus-visible, .chat__btn:focus-visible, .chat__clear:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.chat__count { min-height: 0; font-size: 11px; color: var(--faint, rgba(255, 255, 255, .42)); text-align: right; font-variant-numeric: tabular-nums; }
.chat__count:empty { display: none; }
.chat__notice { margin: 0; padding: 6px 10px; border-radius: 10px; background: rgba(255, 83, 128, .14); color: #FFD3DE; font-size: 12px; }
.chat__notice[hidden] { display: none; }

/* ---- states: signed out, sign-up needed, resting, ended ---- */
.chat__state {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; border-radius: 14px; text-align: center;
  background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px var(--line, rgba(255, 255, 255, .10));
}
.chat__stateT { font-weight: 800; font-size: 14px; }
.chat__stateX { color: var(--muted, rgba(255, 255, 255, .66)); font-size: 12px; }
.chat__btn {
  margin-top: 6px; min-height: 44px; padding: 0 18px; border: 0; border-radius: var(--pill, 999px); cursor: pointer;
  background: linear-gradient(90deg, var(--pink, #FF4DAE), var(--magenta, #FC0187)); color: #fff;
  font: inherit; font-weight: 800; font-size: 13px;
}
.chat__btn:hover { filter: brightness(1.08); }

@media (prefers-reduced-motion: reduce) {
  .chat__msg--in { animation: none; }
  .chat__typing i { animation: none; opacity: .7; }
  .chat__send, .chat__clear { transition: none; }
}
