/* ============================================================
   VASAVAS — the gate. Chat + voice panel for /api/chat.
   Uses the site's existing tokens (--ink / --bg / --accent).
   ============================================================ */

.talk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(5, 7, 6, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.talk-backdrop.open { opacity: 1; pointer-events: auto; }

.talk-panel {
  position: fixed;
  z-index: 9001;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(480px, 100vw);
  display: flex;
  flex-direction: column;
  background: #0a0d0b;
  border-left: 1px solid rgba(23, 232, 143, 0.22);
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
.talk-panel.open { transform: translateX(0); }

@media (max-width: 640px) {
  .talk-panel { width: 100vw; border-left: none; }
}

.talk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(242, 236, 221, 0.1);
  flex: 0 0 auto;
}
.talk-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.talk-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(23, 232, 143, 0.6);
  animation: talk-pulse 2.4s infinite;
  flex: 0 0 auto;
}
@keyframes talk-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(23, 232, 143, 0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(23, 232, 143, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 232, 143, 0); }
}
.talk-title {
  font-family: var(--body);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.talk-phase {
  font-family: var(--body);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  padding: 3px 7px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.talk-phase[hidden] { display: none; }

.talk-close {
  appearance: none;
  background: none;
  border: 1px solid rgba(242, 236, 221, 0.24);
  color: var(--ink);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.talk-close:hover { border-color: var(--accent); color: var(--accent); }

.talk-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
}

.talk-msg {
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: talk-in 0.3s ease both;
}
@keyframes talk-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.talk-msg.bot {
  align-self: flex-start;
  background: rgba(242, 236, 221, 0.07);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.talk-msg.me {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}
.talk-msg.sys {
  align-self: center;
  max-width: 100%;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  background: none;
  padding: 4px 0;
}
.talk-msg.sys a { color: var(--accent); }

/* typing indicator */
.talk-typing { align-self: flex-start; display: flex; gap: 4px; padding: 13px 14px; }
.talk-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-dim);
  animation: talk-bounce 1.3s infinite;
}
.talk-typing span:nth-child(2) { animation-delay: 0.16s; }
.talk-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes talk-bounce {
  0%, 60%, 100% { transform: none; opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.talk-foot {
  flex: 0 0 auto;
  border-top: 1px solid rgba(242, 236, 221, 0.1);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}
.talk-form { display: flex; gap: 10px; align-items: flex-end; }
.talk-input {
  flex: 1 1 auto;
  appearance: none;
  background: rgba(242, 236, 221, 0.06);
  border: 1px solid rgba(242, 236, 221, 0.16);
  border-radius: 12px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px; /* 16px stops iOS zoom-on-focus */
  line-height: 1.45;
  padding: 11px 13px;
  resize: none;
  max-height: 140px;
  transition: border-color 0.2s ease;
}
.talk-input:focus { outline: none; border-color: var(--accent); }
.talk-input::placeholder { color: rgba(242, 236, 221, 0.38); }

.talk-send {
  appearance: none;
  border: none;
  background: var(--accent);
  color: var(--bg);
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: opacity 0.2s ease, transform 0.15s ease;
}
.talk-send:hover:not(:disabled) { transform: translateY(-1px); }
.talk-send:disabled { opacity: 0.32; cursor: not-allowed; }

.talk-note {
  margin-top: 8px;
  font-family: var(--body);
  font-size: 11px;
  line-height: 1.45;
  color: rgba(242, 236, 221, 0.42);
  text-align: center;
}

/* the honeypot — never visible, never announced */
.talk-hp {
  position: absolute;
  left: -9999px;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .talk-backdrop, .talk-panel { transition: none; }
  .talk-msg { animation: none; }
  .talk-dot, .talk-typing span { animation: none; }
}

/* mic toggle — sits left of the input */
.talk-mic {
  appearance: none;
  background: rgba(242, 236, 221, 0.06);
  border: 1px solid rgba(242, 236, 221, 0.16);
  color: var(--ink);
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.talk-mic:hover { border-color: var(--accent); }
.talk-mic.on {
  background: var(--accent);
  border-color: var(--accent);
  animation: talk-live 1.9s ease-in-out infinite;
}
@keyframes talk-live {
  0%, 100% { box-shadow: 0 0 0 0 rgba(23, 232, 143, 0.5); }
  50%      { box-shadow: 0 0 0 7px rgba(23, 232, 143, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .talk-mic.on { animation: none; }
}

/* fallback intake form — shown when the bot is unavailable */
.talk-fallback {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  margin-top: 4px;
  animation: talk-in 0.3s ease both;
}
.talk-fb-in {
  appearance: none;
  width: 100%;
  background: rgba(242, 236, 221, 0.06);
  border: 1px solid rgba(242, 236, 221, 0.16);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px; /* 16px stops iOS zoom-on-focus */
  line-height: 1.45;
  padding: 11px 13px;
  transition: border-color 0.2s ease;
}
.talk-fb-in:focus { outline: none; border-color: var(--accent); }
.talk-fb-in::placeholder { color: rgba(242, 236, 221, 0.38); }
.talk-fb-msg { resize: vertical; min-height: 76px; }
.talk-fb-send {
  appearance: none;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 13px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease;
}
.talk-fb-send:hover:not(:disabled) { transform: translateY(-1px); }
.talk-fb-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* live handoff offer */
.talk-call {
  width: 100%;
  margin-top: 6px;
  padding: 16px;
  border: 1px solid rgba(23, 232, 143, 0.3);
  background: rgba(23, 232, 143, 0.06);
  border-radius: 12px;
  animation: talk-in 0.3s ease both;
}
.talk-call-p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.talk-call-btn {
  appearance: none;
  width: 100%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 13px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.talk-call-btn:hover:not(:disabled) { transform: translateY(-1px); }
.talk-call-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* mic blocked — voice still speaks, it just can't listen */
.talk-mic.denied {
  background: rgba(255, 139, 122, 0.12);
  border-color: rgba(255, 139, 122, 0.4);
  opacity: 0.75;
}
