/* ============================================================
   WEBSITE ASSISTANT — assistant.css
   Chat button and panel added by assistant.js.
   Uses the colors, fonts and radii defined in style.css.
   ============================================================ */

/* --- Launcher button ---
   Bottom-right, where people look for chat. Small and still: no bounce, no
   badge, never opens on its own. Sits below the mobile menu (z-index 500). */
.assistant-launcher {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 390;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.15rem;
  border: none;
  border-radius: var(--radius-pill);
  background-color: var(--sage);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(82, 120, 72, 0.32);
  transition: transform 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.assistant-launcher:hover {
  background-color: #3d6035;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(82, 120, 72, 0.38);
}

.assistant-launcher:focus-visible {
  outline: 3px solid var(--clementine-deep);
  outline-offset: 3px;
}

.assistant-launcher.is-hidden { display: none; }

.assistant-launcher-icon { flex-shrink: 0; }

/* The site's welcome popup shares this corner: lift it above the chat
   button so both stay visible (style.css puts it at 2rem / 1rem on phones) */
.has-assistant .welcome-popup { bottom: 5.5rem; }

/* Once the chat has been opened, the site's welcome popup stays hidden */
.assistant-used .welcome-popup,
.assistant-used .welcome-popup.is-visible { display: none; }

/* --- Panel ---
   Above the welcome popup (400), below the mobile menu (500). */
.assistant-panel {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 410;
  display: flex;
  flex-direction: column;
  width: 340px;
  max-width: calc(100vw - 3rem);
  height: min(480px, calc(100vh - 3rem));
  height: min(480px, calc(100dvh - 3rem));
  background-color: var(--white);
  border: 1px solid rgba(232, 160, 106, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(60, 40, 20, 0.18);
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text-main);
}

.assistant-panel[hidden] { display: none; }

.assistant-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem 0.9rem;
  background-color: var(--clementine-soft);
  border-bottom: 1px solid rgba(232, 160, 106, 0.22);
}

.assistant-title:focus { outline: none; }

.assistant-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.2;
}

.assistant-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.assistant-header-end {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Decorative: the title already names the assistant */
.assistant-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.assistant-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.assistant-close:hover {
  color: var(--text-main);
  background-color: var(--clementine-warm);
}

/* --- Pre-chat notice --- */
.assistant-notice {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  padding: 1.5rem 1.4rem;
  overflow-y: auto;
}

.assistant-notice[hidden] { display: none; }

.assistant-notice-copy {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.assistant-notice-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
}

.assistant-notice-disclaimer { font-weight: 500; }

.assistant-accept { align-self: stretch; }

/* --- Conversation --- */
.assistant-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.assistant-chat[hidden] { display: none; }

.assistant-log {
  position: relative; /* so each message's offsetTop is measured from the log */
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.1rem 1.1rem 0.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.assistant-msg {
  max-width: 88%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.55;
}

.assistant-msg-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-msg--user {
  align-self: flex-end;
  background-color: var(--clementine-warm);
  border-bottom-right-radius: var(--radius-sm);
}

.assistant-msg--bot {
  align-self: flex-start;
  background-color: var(--cream);
  border: 1px solid rgba(60, 40, 20, 0.08);
  border-bottom-left-radius: var(--radius-sm);
}

/* Underline kept (thin) so links stand out from text for everyone */
.assistant-link {
  color: var(--sage);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--sage-light);
  text-underline-offset: 3px;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.assistant-link:hover {
  color: #3d6035;
  text-decoration-color: currentColor;
}

/* --- Hand-off buttons --- */
.assistant-handoff {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.assistant-handoff-btn {
  min-height: 40px;
  padding: 0.5rem 0.95rem;
  font-size: 0.82rem;
}

/* --- Typing indicator --- */
.assistant-typing {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}

.assistant-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-muted);
  opacity: 0.4;
  animation: assistant-pulse 1.2s infinite ease-in-out;
}

.assistant-dot:nth-of-type(3) { animation-delay: 0.15s; }
.assistant-dot:nth-of-type(4) { animation-delay: 0.3s; }

@keyframes assistant-pulse {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 0.9; }
}

/* --- Input area --- */
.assistant-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid rgba(60, 40, 20, 0.08);
}

.assistant-warning {
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background-color: var(--clementine-warm);
  border: 1px solid var(--clementine-deep);
  font-size: 0.82rem;
  line-height: 1.5;
}

.assistant-warning[hidden] { display: none; }

.assistant-input {
  width: 100%;
  min-height: 3.2rem;
  max-height: 8rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(60, 40, 20, 0.18);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem; /* 16px+ stops iOS zooming in on focus */
  line-height: 1.45;
  color: var(--text-main);
  background-color: var(--white);
  resize: vertical;
}

.assistant-input:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-pale);
}

.assistant-input:disabled {
  background-color: var(--cream);
  color: var(--text-muted);
}

.assistant-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.assistant-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.assistant-count.is-over {
  color: #a6491b;
  font-weight: 500;
}

.assistant-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Visible only to screen readers */
.assistant-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Phones: a floating card, not full screen ---
   Keeps the page visible behind it. env(safe-area-inset-bottom) keeps clear
   of the iPhone home bar. */
@media (max-width: 680px) {
  .assistant-launcher {
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .has-assistant .welcome-popup { bottom: 4.75rem; }

  /* The card sits at the bottom of the visible screen. When the keyboard
     opens, assistant.js updates --assistant-vv-top/-height (the area above
     the keyboard) and the card shrinks to fit there, header included. */
  .assistant-panel {
    --assistant-card-h: min(520px, 68dvh, calc(var(--assistant-vv-height, 100dvh) - 1.5rem));
    right: 0.75rem;
    left: 0.75rem;
    top: calc(
      var(--assistant-vv-top, 0px) + var(--assistant-vv-height, 100dvh)
      - var(--assistant-card-h) - max(0.75rem, env(safe-area-inset-bottom))
    );
    bottom: auto;
    width: auto;
    max-width: none;
    height: var(--assistant-card-h);
  }

  .assistant-close {
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
  }

  .assistant-form {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  /* No drag handle on touch screens */
  .assistant-input { resize: none; }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-launcher { transition: none; }
  .assistant-launcher:hover { transform: none; }
  .assistant-dot { animation: none; opacity: 0.6; }
}
