/* ===========================================================================
   SiteBot
   ===========================================================================
   Everything is scoped under .sitebot. The colours come from the site's own
   custom properties, so the card follows whichever theme is active -- and every
   one has a fallback, so it still looks right dropped into a page that has none
   of them.

   Only inline-level elements are used (see init.php), which is why every block
   here is a span set to display:block or flex.

   Two modes. data-mode="card" is an ordinary block in the page. data-mode="bubble"
   is a floating Help icon; sitebot.js moves it onto <body> so it shows on every
   route, and positions it with a transform (see "Bubble mode" below). The visitor
   can drag it anywhere, toss it, and it drifts to the nearest window edge.
   =========================================================================== */

.sitebot[data-mode="card"],
.sitebot-panel {
  display: block;
  max-width: 40rem;
  margin: 1.5rem auto;
  padding: 1.5rem;
  text-align: center;
  color: var(--text, #16202b);
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e3e8ee);
  border-radius: var(--radius, .85rem);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(16, 24, 40, .05));
}

.sitebot [hidden] { display: none !important; }

/* The plugin must size itself the same on a page that has no Bootstrap reboot. */
.sitebot, .sitebot *, .sitebot *::before, .sitebot *::after { box-sizing: border-box; }

.sitebot-title {
  display: block;
  margin-bottom: .75rem;
  font-family: var(--font-display, Georgia, "Times New Roman", serif);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
}

.sitebot-output {
  display: block;
  min-height: 3.2em;
  margin-bottom: .75rem;
  line-height: 1.55;
}

.sitebot-transcript {
  display: block;
  min-height: 1.5em;
  margin-bottom: 1rem;
  font-size: .95rem;
  font-style: italic;
  color: var(--text-muted, #5c6b7a);
  white-space: pre-line;
}

.sitebot-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
}

.sitebot-btn {
  appearance: none;
  padding: .6rem 1.25rem;
  font: inherit;
  font-weight: 600;
  color: var(--text-invert, #ffffff);
  background: var(--brand, #136fbf);
  border: 0;
  border-radius: var(--radius-sm, .5rem);
  cursor: pointer;
  transition: background-color var(--t-fast, 140ms) ease, box-shadow var(--t-fast, 140ms) ease;
}
.sitebot-btn:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--brand-strong, #0f5a9a); }
.sitebot-btn:focus-visible,
.sitebot-input:focus-visible {
  outline: 0;
  box-shadow: var(--ring, 0 0 0 .22rem rgba(19, 111, 191, .28));
}
.sitebot-btn:disabled,
.sitebot-btn[aria-disabled="true"] {
  color: var(--text-muted, #5c6b7a);
  background: var(--surface-2, #f6f8fa);
  border: 1px solid var(--border, #e3e8ee);
  cursor: default;
}
.sitebot-btn-alt   { background: transparent; color: var(--brand, #136fbf); border: 1px solid var(--brand, #136fbf); }
.sitebot-btn-alt:hover:not(:disabled) { background: var(--brand-soft, #eef6fc); }
.sitebot-btn-small { padding: .5rem 1rem; }

/* While it listens the button turns to the brand colour and pulses, so a visitor
   can see the microphone is live -- the opposite of the muted look it has
   while the bot is speaking. The pulse is a ring drawn with box-shadow, so it
   costs no layout. */
.sitebot[data-state="listening"] .sitebot-actions .sitebot-btn:first-child {
  color: var(--text-invert, #ffffff);
  background: var(--brand, #136fbf);
  border-color: transparent;
}
.sitebot[data-state="listening"] .sitebot-actions .sitebot-btn:first-child {
  animation: sitebot-pulse 1.4s ease-out infinite;
}
@keyframes sitebot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--brand-rgb, 19, 111, 191), .55); }
  100% { box-shadow: 0 0 0 .9rem rgba(var(--brand-rgb, 19, 111, 191), 0); }
}
@media (prefers-reduced-motion: reduce) {
  .sitebot[data-state="listening"] .sitebot-actions .sitebot-btn:first-child { animation: none; }
}

.sitebot-field {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  margin-top: 1rem;
}
.sitebot-label { flex: 0 0 100%; }

.sitebot-input {
  flex: 1 1 14rem;
  max-width: 20rem;
  padding: .55rem .75rem;
  font: inherit;
  color: var(--text, #16202b);
  background: var(--bg, #ffffff);
  border: 1px solid var(--border-strong, #cfd7e0);
  border-radius: var(--radius-sm, .5rem);
}

.sitebot-status {
  display: block;
  min-height: 1.5em;
  margin-top: .75rem;
}

.sitebot-note {
  display: block;
  margin-top: 1rem;
  font-size: .85rem;
  color: var(--text-muted, #5c6b7a);
}

/* ===========================================================================
   Bubble mode
   =========================================================================== */

.sitebot[data-mode="bubble"] {
  /* sitebot.js sets transform: translate3d(x, y, 0) -- that is the whole of its
     position, so moving it never triggers layout. The start position here is only
     what shows for the instant before the script has placed it. */
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1041;                 /* just over .back-to-top (1040), under Bootstrap modals */
  display: block;
  margin: 0;
  padding: 0;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  will-change: transform;
}

/* Without JavaScript the bubble would just be an unexplained button in the page
   content, so it is left out, and out of print as well. */
html:not(.js) .sitebot[data-mode="bubble"] { display: none; }
@media print { .sitebot[data-mode="bubble"] { display: none; } }

/* Collapsed, the launcher is a round Help icon. Open, the "Enquiries" label grows
   out beside it. Only max-width and margin are animated on the label, and the
   script follows the size change so the pill stays against its edge. */
.sitebot-launcher {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 3rem;
  height: 3rem;
  padding: 0 .75rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-invert, #ffffff);
  background: var(--brand, #136fbf);
  border: 0;
  border-radius: 1.5rem;
  box-shadow: var(--shadow, 0 4px 16px rgba(16, 24, 40, .07));
  cursor: grab;
  touch-action: none;            /* a touch-drag moves the icon instead of scrolling the page */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: background-color var(--t-fast, 140ms) ease, transform var(--t-fast, 140ms) ease;
}
.sitebot-launcher:hover { background: var(--brand-strong, #0f5a9a); transform: translateY(-1px); }
.sitebot-launcher:focus-visible { outline: 0; box-shadow: var(--shadow, 0 4px 16px rgba(16, 24, 40, .07)), var(--ring, 0 0 0 .22rem rgba(19, 111, 191, .28)); }
.sitebot-launcher[aria-expanded="true"] { background: var(--brand-strong, #0f5a9a); }

.sitebot-launcher-text {
  display: block;
  max-width: 0;
  margin-left: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width var(--t, 260ms) var(--ease, ease-out),
              margin-left var(--t, 260ms) var(--ease, ease-out),
              opacity var(--t, 260ms) var(--ease, ease-out);
}
.sitebot[data-open="true"] .sitebot-launcher { padding-right: 1.15rem; }
.sitebot[data-open="true"] .sitebot-launcher-text { max-width: 20rem; margin-left: .5rem; opacity: 1; }

/* Held in the hand: no hover lift, no easing, a closed-fist cursor. */
.sitebot[data-dragging] .sitebot-launcher { cursor: grabbing; transform: none; transition: none; }

.sitebot-launcher-icon { flex: 0 0 auto; }

/* The panel hangs off the launcher: above it by default, below it when the icon
   is near the top of the window (sitebot.js sets data-v). Its left offset and
   max-height are set by the script too, so it always stays inside the window. */
.sitebot-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + .9rem);
  width: min(24rem, calc(100vw - 2.3rem));
  max-height: min(36rem, calc(100vh - 2rem));
  margin: 0;
  padding: 1.1rem 1.25rem 1.25rem;
  overflow-y: auto;
  box-shadow: var(--shadow-lg, 0 18px 48px rgba(16, 24, 40, .13));
  animation: sitebot-pop var(--t, 260ms) var(--ease, ease-out);
}
.sitebot[data-v="below"] .sitebot-panel {
  top: calc(100% + .9rem);
  bottom: auto;
  animation-name: sitebot-pop-down;
}
@keyframes sitebot-pop {
  from { opacity: 0; transform: translateY(.6rem); }
  to   { opacity: 1; transform: none; }
}
@keyframes sitebot-pop-down {
  from { opacity: 0; transform: translateY(-.6rem); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sitebot-panel, .sitebot-launcher, .sitebot-launcher-text { animation: none; transition: none; }
}

.sitebot-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .75rem;
}
.sitebot-panel-head .sitebot-title { margin: 0; text-align: left; }

.sitebot-close {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted, #5c6b7a);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.sitebot-close:hover { color: var(--text, #16202b); background: var(--surface-2, #f6f8fa); }
.sitebot-close:focus-visible { outline: 0; box-shadow: var(--ring, 0 0 0 .22rem rgba(19, 111, 191, .28)); }

/* Small screens: the panel uses nearly the whole width. */
@media (max-width: 30rem) {
  .sitebot-panel { padding: 1rem; }
}
