/* ==========================================================================
   CHATBOT CHARACTER — the portrait from the logo, brought to life
   --------------------------------------------------------------------------
   • Idle: floats gently, the rose-gold ring slowly turns, sparkles twinkle,
     and she blinks every few seconds (eyelids are tinted with skin tones
     sampled from the logo portrait: #b55e35 and #7a391b).
   • Talking: while she "types", her face bobs and a glow pulses.
   Colours come from the same logo tokens defined in style.css.
   ========================================================================== */

.bot { --bot-size: 66px; position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 100; font-family: var(--sans); }

/* ---------- The face (used in the launcher and the chat header) ---------- */
.face { position: relative; width: var(--s, 60px); height: var(--s, 60px); border-radius: 50%; flex: none; }
.face img { width: 100%; height: 100%; border-radius: 50%; position: relative; z-index: 1; }
.face::before { /* rotating rose-gold ring */
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  background: conic-gradient(from 0deg, #fac1a4, #d47e5d, #92293d, #ee9d75, #fac1a4);
  animation: ring calc(7s / var(--motion)) linear infinite;
}
@keyframes ring { to { transform: rotate(360deg); } }
.lid { /* eyelid that closes for a blink */
  position: absolute; z-index: 2; border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  transform: scaleY(0); transform-origin: 50% 0%;
  animation: blink 5.2s ease-in-out infinite;
}
.lid::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: 0; height: 16%; border-radius: 50%; background: rgba(30, 6, 4, .75); }
.lid.l { left: 31.2%; top: 44.1%; width: 13.4%; height: 6.6%; background: linear-gradient(180deg, #b55e35, #9a523a); }
.lid.r { left: 56.2%; top: 43.2%; width: 13.4%; height: 6.6%; background: linear-gradient(180deg, #a3502b, #7a391b); }
@keyframes blink { 0%, 91%, 100% { transform: scaleY(0); } 93.5% { transform: scaleY(1); } 96% { transform: scaleY(0); } }

.face.talking img { animation: talk calc(.42s * var(--motion)) ease-in-out infinite alternate; }
.face.talking::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%; z-index: 0;
  box-shadow: 0 0 0 0 rgba(238, 157, 117, .55); animation: pulse 1.1s ease-out infinite;
}
@keyframes talk { from { transform: translateY(0) rotate(-1.5deg) scale(1); } to { transform: translateY(-1.5px) rotate(1.5deg) scale(1.035); } }
@keyframes pulse { to { box-shadow: 0 0 0 12px rgba(238, 157, 117, 0); } }

/* ---------- Launcher ---------- */
.bot-launch {
  position: relative; width: var(--bot-size); height: var(--bot-size); border-radius: 50%;
  display: grid; place-items: center;
  background: var(--wine-950); box-shadow: 0 16px 34px -10px rgba(30, 2, 17, .7);
  animation: float calc(3.6s / var(--motion)) ease-in-out infinite;
}
.bot-launch .face { --s: calc(var(--bot-size) - 10px); }
.bot-launch .online { position: absolute; right: 3px; bottom: 5px; z-index: 3; width: 13px; height: 13px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 2.5px var(--wine-950); }
.bot-launch .tw { position: absolute; z-index: 3; color: var(--rose-gold-hi); width: 12px; height: 12px; animation: twinkle 2.4s ease-in-out infinite; }
.bot-launch .tw:nth-of-type(1) { top: -6px; left: 2px; }
.bot-launch .tw:nth-of-type(2) { top: 6px; right: -9px; width: 9px; height: 9px; animation-delay: .8s; }
.bot-launch .tw:nth-of-type(3) { bottom: -4px; left: -7px; width: 8px; height: 8px; animation-delay: 1.5s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
.bot.open .bot-launch { display: none; }
.bot.away:not(.open) .bot-launch { opacity: 0; transform: scale(.6); pointer-events: none; transition: opacity .25s ease, transform .25s ease; }

/* ---------- Greeting bubble ---------- */
.bot-hello {
  position: absolute; right: 4px; bottom: calc(var(--bot-size) + 14px); width: max-content; max-width: min(78vw, 260px);
  padding: 12px 34px 12px 14px; border-radius: 18px 18px 6px 18px;
  background: var(--pearl); color: var(--ink); font-size: .95rem; line-height: 1.4;
  box-shadow: 0 18px 40px -16px rgba(30, 2, 17, .55), 0 0 0 1px var(--blush-line);
  animation: helloIn calc(.5s * var(--motion)) cubic-bezier(.2, .9, .3, 1.2) both;
  cursor: pointer;
}
.bot-hello[hidden] { display: none; }
.bot-hello .wave { display: inline-block; transform-origin: 70% 70%; animation: wave 1.6s ease-in-out 2; }
.bot-hello-x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-soft); }
.bot-hello-x svg { width: 14px; height: 14px; }
@keyframes helloIn { from { opacity: 0; transform: translateY(8px) scale(.92); } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 20%, 60% { transform: rotate(16deg); } 40%, 80% { transform: rotate(-8deg); } }

/* ---------- Chat panel ---------- */
.bot-panel {
  position: fixed; right: 0; bottom: 0; left: 0; height: min(88svh, 720px);
  display: flex; flex-direction: column;
  background: var(--pearl); color: var(--ink);
  border-radius: 24px 24px 0 0; overflow: hidden;
  box-shadow: 0 -20px 60px -20px rgba(30, 2, 17, .6);
  animation: panelIn calc(.42s * var(--motion)) cubic-bezier(.2, .8, .2, 1) both;
}
.bot-panel[hidden] { display: none; }
@keyframes panelIn { from { opacity: 0; transform: translateY(24px); } }
@media (min-width: 600px) {
  .bot-panel { left: auto; right: 20px; bottom: 20px; width: 384px; height: min(640px, calc(100vh - 40px)); border-radius: 24px; box-shadow: 0 30px 80px -24px rgba(30, 2, 17, .65), 0 0 0 1px var(--blush-line); }
}
.bot-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 18px;
  color: var(--cream);
  background: radial-gradient(120% 140% at 0% 0%, var(--rose-wine), var(--wine-950) 70%);
}
.bot-head .face { --s: 46px; }
.bot-title { flex: 1; min-width: 0; line-height: 1.25; }
.bot-title b { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.15rem; }
.bot-title span { font-size: .8rem; color: var(--cream-soft); display: inline-flex; align-items: center; gap: 6px; }
.bot-title span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; }
.bot-x { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--cream); background: rgba(253, 238, 230, .1); }
.bot-x svg { width: 18px; height: 18px; }

.bot-log { flex: 1; overflow-y: auto; padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; overscroll-behavior: contain; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 92%; animation: msgIn calc(.32s * var(--motion)) ease both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
.msg .mini { width: 28px; height: 28px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1.5px var(--rose-gold); }
.bubble { padding: 10px 14px; border-radius: 18px; font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg.bot-msg .bubble { background: #fff; border: 1px solid var(--blush-line); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: var(--wine-700); color: var(--cream); border-bottom-right-radius: 6px; }
.bubble b { font-weight: 700; }
.bot-photo { display: block; width: 100%; max-width: 240px; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 20%; border-radius: 90px 90px 12px 12px / 70px 70px 12px 12px; margin-bottom: 8px; }
.bubble ul { list-style: none; margin: 6px 0 2px; display: grid; gap: 4px; }
.bubble li { display: flex; gap: 8px; }
.bubble li::before { content: ""; width: 6px; height: 6px; margin-top: 8px; flex: none; transform: rotate(45deg); background: var(--rose-gold-deep); }
.bubble p + p, .bubble p + ul, .bubble ul + p { margin-top: 6px; }
.bubble .bot-btn { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: .9rem; text-decoration: none; }
.bubble .bot-btn svg { width: 16px; height: 16px; }
.bubble .bot-btn.wa { background: #25d366; color: #062612; }
.bubble .bot-btn.rose { background: var(--foil); color: var(--ink); }
.combo-mini { display: grid; gap: 6px; margin-top: 8px; }
.combo-mini div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--blush); }
.combo-mini b { font-family: var(--serif); font-weight: 400; font-size: 1.02rem; }
.combo-mini small { display: block; font-family: var(--sans); font-size: .78rem; color: var(--ink-soft); }
.combo-mini span { color: var(--rose-ink); font-weight: 700; white-space: nowrap; }

.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--rose-gold-deep); animation: dot 1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.bot-chips { display: flex; gap: 8px; padding: 8px 14px 4px; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.bot-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 14px; border-radius: 999px; font-size: .9rem; font-weight: 700; color: var(--rose-ink); background: #fff; border: 1.5px solid var(--blush-line); transition: background-color .2s ease, border-color .2s ease; }
.chip:hover { border-color: var(--rose-gold); background: var(--blush); }
.chip.primary { background: var(--foil); color: var(--ink); border-color: transparent; }

.bot-input { display: flex; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--blush-line); background: var(--pearl); }
.bot-input input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--blush-line); background: #fff; outline: none; color: var(--ink); transition: border-color .2s ease, box-shadow .3s ease; }
.bot-input input:focus { border-color: var(--rose-gold); box-shadow: 0 0 0 4px rgba(238, 157, 117, .18); }
.bot-input button { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--foil); color: var(--ink); flex: none; }
.bot-input button svg { width: 20px; height: 20px; }
.bot-note { font-size: .72rem; color: var(--ink-soft); text-align: center; padding: 0 12px 6px; background: var(--pearl); }

@media (prefers-reduced-motion: reduce) {
  .lid { display: none; }
}
