/* ==========================================================================
   Made by a Mexican — Lead-Bot widget
   Self-contained. Every brand var carries a literal fallback because the home
   page does NOT load tokens.css. Namespaced under #mbm-leadbot / .mbm-leadbot.
   Dark cinematic editorial: obsidian/surface, gold accents, bone text (never
   pure #fff), hairline borders, subtle gold glow. Mobile-first.
   Fonts (Archivo Black + Inter) are already loaded by the pages.
   ========================================================================== */

/* ----- Root / floating anchor -------------------------------------------- */
#mbm-leadbot {
  position: fixed;
  bottom: 16px;
  z-index: 200;
}
#mbm-leadbot[data-position="left"]  { left: 16px; }
#mbm-leadbot[data-position="right"] { right: 16px; }

/* Shared typography for both the floating root (#mbm-leadbot) and the inline
   mount (.mbm-leadbot--inline is set by our JS on the pitch-page host div). */
#mbm-leadbot,
.mbm-leadbot--inline {
  font-family: var(--body, 'Inter', system-ui, sans-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--bone, #F4ECDC);
}
#mbm-leadbot *,
#mbm-leadbot *::before,
#mbm-leadbot *::after,
.mbm-leadbot--inline *,
.mbm-leadbot--inline *::before,
.mbm-leadbot--inline *::after { box-sizing: border-box; }

/* noscript fallback (rendered when JS is off) */
.mbm-leadbot__noscript {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--surface, #1c1710);
  border: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  color: var(--gold, #C8A24B);
  font-family: var(--display, 'Archivo Black', Inter, sans-serif);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
}

/* ----- Pill button -------------------------------------------------------- */
.mbm-leadbot__pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  border-radius: 999px;
  background:
    linear-gradient(180deg, var(--surface-2, #241d14) 0%, var(--surface, #1c1710) 100%);
  color: var(--bone, #F4ECDC);
  font-family: var(--display, 'Archivo Black', Inter, sans-serif);
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow:
    0 10px 30px -12px rgba(0, 0, 0, 0.8),
    0 0 22px -6px rgba(200, 162, 75, 0.35);
  transition:
    transform 0.25s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    box-shadow 0.25s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    border-color 0.25s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1));
}
.mbm-leadbot__pill:hover {
  transform: translateY(-2px);
  border-color: var(--gold, #C8A24B);
  box-shadow:
    0 14px 36px -12px rgba(0, 0, 0, 0.85),
    0 0 30px -4px rgba(200, 162, 75, 0.55);
}
.mbm-leadbot__pill:focus-visible {
  outline: 2px solid var(--gold-hi, #E0B84C);
  outline-offset: 3px;
}
.mbm-leadbot__pill-arrow {
  color: var(--gold, #C8A24B);
  font-family: var(--body, 'Inter', system-ui, sans-serif);
  transition: transform 0.25s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1));
}
.mbm-leadbot__pill:hover .mbm-leadbot__pill-arrow { transform: translateX(3px); }

/* When open, hide the pill (floating mode only) */
#mbm-leadbot.mbm-leadbot--open .mbm-leadbot__pill { display: none; }

/* ----- Panel -------------------------------------------------------------- */
.mbm-leadbot__panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, 78vh);
  max-height: min(560px, 78dvh);
  overflow: hidden;
  border: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  border-radius: var(--radius, 14px);
  background:
    linear-gradient(180deg, var(--surface, #1c1710) 0%, var(--obsidian, #15110C) 100%);
  box-shadow:
    0 26px 70px -30px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 0 40px -18px rgba(200, 162, 75, 0.28);
}

/* Floating: hidden until open, with a small slide-up (panel = widget's own el) */
#mbm-leadbot:not(.mbm-leadbot--inline) .mbm-leadbot__panel {
  position: absolute;
  bottom: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.22s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    transform 0.22s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    visibility 0s linear 0.22s;
}
#mbm-leadbot[data-position="left"]  .mbm-leadbot__panel { left: 0; }
#mbm-leadbot[data-position="right"] .mbm-leadbot__panel { right: 0; }

#mbm-leadbot.mbm-leadbot--open .mbm-leadbot__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition:
    opacity 0.22s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    transform 0.22s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    visibility 0s linear 0s;
}

/* ----- Header ------------------------------------------------------------- */
.mbm-leadbot__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  background: rgba(0, 0, 0, 0.18);
}
.mbm-leadbot__head-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mbm-leadbot__kicker {
  font-family: var(--body, 'Inter', system-ui, sans-serif);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--jade, #0E8C8B);
}
.mbm-leadbot__title {
  font-family: var(--display, 'Archivo Black', Inter, sans-serif);
  font-size: 16px;
  line-height: 1.1;
  color: var(--bone, #F4ECDC);
}
.mbm-leadbot__close {
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  border-radius: 8px;
  background: transparent;
  color: var(--bone, #F4ECDC);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition:
    color 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    border-color 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    background 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1));
}
.mbm-leadbot__close:hover {
  color: var(--gold-hi, #E0B84C);
  border-color: var(--gold, #C8A24B);
  background: var(--surface-2, #241d14);
}
.mbm-leadbot__close:focus-visible {
  outline: 2px solid var(--gold-hi, #E0B84C);
  outline-offset: 2px;
}

/* ----- Message log -------------------------------------------------------- */
.mbm-leadbot__log {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline, rgba(200, 162, 75, .22)) transparent;
}
.mbm-leadbot__log::-webkit-scrollbar { width: 8px; }
.mbm-leadbot__log::-webkit-scrollbar-thumb {
  background: var(--hairline, rgba(200, 162, 75, .22));
  border-radius: 8px;
}

/* ----- Message bubbles ---------------------------------------------------- */
.mbm-leadbot__msg { display: flex; flex-direction: column; max-width: 86%; }
.mbm-leadbot__msg--user { align-self: flex-end; align-items: flex-end; }
.mbm-leadbot__msg--assistant,
.mbm-leadbot__msg--system,
.mbm-leadbot__msg--martin { align-self: flex-start; align-items: flex-start; }

.mbm-leadbot__bubble {
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--bone, #F4ECDC);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* assistant (the bot) — surface with hairline */
.mbm-leadbot__msg--assistant .mbm-leadbot__bubble {
  background: var(--surface-2, #241d14);
  border: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  border-bottom-left-radius: 4px;
}

/* user — gold-tinted, warm */
.mbm-leadbot__msg--user .mbm-leadbot__bubble {
  background: rgba(200, 162, 75, 0.14);
  border: 1px solid rgba(200, 162, 75, 0.38);
  color: var(--bone, #F4ECDC);
  border-bottom-right-radius: 4px;
}

/* Martin — distinct jade-flagged treatment + visible label */
.mbm-leadbot__who {
  font-family: var(--body, 'Inter', system-ui, sans-serif);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--jade, #0E8C8B);
  margin-bottom: 4px;
  padding-left: 2px;
}
.mbm-leadbot__msg--martin .mbm-leadbot__bubble {
  background: rgba(14, 140, 139, 0.16);
  border: 1px solid rgba(14, 140, 139, 0.45);
  border-bottom-left-radius: 4px;
}

/* system (degraded) — muted terracotta */
.mbm-leadbot__bubble--system {
  background: rgba(181, 81, 46, 0.12);
  border: 1px solid rgba(181, 81, 46, 0.42);
  color: var(--bone, #F4ECDC);
  font-size: 13.5px;
}
.mbm-leadbot__mailto {
  color: var(--gold, #C8A24B);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.mbm-leadbot__mailto:hover { color: var(--gold-hi, #E0B84C); }

/* ----- Thinking / typing dots -------------------------------------------- */
.mbm-leadbot__dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 13px 15px;
}
.mbm-leadbot__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold, #C8A24B);
  opacity: 0.4;
  animation: mbm-leadbot-blink 1.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)) infinite;
}
.mbm-leadbot__dot:nth-child(2) { animation-delay: 0.2s; }
.mbm-leadbot__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes mbm-leadbot-blink {
  0%, 60%, 100% { opacity: 0.35; }
  30%           { opacity: 1; }
}

/* ----- Suggested-question chips ------------------------------------------ */
.mbm-leadbot__chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  margin-top: 2px;
}
.mbm-leadbot__chip {
  max-width: 100%;
  text-align: left;
  padding: 9px 13px;
  border: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  border-radius: 999px;
  background: transparent;
  color: var(--gold, #C8A24B);
  font-family: var(--body, 'Inter', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    background 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    color 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1));
}
.mbm-leadbot__chip:hover {
  border-color: var(--gold, #C8A24B);
  background: rgba(200, 162, 75, 0.10);
  color: var(--gold-hi, #E0B84C);
}
.mbm-leadbot__chip:focus-visible {
  outline: 2px solid var(--gold-hi, #E0B84C);
  outline-offset: 2px;
}

/* ----- Capture confirmation banner --------------------------------------- */
.mbm-leadbot__banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(200, 162, 75, 0.4);
  border-radius: 11px;
  background: rgba(200, 162, 75, 0.10);
}
.mbm-leadbot__banner-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: var(--gold, #C8A24B);
}
.mbm-leadbot__banner-txt {
  font-family: var(--body, 'Inter', system-ui, sans-serif);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--bone, #F4ECDC);
}

/* ----- Composer form ------------------------------------------------------ */
.mbm-leadbot__form {
  display: flex;
  gap: 8px;
  padding: 12px 12px 13px;
  border-top: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  background: rgba(0, 0, 0, 0.18);
}
.mbm-leadbot__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--hairline, rgba(200, 162, 75, .22));
  border-radius: 10px;
  background: var(--obsidian, #15110C);
  color: var(--bone, #F4ECDC);
  font-family: var(--body, 'Inter', system-ui, sans-serif);
  font-size: 14.5px;
}
.mbm-leadbot__input::placeholder { color: rgba(244, 236, 220, 0.42); }
.mbm-leadbot__input:focus {
  outline: none;
  border-color: var(--gold, #C8A24B);
  box-shadow: 0 0 0 2px rgba(200, 162, 75, 0.18);
}
.mbm-leadbot__input:disabled { opacity: 0.55; }

.mbm-leadbot__send {
  flex: none;
  padding: 0 16px;
  border: 1px solid var(--gold, #C8A24B);
  border-radius: 10px;
  background: var(--gold, #C8A24B);
  color: var(--obsidian, #15110C);
  font-family: var(--display, 'Archivo Black', Inter, sans-serif);
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    background 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)),
    border-color 0.2s var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1));
}
.mbm-leadbot__send:hover {
  background: var(--gold-hi, #E0B84C);
  border-color: var(--gold-hi, #E0B84C);
}
.mbm-leadbot__send:focus-visible {
  outline: 2px solid var(--gold-hi, #E0B84C);
  outline-offset: 2px;
}
.mbm-leadbot__send:disabled { opacity: 0.5; cursor: default; }

/* honeypot — visually hidden, kept in the a11y/tab tree off-screen for bots */
.mbm-leadbot__hp {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----- Inline mode (pitch page): static flow, permanently open ------------ */
.mbm-leadbot--inline {
  position: static;
  z-index: auto;
  inset: auto;
  width: 100%;
}
.mbm-leadbot--inline .mbm-leadbot__panel {
  position: static;
  width: 100%;
  max-height: min(620px, 80vh);
  max-height: min(620px, 80dvh);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

/* ----- Mobile: full-width anchored above the pill ------------------------- */
@media (max-width: 480px) {
  #mbm-leadbot:not(.mbm-leadbot--inline) {
    left: 12px;
    right: 12px;
  }
  #mbm-leadbot:not(.mbm-leadbot--inline) .mbm-leadbot__pill {
    /* keep the pill on its data-position side, not stretched */
    position: absolute;
    bottom: 0;
  }
  #mbm-leadbot[data-position="left"]:not(.mbm-leadbot--inline)  .mbm-leadbot__pill { left: 0; }
  #mbm-leadbot[data-position="right"]:not(.mbm-leadbot--inline) .mbm-leadbot__pill { right: 0; }
  .mbm-leadbot__panel {
    width: 100%;
    max-height: min(70vh, 520px);
    max-height: min(70dvh, 520px);
  }
  #mbm-leadbot:not(.mbm-leadbot--inline) .mbm-leadbot__panel {
    left: 0;
    right: 0;
    bottom: 58px; /* clear the pill footprint */
  }
}

/* ----- Reduced motion: opacity-only, no transforms/loops ------------------ */
@media (prefers-reduced-motion: reduce) {
  #mbm-leadbot:not(.mbm-leadbot--inline) .mbm-leadbot__panel,
  #mbm-leadbot.mbm-leadbot--open .mbm-leadbot__panel {
    transform: none;
    transition: opacity 0.15s linear, visibility 0s linear;
  }
  .mbm-leadbot__pill,
  .mbm-leadbot__pill-arrow,
  .mbm-leadbot__pill:hover { transform: none; transition: none; }
  .mbm-leadbot__dot {
    animation: none;
    opacity: 0.6;
  }
}
