/* ================================================================
   Site chat: one launcher, one panel holding the AI assistant and the
   way to a person (templates/partials/assist.html, static/js/assist.js).
   Its own file so a change here never depends on the CDN refreshing
   v3-blueprint.css. Sits below the nav (z 1000) so the mobile menu
   still covers it.
   ================================================================ */

.assist {
  --as-accent: var(--accent, #0B5FFF);
  --as-accent-hover: var(--accent-hover, #0A4FD6);
  --as-ink: var(--ink, #0d1b2e);
  --as-ink-2: var(--ink-2, #52627a);
  --as-line: var(--line, rgba(13, 27, 46, 0.12));
  --as-surface: var(--surface, #fff);
  --as-soft: var(--surface-3, #EEF3FA);
  --as-wa: #25D366;
  --as-wa-ink: #0b3d1f;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 990;
  font-family: var(--font-sans, system-ui, sans-serif);
  color: var(--as-ink);
}

/* ---------- Launcher ---------- */
.assist-launch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--as-accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 28px -10px rgba(13, 27, 46, 0.45), 0 2px 6px rgba(13, 27, 46, 0.12);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.assist-launch:hover { transform: translateY(-2px); background: var(--as-accent-hover); }
.assist.is-open .assist-launch { background: var(--as-ink); }

/* ---------- Panel ---------- */
.assist-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(390px, calc(100vw - 32px));
  /* 180px = the launcher row below (80) + the fixed site nav above (~80) + air,
     so the header buttons never slide under the nav. */
  height: min(600px, calc(100vh - 180px));
  height: min(600px, calc(100dvh - 180px));
  display: flex;
  flex-direction: column;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: 16px;
  box-shadow: 0 24px 60px -20px rgba(13, 27, 46, 0.45);
  overflow: hidden;
}
.assist-panel[hidden] { display: none; }
.assist.is-large .assist-panel {
  width: min(680px, calc(100vw - 32px));
  height: min(860px, calc(100vh - 180px));
  height: min(860px, calc(100dvh - 180px));
}

.assist-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 10px 16px;
  border-bottom: 1px solid var(--as-line);
}
.assist-head-text { min-width: 0; }
.assist-title { margin: 0; font-size: 1rem; font-weight: 650; line-height: 1.3; color: var(--as-ink); }
.assist-sub { margin: 2px 0 0; font-size: 0.75rem; color: var(--as-ink-2); }
.assist-tools { display: flex; flex: none; gap: 2px; }
.assist-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--as-ink-2);
  cursor: pointer;
}
.assist-icon:hover { background: var(--as-soft); color: var(--as-ink); }
.assist-icon[aria-pressed="true"] { color: var(--as-accent-hover); }

/* A person, always one tap away. */
.assist-human {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--as-line);
  background: var(--as-soft);
  font-size: 0.8rem;
  color: var(--as-ink-2);
}
.assist-human a { color: var(--as-accent-hover); font-weight: 600; }
.assist-human a.assist-human-wa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--as-wa);
  color: var(--as-wa-ink);
  text-decoration: none;
}

.assist-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.assist-turn { display: flex; flex-direction: column; gap: 8px; }

.assist-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.assist-msg.bot { align-self: flex-start; background: var(--as-soft); color: var(--as-ink); border-bottom-left-radius: 4px; }
.assist-msg.me { align-self: flex-end; background: var(--as-accent); color: #fff; border-bottom-right-radius: 4px; }
.assist-msg.typing { color: var(--as-ink-2); font-style: italic; }

.assist-cards { display: flex; flex-direction: column; gap: 8px; }
.assist-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--as-line);
  border-radius: 10px;
  background: var(--as-surface);
  color: var(--as-ink);
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.assist-card:hover { border-color: var(--as-accent); color: var(--as-ink); }
.assist-card-img { flex: none; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--as-soft); }
.assist-card-body { min-width: 0; }
.assist-card strong { display: block; font-size: 0.9rem; line-height: 1.35; }
/* Short on purpose: the actor page holds the details. */
.assist-card small {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--as-ink-2);
}
.assist-card-meta { display: block; margin-top: 5px; font-family: var(--font-mono, monospace); font-size: 0.72rem; color: var(--as-accent-hover); }

.assist-offer {
  padding: 9px 12px;
  border: 1px solid var(--as-accent);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--as-surface);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--as-ink);
}

.assist-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.assist-actions a {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--as-accent);
  color: var(--as-accent-hover);
  background: var(--as-surface);
}
.assist-actions a.is-wa { border-color: var(--as-wa); background: var(--as-wa); color: var(--as-wa-ink); }

.assist-suggest { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.assist-suggest button {
  max-width: 90%;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--as-accent);
  background: var(--as-surface);
  color: var(--as-accent-hover);
  font-size: 0.82rem;
  text-align: right;
  cursor: pointer;
}
.assist-suggest button:hover { background: var(--as-accent); color: #fff; }

.assist-form { display: flex; gap: 6px; padding: 10px 12px 4px; border-top: 1px solid var(--as-line); }
.assist-form input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--as-line);
  background: var(--as-surface);
  color: var(--as-ink);
  font-size: 16px; /* under 16px iOS zooms the page on focus */
}
.assist-form input:focus { border-color: var(--as-accent); outline: none; }
.assist-mic,
.assist-send {
  flex: none;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
}
.assist-mic[hidden] { display: none; }
.assist-mic { border: 1px solid var(--as-line); background: var(--as-surface); color: var(--as-ink-2); }
.assist-mic.is-on { border-color: #d93025; color: #d93025; }
.assist-send { border: 0; background: var(--as-accent); color: #fff; }
.assist-send:disabled { opacity: 0.5; cursor: default; }

.assist-status { min-height: 1.4em; margin: 0; padding: 2px 14px 8px; font-size: 0.74rem; color: var(--as-ink-2); }

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .assist-launch { width: 52px; padding: 0; }
  .assist-launch-label { display: none; }
  .assist-only-wide { display: none; }
  .assist-panel,
  .assist.is-large .assist-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 76px;
    width: auto;
    height: calc(100vh - 160px);
    height: calc(100dvh - 160px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .assist-launch, .assist-card { transition: none; }
  .assist-launch:hover { transform: none; }
}

@media print { .assist { display: none; } }
