/* ============================================================
   BELVION assistant — floating chat widget.
   Same instrument language as the site: sharp corners, mono type,
   one cream accent, theme variables from style.css.
   ============================================================ */

/* ---------- launcher ---------- */
#bv-chat-launcher {
  position: fixed; z-index: 120;
  right: clamp(16px, 3vw, 32px); bottom: clamp(16px, 3vw, 32px);
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  background: var(--cream); color: var(--ink);
  border: 1px solid var(--cream);
  font-family: var(--mono);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  transition: background-color 0.25s, color 0.25s, opacity 0.25s, transform 0.25s;
}
#bv-chat-launcher:hover, #bv-chat-launcher:focus-visible {
  background: transparent; color: var(--cream);
}
#bv-chat-launcher .bv-dot {
  width: 6px; height: 6px; background: currentColor; display: block;
  animation: bv-pulse 2.4s ease-in-out infinite;
}
@keyframes bv-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
#bv-chat-launcher[hidden] { display: none; }

/* ---------- panel ---------- */
#bv-chat {
  position: fixed; z-index: 121;
  right: clamp(16px, 3vw, 32px); bottom: clamp(16px, 3vw, 32px);
  width: min(384px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 96px));
  display: flex; flex-direction: column;
  background: var(--ink-2);
  border: 1px solid var(--line-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
/* Open state is the BASE state — always fully opaque. The entry animates the
   slide only, so a frozen/throttled animation clock can never leave the panel
   invisible; the worst case is a 12px offset nobody will notice. */
#bv-chat.is-open { animation: bv-chat-in 0.28s ease; }
@keyframes bv-chat-in {
  from { transform: translateY(12px); }
  to   { transform: none; }
}
#bv-chat[hidden] { display: none; }

.bv-chat-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.bv-chat-head h2 {
  font-family: var(--mono);
  font-size: 10px; font-weight: 400;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--cream);
}
.bv-chat-head p {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.06em; line-height: 1.6;
  color: var(--faint); margin-top: 6px;
}
.bv-chat-close {
  margin-left: auto; flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--dim); font-size: 13px; line-height: 1;
  transition: color 0.25s, border-color 0.25s;
}
.bv-chat-close:hover, .bv-chat-close:focus-visible { color: var(--cream); border-color: var(--cream); }

/* ---------- log ---------- */
.bv-chat-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin;
}
.bv-msg {
  font-size: 13.5px; line-height: 1.65;
  max-width: 92%;
  white-space: pre-wrap; word-wrap: break-word;
}
.bv-msg.bot {
  color: var(--body);
  border-left: 1px solid var(--cream);
  padding-left: 12px;
}
.bv-msg.user {
  align-self: flex-end;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 12px; letter-spacing: 0.02em;
  border: 1px solid var(--line);
  background: var(--ink-3);
  padding: 9px 12px;
}
.bv-msg.err { color: var(--cream); font-family: var(--mono); font-size: 11.5px; }

.bv-typing { display: flex; gap: 5px; padding-left: 13px; }
.bv-typing i {
  width: 5px; height: 5px; background: var(--dim); display: block;
  animation: bv-blink 1.2s ease-in-out infinite;
}
.bv-typing i:nth-child(2) { animation-delay: 0.18s; }
.bv-typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes bv-blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

/* ---------- suggested questions ---------- */
.bv-chat-sugg { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.bv-chat-sugg button {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  transition: color 0.25s, border-color 0.25s;
}
.bv-chat-sugg button:hover, .bv-chat-sugg button:focus-visible { color: var(--cream); border-color: var(--cream); }
.bv-chat-sugg[hidden] { display: none; }

/* ---------- composer ---------- */
.bv-chat-form {
  display: flex; align-items: stretch; gap: 0;
  border-top: 1px solid var(--line);
}
.bv-chat-form textarea {
  flex: 1;
  background: transparent;
  border: 0; border-radius: 0;
  color: var(--body);
  font-family: var(--mono);
  font-size: 12.5px; letter-spacing: 0.02em; line-height: 1.5;
  padding: 14px 14px;
  /* fixed two-line box that scrolls internally — questions are short (400 char cap) */
  resize: none; height: 58px; overflow-y: auto;
}
.bv-chat-form textarea:focus { outline: none; }
.bv-chat-form textarea::placeholder { color: var(--faint); }
.bv-chat-send {
  flex: none; padding: 0 18px;
  background: var(--cream); color: var(--ink);
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  transition: opacity 0.25s;
}
.bv-chat-send:disabled { opacity: 0.4; cursor: default; }

.bv-chat-note {
  padding: 9px 16px 12px;
  font-family: var(--mono);
  font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint);
  border-top: 1px solid var(--line);
}

/* ---------- mobile: bottom sheet ---------- */
@media (max-width: 560px) {
  #bv-chat {
    right: 0; bottom: 0; left: 0;
    width: 100%; height: min(84vh, 620px);
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  #bv-chat-launcher { right: 16px; bottom: 16px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #bv-chat.is-open { animation: none; }
  #bv-chat-launcher .bv-dot, .bv-typing i { animation: none; }
}
