/* =========================================================
   Barbwired Bot: the little helper in the bottom right corner.
   A navy tile with the logo's barber pole turned into a bot. It
   follows you down the page, leans with your scroll, and opens a
   small chat that minimizes back into the tile. Drawn by js/bot.js.
   Colors come from css/styles.css, so day and dark mode just work.
   ========================================================= */

.bwb {
  --bwb-tile: 60px;
  --bwb-gap: 22px;
  --bwb-lift: 0px;           /* raised above bars pinned to the bottom (js/bot.js) */
  --bwb-tilt: 0deg;          /* leans with the scroll */
  --bwb-look: 0px;           /* eyes look up or down while scrolling */
  --bwb-head: #151927;
  --bwb-head-2: #0b0e1a;
  --bwb-bot-bg: var(--mist);
  --bwb-me-bg: var(--fill);
  --bwb-me-text: var(--on-fill);
  --bwb-card: var(--paper);
  --bwb-shadow: 0 24px 60px -18px rgba(7, 10, 20, .45), 0 0 0 1px rgba(11, 14, 26, .06);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}
:root[data-theme="dark"] .bwb {
  --bwb-bot-bg: #1d2439;
  --bwb-card: #161c2f;
  --bwb-shadow: 0 24px 60px -18px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .08);
}

/* ---------- the floating tile ---------- */
.bwb-launch {
  position: fixed;
  right: calc(var(--bwb-gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--bwb-gap) + env(safe-area-inset-bottom, 0px) + var(--bwb-lift));
  z-index: 110;
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: bottom .35s cubic-bezier(.2, .7, .2, 1), opacity .25s ease, transform .3s ease;
}
.bwb-launch__tile {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--bwb-tile);
  height: var(--bwb-tile);
  border-radius: 28%;
  background: radial-gradient(120% 90% at 30% 12%, #262e49 0%, #151927 58%, #0f1322 100%);
  box-shadow: 0 14px 30px -12px rgba(7, 10, 20, .65), 0 2px 6px -2px rgba(7, 10, 20, .35), inset 0 0 0 1px rgba(255, 255, 255, .07);
  transform: rotate(var(--bwb-tilt)) scale(var(--bwb-scale, 1));
  transition: transform .55s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease;
}
:root[data-theme="dark"] .bwb-launch__tile {
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .8), inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.bwb-launch:hover .bwb-launch__tile { box-shadow: 0 18px 36px -12px rgba(7, 10, 20, .7), inset 0 0 0 1px rgba(255, 255, 255, .14); }
.bwb-launch:focus-visible { outline: none; }
.bwb-launch:focus-visible .bwb-launch__tile { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--pole-blue); }
.bwb-launch .bwbot { width: 86%; height: 86%; }

/* While scrolling: leans with the page and shrinks a touch so it never
   gets in the way, then springs back when you stop */
.bwb.is-scrolling { --bwb-scale: .92; }
.bwb.is-scrolling .bwb-launch { opacity: .9; }

/* "Ask Barbwired Bot" slides out on computers */
.bwb-launch__label {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 28px -12px rgba(7, 10, 20, .5), 0 0 0 1px var(--line);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(8px, -50%);
  transition: opacity .2s ease, transform .25s ease;
}
@media (hover: hover) and (min-width: 700px) {
  .bwb-launch:hover .bwb-launch__label,
  .bwb-launch:focus-visible .bwb-launch__label { opacity: 1; transform: translate(0, -50%); }
}

.bwb-launch__badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pole-red);
  color: #fff;
  box-shadow: 0 0 0 2.5px var(--bg);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  animation: bwb-pop .4s cubic-bezier(.34, 1.56, .64, 1) both;
}
.bwb-launch__badge[hidden] { display: none; }

/* While the chat is open the tile just minimizes it (on phones it hides:
   the chat covers the screen) */
.bwb[data-open="true"] .bwb-launch__label { display: none; }

/* ---------- the bot's little moves ---------- */
.bwbot__eyes { transform-box: fill-box; transform-origin: center; transform: translateY(var(--bwb-look)); transition: transform .25s ease; }
.bwb-blink .bwbot__eyes { animation: bwb-blink .22s ease; }
.bwbot__antenna circle { transform-box: fill-box; transform-origin: center; }
.bwb-ping .bwbot__antenna circle { animation: bwb-ping 1.2s ease 2; }
.bwbot__pole { transform-box: view-box; }
.is-thinking .bwbot__pole { animation: bwb-pole .9s linear infinite; }
.bwb-hop .bwb-launch__tile { animation: bwb-hop .6s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes bwb-blink { 50% { transform: translateY(var(--bwb-look)) scaleY(.1); } }
@keyframes bwb-ping { 50% { transform: scale(1.35); fill: #ff6b73; } }
@keyframes bwb-pole { to { transform: translateY(-15.6px); } }
@keyframes bwb-hop { 35% { transform: translateY(-7px) rotate(-6deg); } 70% { transform: translateY(0) rotate(3deg); } }
@keyframes bwb-pop { from { transform: scale(.3); opacity: 0; } }
@keyframes bwb-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes bwb-sheet { from { transform: translateY(100%); } }
@keyframes bwb-msg { from { opacity: 0; transform: translateY(6px); } }
@keyframes bwb-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ---------- the little "need a hand?" bubble ---------- */
.bwb-teaser {
  position: fixed;
  right: calc(var(--bwb-gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--bwb-gap) + env(safe-area-inset-bottom, 0px) + var(--bwb-lift) + var(--bwb-tile) + 12px);
  z-index: 110;
  width: min(270px, calc(100vw - 2 * var(--bwb-gap)));
  padding: 14px 38px 14px 16px;
  border-radius: 18px 18px 6px 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--bwb-shadow);
  font-size: 0.9375rem;
  line-height: 1.4;
  cursor: pointer;
  animation: bwb-in .4s cubic-bezier(.2, .7, .2, 1) both;
}
.bwb-teaser[hidden] { display: none; }
.bwb-teaser b { display: block; margin-bottom: 2px; font-weight: 600; }
.bwb-teaser span { color: var(--ink-2); }
.bwb-teaser__x {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.bwb-teaser__x:hover { background: var(--mist); color: var(--ink); }
.bwb-teaser__x svg { width: 14px; height: 14px; }

/* ---------- the chat ---------- */
.bwb-panel {
  position: fixed;
  right: calc(var(--bwb-gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--bwb-gap) + env(safe-area-inset-bottom, 0px) + var(--bwb-lift) + var(--bwb-tile) + 14px);
  z-index: 115;
  display: flex;
  flex-direction: column;
  width: 390px;
  height: min(640px, calc(100vh - var(--bwb-lift) - var(--bwb-tile) - 2 * var(--bwb-gap) - 40px));
  min-height: 320px;
  overflow: hidden;
  border-radius: 24px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--bwb-shadow);
  transform-origin: bottom right;
  animation: bwb-in .32s cubic-bezier(.2, .7, .2, 1) both;
}
.bwb-panel[hidden] { display: none; }

.bwb-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 10px 14px 14px;
  background: linear-gradient(180deg, #1a2034 0%, var(--bwb-head) 55%, var(--bwb-head-2) 100%);
  color: #f4f5f8;
}
.bwb-head__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
}
.bwb-head__avatar .bwbot { width: 40px; height: 40px; }
.bwb-head__txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.bwb-head__txt b { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.bwb-head__txt span { display: flex; align-items: center; gap: 6px; color: rgba(236, 239, 247, .68); font-size: 0.8125rem; }
.bwb-head__txt span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ccf7a; box-shadow: 0 0 0 3px rgba(60, 207, 122, .18); }
.bwb-iconbtn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: rgba(244, 245, 248, .85);
  cursor: pointer;
  transition: background-color .15s ease;
}
.bwb-iconbtn:hover, .bwb-iconbtn[aria-expanded="true"] { background: rgba(255, 255, 255, .1); color: #fff; }
.bwb-iconbtn:focus-visible { outline: 2px solid var(--pole-blue); outline-offset: -2px; }
.bwb-iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.bwb-menu {
  position: absolute;
  top: calc(100% - 6px);
  right: 10px;
  z-index: 2;
  display: grid;
  min-width: 190px;
  padding: 6px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 16px 40px -12px rgba(7, 10, 20, .45), 0 0 0 1px var(--line);
  animation: bwb-in .18s ease both;
}
.bwb-menu[hidden] { display: none; }
.bwb-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  font: 500 0.9375rem/1.2 var(--font-sans);
  text-align: left;
  cursor: pointer;
}
.bwb-menu button:hover, .bwb-menu button:focus-visible { background: var(--mist); outline: none; }
.bwb-menu svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-2); }

/* Messages */
.bwb-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 8px;
  scroll-behavior: smooth;
}
.bwb-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 6px; animation: bwb-msg .25s ease both; }
.bwb-row--me { justify-content: flex-end; }
.bwb-row__av {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: #151927;
}
.bwb-row__av .bwbot { width: 25px; height: 25px; }
.bwb-row__av--ghost { visibility: hidden; }
.bwb-bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 6px;
  background: var(--bwb-bot-bg);
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.bwb-bubble p { margin: 0; }
.bwb-bubble p + p, .bwb-bubble p + ul, .bwb-bubble p + ol, .bwb-bubble ul + p, .bwb-bubble ol + p { margin-top: 8px; }
.bwb-bubble ul, .bwb-bubble ol { margin: 6px 0 0; padding-left: 20px; list-style: disc; }
.bwb-bubble ol { list-style: decimal; }
.bwb-bubble li + li { margin-top: 3px; }
.bwb-bubble b { font-weight: 600; }
.bwb-bubble em { font-style: normal; color: var(--ink-2); }
.bwb-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bwb-row--me .bwb-bubble { border-radius: 18px 18px 6px 18px; background: var(--bwb-me-bg); color: var(--bwb-me-text); }
.bwb-gap { height: 10px; }

/* Typing: three dots, and the bot's pole spins */
.bwb-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.bwb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: bwb-dot 1.1s ease-in-out infinite; }
.bwb-typing i:nth-child(2) { animation-delay: .15s; }
.bwb-typing i:nth-child(3) { animation-delay: .3s; }

/* Link buttons under an answer */
.bwb-links { display: grid; gap: 6px; margin: 8px 0 4px 36px; }
.bwb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 12px 9px 14px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--bwb-card);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.bwb-link:hover { border-color: var(--line-strong); }
.bwb-link:active { transform: scale(.985); }
.bwb-link:focus-visible { outline: 2px solid var(--pole-blue); outline-offset: 2px; }
.bwb-link__txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.bwb-link__txt small { color: var(--ink-3); font-size: 0.8125rem; font-weight: 400; }
.bwb-link svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-3); transition: transform .15s ease; }
.bwb-link:hover svg { transform: translateX(2px); }
.bwb-link--go { border-color: transparent; background: var(--accent); color: #fff; }
.bwb-link--go:hover { border-color: transparent; background: var(--accent-hover); }
.bwb-link--go small, .bwb-link--go svg { color: rgba(255, 255, 255, .78); }

/* Barber cards: swipe sideways */
.bwb-cards {
  display: flex;
  gap: 8px;
  margin: 8px -14px 4px 0;
  padding: 2px 14px 6px 36px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.bwb-cards::-webkit-scrollbar { display: none; }
.bwb-card {
  flex: none;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 220px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--bwb-card);
  scroll-snap-align: start;
}
.bwb-cards--one .bwb-card { width: 100%; max-width: 300px; }
.bwb-card__top { display: flex; align-items: center; gap: 10px; padding: 12px 12px 0; }
.bwb-card__img { flex: none; width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: var(--mist); }
.bwb-card__ini { display: grid; place-items: center; color: var(--ink-2); font-weight: 600; }
.bwb-card__who { min-width: 0; display: grid; gap: 2px; }
.bwb-card__who b { overflow: hidden; font-size: 0.9375rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.bwb-card__who span { color: var(--ink-3); font-size: 0.8125rem; }
.bwb-card__star { color: var(--star); }
.bwb-card__body { padding: 8px 12px 0; color: var(--ink-2); font-size: 0.8125rem; line-height: 1.4; }
.bwb-card__body b { color: var(--ink); font-weight: 600; }
.bwb-card__acts { display: flex; gap: 6px; padding: 10px 12px 12px; }
.bwb-card__btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.bwb-card__btn:hover { background: var(--accent-hover); }
.bwb-card__btn--ghost { flex: none; border: 1px solid var(--line-2); background: transparent; color: var(--ink); }
.bwb-card__btn--ghost:hover { background: var(--mist); }
.bwb-card__btn:focus-visible { outline: 2px solid var(--pole-blue); outline-offset: 2px; }

/* Quick replies */
.bwb-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin: 10px 0 6px; }
.bwb-chip {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: 500 0.875rem/1 var(--font-sans);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.bwb-chip:hover { border-color: var(--ink); }
.bwb-chip:focus-visible { outline: 2px solid var(--pole-blue); outline-offset: 2px; }
.bwb-chip--human { border-style: dashed; color: var(--ink-2); }

/* Was this helpful? */
.bwb-rate { display: flex; align-items: center; gap: 4px; margin: 2px 0 4px 36px; color: var(--ink-3); font-size: 0.75rem; }
.bwb-rate button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.bwb-rate button:hover { background: var(--mist); color: var(--ink); }
.bwb-rate button[aria-pressed="true"] { color: var(--accent); }
.bwb-rate svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Typing a message */
.bwb-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 6px 12px 0;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line-2);
  border-radius: 22px;
  background: var(--input-bg);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.bwb-form:focus-within { border-color: var(--ink-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pole-blue) 18%, transparent); }
.bwb-form textarea {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 400 1rem/1.4 var(--font-sans);   /* 16px: phones don't zoom in */
  resize: none;
  outline: none;
}
.bwb-form textarea::placeholder { color: var(--placeholder); }
.bwb-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--on-fill);
  cursor: pointer;
  transition: opacity .15s ease, transform .15s ease;
}
.bwb-send:disabled { opacity: .35; cursor: default; }
.bwb-send:not(:disabled):active { transform: scale(.92); }
.bwb-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.bwb-fine { margin: 0; padding: 8px 16px 12px; color: var(--ink-3); font-size: 0.6875rem; line-height: 1.35; text-align: center; }

/* ---------- phones: the chat covers the screen ---------- */
@media (max-width: 599px) {
  .bwb { --bwb-tile: 54px; --bwb-gap: 16px; }
  .bwb-panel {
    top: var(--bwb-vv-top, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    width: auto;
    height: var(--bwb-vv-h, 100dvh);
    min-height: 0;
    border-radius: 0;
    animation: bwb-sheet .34s cubic-bezier(.2, .7, .2, 1) both;
  }
  .bwb-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .bwb-fine { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .bwb[data-open="true"] .bwb-launch, .bwb[data-open="true"] .bwb-teaser { display: none; }
  .bwb-card { width: 78%; }
}
html.bwb-lock, html.bwb-lock body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .bwb *, .bwb *::before, .bwb *::after { animation: none !important; transition: none !important; }
  .bwb { --bwb-tilt: 0deg !important; }
}
@media print { .bwb { display: none !important; } }
