/* ── Ayra — site companion ───────────────────────────────────────────────── */
#ayra-companion {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

#ayra-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 10px;
  border: 1px solid rgba(0, 232, 219, 0.35);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(0, 232, 219, 0.16), rgba(139, 92, 246, 0.12));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #a5f3fc;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 0 18px rgba(0, 232, 219, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

#ayra-fab.ready {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#ayra-fab:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 232, 219, 0.6);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 232, 219, 0.28);
}

#ayra-fab:focus-visible,
#ayra-chat-close:focus-visible,
.ayra-chip:focus-visible,
#ayra-send:focus-visible {
  outline: 2px solid #00e8db;
  outline-offset: 2px;
}

#ayra-fab.hint::after {
  content: '';
  position: absolute;
  top: -7px;
  right: 24px;
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  background: rgba(0, 232, 219, 0.1);
  border-left: 1px solid rgba(0, 232, 219, 0.35);
  border-top: 1px solid rgba(0, 232, 219, 0.35);
}

/* Shown while the panel has auto-minimized with an unanswered question
 * waiting — a quiet signal that the conversation paused, not ended. */
#ayra-fab.ayra-pending::before {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #8b5cf6;
  border: 2px solid #030308;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.7);
  animation: ayraPending 1.8s ease-in-out infinite;
}

@keyframes ayraPending { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.85); } }

/* Avatar wells — hold Ayra's portrait when the asset exists, and fall back to
 * the sparkle mark (which sits underneath) when the <img> is removed on error. */
#ayra-fab-dot,
#ayra-chat-avatar,
.ayra-msg-dot {
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #cffafe, #00e8db 55%, #8b5cf6);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #042f2e;
}

#ayra-fab-dot {
  width: 30px;
  height: 30px;
  font-size: 12px;
  box-shadow: 0 0 12px rgba(0, 232, 219, 0.6);
}

#ayra-chat-avatar {
  width: 32px;
  height: 32px;
  font-size: 13px;
  box-shadow: 0 0 10px rgba(0, 232, 219, 0.5);
}

.ayra-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#ayra-fab-label { white-space: nowrap; }

#ayra-guide {
  position: fixed;
  right: 20px;
  bottom: 86px;
  z-index: 2999;
  max-width: 250px;
  background: linear-gradient(135deg, rgba(0, 232, 219, 0.14), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(0, 232, 219, 0.3);
  border-radius: 14px;
  padding: 10px 14px;
  color: #a5f3fc;
  font-size: 12px;
  line-height: 1.5;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}

#ayra-guide.show { opacity: 1; transform: translateY(0); }

#ayra-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 3001;
  width: min(360px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 90px));
  display: flex;
  flex-direction: column;
  background: rgba(10, 8, 16, 0.94);
  border: 1px solid rgba(0, 232, 219, 0.22);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65), 0 0 30px rgba(0, 232, 219, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  /* visibility (not just opacity) keeps the closed dialog out of the
   * accessibility tree and out of the tab order. */
  visibility: hidden;
  pointer-events: none;
}

#ayra-chat.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
}

#ayra-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(135deg, rgba(0, 232, 219, 0.1), rgba(139, 92, 246, 0.06));
}

#ayra-chat-id { min-width: 0; }
#ayra-chat-title { font-size: 13px; font-weight: 700; color: #a5f3fc; }
#ayra-chat-sub { font-size: 10px; color: #94a3b8; }

#ayra-chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

#ayra-chat-close:hover { color: #fecaca; background: rgba(248, 113, 113, 0.12); }

#ayra-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

#ayra-msgs::-webkit-scrollbar { width: 5px; }
#ayra-msgs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 3px; }

.ayra-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
}

.ayra-msg.ayra-user { flex-direction: row-reverse; }

.ayra-msg-dot {
  width: 22px;
  height: 22px;
  font-size: 10px;
  box-shadow: none;
}

.ayra-msg-text {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  max-width: 78%;
  overflow-wrap: break-word;
}

.ayra-msg.ayra-user .ayra-msg-text {
  background: linear-gradient(135deg, rgba(0, 232, 219, 0.22), rgba(139, 92, 246, 0.16));
  border-color: rgba(0, 232, 219, 0.3);
  color: #a5f3fc;
}

.ayra-typing { display: inline-flex; gap: 4px; padding: 3px 2px; }
.ayra-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #00e8db;
  animation: ayraTyping 1.2s ease-in-out infinite;
}
.ayra-typing span:nth-child(2) { animation-delay: 0.15s; }
.ayra-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ayraTyping { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

#ayra-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 14px 10px;
}

.ayra-chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(0, 232, 219, 0.3);
  background: rgba(0, 232, 219, 0.08);
  color: #a5f3fc;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  font-family: inherit;
}

.ayra-chip:hover {
  background: rgba(0, 232, 219, 0.18);
  border-color: rgba(0, 232, 219, 0.55);
  transform: translateY(-1px);
}

#ayra-input-row {
  display: none;
  padding: 0 14px 14px;
  gap: 8px;
}

#ayra-input-row.show { display: flex; }

#ayra-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#ayra-input::placeholder { color: #64748b; }
#ayra-input:focus { border-color: rgba(0, 232, 219, 0.55); }

#ayra-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(0, 232, 219, 0.4);
  background: linear-gradient(135deg, #00e8db, #8b5cf6);
  color: #042f2e;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
  font-weight: 700;
  line-height: 1;
}

#ayra-send:hover { opacity: 0.88; transform: scale(1.05); }

@media (max-width: 480px) {
  #ayra-fab { right: 14px; bottom: 14px; }
  #ayra-guide { right: 14px; bottom: 78px; max-width: calc(100vw - 28px); }
  #ayra-chat {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    /* A chat panel should never dominate the page behind it. Capped so the
     * majority of the screen stays visible while it's open. */
    height: min(38vh, 340px);
    /* 100vh is measured against the tallest the viewport can be, ignoring
     * the browser's address bar — on iOS Safari that makes this box taller
     * than what's actually visible. svh is pinned to the visible area, so
     * this line (where supported) replaces the vh-based sizing above. */
    height: min(38svh, 340px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #ayra-fab, #ayra-chat, #ayra-guide { transition: none; }
  .ayra-typing span { animation: none; }
  #ayra-fab.ayra-pending::before { animation: none; }
}
