/* ==========================================================================
   Beexy — EXYVRON's 3D bee assistant (floating contact chatbox)
   Every rule is scoped to .beexy; nothing here affects the rest of the site.
   ========================================================================== */
.beexy {
  --beexy-size: 172px;                 /* bee canvas (the bee itself is ~70% of this) */
  --beexy-right: clamp(10px, 1.6vw, 26px);
  --beexy-bottom: clamp(8px, 1.6vw, 22px);
  --beexy-brand: var(--brand, #800020);
  --beexy-wine: var(--wine, #4a0616);
  --beexy-cream: var(--cream, #f5f0e8);
  --beexy-ink: var(--ink, #171717);
  --beexy-ink-2: var(--ink-2, #626262);
  --beexy-font: var(--sans, "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
  --beexy-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: fixed;
  right: var(--beexy-right);
  bottom: var(--beexy-bottom);
  z-index: 440;                         /* above page content, below header (500), mobile menu (450) and page transitions */
  width: var(--beexy-size);
  height: var(--beexy-size);
  pointer-events: none;                 /* only the bee and the open chatbox catch the pointer */
  font-family: var(--beexy-font);
  color: var(--beexy-ink);
  -webkit-tap-highlight-color: transparent;
}
.beexy *,
.beexy *::before,
.beexy *::after { box-sizing: border-box; }

/* ---------- the bee ---------- */
.beexy__bee {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translate3d(0, 18px, 0) scale(0.92);
  transform-origin: 60% 60%;
  transition: opacity 0.9s var(--beexy-ease), transform 0.9s var(--beexy-ease);
}
.beexy.is-ready .beexy__bee { opacity: 1; transform: none; }
.beexy.is-ready.is-open .beexy__bee { transform: translate3d(6px, 6px, 0) scale(0.9); }

.beexy__canvas,
.beexy__still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
}
.beexy__canvas { opacity: 0; transition: opacity 0.6s ease; }
.beexy__still { opacity: 1; transition: opacity 0.6s ease; object-fit: contain; }
.beexy.is-live .beexy__canvas { opacity: 1; }
.beexy.is-live .beexy__still { opacity: 0; }
/* without WebGL the still rendering keeps a gentle hover */
.beexy.is-still .beexy__still { animation: beexy-float 3.8s ease-in-out infinite; }
@keyframes beexy-float {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(-2px, -6px, 0) rotate(-1.2deg); }
}

/* soft contact shadow: sells the hover without any background container */
.beexy__shadow {
  position: absolute;
  left: 30%;
  width: 46%;
  bottom: 9%;
  height: 7%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 20, 10, 0.20), rgba(40, 20, 10, 0));
  filter: blur(2px);
  pointer-events: none;
}

/* the clickable trigger is the bee itself: an invisible oval over its body */
.beexy__hit {
  position: absolute;
  left: 9%;
  right: 12%;
  top: 22%;
  bottom: 20%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 48%;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
.beexy__hit:focus { outline: none; }
.beexy__hit:focus-visible {
  outline: 2px solid var(--beexy-brand);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(128, 0, 32, 0.12);
}

/* name label */
.beexy__name {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  padding: 2px 9px 3px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--beexy-brand);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 1px 2px rgba(23, 23, 23, 0.06), inset 0 0 0 1px rgba(128, 0, 32, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}
.beexy.is-open .beexy__name { opacity: 0; }

/* hover speech bubble */
.beexy__tip {
  position: absolute;
  right: 84%;
  top: 22%;
  padding: 8px 13px;
  border-radius: 14px 14px 4px 14px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  white-space: nowrap;
  color: var(--beexy-ink);
  background: #fff;
  box-shadow: 0 1px 2px rgba(23, 23, 23, 0.05), 0 10px 26px -10px rgba(74, 6, 22, 0.28), inset 0 0 0 1px rgba(128, 0, 32, 0.10);
  opacity: 0;
  transform: translate3d(8px, 4px, 0) scale(0.94);
  transform-origin: 100% 100%;
  transition: opacity 0.28s ease, transform 0.38s var(--beexy-ease);
  pointer-events: none;
}
.beexy__tip::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: 7px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 0 0 3px 0;
  transform: rotate(-45deg);
  box-shadow: 1px 1px 0 rgba(128, 0, 32, 0.08);
}
.beexy.is-hover:not(.is-open) .beexy__tip { opacity: 1; transform: none; }

/* ---------- chatbox ---------- */
.beexy__panel {
  position: absolute;
  right: 4px;
  bottom: calc(100% - 14px);
  width: min(328px, calc(100vw - 2 * var(--beexy-right)));
  max-height: calc(100vh - var(--beexy-size) - var(--beexy-bottom) - 20px);
  max-height: calc(100dvh - var(--beexy-size) - var(--beexy-bottom) - 20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(23, 23, 23, 0.05), 0 22px 48px -18px rgba(74, 6, 22, 0.32), 0 0 0 1px rgba(128, 0, 32, 0.07);
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 16px, 0) scale(0.95);
  transform-origin: 88% 100%;
  transition: opacity 0.32s ease, transform 0.46s var(--beexy-ease), visibility 0s linear 0.46s;
  pointer-events: none;
}
.beexy.is-open .beexy__panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.36s ease, transform 0.52s var(--beexy-ease), visibility 0s;
  pointer-events: auto;
}
.beexy__panel:focus { outline: none; }
.beexy__panel:focus-visible { outline: 2px solid var(--beexy-brand); outline-offset: 2px; }

.beexy__head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 12px 13px 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--beexy-brand) 0%, var(--beexy-wine) 100%);
  flex: none;
}
.beexy__avatar {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 35% 30%, #fffaf1, var(--beexy-cream) 70%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.28);
}
.beexy__avatar img { width: 100%; height: 100%; display: block; object-fit: cover; transform: scale(1.18); }
.beexy__avatar::after {                /* online dot */
  content: "";
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3fb37f;
  box-shadow: 0 0 0 2px var(--beexy-brand);
}
.beexy__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.beexy__who strong { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.beexy__who small { font-size: 12px; opacity: 0.82; }
.beexy__close {
  margin: 0 0 0 auto;
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.10);
  cursor: pointer;
  transition: background-color 0.22s ease, transform 0.3s var(--beexy-ease);
}
.beexy__close svg { width: 18px; height: 18px; }
.beexy__close:hover { background: rgba(255, 255, 255, 0.2); transform: rotate(90deg); }
.beexy__close:focus { outline: none; }
.beexy__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.beexy__body {
  padding: 14px 14px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(#fff, #fdfbf8);
}
.beexy__msg {
  position: relative;
  margin: 0 0 12px 0;
  padding: 11px 13px 12px;
  border-radius: 4px 16px 16px 16px;
  background: var(--beexy-cream);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--beexy-ink);
}
.beexy__msg p { margin: 0; }
.beexy__msg p + p { margin-top: 6px; color: #3d3a37; }
.beexy__msg p:first-child { font-weight: 500; }

.beexy__opts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.beexy__opts li { margin: 0; padding: 0; }
.beexy-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 8px 12px 8px 8px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--beexy-ink);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line, #e8e5e2);
  transition: box-shadow 0.25s ease, background-color 0.25s ease, transform 0.35s var(--beexy-ease);
}
.beexy-opt__ic {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--beexy-brand);
  background: rgba(128, 0, 32, 0.06);
  transition: background-color 0.25s ease, color 0.25s ease;
}
.beexy-opt__ic svg { width: 20px; height: 20px; display: block; }
.beexy-opt__txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.beexy-opt__txt strong { font-size: 14px; font-weight: 600; }
.beexy-opt__txt small { font-size: 12px; color: var(--beexy-ink-2); }
.beexy-opt__go {
  width: 16px;
  height: 16px;
  margin-left: auto;
  flex: none;
  color: var(--beexy-brand);
  opacity: 0.45;
  transform: translateX(-3px);
  transition: opacity 0.25s ease, transform 0.35s var(--beexy-ease);
}
a.beexy-opt:hover {
  background: #fffdfa;
  box-shadow: inset 0 0 0 1px rgba(128, 0, 32, 0.28), 0 8px 20px -14px rgba(74, 6, 22, 0.45);
  transform: translateY(-1px);
}
a.beexy-opt:hover .beexy-opt__ic { background: var(--beexy-brand); color: #fff; }
a.beexy-opt:hover .beexy-opt__go { opacity: 1; transform: none; }
a.beexy-opt:focus { outline: none; }
a.beexy-opt:focus-visible { outline: 2px solid var(--beexy-brand); outline-offset: 2px; }
.beexy-opt.is-pending { opacity: 0.55; cursor: default; }

/* staggered entrance of the conversation */
.beexy__msg,
.beexy__opts li {
  opacity: 0;
  transform: translate3d(0, 8px, 0);
  transition: opacity 0.3s ease, transform 0.4s var(--beexy-ease);
}
.beexy.is-open .beexy__msg { opacity: 1; transform: none; transition-delay: 0.12s; }
.beexy.is-open .beexy__opts li { opacity: 1; transform: none; transition-delay: calc(0.2s + var(--i) * 0.05s); }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .beexy { --beexy-size: 148px; }
}
@media (max-width: 640px) {
  .beexy { --beexy-size: 124px; --beexy-right: 8px; --beexy-bottom: 8px; }
  .beexy__panel { right: 4px; width: calc(100vw - 2 * var(--beexy-right) - 4px); max-width: 340px; }
  .beexy__tip { font-size: 12px; padding: 7px 11px; }
  .beexy__name { font-size: 10px; }
}
@media (max-width: 380px) {
  .beexy { --beexy-size: 112px; }
  .beexy-opt { min-height: 48px; }
}
/* short viewports (landscape phones): two-column options so all four stay in view */
@media (max-height: 560px) {
  .beexy { --beexy-size: 112px; }
  .beexy__head { padding-top: 9px; padding-bottom: 9px; }
  .beexy__msg { font-size: 12.5px; line-height: 1.42; padding: 8px 11px; margin-bottom: 9px; }
  .beexy__opts { grid-template-columns: 1fr 1fr; gap: 6px; }
  .beexy-opt { min-height: 46px; padding: 6px 8px 6px 6px; gap: 8px; }
  .beexy-opt__ic { width: 32px; height: 32px; }
  .beexy-opt__go { display: none; }
  .beexy__body { padding: 10px 12px 12px; }
  /* the chatbox sits beside Beexy so it can use the full height */
  .beexy__panel {
    right: calc(100% - 18px);
    bottom: 0;
    width: min(400px, calc(100vw - var(--beexy-size) - 2 * var(--beexy-right)));
    max-height: calc(100vh - 2 * var(--beexy-bottom));
    max-height: calc(100dvh - 2 * var(--beexy-bottom));
    transform-origin: 100% 90%;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .beexy__bee,
  .beexy__panel,
  .beexy.is-open .beexy__panel,
  .beexy__tip,
  .beexy__msg,
  .beexy__opts li,
  .beexy-opt,
  .beexy__close { transition-duration: 0.01s !important; transition-delay: 0s !important; }
  .beexy.is-still .beexy__still { animation: none; }
  .beexy.is-ready.is-open .beexy__bee { transform: none; }
}
.beexy.is-reduced.is-still .beexy__still { animation: none; }

@media print { .beexy { display: none !important; } }
