/**
 * Bretzi — chat widget
 * Dark panel, orange for the main action, lime for Bretzi.
 */

.bz {
  --bz-bg:      #080808;
  --bz-panel:   #111111;
  --bz-line:    rgba(255, 255, 255, 0.10);
  --bz-text:    #ffffff;
  --bz-muted:   rgba(255, 255, 255, 0.55);
  --bz-orange:  #FF5C00;
  --bz-lime:    #C8FF00;
  --bz-radius:  20px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  /* the widget keeps its own type whatever the page sets on body */
  font-weight: 400;
  letter-spacing: normal;
  line-height: normal;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
}

/* ── Launcher: just Bretzi's round face ── */
.bz-launch {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease;
}

.bz-launch:hover { transform: translateY(-2px) scale(1.04); }
.bz-launch:focus-visible { outline: 2px solid var(--bz-lime); outline-offset: 4px; }

.bz-launch__badge {
  position: absolute;
  top: -6px;
  left: -8px;
  padding: 2px 7px;
  border: 2px solid var(--bz-bg);
  border-radius: 8px;
  background: var(--bz-lime);
  color: #080808;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

/* Round face, used in the launcher and the header */
.bz-face {
  display: block;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 2px solid var(--bz-lime);
  border-radius: 50%;
  background: var(--bz-bg);
  overflow: hidden;
}

.bz-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bz-face--launch {
  width: 100%;
  height: 100%;
  border-width: 3px;
}

.bz.is-open .bz-launch { display: none; }

/* New message while the chat is closed */
.bz.has-unread .bz-launch::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  border: 3px solid var(--bz-bg);
  border-radius: 50%;
  background: var(--bz-orange);
}

.bz-peek {
  position: absolute;
  right: 0;
  bottom: 78px;
  display: flex;
  align-items: flex-start;
  width: max-content;
  max-width: min(290px, calc(100vw - 32px));
  background: var(--bz-bg);
  color: var(--bz-text);
  border: 1px solid var(--bz-line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.bz-peek[hidden],
.bz.is-open .bz-peek { display: none; }

.bz-peek__open {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 4px 12px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.bz-peek__name { font-size: 12px; font-weight: 600; color: var(--bz-muted); }

.bz-peek__close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin: 6px 6px 0 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--bz-muted);
  cursor: pointer;
}

.bz-peek__close:hover { background: rgba(255, 255, 255, 0.08); color: var(--bz-text); }

/* ── Panel ── */
.bz-panel {
  display: none;
  flex-direction: column;
  width: 380px;
  height: min(620px, calc(100vh - 40px));
  background: var(--bz-bg);
  color: var(--bz-text);
  border: 1px solid var(--bz-line);
  border-radius: var(--bz-radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.bz.is-open .bz-panel { display: flex; }

.bz-panel { position: relative; }

.bz-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--bz-line);
}

.bz-head__name {
  font-family: 'Archivo Black', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bz-badge {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 1px 8px;
  border: 1.5px solid var(--bz-lime);
  border-radius: 999px;
  color: var(--bz-lime);
}

.bz-head__sub { font-size: 12px; color: var(--bz-muted); margin-top: 2px; }

.bz-head__actions { margin-left: auto; display: flex; gap: 4px; }

.bz-icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--bz-muted);
  cursor: pointer;
}

.bz-icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--bz-text); }

/* ── Messages: plain text, no bubbles (the only bubble is Bretzi's eureka) ── */
.bz-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}

.bz-msg {
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bz-row {
  align-self: flex-start;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
}

.bz-row__face { flex-shrink: 0; width: 26px; margin-top: -2px; }
.bz-row__face img { display: block; width: 26px; height: auto; }

.bz-msg--bot { color: var(--bz-text); }

/* A person from the team: photo, name, then the text */
.bz-row__avatar {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bz-panel);
}

.bz-row__avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }

.bz-row__name { font-size: 12px; font-weight: 600; color: var(--bz-muted); margin-bottom: 2px; }

.bz-msg--team { color: var(--bz-text); }

.bz-initial {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
  font-size: 13px;
  color: var(--bz-text);
}

.bz-head__face .bz-initial { font-size: 18px; }

/* "Luciana joined the chat" / "Bretzi is back" */
.bz-sys {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--bz-muted);
  text-align: center;
}

.bz-sys::before,
.bz-sys::after { content: ''; flex: 1; height: 1px; background: var(--bz-line); }

/* While a person is in the chat: white ring and badge instead of Bretzi's lime */
.bz.has-agent .bz-head__face { border-color: var(--bz-text); }
.bz.has-agent .bz-badge { border-color: var(--bz-text); color: var(--bz-text); }
.bz.has-agent .bz-human { display: none; }

/* What the visitor wrote: right-aligned, softer, marked with a thin orange line */
.bz-msg--user {
  align-self: flex-end;
  max-width: 80%;
  padding-right: 12px;
  border-right: 2px solid var(--bz-orange);
  color: rgba(255, 255, 255, 0.62);
  text-align: right;
}

.bz-typing { display: inline-flex; gap: 4px; padding-top: 9px; }
.bz-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bz-lime);
  animation: bz-dot 1s infinite ease-in-out;
}
.bz-typing span:nth-child(2) { animation-delay: 0.15s; }
.bz-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bz-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ── Eureka: a sudden idea floating over the chat ── */
.bz-eureka-layer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 96px;
  pointer-events: none;
  z-index: 2;
}

.bz-eureka {
  pointer-events: auto;
  width: fit-content;
  max-width: 100%;
  padding-bottom: 26px; /* room for the thought trail */
  opacity: 0;
  transform: translateX(-36px) scale(0.96);
  transition: opacity 0.4s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.bz-eureka.is-in  { opacity: 1; transform: translateX(0) scale(1); }
.bz-eureka.is-out { opacity: 0; transform: translateX(48px) scale(0.98); transition-duration: 0.4s; }

/* slow drift left → right while it waits */
.bz-eureka__drift { animation: bz-drift 3.5s linear forwards; }
.bz-eureka.is-held .bz-eureka__drift { animation-play-state: paused; }

@keyframes bz-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(28px); }
}

.bz-eureka__card {
  position: relative;
  max-width: 300px;
  margin-left: 22px;
  background: var(--bz-lime);
  border-radius: 24px;
  box-shadow: 0 0 28px rgba(200, 255, 0, 0.28), 0 16px 34px rgba(0, 0, 0, 0.55);
}

/* thought trail: two little circles drifting down towards Bretzi */
.bz-eureka__card::before,
.bz-eureka__card::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: var(--bz-lime);
}
.bz-eureka__card::before { width: 13px; height: 13px; left: 6px;  bottom: -15px; }
.bz-eureka__card::after  { width: 7px;  height: 7px;  left: -8px; bottom: -25px; }

.bz-eureka__main {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 40px 10px 14px;
  border: 0;
  background: transparent;
  color: #080808;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.bz-eureka__main svg { flex-shrink: 0; }

.bz-eureka__close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(8, 8, 8, 0.55);
  cursor: pointer;
}

.bz-eureka__close:hover { background: rgba(8, 8, 8, 0.1); color: #080808; }

.bz-eureka__detail {
  display: none;
  padding: 0 14px 12px 38px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(8, 8, 8, 0.78);
}

.bz-eureka.is-open .bz-eureka__detail { display: block; }

/* ── Contact actions ── */
.bz-contact { align-self: flex-start; display: flex; gap: 8px; flex-wrap: wrap; margin-left: 36px; margin-top: -6px; }

.bz-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.bz-btn--primary { background: var(--bz-orange); color: #080808; }
.bz-btn--ghost   { border: 1px solid var(--bz-line); color: var(--bz-text); }
.bz-btn:hover    { filter: brightness(1.08); }

/* ── Composer ── */
.bz-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--bz-line);
}

.bz-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid var(--bz-line);
  border-radius: 18px;
  background: var(--bz-panel);
  color: var(--bz-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
}

.bz-input:focus { border-color: rgba(255, 255, 255, 0.3); }

.bz-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--bz-orange);
  color: #080808;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.bz-send:disabled { opacity: 0.4; cursor: default; }

/* The AI and non-binding notice: 12.5px, 72% white on the panel's #080808 = 10.3:1 */
.bz-note {
  padding: 0 16px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.72);
}

.bz-note__lead { font-weight: 600; color: var(--bz-text); }

.bz .bz-note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bz .bz-note a:hover { color: var(--bz-text); }
.bz .bz-note a:focus-visible { outline: 2px solid var(--bz-lime); outline-offset: 2px; border-radius: 2px; }

/* ── Starting soon (bretzi.js without data-mode="chat"): Bretzi's one message and the
   two buttons, so the panel is only as tall as they are ── */
.bz--soon .bz-panel { height: auto; max-height: min(620px, calc(100vh - 40px)); }
.bz--soon .bz-log { flex: 0 1 auto; padding-bottom: 22px; }
.bz--soon .bz-msg:focus { outline: none; } /* opening puts the focus here, so screen readers read it first */

/* ── Mobile: full screen ── */
@media (max-width: 520px) {
  .bz { right: 12px; bottom: 12px; }
  .bz.is-open { inset: 0; }
  .bz-panel { width: 100%; height: 100%; border-radius: 0; border: 0; }
  .bz-launch { width: 58px; height: 58px; }
  .bz-peek { bottom: 70px; }
  .bz-input { font-size: 16px; } /* avoid iOS zoom on focus */
  /* starting soon: a card in the launcher's corner, not the full screen */
  .bz.bz--soon.is-open { inset: auto 12px 12px; }
  .bz--soon .bz-panel { height: auto; max-height: calc(100vh - 24px); border: 1px solid var(--bz-line); border-radius: var(--bz-radius); }
}

@media (prefers-reduced-motion: reduce) {
  .bz-launch { transition: none; }
  .bz-eureka { transform: none !important; }
  .bz-eureka__drift { animation: none; }
  .bz-launch:hover { transform: none; }
  .bz-typing span { animation: none; opacity: 0.7; }
}
