/* ============================================================
   Website chat demo (home page) — launcher, panel, messages.
   Built by /js/chat-demo.js. Canon: apps/syntro/README.md § Website chat demo
   ============================================================ */

.chat-demo-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 18px;
  border: 0;
  border-radius: var(--border-radius-full);
  background: var(--color-primary);
  color: var(--text-on-primary);
  font: 600 var(--font-size-sm) / 1.2 var(--font-family);
  box-shadow: var(--shadow-xl);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.chat-demo-launcher:hover { background: var(--color-primary-light); transform: translateY(-2px); }
.chat-demo-launcher:focus-visible { outline: 3px solid var(--color-primary-light); outline-offset: 3px; }
.chat-demo-launcher[hidden] { display: none; }

.chat-demo {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1500; /* above the sticky header (1000) and nav (1001), below the voice demo modal (2000) */
  display: flex;
  flex-direction: column;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  font-family: var(--font-family);
}
.chat-demo[hidden] { display: none; }

.chat-demo__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: 14px 16px;
  background: var(--color-navy);
  border-bottom: 1px solid var(--border-color);
}
.chat-demo__title { margin: 0; font-size: var(--font-size-base); font-weight: 700; color: var(--text-primary); }
.chat-demo__sub { margin: 2px 0 0; font-size: var(--font-size-xs); color: var(--text-muted); }
.chat-demo__close {
  margin-left: auto;
  padding: 6px;
  border: 0;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.chat-demo__close:hover { color: var(--text-primary); background: var(--bg-card); }

.chat-demo__log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.chat-demo__msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: var(--font-size-sm);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-demo__msg--agent { align-self: flex-start; background: var(--bg-card); color: var(--text-primary); border-bottom-left-radius: 4px; }
.chat-demo__msg--user { align-self: flex-end; background: var(--color-primary); color: var(--text-on-primary); border-bottom-right-radius: 4px; }
.chat-demo__msg--note { align-self: center; max-width: 100%; background: transparent; color: var(--text-muted); font-size: var(--font-size-xs); text-align: center; padding: 0; }
.chat-demo__typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--bg-card); border-radius: 14px; }
.chat-demo__typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: chat-demo-dot 1.2s infinite ease-in-out; }
.chat-demo__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-demo__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-demo-dot { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.chat-demo__fine {
  margin: 0;
  padding: 8px 16px;
  font-size: var(--font-size-xs);
  line-height: 1.4;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}
.chat-demo__fine a { color: var(--color-primary); }

.chat-demo__form { display: flex; gap: var(--space-sm); padding: 10px 12px 12px; }
.chat-demo__input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
  /* 16px or more: iPhones zoom the whole page into any smaller box when it is tapped, which
     pushed Send off the screen (Ty 2026-10-09). Checked by tests/chat-phone.mjs. */
  font-size: 1rem;
}
.chat-demo__input:focus { outline: none; border-color: var(--border-color-focus); }
.chat-demo__send {
  padding: 0 16px;
  border: 0;
  border-radius: var(--border-radius-md);
  background: var(--color-primary);
  color: var(--text-on-primary);
  font-weight: 600;
  font-size: var(--font-size-sm);
  cursor: pointer;
}
.chat-demo__send:disabled, .chat-demo__input:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-demo__restart {
  align-self: center;
  padding: 8px 14px;
  border: 1px solid var(--color-primary);
  border-radius: var(--border-radius-full);
  background: transparent;
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
}

.chat-demo-launcher.is-away { display: none; }
.chat-demo:focus { outline: none; }

/* Phones: full screen, above the cookie banner (9999), sized by chat-demo.js to the part of the
   screen the keyboard leaves showing (--chat-top, --chat-h), so the box and Send stay in view. */
@media (max-width: 480px) {
  .chat-demo {
    z-index: 10000;
    top: var(--chat-top, 0);
    right: 0;
    bottom: auto;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: var(--chat-h, 100dvh);
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .chat-demo__form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .chat-demo-launcher { right: 16px; }
}

/* Below 1024px the phone action bar (styles.css) holds the bottom 64px; the launcher sits above it. */
@media (max-width: 1023px) {
  .chat-demo-launcher {
    bottom: calc(76px + env(safe-area-inset-bottom));
    transition: transform 0.15s ease, background-color 0.15s ease, opacity 0.2s ease, visibility 0.2s;
  }
  /* Waits with the action bar until the hero's buttons are scrolled clear (styles.css § Phone action bar). */
  .dock-wait .chat-demo-launcher { opacity: 0; visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-demo__typing span { animation: none; opacity: 0.7; }
  .chat-demo-launcher { transition: none; }
}
