/* The support chat's panel and the site's bubble (templates/_support_chat.html), on the app and
   the site. Standalone, so both show it alike: site.css and app.css style none of its classes
   (a test checks; site.css's example chats have their own .chat-head and .chat-body). Its blue
   (owner, 2026-11-30) is a little brighter than the app's, so the chat stands out: white text on
   it is 4.3:1 (AA wants 4.5:1 under 18.7px bold). */
.support-chat {
  --chat-blue: #5475d3;
  --chat-blue-hover: #3f61c4;
  --chat-text: #3a3b45;
  --chat-border: #e3e6f0;
  --chat-field: #8c8fa1;
  --chat-tint: #eef2fd;
  --chat-error: #8a3328;
  --chat-red: #d93025;          /* the badge: white text 4.8:1 */
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .75rem;
  font-size: 15px;
  color: var(--chat-text);
  pointer-events: none; /* the box around the bubble lets clicks through to the page */
}
.support-chat > * { pointer-events: auto; }
.support-chat[hidden], .support-chat [hidden], .nav-chat .chat-badge[hidden] { display: none !important; }
/* The site's bubble: out of the cookie banner's way until it is answered (consent.js). The app's
   panel opens only from its menu, so it may cover the banner. */
body:has(.consent:not([hidden])) .support-chat:has(.chat-open) { display: none; }

/* The bubble: eases in a moment after the page shows. */
.chat-open {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: 0 1.125rem;
  border: 0;
  border-radius: 999px;
  background: var(--chat-blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  box-shadow: 0 6px 18px rgb(84 117 211 / .4);
  cursor: pointer;
  transition: background-color 150ms, transform 150ms;
  animation: chat-rise 400ms cubic-bezier(.2, .8, .3, 1.2) 600ms both;
}
.chat-open:hover { background: var(--chat-blue-hover); transform: translateY(-1px); }
.chat-open .icon { width: 1.25rem; height: 1.25rem; }
.support-chat.open .chat-label { display: none; }
.support-chat.open .chat-open { padding: 0 .75rem; }

/* What the visitor hasn't read, top right of the bubble. */
.chat-badge {
  position: absolute;
  top: -.375rem;
  right: -.25rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .3rem;
  box-sizing: border-box;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--chat-red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
}
.chat-badge.pop { animation: chat-pop 450ms cubic-bezier(.3, 1.6, .5, 1) both; }
.chat-badge.pop.late { animation-delay: 1000ms; } /* on page load: once the bubble is in */
/* In the app's menu ("Chat with us"): at the end of the line, not on a corner. */
.nav-chat .chat-badge { position: static; margin-left: auto; border: 0; background: #d93025; line-height: 1.25rem; }

/* The panel: grows from the bubble, fades away back into it. */
.chat-panel {
  display: flex;
  flex-direction: column;
  width: 22rem;
  height: min(32rem, calc(100vh - 6rem));
  border-radius: .75rem;
  background: #fff;
  box-shadow: 0 12px 36px rgb(58 59 69 / .22);
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity 200ms ease, transform 200ms cubic-bezier(.2, .8, .3, 1);
}
.chat-panel.entering, .chat-panel.leaving { opacity: 0; transform: translateY(12px) scale(.95); }
.chat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .625rem .75rem .625rem 1rem;
  background: var(--chat-blue);
  color: #fff;
}
.chat-bar h2 { margin: 0; font-size: 16px; font-weight: 600; color: #fff; }
.chat-close {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: .375rem;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.chat-close:hover { background: rgb(255 255 255 / .15); }
.chat-close .icon { width: 1.25rem; height: 1.25rem; }

.chat-scroll { flex: 1; overflow-y: auto; padding: 1rem; }
.chat-log { display: flex; flex-direction: column; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.chat-log li {
  max-width: 85%;
  padding: .5rem .75rem;
  border-radius: .75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: chat-in 220ms ease-out both;
}
.chat-log .from-visitor { align-self: flex-end; background: var(--chat-blue); color: #fff; border-bottom-right-radius: .25rem; }
.chat-log .from-support { align-self: flex-start; background: var(--chat-tint); border-bottom-left-radius: .25rem; }
/* A message not confirmed yet (support-chat.js's outbox): what is happening, under it. */
.chat-log li[data-status]::after { content: attr(data-status); display: block; margin-top: .25rem; font-size: 12px; font-style: italic; }

.chat-form { display: grid; gap: .5rem; padding: .75rem; border-top: 1px solid var(--chat-border); }
.chat-email { display: grid; gap: .25rem; font-size: 13px; color: #6e707e; }
.chat-email input, .chat-compose textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--chat-field);
  border-radius: .375rem;
  padding: .5rem .625rem;
  font: inherit;
  color: var(--chat-text);
  background: #fff;
}
.chat-email input { min-height: 2.25rem; }
.chat-compose { display: flex; gap: .5rem; align-items: flex-end; }
.chat-compose textarea { resize: none; min-height: 2.75rem; max-height: 8rem; }
.chat-send {
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 0;
  border-radius: .375rem;
  background: var(--chat-blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms;
}
.chat-send:hover { background: var(--chat-blue-hover); }
.chat-send:disabled { opacity: .6; cursor: default; }
.chat-error { margin: 0; color: var(--chat-error); font-size: 13px; }
.support-chat :focus-visible { outline: 2px solid #4e73df; outline-offset: 2px; }
.chat-bar :focus-visible { outline-color: #fff; }

@keyframes chat-rise { from { opacity: 0; transform: translateY(16px) scale(.9); } }
@keyframes chat-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes chat-in { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 40rem) {
  .support-chat { right: .75rem; bottom: .75rem; left: .75rem; }
  .chat-panel { width: 100%; height: min(32rem, calc(100vh - 5.5rem)); }
}
/* No movement for those who asked for less (WCAG 2.3.3). */
@media (prefers-reduced-motion: reduce) {
  .chat-open, .chat-panel, .chat-badge.pop, .chat-log li, .chat-send { animation: none; transition: none; }
}
