/* Chat panel (Buzz, the scripted FAQ bot). Uses the tokens in main.css. */
/* Base rules the panel needs that proto.css does not have. */
.launcher[hidden], .chat[hidden], .chat-backdrop[hidden], .chat [hidden] { display: none !important; }
.chat textarea { font: inherit; color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* =====================================================================
   Chat
   ===================================================================== */

/* Launcher: bottom right on every page. Only shown when the script runs. */
.launcher {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 30;
  display: none; align-items: center; gap: 0.625rem;
  min-height: 3.5rem; padding: 0.75rem 1.25rem 0.75rem 1rem;
  border: 0; border-radius: 62rem;
  background: var(--accent); color: var(--ink);
  font-size: 1rem; font-weight: 800; line-height: 1.2; cursor: pointer;
  box-shadow: 0 10px 28px rgba(11, 27, 51, 0.28), 0 2px 6px rgba(11, 27, 51, 0.18);
  transition: background-color 160ms var(--ease), transform 160ms var(--ease);
}
.launcher:not([hidden]) { display: inline-flex; }   /* shown only while the chat is minimized */
.launcher svg { width: 1.5rem; height: 1.5rem; }
.launcher:hover { background: var(--accent-hover); transform: translateY(-2px); }
.launcher:active { transform: translateY(0); }
.launcher:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 62rem; }
@media (min-width: 700px) { .launcher { right: 1.5rem; bottom: 1.5rem; } }

.chat-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(11, 27, 51, 0.5); }
@media (min-width: 700px) { .chat-backdrop { background: rgba(11, 27, 51, 0.22); } }

/* Phone: the panel is the whole screen. */
.chat {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  background: #fff; color: var(--ink);
  overflow: hidden;
}
html.chat-open { overflow: hidden; }

/* Laptop: a corner panel. */
@media (min-width: 700px) {
  .chat {
    inset: auto 1.5rem 1.5rem auto;
    width: 24.5rem; height: min(41rem, calc(100vh - 3rem)); height: min(41rem, calc(100dvh - 3rem));
    border-radius: 1.25rem;
    box-shadow: 0 28px 64px rgba(11, 27, 51, 0.34), 0 4px 12px rgba(11, 27, 51, 0.16);
  }
  html.chat-open { overflow: visible; }
}

.chat__head {
  flex: none; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem 0.75rem 0.875rem 1rem;
  background: var(--navy); color: #fff;
}
.chat__head :focus-visible { outline-color: #fff; }
.chat__mark { flex: none; width: 2.5rem; height: 2.5rem; }
.chat__id { flex: 1; min-width: 0; }
.chat__title { font-size: 1.0625rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; }
.chat__sub { margin-top: 0.1875rem; display: flex; align-items: center; gap: 0.4375rem; font-size: 0.8125rem; line-height: 1.3; color: var(--on-navy-muted); }
.chat__badge {
  flex: none; padding: 0.0625rem 0.375rem; border-radius: 0.3125rem;
  background: var(--accent); color: var(--ink); font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.02em;
}
.chat__close, .chat__min {
  flex: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem;
  border: 0; border-radius: 0.625rem; background: transparent; color: #fff; cursor: pointer;
  transition: background-color 140ms var(--ease);
}
.chat__close:hover, .chat__min:hover { background: rgba(255, 255, 255, 0.12); }
.chat__close svg, .chat__min svg { width: 1.375rem; height: 1.375rem; }

.chat__bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem; background: var(--tint); border-bottom: 1px solid #CDE9FB;
  font-size: 0.8125rem; color: var(--muted);
}
.chat__person {
  flex: none; display: inline-flex; align-items: center; gap: 0.4375rem;
  min-height: 2.5rem; padding: 0.375rem 0.75rem;
  border: 1.5px solid var(--accent-text); border-radius: 62rem; background: #fff; color: var(--accent-text);
  font-size: 0.8125rem; font-weight: 800; line-height: 1.2; cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.chat__person svg { width: 1rem; height: 1rem; }
.chat__person:hover { background: var(--accent-text); color: #fff; }

.chat__log {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 0.625rem;
  padding: 1rem;
  scroll-behavior: smooth;
}
.chat__log:focus-visible { outline-offset: -3px; }

.msg { display: flex; max-width: 100%; }
.msg--user { justify-content: flex-end; }
.msg__bubble {
  max-width: 86%; padding: 0.625rem 0.875rem; border-radius: 1.125rem;
  font-size: 0.9375rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-line;
}
.msg--bot .msg__bubble { background: var(--surface); color: var(--ink); border-bottom-left-radius: 0.375rem; }
.msg--user .msg__bubble { background: var(--accent); color: var(--ink); font-weight: 600; border-bottom-right-radius: 0.375rem; }

.msg--typing .msg__bubble { display: inline-flex; align-items: center; gap: 0.3125rem; min-height: 2.5rem; color: var(--muted); }
.dot { width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: var(--field-line); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4375rem; padding-top: 0.125rem; }
.chips__chip {
  min-height: 2.5rem; padding: 0.4375rem 0.8125rem;
  border: 1.5px solid #9CCFEE; border-radius: 62rem; background: #fff; color: var(--accent-text);
  font-size: 0.875rem; font-weight: 700; line-height: 1.25; text-align: left; cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease);
}
.chips__chip:hover { background: var(--tint); border-color: var(--accent-text); }

.handoff { padding: 0.875rem; border: 1.5px solid var(--navy); border-radius: 1rem; background: #fff; }
.handoff__title { font-size: 0.9375rem; font-weight: 800; line-height: 1.2; }
.handoff__text { margin-top: 0.125rem; font-size: 0.8125rem; color: var(--muted); }
.handoff__actions { margin-top: 0.75rem; display: grid; gap: 0.5rem; }
.handoff__btn {
  display: flex; align-items: center; justify-content: center; width: 100%;
  min-height: 2.75rem; padding: 0.5rem 0.875rem;
  border: 1.5px solid var(--field-line); border-radius: 0.625rem; background: #fff; color: var(--ink);
  font-size: 0.9375rem; font-weight: 700; line-height: 1.2; text-decoration: none; text-align: center; cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease);
}
.handoff__btn:hover { background: var(--surface); border-color: var(--ink); }
.handoff__btn--accent { background: var(--accent); border-color: var(--accent); }
.handoff__btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.handoff__note { margin-top: 0.625rem; font-size: 0.75rem; line-height: 1.45; color: var(--muted); }

.chat__foot { flex: none; padding: 0.625rem 0.75rem calc(0.625rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: #fff; }
.chat__form { display: flex; align-items: flex-end; gap: 0.5rem; }
.chat__input {
  flex: 1; min-width: 0; min-height: 2.875rem; max-height: 7rem; padding: 0.6875rem 0.875rem;
  border: 1px solid var(--field-line); border-radius: 0.875rem; background: #fff; resize: none;
  font-size: 1rem; line-height: 1.4;   /* 16 px: no zoom on focus on a phone */
}
.chat__input::placeholder { color: #6B7385; }
.chat__input:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; border-color: var(--accent-text); border-radius: 0.875rem; }
.chat__send {
  flex: none; display: grid; place-items: center; width: 2.875rem; height: 2.875rem;
  border: 0; border-radius: 0.875rem; background: var(--accent); color: var(--ink); cursor: pointer;
  transition: background-color 140ms var(--ease), transform 120ms var(--ease);
}
.chat__send:hover { background: var(--accent-hover); }
.chat__send:active { transform: translateY(1px); }
.chat__send:disabled { background: var(--line); color: var(--field-line); cursor: default; }
.chat__send svg { width: 1.25rem; height: 1.25rem; }
.chat__count { min-height: 0; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-align: right; }
.chat__count:not(:empty) { margin-top: 0.25rem; }
.chat__privacy { margin-top: 0.5rem; font-size: 0.75rem; line-height: 1.45; color: var(--muted); }

/* Motion: only when it is welcome. */
@media (prefers-reduced-motion: no-preference) {
  .chat { animation: chat-in 240ms var(--ease) both; }
  .chat-backdrop { animation: fade-in 200ms ease both; }
  .msg, .chips, .handoff { animation: msg-in 220ms var(--ease) both; }
  .dot { animation: dot 1.1s ease-in-out infinite; }
  .dot:nth-child(2) { animation-delay: 0.15s; }
  .dot:nth-child(3) { animation-delay: 0.3s; }
}
@keyframes chat-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .chat__log { scroll-behavior: auto; }
  .btn, .launcher, .reach__btn, .chat__send, .chips__chip, .handoff__btn, .faq__item summary::after { transition: none; }
  .launcher:hover { transform: none; }
}

/* Minimize sits just left of the X. */
.chat__min { margin-left: auto; margin-right: -0.25rem; }

/* Little lightning bolt next to Buzz's name. */
.name-bolt { display: inline-block; width: 0.75em; height: 1.15em; margin-left: 0.15em; vertical-align: -0.1em; fill: var(--accent); }
.launcher .name-bolt { width: 0.75em; height: 1.15em; fill: currentColor; }
.launcher > span { display: inline-flex; align-items: center; }
