/* chat.css — chat assistant widget (chat.js). Load it before style.css; set the --chat-* tokens there to match the site. */

:root {
  --chat-paper: var(--paper);       /* panel */
  --chat-paper-2: #fff;             /* bubbles, input */
  --chat-ink: var(--ink);
  --chat-line: rgba(0, 0, 0, .12);
  --chat-brand: var(--ink);         /* chat button and the visitor's messages */
  --chat-on-brand: var(--paper);
  --chat-accent: var(--accent);     /* send button */
  --chat-on-accent: var(--ink);
  --chat-z: 65;
}

/* ---------- button ---------- */
.chat-launch {
  position: fixed; z-index: var(--chat-z); inset-inline-end: 20px; bottom: 20px;
  display: inline-flex; align-items: center; gap: 10px; min-height: 54px; padding-block: 7px; padding-inline: 7px 20px;
  border-radius: 999px; background: var(--chat-brand); color: var(--chat-on-brand); font: 600 15px/1 var(--sans);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .55);
  translate: 0 calc(100% + 40px); transition: translate .7s var(--ease), bottom .5s var(--ease), opacity .3s;
}
.chat-launch.is-in { translate: 0 0; }
.chat-launch img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.chat-launch-badge { display: none; }
.chat-launch:focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 3px; }
.chat-is-open .chat-launch { opacity: 0; pointer-events: none; }

/* ---------- panel ---------- */
.chat {
  position: fixed; z-index: var(--chat-z); inset-inline-end: 20px; bottom: 20px;
  width: min(400px, calc(100vw - 40px)); height: min(640px, calc(100vh - 40px));
  display: flex; flex-direction: column; overflow: hidden; border-radius: 24px;
  background: var(--chat-paper); color: var(--chat-ink); font-family: var(--sans);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6), 0 0 0 1px var(--chat-line);
  opacity: 0; translate: 0 24px; transform-origin: bottom right;
  transition: opacity .3s, translate .55s var(--ease);
}
.chat.is-open { opacity: 1; translate: 0 0; }

.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--chat-line); }
.chat-avatar img { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.chat-titles { flex: 1; min-width: 0; }
.chat-titles h2 { font: italic 400 26px/1 var(--serif); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-titles p { margin-top: 3px; font-size: 12px; opacity: .6; }
.chat-actions { display: flex; align-items: center; gap: 6px; }
.chat-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--chat-line); transition: background .25s; }
.chat-icon:hover { background: var(--chat-paper-2); }
.chat-icon svg, .chat-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chat-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.chat-msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.chat-msg--bot { align-self: flex-start; background: var(--chat-paper-2); box-shadow: inset 0 0 0 1px var(--chat-line); border-end-start-radius: 6px; }
.chat-msg--user { align-self: flex-end; background: var(--chat-brand); color: var(--chat-on-brand); border-end-end-radius: 6px; }
.chat-msg--note { align-self: center; max-width: 92%; padding: 6px 10px; font-size: 13px; text-align: center; opacity: .75; }
.chat-cards { display: grid; gap: 8px; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-chip { padding: 9px 14px; border-radius: 999px; font-size: 14px; text-align: start; box-shadow: inset 0 0 0 1px var(--chat-line); transition: background .25s; }
.chat-chip:hover { background: var(--chat-paper-2); }

.chat-typing { align-self: flex-start; display: flex; gap: 5px; padding: 14px 16px; border-radius: 18px; background: var(--chat-paper-2); box-shadow: inset 0 0 0 1px var(--chat-line); }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35; animation: chat-dot 1.1s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 30% { opacity: .9; translate: 0 -3px; } }

.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 8px; border-top: 1px solid var(--chat-line); }
.chat-form textarea {
  flex: 1; min-height: 46px; max-height: 132px; resize: none; padding: 12px 16px; border: 0; border-radius: 23px; outline: none;
  background: var(--chat-paper-2); box-shadow: inset 0 0 0 1px var(--chat-line); color: inherit; font: 16px/1.4 var(--sans); /* 16px: iOS zooms into smaller inputs */
}
.chat-form textarea:focus { box-shadow: inset 0 0 0 2px var(--chat-brand); }
.chat-send { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--chat-accent); color: var(--chat-on-accent); transition: opacity .25s; }
.chat-form.is-busy .chat-send { opacity: .45; }
.chat-notice { padding: 0 16px 12px; font-size: 11.5px; line-height: 1.4; text-align: center; opacity: .55; }

/* ---------- phones: full screen ---------- */
@media (max-width: 640px) {
  .chat-launch { inset-inline-end: 12px; bottom: 12px; transition: translate .7s var(--ease), bottom .5s var(--ease), opacity .3s, padding .5s var(--ease), gap .5s var(--ease); }
  .chat-launch span { max-width: 180px; overflow: hidden; white-space: nowrap; transition: max-width .5s var(--ease), opacity .3s; }
  .chat-launch.is-compact { gap: 0; padding-inline-end: 7px; }
  .chat-launch.is-compact span { max-width: 0; opacity: 0; }
  .chat-launch.is-compact .chat-launch-badge {
    display: grid; place-items: center; position: absolute; top: -4px; inset-inline-end: -4px; width: 22px; height: 22px; border-radius: 50%;
    background: var(--chat-accent); color: var(--chat-on-accent); box-shadow: 0 0 0 2px var(--chat-brand);
  }
  .chat-launch-badge svg { width: 12px; height: 12px; fill: currentColor; }
  .chat { inset: 0; width: 100%; height: 100%; border-radius: 0; box-shadow: none; translate: 0 100%; opacity: 1; }
  .chat.is-open { translate: 0 0; }
  .chat-titles h2 { font-size: 24px; }
  html.chat-is-open, html.chat-is-open body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .chat, .chat-launch { transition: none; }
  .chat-typing span { animation: none; }
}
