/* ===========================================================================
   False Bay High School — Virtual Assistant
   Everything is scoped under .fbh-chat and every property is set explicitly,
   so a WordPress theme cannot leak into the widget and the widget cannot leak
   into the theme.

   The palette is the school's own, sampled from its letterhead: the deep olive
   of the wordmark, the brass of the crest, and a cream ground.
   =========================================================================== */

.fbh-chat {
  --fbh-olive:  #48422A;
  --fbh-ink:    #2B2718;
  --fbh-gold:   #927B2C;
  --fbh-gold-l: #C2AC62;
  --fbh-cream:  #FBF8F0;
  --fbh-sand:   #F0EBDC;
  --fbh-line:   #E1DBCA;
  --fbh-grey:   #6E6857;
  --fbh-wa:     #25D366;
  --fbh-wa-d:   #128C7E;

  --fbh-bottom: 24px;
  --fbh-right:  24px;

  --fbh-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
              Helvetica, Arial, sans-serif;

  position: fixed;
  bottom: var(--fbh-bottom);
  right: var(--fbh-right);
  /* Above Elementor, the Events Calendar and anything else on the page. */
  z-index: 2147483000;
  font-family: var(--fbh-font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fbh-ink);
}

.fbh-chat *,
.fbh-chat *::before,
.fbh-chat *::after { box-sizing: border-box; }

.fbh-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Launcher ---------- */
.fbh-launcher {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0; padding: 13px 20px 13px 16px;
  font: inherit; font-weight: 600; font-size: 15px;
  color: #fff; background: var(--fbh-olive);
  border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(43, 39, 24, .24), 0 12px 32px rgba(43, 39, 24, .18);
  transition: transform .16s ease, background-color .16s ease, box-shadow .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.fbh-launcher:hover { background: var(--fbh-ink); transform: translateY(-1px); }
.fbh-launcher:focus-visible { outline: 3px solid var(--fbh-gold-l); outline-offset: 3px; }
.fbh-launcher__icon { display: grid; place-items: center; width: 22px; height: 22px; flex: none; }
.fbh-launcher__icon svg { width: 22px; height: 22px; }
.fbh-chat.is-open .fbh-launcher { opacity: 0; pointer-events: none; }

/* ---------- Panel ---------- */
.fbh-panel {
  position: absolute; bottom: 0; right: 0;
  width: min(392px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 48px));
  display: flex; flex-direction: column;
  background: #fff;
  border: 1px solid var(--fbh-line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(43, 39, 24, .14), 0 28px 64px rgba(43, 39, 24, .20);
  animation: fbh-in .2s ease;
}
.fbh-panel[hidden] { display: none; }
@keyframes fbh-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  .fbh-panel { animation: none; }
  .fbh-launcher { transition: none !important; }
}

/* ---------- Header ---------- */
.fbh-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 14px 15px 18px;
  background: var(--fbh-olive); color: #fff;
  flex: none;
}
.fbh-head__text { flex: 1 1 auto; min-width: 0; }
.fbh-head__title {
  margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; color: #fff;
}
.fbh-head__sub {
  margin: 2px 0 0; font-size: 12px; color: #D8D2BE;
  display: flex; align-items: center; gap: 6px;
}
.fbh-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--fbh-gold-l); flex: none;
}
.fbh-close {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); border: 0; border-radius: 50%;
  color: #fff; cursor: pointer; padding: 0;
}
.fbh-close svg { width: 17px; height: 17px; }
.fbh-close:hover { background: rgba(255, 255, 255, .22); }
.fbh-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Message log ---------- */
.fbh-log {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 16px 8px;
  background: var(--fbh-cream);
  -webkit-overflow-scrolling: touch;
}
.fbh-msg {
  max-width: 88%; margin: 0 0 12px;
  padding: 11px 14px; border-radius: 14px;
  font-size: 14.5px; word-wrap: break-word; overflow-wrap: anywhere;
}
.fbh-msg p { margin: 0 0 .7em; }
.fbh-msg p:last-child { margin-bottom: 0; }
.fbh-msg strong { font-weight: 650; }
.fbh-msg--bot {
  background: #fff; border: 1px solid var(--fbh-line);
  border-bottom-left-radius: 5px; color: var(--fbh-ink);
}
.fbh-msg--user {
  background: var(--fbh-olive); color: #fff; margin-left: auto;
  border-bottom-right-radius: 5px;
}
.fbh-msg--user p { color: #fff; }

/* Sources and links under an answer */
.fbh-src { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--fbh-line); }
.fbh-src__links { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.fbh-src__link {
  color: var(--fbh-gold); font-weight: 600; font-size: 13.5px;
  text-decoration: none; padding: 3px 0;
}
.fbh-src__link:hover { color: var(--fbh-ink); text-decoration: underline; }
.fbh-src__note { margin: 0; font-size: 11.5px; color: var(--fbh-grey); }
.fbh-src__note--warn { margin-top: 3px; color: #8A6512; }

/* The "what the school does publish" block inside a Level 2 answer */
.fbh-related {
  margin-top: 12px; padding: 11px 13px;
  background: var(--fbh-sand); border-radius: 10px;
}
.fbh-related__head {
  margin: 0 0 .5em; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--fbh-grey);
}
.fbh-related .fbh-src { border-top-color: #D9D2BE; }

/* ---------- Action buttons ---------- */
.fbh-actions { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.fbh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; min-height: 46px; padding: 11px 16px;
  font: inherit; font-size: 14.5px; font-weight: 600; text-align: center;
  color: var(--fbh-ink); background: #fff;
  border: 1.5px solid var(--fbh-line); border-radius: 10px;
  cursor: pointer; text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.fbh-btn:hover { border-color: var(--fbh-gold); }
.fbh-btn:focus-visible { outline: 3px solid var(--fbh-gold-l); outline-offset: 2px; }
.fbh-btn svg { width: 19px; height: 19px; flex: none; }
.fbh-btn--wa {
  background: var(--fbh-wa); border-color: var(--fbh-wa); color: #fff;
}
.fbh-btn--wa:hover { background: var(--fbh-wa-d); border-color: var(--fbh-wa-d); }
.fbh-btn--quiet {
  min-height: 42px; font-weight: 500; font-size: 13.5px; color: var(--fbh-grey);
  background: transparent; border-color: transparent;
}
.fbh-btn--quiet:hover { color: var(--fbh-ink); background: #fff; border-color: var(--fbh-line); }

/* ---------- Quick questions ---------- */
.fbh-quick { margin: 4px 0 14px; }
.fbh-quick__head {
  margin: 0 0 8px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--fbh-grey);
}
.fbh-quick__grid { display: flex; flex-wrap: wrap; gap: 7px; }
.fbh-chip {
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 9px 14px; min-height: 38px;
  color: var(--fbh-olive); background: #fff;
  border: 1.5px solid var(--fbh-line); border-radius: 999px; cursor: pointer;
}
.fbh-chip:hover { border-color: var(--fbh-gold); background: var(--fbh-sand); }
.fbh-chip:focus-visible { outline: 3px solid var(--fbh-gold-l); outline-offset: 2px; }

/* ---------- Typing indicator ---------- */
.fbh-msg--typing { padding: 14px; }
.fbh-typing { display: inline-flex; gap: 4px; }
.fbh-typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--fbh-gold-l);
  animation: fbh-bounce 1.1s infinite ease-in-out;
}
.fbh-typing i:nth-child(2) { animation-delay: .16s; }
.fbh-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes fbh-bounce { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .fbh-typing i { animation: none; opacity: .6; } }

/* ---------- Composer ---------- */
.fbh-form {
  flex: none; display: flex; gap: 8px; align-items: center;
  padding: 12px 14px 8px; background: #fff; border-top: 1px solid var(--fbh-line);
}
.fbh-input {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: 15px;
  /* 16px on iOS would be safer against zoom, but the panel is fixed-position
     and iOS only zooms on focus when the field is under 16px in a scrollable
     page; 15px with the viewport meta on the host site behaves correctly. */
  padding: 11px 14px; min-height: 44px;
  color: var(--fbh-ink); background: #fff;
  border: 1.5px solid var(--fbh-line); border-radius: 10px;
}
.fbh-input:focus {
  outline: none; border-color: var(--fbh-gold);
  box-shadow: 0 0 0 3px rgba(194, 172, 98, .25);
}
.fbh-send {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--fbh-olive); color: #fff; border: 0; border-radius: 10px;
  cursor: pointer; padding: 0;
}
.fbh-send svg { width: 20px; height: 20px; }
.fbh-send:hover { background: var(--fbh-ink); }
.fbh-send:focus-visible { outline: 3px solid var(--fbh-gold-l); outline-offset: 2px; }

.fbh-foot {
  flex: none; margin: 0; padding: 0 16px 12px;
  font-size: 11px; line-height: 1.45; color: var(--fbh-grey); background: #fff;
}

/* ---------- Phones ---------- */
@media (max-width: 560px) {
  .fbh-chat { --fbh-bottom: 16px; --fbh-right: 16px; }

  .fbh-launcher {
    padding: 13px 18px 13px 15px; font-size: 14.5px;
    transition: width .18s ease, padding .18s ease, background-color .16s ease;
  }
  /* The full pill is useful when the page first loads — it says what the button
     is. Once the visitor starts reading, it becomes an obstruction on a 390px
     screen, so it folds back to the icon. */
  .fbh-chat.is-scrolled .fbh-launcher {
    width: 56px; height: 56px; padding: 0; justify-content: center;
  }
  .fbh-chat.is-scrolled .fbh-launcher__label { display: none; }

  /* Full-height sheet: a 390px-wide phone has no room for a floating card. */
  .fbh-panel {
    position: fixed; inset: 0;
    width: 100%; height: 100%; height: 100dvh;
    border: 0; border-radius: 0;
  }
  .fbh-head { padding-top: max(15px, env(safe-area-inset-top)); }
  .fbh-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .fbh-msg { max-width: 92%; font-size: 15px; }
}

/* Small phones in landscape, where a full-height sheet leaves no room. */
@media (max-height: 460px) and (min-width: 561px) {
  .fbh-panel { height: calc(100vh - 24px); }
}

/* ---------- High contrast / forced colours ---------- */
@media (forced-colors: active) {
  .fbh-panel, .fbh-msg, .fbh-btn, .fbh-chip { border: 1px solid CanvasText; }
  .fbh-launcher { border: 1px solid CanvasText; }
}
