/* chat.css — floating "Message me" button + small chat panel (360px; full screen on phones). Works in dark and light themes */

.chat { position: fixed; right: 20px; bottom: 20px; z-index: 900; }   /* under the splash (1000), above the page */

/* ---------- Round button ---------- */
.chat__fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 10px 28px var(--yellow-glow), 0 4px 12px var(--black-a25);
  transition: transform 0.2s ease;
}
.chat__fab:hover { transform: translateY(-2px); }
.chat__fab:focus-visible { outline: 3px solid var(--heading); outline-offset: 3px; }
.chat__fab svg { width: 24px; height: 24px; }

/* One tiny bounce, 6 seconds after the page loads (chat.js adds .is-bouncing) */
.chat__fab.is-bouncing { animation: chat-bounce 0.7s ease; }
@keyframes chat-bounce {
  0%, 100% { transform: translateY(0); }
  30%      { transform: translateY(-10px); }
  55%      { transform: translateY(0); }
  75%      { transform: translateY(-4px); }
}

/* Tooltip "Message me" on hover / keyboard focus */
.chat__tip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--heading);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
  opacity: 0;
  translate: 6px -50%;
  pointer-events: none;
  transition: opacity 0.2s ease, translate 0.2s ease;
}
.chat__fab:hover .chat__tip,
.chat__fab:focus-visible .chat__tip { opacity: 1; translate: 0 -50%; }
.chat.is-open .chat__tip { display: none; }

/* ---------- Panel ---------- */
.chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  display: flex;
  flex-direction: column;
  width: 360px;
  max-height: min(640px, calc(100vh - 120px));
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-strong);
  animation: chat-in 0.25s ease;
}
.chat__panel[hidden] { display: none; }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.chat__avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: top; background: var(--yellow); }
.chat__who { flex: 1; min-width: 0; }
.chat__name { font-size: 15px; font-weight: 700; color: var(--heading); }
.chat__status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.chat__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.chat__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--heading);
  transition: background 0.2s ease;
}
.chat__close:hover { background: var(--line); }
.chat__close svg { width: 18px; height: 18px; }

.chat__body { display: flex; flex-direction: column; gap: 14px; padding: 16px; overflow-y: auto; }

/* Message bubbles: from Aya (left) and the visitor's confirmation */
.chat__bubble {
  align-self: flex-start;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--heading);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  animation: chat-in 0.25s ease;
}

/* ---------- Form inside the panel ---------- */
.chat__form { display: flex; flex-direction: column; gap: 10px; }
.chat__form[hidden] { display: none; }

.chat__field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--heading); }
.chat__field em { font-style: normal; color: var(--rose-ink); }
.chat__field small { font-weight: 400; color: var(--muted); }

.chat__field input,
.chat__field textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--heading);
  background: var(--surface-2);
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat__field input:focus,
.chat__field textarea:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-a25); }

/* Honeypot: off screen, invisible to people */
.chat__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.chat__error { padding: 8px 12px; border-radius: 10px; font-size: 13px; color: var(--ink); background: var(--rose); box-shadow: inset 3px 0 0 var(--rose-ink); }

.chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--ink);
  background: var(--yellow);
  transition: opacity 0.2s ease;
}
.chat__send svg { width: 16px; height: 16px; }
.chat__send:disabled { opacity: 0.6; cursor: progress; }

/* ---------- Phones: the panel fills the screen ---------- */
@media (max-width: 560px) {
  .chat { right: 16px; bottom: 16px; }
  .chat__panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
  }
  .chat__body { flex: 1; }
  .chat.is-open .chat__fab { display: none; }   /* the panel's X closes it */
}

@media (prefers-reduced-motion: reduce) {
  .chat__fab.is-bouncing,
  .chat__panel,
  .chat__bubble { animation: none; }
}
