/*
 * The chat bubble (chat.mjs): Top Source's, from its styles.css, set in the
 * theme's own tokens, which every theme defines. Copied into every site
 * whose chat this is, beside chrome.css and page.css.
 */
.tchat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  /* Above every theme's sticky header, whose own z-index varies. */
  z-index: 9000;
  font-family: var(--body);
}
.tchat--tucked .tchat__btn,
.tchat--tucked .tchat__teaser {
  display: none;
}
.tchat__btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(var(--shadow), 0.28);
  margin-left: auto;
  transition: transform 0.15s, background 0.15s;
}
.tchat__btn:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
}
.tchat__btn:focus-visible {
  outline: 3px solid var(--ask-accent);
  outline-offset: 3px;
}
.tchat__btn svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
/* The unread badge: a new message waiting. */
.tchat__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #d93636;
  border: 2px solid #fff;
  color: #fff;
  font: 700 12px/18px var(--body);
  text-align: center;
  animation: tchat-pop 0.35s cubic-bezier(0.3, 1.6, 0.6, 1);
}
.tchat__badge[hidden],
.tchat--open .tchat__badge {
  display: none;
}
@keyframes tchat-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
.tchat--ring .tchat__btn {
  animation: tchat-ring 0.9s ease-in-out;
}
@keyframes tchat-ring {
  0%, 100% { transform: rotate(0); }
  15%, 45%, 75% { transform: rotate(-12deg); }
  30%, 60%, 90% { transform: rotate(12deg); }
}
.tchat__teaser {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 300px;
  padding: 16px 16px 14px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(var(--shadow), 0.18);
  animation: tchat-in 0.25s ease-out;
}
.tchat__teaser[hidden] {
  display: none;
}
@keyframes tchat-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
/* Who it is from, as a message notification shows it. */
.tchat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 26px 10px 0;
}
.tchat__head .tchat__av {
  position: relative;
}
.tchat__on {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #2fb36b;
  border: 2px solid var(--card);
}
.tchat__who {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.tchat__who b {
  color: var(--ink);
  font-size: 0.92rem;
}
.tchat__who small {
  color: var(--muted);
  font-size: 0.78rem;
}
.tchat__now {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
}
/* The assistant typing, before the words arrive. */
.tchat__typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  margin-bottom: 4px;
  border-radius: 16px 16px 16px 4px;
  background: var(--tint);
}
.tchat__typing[hidden] {
  display: none;
}
.tchat__typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: tchat-dot 1s infinite ease-in-out;
}
.tchat__typing i:nth-child(2) { animation-delay: 0.15s; }
.tchat__typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tchat-dot {
  0%, 60%, 100% { opacity: 0.35; transform: none; }
  30% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .tchat__teaser,
  .tchat__badge,
  .tchat--ring .tchat__btn,
  .tchat__typing i { animation: none; }
}
.tchat__x {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
}
.tchat__x:hover {
  background: var(--tint);
}
.tchat__hello {
  margin: 0 0 12px;
  padding: 10px 13px;
  border-radius: 16px 16px 16px 4px;
  background: var(--tint);
  animation: tchat-in 0.25s ease-out;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
}
.tchat__hello[hidden],
.tchat__quick[hidden] {
  display: none;
}
.tchat__hello b {
  display: block;
  color: var(--ink);
}
.tchat__av {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tchat__quick {
  display: grid;
  gap: 8px;
}
.tchat__quick button {
  min-height: 42px;
  border-radius: 21px;
  border: 1.5px solid var(--accent);
  background: var(--card);
  color: var(--accent-deep);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tchat__quick button:hover {
  background: var(--accent-wash);
}
.tchat__quick button:focus-visible {
  outline: 3px solid var(--ask-accent);
  outline-offset: 2px;
}
.tchat__panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 390px;
  height: min(640px, calc(100vh - 110px));
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 24px 60px rgba(var(--shadow), 0.3);
}
.tchat__panel[hidden] {
  display: none;
}
.tchat__panel iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
@media (max-width: 700px) {
  .tchat {
    right: 16px;
    bottom: 16px;
  }
  .tchat__teaser {
    width: calc(100vw - 32px);
    max-width: 340px;
  }
  /* On a phone the chat takes the screen, as a messaging app does. */
  .tchat--open {
    inset: 0;
  }
  .tchat--open .tchat__btn {
    display: none;
  }
  .tchat__panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
  }
  html.tchat-lock,
  html.tchat-lock body {
    overflow: hidden;
  }
}
