/* ============================================================================
   TERRENCE — spinning-emblem chat CTA (bottom-right), shared across all pages.
   Ported verbatim from index.html's inlined launcher/panel/voice styles so the
   orb is identical on every page. Brand red #c8102e on pure ink #0a0a0a.
============================================================================ */

/* ===== CHAT LAUNCHER ===== */
#tnaado-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #0a0a0a;
  border: 1px solid rgba(200, 16, 46, 0.55);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  padding: 0;
  box-shadow: 0 0 14px rgba(200, 16, 46, 0.10),
              0 8px 24px rgba(0, 0, 0, 0.55);
  animation: tn-cta-breathe 4s ease-in-out infinite;
  transition: border-color 600ms ease-out,
              box-shadow 800ms ease-out,
              transform 400ms ease-out;
}
#tnaado-chat-btn:hover,
#tnaado-chat-btn:focus-visible {
  border-color: #c8102e;
  box-shadow: 0 0 24px rgba(200, 16, 46, 0.30),
              0 0 48px rgba(200, 16, 46, 0.18),
              0 8px 24px rgba(0, 0, 0, 0.55);
  animation: none;
}
@keyframes tn-cta-breathe {
  0%, 100% { box-shadow: 0 0 14px rgba(200, 16, 46, 0.10),
                          0 8px 24px rgba(0, 0, 0, 0.55); }
  50%      { box-shadow: 0 0 22px rgba(200, 16, 46, 0.22),
                          0 8px 24px rgba(0, 0, 0, 0.55); }
}
.chat-btn-emblem {
  width: 48px;
  height: 48px;
  animation: spin-emblem 8s linear infinite;
  transition: filter 600ms ease-out, opacity 400ms ease-out;
  filter: drop-shadow(0 0 6px rgba(200, 16, 46, 0.45));
  opacity: 0.92;
}
#tnaado-chat-btn:hover .chat-btn-emblem {
  animation-duration: 3s;
  filter: drop-shadow(0 0 10px rgba(200, 16, 46, 0.65));
  opacity: 1;
}
@keyframes spin-emblem { to { transform: rotate(360deg); } }
.chat-btn-close {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 50%;
  color: #c8102e;
  font-size: 22px;
}
#tnaado-chat-btn.open { border-color: #c8102e; animation: none; }
#tnaado-chat-btn.open .chat-btn-emblem { opacity: 0.15; }
#tnaado-chat-btn.open .chat-btn-close { display: flex; }
.chat-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #c8102e;
  border-radius: 50%;
  border: 1px solid #0a0a0a;
  animation: pulse-badge 2.4s ease-in-out infinite;
  z-index: 1;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.2); }
}

/* ===== CHAT PANEL ===== */
#tnaado-chat-panel {
  position: fixed;
  bottom: 116px;
  right: 28px;
  width: 380px;
  max-height: 580px;
  background: #0a0a0a;
  border: 1px solid rgba(245, 241, 232, 0.10);
  border-radius: 0;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65),
              0 0 0 1px rgba(200, 16, 46, 0.06);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 600ms ease-out, opacity 400ms ease-out;
  font-family: 'IBM Plex Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #f5f1e8;
}
#tnaado-chat-panel.open { transform: translateY(0); opacity: 1; pointer-events: all; }
#tnaado-chat-panel.expanded { width: min(680px, 100%); height: 82vh; max-height: 82vh; bottom: 100px; }
#tnaado-chat-panel.expanded .chat-messages { font-size: 15px; }
#tnaado-chat-panel.expanded .chat-msg-bubble { font-size: 15px; padding: 12px 16px; }
#tnaado-chat-panel.expanded .chat-input-bar textarea { font-size: 15px; }
@media (max-width: 720px) {
  #tnaado-chat-panel.expanded { width: calc(100vw - 16px); height: 88vh; max-height: 88vh; right: 8px; bottom: 80px; }
}
#tnaado-chat-panel.minimized { max-height: 62px; overflow: hidden; }
#tnaado-chat-panel.minimized .chat-messages,
#tnaado-chat-panel.minimized .chat-input-bar,
#tnaado-chat-panel.minimized .chat-footer { display: none; }

.chat-header {
  background: #0a0a0a; color: #f5f1e8; padding: 16px 18px;
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  border-bottom: 1px solid rgba(245, 241, 232, 0.10); position: relative;
}
.chat-header::after {
  content: ''; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 1px;
  background: linear-gradient(to right, transparent 0%, rgba(200, 16, 46, 0.45) 50%, transparent 100%);
}
.chat-header-avatar {
  width: 36px; height: 36px; background: transparent;
  border: 1px solid rgba(200, 16, 46, 0.55); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: #c8102e; box-shadow: 0 0 10px rgba(200, 16, 46, 0.15);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h4 {
  margin: 0 0 2px; font-family: 'Fraunces', 'Inter', serif; font-style: italic;
  font-size: 17px; font-weight: 400; letter-spacing: 0.01em; color: #f5f1e8;
}
.chat-header-info span {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase; color: rgba(245, 241, 232, 0.55);
  display: flex; align-items: center; gap: 6px;
}
.chat-header-info span::before {
  content: ''; display: inline-block; width: 6px; height: 6px; background: #c8102e;
  border-radius: 50%; box-shadow: 0 0 6px rgba(200, 16, 46, 0.55);
  animation: tn-cta-status-pulse 2.4s ease-in-out infinite;
}
@keyframes tn-cta-status-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
.chat-header-actions { display: flex; gap: 4px; }
.chat-header-actions button {
  background: transparent; border: 1px solid rgba(245, 241, 232, 0.10);
  color: rgba(245, 241, 232, 0.65); width: 28px; height: 28px; border-radius: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color 400ms ease-out, border-color 400ms ease-out, background 400ms ease-out; outline: none;
}
.chat-header-actions button:hover,
.chat-header-actions button:focus-visible {
  color: #c8102e; border-color: rgba(200, 16, 46, 0.55); background: rgba(200, 16, 46, 0.04);
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column;
  gap: 14px; scroll-behavior: smooth; background: #0a0a0a;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(245, 241, 232, 0.12); border-radius: 0; }
.chat-msg { display: flex; gap: 10px; max-width: 90%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.bot { align-self: flex-start; }
.chat-msg-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: transparent;
  border: 1px solid rgba(200, 16, 46, 0.55); color: #c8102e;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.chat-msg-bubble {
  padding: 11px 14px; border-radius: 0; font-size: 13.5px; line-height: 1.6;
  word-break: break-word; font-family: 'IBM Plex Sans', 'Inter', sans-serif; letter-spacing: 0.01em;
}
.chat-msg.bot .chat-msg-bubble {
  background: rgba(245, 241, 232, 0.04); border: 1px solid rgba(245, 241, 232, 0.08); color: rgba(245, 241, 232, 0.92);
}
.chat-msg.user .chat-msg-bubble {
  background: rgba(200, 16, 46, 0.10); border: 1px solid rgba(200, 16, 46, 0.40); color: #f5f1e8;
}
.typing-indicator .chat-msg-bubble {
  display: flex; align-items: center; gap: 5px; padding: 12px 16px;
  background: rgba(245, 241, 232, 0.04); border: 1px solid rgba(245, 241, 232, 0.08);
}
.typing-dot { width: 6px; height: 6px; background: rgba(245, 241, 232, 0.45); border-radius: 50%; animation: typing-bounce 1.4s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.lead-form { background: rgba(200, 16, 46, 0.04); border: 1px solid rgba(200, 16, 46, 0.30); border-radius: 0; padding: 14px; margin: 4px 0; }
.lead-form p { margin: 0 0 10px; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(245, 241, 232, 0.78); }
.lead-form input { width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid rgba(245, 241, 232, 0.12); border-radius: 0; font-size: 13px; font-family: 'IBM Plex Sans', inherit; margin-bottom: 8px; outline: none; color: #f5f1e8; background: rgba(245, 241, 232, 0.03); transition: border-color 400ms ease-out; }
.lead-form input::placeholder { color: rgba(245, 241, 232, 0.35); }
.lead-form input:focus { border-color: #c8102e; }
.lead-form button { width: 100%; padding: 10px; background: transparent; color: #c8102e; border: 1px solid #c8102e; border-radius: 0; font-family: 'IBM Plex Sans', inherit; font-size: 12px; font-weight: 500; letter-spacing: 0.05em; cursor: pointer; transition: background 600ms ease-out, color 600ms ease-out; }
.lead-form button:hover { background: #c8102e; color: #f5f1e8; }

.chat-input-bar {
  padding: 12px 14px; border-top: 1px solid rgba(245, 241, 232, 0.10); background: #0a0a0a;
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0;
}
.chat-input-bar textarea {
  flex: 1; border: 1px solid rgba(245, 241, 232, 0.10); border-radius: 0; padding: 10px 14px;
  font-size: 13.5px; font-family: 'IBM Plex Sans', inherit; resize: none; min-height: 40px; max-height: 120px;
  outline: none; color: #f5f1e8; background: rgba(245, 241, 232, 0.03); line-height: 1.4;
  transition: border-color 400ms ease-out; overflow-y: auto;
}
.chat-input-bar textarea:focus { border-color: rgba(200, 16, 46, 0.55); }
.chat-input-bar textarea::placeholder { color: rgba(245, 241, 232, 0.35); }
.chat-send-btn, .chat-mic-btn {
  width: 40px; height: 40px; background: transparent; border: 1px solid rgba(245, 241, 232, 0.12);
  border-radius: 0; color: rgba(245, 241, 232, 0.65); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: color 400ms ease-out, border-color 400ms ease-out, background 400ms ease-out; outline: none;
}
.chat-send-btn:hover, .chat-mic-btn:hover { color: #c8102e; border-color: rgba(200, 16, 46, 0.55); background: rgba(200, 16, 46, 0.04); }
.chat-send-btn:disabled { color: rgba(245, 241, 232, 0.20); border-color: rgba(245, 241, 232, 0.06); background: transparent; cursor: not-allowed; }
.chat-mic-btn.listening { color: #f5f1e8; background: #c8102e; border-color: #c8102e; animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.55); } 50% { box-shadow: 0 0 0 8px rgba(200, 16, 46, 0); } }

.chat-msg-speak { background: none; border: none; cursor: pointer; color: rgba(245, 241, 232, 0.40); padding: 2px 4px; border-radius: 0; display: inline-flex; align-items: center; margin-left: 4px; vertical-align: middle; transition: color 400ms ease-out; outline: none; }
.chat-msg-speak:hover { color: #c8102e; }
.chat-msg-speak.speaking { color: #c8102e; }

#chat-voice-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10, 10, 10, 0.94);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 99999;
  align-items: center; justify-content: center; flex-direction: column; gap: 24px;
  font-family: 'IBM Plex Sans', 'Inter', sans-serif; color: #f5f1e8;
}
#chat-voice-overlay.active { display: flex; }
.voice-orb {
  width: 120px; height: 120px; border-radius: 50%; background: #0a0a0a;
  border: 1px solid rgba(200, 16, 46, 0.55); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 24px rgba(200, 16, 46, 0.18), 0 0 48px rgba(200, 16, 46, 0.10);
  transition: transform 0.15s; color: #c8102e;
}
.voice-orb.listening { animation: orb-pulse 1.8s ease-in-out infinite; }
.voice-orb.speaking  { animation: orb-wave 1s ease-in-out infinite alternate; }
@keyframes orb-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.55), 0 0 24px rgba(200, 16, 46, 0.18); } 50% { box-shadow: 0 0 0 30px rgba(200, 16, 46, 0), 0 0 24px rgba(200, 16, 46, 0.18); } }
@keyframes orb-wave { from { transform: scale(1); } to { transform: scale(1.10); } }
.voice-status { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(245, 241, 232, 0.78); }
.voice-transcript { font-family: 'Fraunces', serif; font-style: italic; font-size: 16px; color: rgba(245, 241, 232, 0.65); max-width: 340px; text-align: center; min-height: 20px; line-height: 1.5; }
.voice-end-btn { margin-top: 8px; padding: 12px 32px; background: transparent; border: 1px solid #c8102e; border-radius: 0; color: #c8102e; font-family: 'IBM Plex Sans', inherit; font-size: 12px; font-weight: 500; letter-spacing: 0.10em; text-transform: uppercase; cursor: pointer; transition: background 600ms ease-out, color 600ms ease-out; }
.voice-end-btn:hover { background: #c8102e; color: #f5f1e8; }

.chat-footer { text-align: center; padding: 8px 14px 12px; font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(245, 241, 232, 0.35); background: #0a0a0a; border-top: 1px solid rgba(245, 241, 232, 0.06); flex-shrink: 0; }
.chat-footer a { color: rgba(245, 241, 232, 0.55); text-decoration: none; transition: color 400ms ease-out; }
.chat-footer a:hover { color: #c8102e; }

@media (max-width: 480px) {
  #tnaado-chat-panel { width: calc(100vw - 24px); right: 12px; bottom: 96px; border-radius: 0; }
  #tnaado-chat-btn { right: 16px; bottom: 16px; width: 64px; height: 64px; }
  #tnaado-chat-btn .chat-btn-emblem { width: 42px; height: 42px; }
  #tnaado-chat-panel.expanded { width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  #tnaado-chat-btn, .chat-btn-emblem, .chat-badge, .chat-header-info span::before, .voice-orb { animation: none !important; }
}
