/* aha Assistant chat widget, in the bottom right corner.
 * Small: an ink glass pill with the aha mark and "Ask aha".
 * Wide (.is-wide): the pill stretches left, shows the send button and types out suggested questions.
 * Open (.is-open): the pill grows into a glass chat box. The page behind stays as it is.
 * Brand tokens come from the aha theme, with fallbacks so it also works elsewhere. */

.aha-chat {
  --ac-coral: var(--coral, #ff3857);
  --ac-coral-strong: var(--coral-strong, #d92b48);
  --ac-coral-deep: var(--coral-deep, #b81f3a);
  --ac-yellow: var(--yellow, #ffad00);
  --ac-ink: var(--ink, #1a1a2e);
  --ac-font-body: var(--font-body, "Lato", system-ui, -apple-system, "Segoe UI", sans-serif);
  --ac-font-display: var(--font-display, "Antipasto Pro", "Avenir Next", system-ui, sans-serif);
  --ac-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ac-text: #fff;
  --ac-text-muted: rgba(255, 255, 255, 0.68);
  --ac-text-soft: rgba(255, 255, 255, 0.5);
  --ac-edge: rgba(255, 255, 255, 0.16);
  --ac-gap: 24px;
  --ac-offset: 0px; /* raised above the cookie bar while it shows */
  --ac-pill-h: 60px;
  --ac-mini-w: 148px; /* set exactly by the script to fit the label */
  --ac-pill-w: min(480px, calc(100vw - 32px));
  --ac-open-w: min(600px, calc(100vw - 32px));
  --ac-open-h: min(720px, calc(100dvh - 2 * var(--ac-gap) - var(--ac-offset)));

  font-family: var(--ac-font-body);
  color: var(--ac-text);
  -webkit-font-smoothing: antialiased;
}
.aha-chat *, .aha-chat *::before, .aha-chat *::after { box-sizing: border-box; }
/* Widget resets leave the embedded contact form alone, so it looks as it does on the Contact page. */
.aha-chat button:not(.aha-chat__formcard *) { font: inherit; color: inherit; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.aha-chat svg:not(.aha-chat__formcard *) { display: block; flex: none; }
.aha-chat :focus-visible:not(.aha-chat__formcard *, .aha-chat__input) { outline: 2px solid var(--ac-yellow); outline-offset: 2px; }
html.aha-chat-locked { overflow: hidden; }

/* ---------- The box: a small pill that stretches, then grows into the chat ---------- */
/* Anchored by its right edge, so it always grows left and up out of the corner. */
.aha-chat__box {
  position: fixed; z-index: 9991;
  right: max(var(--ac-gap), env(safe-area-inset-right));
  bottom: calc(max(var(--ac-gap), env(safe-area-inset-bottom)) + var(--ac-offset));
  width: var(--ac-mini-w); height: var(--ac-pill-h);
  overflow: hidden;
  border: 1px solid var(--ac-edge); border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0) 55%),
    rgba(26, 26, 46, 0.62);
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  box-shadow:
    0 16px 44px rgba(26, 26, 46, 0.3),
    0 2px 8px rgba(26, 26, 46, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition:
    width 560ms var(--ac-ease), height 560ms var(--ac-ease),
    border-radius 560ms var(--ac-ease), background-color 420ms var(--ac-ease),
    box-shadow 420ms var(--ac-ease), bottom 320ms var(--ac-ease), right 320ms var(--ac-ease);
  animation: aha-chat-rise 700ms var(--ac-ease) 500ms both;
}
.aha-chat__box:hover:not(:is(.is-open *)) {
  box-shadow: 0 20px 52px rgba(26, 26, 46, 0.36), 0 2px 8px rgba(26, 26, 46, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.aha-chat.is-wide .aha-chat__box { width: var(--ac-pill-w); cursor: text; }
.aha-chat.is-open .aha-chat__box {
  width: var(--ac-open-w); height: var(--ac-open-h);
  border-radius: 28px; cursor: auto;
  background:
    radial-gradient(70% 40% at 100% 0%, rgba(255, 56, 87, 0.22), transparent 70%),
    radial-gradient(60% 35% at 0% 100%, rgba(255, 173, 0, 0.14), transparent 70%),
    rgba(26, 26, 46, 0.86);
  box-shadow: 0 32px 80px rgba(10, 10, 22, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Parts that only exist in the open state */
.aha-chat__header, .aha-chat__log, .aha-chat__note {
  opacity: 0; visibility: hidden;
  transition: opacity 200ms var(--ac-ease), visibility 0s linear 200ms;
}
.aha-chat.is-open :is(.aha-chat__header, .aha-chat__log, .aha-chat__note) {
  opacity: 1; visibility: visible;
  transition: opacity 360ms var(--ac-ease) 220ms, visibility 0s;
}

/* ---------- Header ---------- */
.aha-chat__header {
  position: absolute; z-index: 2; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px 16px 22px;
  background: linear-gradient(rgba(26, 26, 46, 0.92), rgba(26, 26, 46, 0.6) 70%, rgba(26, 26, 46, 0));
}
.aha-chat__avatar {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, 0.1); border: 1px solid var(--ac-edge); color: var(--ac-coral);
}
.aha-chat__avatar svg { width: 24px; height: 24px; }
.aha-chat__heading { flex: 1; min-width: 0; }
.aha-chat__title { margin: 0; font: 600 1.3125rem/1.1 var(--ac-font-display); color: var(--ac-text); letter-spacing: 0; text-transform: lowercase; }
.aha-chat__subtitle { margin: 3px 0 0; font-size: 0.8125rem; line-height: 1.3; color: var(--ac-text-muted); }
.aha-chat__icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--ac-text-muted);
  transition: background-color 180ms var(--ac-ease), color 180ms var(--ac-ease);
}
.aha-chat__icon-btn[hidden] { display: none; }
.aha-chat__icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--ac-text); }
.aha-chat__icon-btn svg { width: 20px; height: 20px; }

/* ---------- Conversation ---------- */
.aha-chat__log {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 88px 28px 132px;
  display: flex; flex-direction: column; gap: 18px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  -webkit-mask-image: linear-gradient(transparent 56px, #000 96px, #000 calc(100% - 118px), transparent calc(100% - 88px));
          mask-image: linear-gradient(transparent 56px, #000 96px, #000 calc(100% - 118px), transparent calc(100% - 88px));
}
.aha-chat__msg { max-width: 90%; animation: aha-chat-in 360ms var(--ac-ease) both; }
.aha-chat__text { font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.aha-chat__msg--bot { align-self: flex-start; color: rgba(255, 255, 255, 0.92); }
.aha-chat__msg--welcome .aha-chat__text { font: 400 clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem)/1.35 var(--ac-font-display); color: var(--ac-text); letter-spacing: 0; }
.aha-chat__msg--user { align-self: flex-end; }
.aha-chat__msg--user .aha-chat__text {
  padding: 10px 18px; border-radius: 22px 22px 6px 22px;
  background: var(--ac-coral-strong); color: #fff; white-space: pre-wrap;
  box-shadow: 0 8px 22px rgba(217, 43, 72, 0.3);
}
.aha-chat__text > :first-child { margin-top: 0; }
.aha-chat__text > :last-child { margin-bottom: 0; }
.aha-chat__text p { margin: 0 0 0.65em; }
.aha-chat__text ul, .aha-chat__text ol { margin: 0 0 0.65em; padding-left: 1.25em; }
.aha-chat__text li { margin: 0.25em 0; }
.aha-chat__text li::marker { color: var(--ac-coral); }
.aha-chat__text strong { font-weight: 700; color: #fff; }
.aha-chat__text code { padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); font-size: 0.9em; }
.aha-chat__text a {
  color: var(--ac-yellow); font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: rgba(255, 173, 0, 0.45);
}
.aha-chat__text a:hover { color: #ffc240; text-decoration-color: currentColor; }
.aha-chat__msg--error .aha-chat__text { padding: 12px 16px; border-radius: 16px; background: rgba(255, 56, 87, 0.12); border: 1px solid rgba(255, 56, 87, 0.3); }

/* Link and suggestion chips */
.aha-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.aha-chat__suggestions { margin-top: -4px; animation: aha-chat-in 420ms var(--ac-ease) 120ms both; }
.aha-chat__chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  min-height: 38px; padding: 8px 16px;
  border: 1px solid var(--ac-edge); border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); color: var(--ac-text);
  font: 700 0.875rem/1.25 var(--ac-font-body); text-align: left; text-decoration: none;
  transition: background-color 180ms var(--ac-ease), border-color 180ms var(--ac-ease), transform 320ms var(--ac-ease);
}
.aha-chat__chip:hover { background: rgba(255, 173, 0, 0.16); border-color: rgba(255, 173, 0, 0.55); color: #fff; }
.aha-chat__chip:active { transform: scale(0.97); transition-duration: 100ms; }
.aha-chat__chip svg { width: 14px; height: 14px; color: var(--ac-yellow); transition: transform 320ms var(--ac-ease); }
.aha-chat__chip:hover svg { transform: translateX(2px); }
.aha-chat__chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aha-chat__suggestions .aha-chat__chip span { white-space: normal; }
.aha-chat__chip--contact { background: var(--ac-coral-strong); border-color: var(--ac-coral-strong); }
.aha-chat__chip--contact svg { color: #fff; }
.aha-chat__chip--contact:hover { background: var(--ac-coral-deep); border-color: var(--ac-coral-deep); }

/* The contact form: the same Gravity Form as the Contact page, on a white card so its own styles apply */
.aha-chat__formcard {
  align-self: stretch; flex: none;
  margin-top: -4px; padding: 20px 20px 8px;
  border-radius: 20px; background: #fff; color: var(--ac-ink);
  font: 400 1rem/1.5 var(--ac-font-body); text-align: left;
  -webkit-font-smoothing: auto;
  box-shadow: 0 14px 36px rgba(10, 10, 22, 0.35);
  animation: aha-chat-in 420ms var(--ac-ease) both;
}
.aha-chat__formcard-title { margin: 0 0 14px; font: 600 1.25rem/1.2 var(--ac-font-display); color: var(--ac-ink); letter-spacing: 0; }
.aha-chat__formcard :focus-visible { outline: 2px solid var(--ac-coral-strong); outline-offset: 2px; }
.aha-chat-form-source[hidden] { display: none !important; }

/* Typing indicator */
.aha-chat__typing { display: inline-flex; gap: 6px; padding: 8px 2px; }
.aha-chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ac-coral); animation: aha-chat-dot 1.1s infinite ease-in-out; }
.aha-chat__typing i:nth-child(2) { animation-delay: 0.15s; background: #ff7a3c; }
.aha-chat__typing i:nth-child(3) { animation-delay: 0.3s; background: var(--ac-yellow); }

/* ---------- Composer ---------- */
.aha-chat__dock { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; transition: padding 560ms var(--ac-ease); }
.aha-chat.is-open .aha-chat__dock { padding: 0 14px 10px; }
.aha-chat__form {
  display: flex; align-items: center; gap: 10px;
  height: calc(var(--ac-pill-h) - 2px); min-height: calc(var(--ac-pill-h) - 2px); padding: 6px 7px 6px 8px;
  border: 1px solid transparent; border-radius: 999px;
  transition: background-color 420ms var(--ac-ease), border-color 420ms var(--ac-ease), box-shadow 200ms var(--ac-ease), border-radius 200ms var(--ac-ease);
}
/* Until it opens, the form is laid out at the wide pill's width; the small pill simply clips it,
 * so stretching the pill reveals the send button rather than squashing anything. */
.aha-chat:not(.is-open) .aha-chat__form { width: calc(var(--ac-pill-w) - 2px); }
.aha-chat.is-open .aha-chat__form {
  height: auto;
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.aha-chat.is-open .aha-chat__form:focus-within { border-color: rgba(255, 255, 255, 0.28); }
.aha-chat__form.is-multiline { border-radius: 26px; align-items: flex-end; }
.aha-chat__mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, 0.1); color: var(--ac-coral);
}
.aha-chat__mark svg { width: 26px; height: 26px; }
.aha-chat__field { position: relative; flex: 1; min-width: 0; align-self: center; }
.aha-chat__input {
  display: block; width: 100%; max-height: 132px; margin: 0; padding: 8px 0; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--ac-text); box-shadow: none; caret-color: var(--ac-yellow);
  font: 400 1rem/1.45 var(--ac-font-body); overflow-y: auto; cursor: inherit;
}
.aha-chat:not(.is-open) .aha-chat__input { pointer-events: none; } /* clicks go to the pill */
.aha-chat .aha-chat__input:is(:focus, :focus-visible) { outline: 0; box-shadow: none; }
.aha-chat__label {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  white-space: nowrap; pointer-events: none;
  font: 700 1rem/1.2 var(--ac-font-body); color: var(--ac-text);
  transition: opacity 260ms var(--ac-ease) 120ms, visibility 0s;
}
.aha-chat:is(.is-wide, .is-open) .aha-chat__label {
  opacity: 0; visibility: hidden;
  transition: opacity 140ms var(--ac-ease), visibility 0s linear 140ms;
}
.aha-chat__input::placeholder { color: var(--ac-text-soft); opacity: 1; }
.aha-chat__ticker {
  position: absolute; inset: 0; display: flex; align-items: center; pointer-events: none;
  font: 400 1rem/1.45 var(--ac-font-body); color: rgba(255, 255, 255, 0.82);
  white-space: nowrap; overflow: hidden;
}
.aha-chat__ticker[hidden] { display: none; }
.aha-chat__ticker-text { overflow: hidden; text-overflow: ellipsis; }
.aha-chat__caret { flex: none; width: 2px; height: 1.15em; margin-left: 2px; border-radius: 1px; background: var(--ac-coral); animation: aha-chat-blink 1s steps(1) infinite; }
.aha-chat__send {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; flex: none;
  border: 0; border-radius: 50%;
  background: var(--ac-coral-strong); color: #fff;
  box-shadow: 0 6px 16px rgba(217, 43, 72, 0.35);
  transition: background-color 180ms var(--ac-ease), transform 320ms var(--ac-ease), opacity 180ms var(--ac-ease);
}
.aha-chat__send svg { width: 20px; height: 20px; }
.aha-chat__send:hover:not(:disabled) { background: var(--ac-coral-deep); }
.aha-chat__send:active:not(:disabled) { transform: scale(0.92); transition-duration: 100ms; }
.aha-chat__send:disabled { opacity: 0.35; box-shadow: none; cursor: default; }
.aha-chat:not(.is-wide):not(.is-open) .aha-chat__send { opacity: 0; transform: scale(0.6); pointer-events: none; }
.aha-chat:not(.is-open) .aha-chat__note { display: none; }
.aha-chat__note { margin: 8px 0 0; text-align: center; font-size: 0.75rem; line-height: 1.3; color: var(--ac-text-soft); }
.aha-chat__note a { color: var(--ac-text-muted); text-decoration: underline; text-underline-offset: 2px; }
.aha-chat__note a:hover { color: #fff; }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .aha-chat__box { background: rgba(26, 26, 46, 0.94); }
}

.aha-chat__sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .aha-chat {
    --ac-gap: 12px;
    --ac-pill-h: 56px;
    --ac-pill-w: calc(100vw - 24px);
    --ac-open-w: calc(100vw - 16px);
    --ac-open-h: calc(100dvh - 16px - env(safe-area-inset-top) - var(--ac-offset));
  }
  .aha-chat.is-open .aha-chat__box { bottom: calc(8px + var(--ac-offset)); right: 8px; border-radius: 24px; }
  .aha-chat__mark { width: 38px; height: 38px; }
  .aha-chat__send { width: 42px; height: 42px; }
  .aha-chat__log { padding: 84px 18px 126px; }
  .aha-chat__msg { max-width: 94%; }
  .aha-chat__formcard { padding: 16px 16px 6px; border-radius: 18px; }
  .aha-chat__header { padding: 14px 10px 14px 16px; }
}

/* ---------- Motion ---------- */
@keyframes aha-chat-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes aha-chat-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes aha-chat-dot { 0%, 70%, 100% { transform: translateY(0); opacity: 0.55; } 35% { transform: translateY(-5px); opacity: 1; } }
@keyframes aha-chat-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .aha-chat *, .aha-chat__box { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .aha-chat__caret { opacity: 1; }
}

@media print { .aha-chat { display: none !important; } }
