/* Benny, the Brave Bot. (site.css forces square corners on everything with !important, so
   Benny's rounded corners need !important too; his more specific selectors then win.)
   Uses the site's colour and font tokens (site.css). Unlike the rest of the
   site, Benny is rounded and lime (the brand's button colour) so he's easy to spot, and he hops
   and rings now and then (less often once the chat has been opened), his eyes follow the pointer,
   and his mouth moves while he types. No movement at all with reduced motion. */

.benny { position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 58; font-family: var(--font-body); color: var(--color-ink); display: flex; flex-direction: column; align-items: flex-end; gap: .75rem; }
@media (min-width: 768px) { .benny { right: 1.5rem; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); } }

/* The back-to-top button moves up to make room. */
body.benny-on button[aria-label="Back to top"] { margin-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)) !important; }

/* The site justifies body text; chat text reads better left-aligned. */
.benny p, .benny .benny-bubble, .benny-nudge { text-align: left !important; hyphens: manual; }
.benny-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.benny-avatar { display: block; }

/* ---- launcher: a lime pill with Benny's face ---- */
.benny-launcher { position: relative; display: inline-flex; align-items: center; gap: .625rem; height: 3.5rem; padding: 0 1.375rem 0 .5rem; border: 0; border-radius: 999px !important; background: var(--color-acid); color: var(--color-ink); font: inherit; font-size: 1rem; cursor: pointer; box-shadow: 0 0 0 1px rgba(20, 20, 20, .08), 0 14px 34px -12px rgba(20, 20, 20, .55); transition: background-color .25s, color .25s, box-shadow .3s, transform .45s cubic-bezier(.34, 1.56, .64, 1); animation: benny-attn 7s ease-in-out 1.5s infinite; }
.benny-launcher:active { transform: scale(.97); }
.benny-launcher .benny-avatar { width: 2.5rem; height: 2.5rem; }
/* a soft ring that ripples out with each hop */
.benny-launcher::after { content: ''; position: absolute; inset: 0; border-radius: inherit !important; border: 2px solid var(--color-acid); opacity: 0; pointer-events: none; animation: benny-ring 7s ease-out 1.5s infinite; }
.benny-launcher:focus-visible, .benny-chip:focus-visible, .benny-icon:focus-visible, .benny-send:focus-visible { outline: 2px solid var(--color-peri); outline-offset: 3px; }
.benny.is-open .benny-launcher { display: none; }
/* once they've opened the chat, he asks for attention less often: a gentle ring every 14s */
.benny.is-quiet .benny-launcher { animation: benny-attn-quiet 14s ease-in-out 4s infinite; }
.benny.is-quiet .benny-launcher::after { animation: benny-ring-quiet 14s ease-out 4s infinite; }
/* a wiggle whenever he "says" something in a speech bubble */
.benny.benny-wave .benny-launcher { animation: benny-wiggle .9s ease-in-out; }
/* ---- hover (or keyboard focus): Benny says hi ----
   the pill lifts with a springy bounce and a lime glow, his face smiles (happy squint, "..." curves
   into a grin), and the label swaps to "Hi there! 👋" with a waving hand. Listed last so it wins
   over the attention animations, which stop while he's being looked at. */
.benny .benny-launcher:hover, .benny .benny-launcher:focus-visible { animation: none; transform: translateY(-4px) scale(1.05); box-shadow: 0 0 0 6px rgba(220, 235, 74, .35), 0 20px 40px -14px rgba(20, 20, 20, .6); }
.benny .benny-launcher:hover::after, .benny .benny-launcher:focus-visible::after { animation: none; opacity: 0; }
.benny-launcher .benny-eyes rect, .benny-launcher .benny-mouth rect, .benny-head .benny-eyes rect, .benny-head .benny-mouth rect { transform-box: fill-box; transform-origin: center bottom; transition: transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.benny-launcher:hover .benny-eyes rect, .benny-launcher:focus-visible .benny-eyes rect { transform: scaleY(.45); }
.benny-launcher:hover .benny-mouth rect:nth-child(1), .benny-launcher:focus-visible .benny-mouth rect:nth-child(1),
.benny-launcher:hover .benny-mouth rect:nth-child(3), .benny-launcher:focus-visible .benny-mouth rect:nth-child(3) { transform: translateY(-2.5px); }
.benny-launcher:hover .benny-mouth rect:nth-child(2), .benny-launcher:focus-visible .benny-mouth rect:nth-child(2) { transform: translateY(1px); }
/* hovering his face in the chat header: a head tilt, a wink and a grin */
.benny-head .benny-avatar { transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s; }
.benny-head .benny-avatar:hover { transform: rotate(-8deg) scale(1.1); box-shadow: 0 0 0 2px var(--color-acid), 0 0 0 7px rgba(220, 235, 74, .3); }
.benny-head .benny-avatar:hover .benny-eyes rect:nth-child(2) { transform: scaleY(.15); }
.benny-head .benny-avatar:hover .benny-mouth rect:nth-child(1), .benny-head .benny-avatar:hover .benny-mouth rect:nth-child(3) { transform: translateY(-2.5px); }
.benny-head .benny-avatar:hover .benny-mouth rect:nth-child(2) { transform: translateY(1px); }
/* the two labels share one spot, so the pill keeps its width when they swap */
.benny-launcher-label { display: grid; }
.benny-l1, .benny-l2 { grid-area: 1 / 1; white-space: nowrap; transition: opacity .25s, transform .35s cubic-bezier(.34, 1.56, .64, 1); }
.benny-l2 { opacity: 0; transform: translateY(8px); }
.benny-launcher:hover .benny-l1, .benny-launcher:focus-visible .benny-l1 { opacity: 0; transform: translateY(-8px); }
.benny-launcher:hover .benny-l2, .benny-launcher:focus-visible .benny-l2 { opacity: 1; transform: none; }
.benny-hand { display: inline-block; transform-origin: 70% 80%; }
.benny-launcher:hover .benny-hand, .benny-launcher:focus-visible .benny-hand { animation: benny-wave-hand 1s ease-in-out .15s 2; }
@media (max-width: 480px) { .benny-launcher-label { display: none; } .benny-launcher { padding: 0 .5rem; } }

/* his eyes follow the pointer (benny.js sets --ex/--ey) and blink */
.benny-look { transform: translate(var(--ex, 0px), var(--ey, 0px)); transition: transform .45s cubic-bezier(.22, 1, .36, 1); }
/* his "..." mouth moves while he types; a happy hop when he finds courses */
.benny.is-typing .benny-head .benny-mouth rect { animation: benny-dot 1s ease-in-out infinite; }
.benny.is-typing .benny-head .benny-mouth rect:nth-child(2) { animation-delay: .15s; }
.benny.is-typing .benny-head .benny-mouth rect:nth-child(3) { animation-delay: .3s; }
.benny.benny-cheer .benny-head .benny-avatar { animation: benny-cheer .8s cubic-bezier(.33, 0, .2, 1); }
.benny-eyes { transform-box: fill-box; transform-origin: center; animation: benny-blink 5s ease-in-out infinite; }

/* ---- hello nudge ---- */
.benny-nudge { position: relative; max-width: 15rem; padding: .875rem 2.25rem .875rem 1rem; background: var(--color-paper); border: 1px solid var(--color-ink-12); border-radius: 18px 18px 6px 18px !important; box-shadow: 0 24px 64px rgba(20, 20, 20, .18); font-size: .9375rem; line-height: 1.4; cursor: pointer; animation: benny-pop .5s cubic-bezier(.22, 1, .36, 1); }
.benny-nudge[hidden] { display: none; }
.benny-nudge p { margin: 0; }
.benny-nudge-x { position: absolute; top: .375rem; right: .375rem; width: 1.75rem; height: 1.75rem; border: 0; border-radius: 50% !important; background: none; color: var(--color-ink-60); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.benny-nudge-x:hover { background: var(--color-ink-06); color: var(--color-ink); }

/* ---- panel ---- */
.benny-panel { display: flex; flex-direction: column; width: 24rem; height: min(38rem, calc(100dvh - 3rem)); overflow: hidden; background: var(--color-paper); border: 1px solid var(--color-ink-12); border-radius: 24px !important; box-shadow: 0 24px 64px rgba(20, 20, 20, .22); transform-origin: bottom right; animation: benny-pop .4s cubic-bezier(.22, 1, .36, 1); }
.benny-panel[hidden] { display: none; }
@media (max-width: 480px) {
  .benny.is-open { inset: 0; z-index: 80; } /* full screen, above the site header */
  .benny-panel { width: 100%; height: 100%; border: 0; border-radius: 0 !important; padding-bottom: env(safe-area-inset-bottom, 0px); }
}

.benny-head { display: flex; align-items: center; gap: .75rem; padding: .875rem 1rem; background: var(--color-ink); color: var(--color-paper); }
.benny-head .benny-avatar { width: 2.75rem; height: 2.75rem; flex: none; border-radius: 12px !important; box-shadow: 0 0 0 2px var(--color-acid); }
.benny-head-text { flex: 1; min-width: 0; }
.benny-head-text p { margin: 0; }
#benny-title { font-family: var(--font-display); font-size: 1.125rem; letter-spacing: -.02em; }
.benny-sub { display: flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--color-on-ink-2); }
.benny-sub::before { content: ''; width: .5rem; height: .5rem; border-radius: 50% !important; background: var(--color-acid); }
.benny-icon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 0; border-radius: 50% !important; background: none; color: var(--color-paper); cursor: pointer; transition: background-color .2s, color .2s; }
.benny-icon:hover { background: var(--color-paper); color: var(--color-ink); }
.benny-icon svg { width: 1.125rem; height: 1.125rem; }

/* ---- conversation ---- */
.benny-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; scroll-behavior: smooth; }
.benny-row { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; max-width: 88%; }
.benny-you { align-self: flex-end; align-items: flex-end; }
.benny-bubble { margin: 0; padding: .6875rem .9375rem; font-size: .9375rem; line-height: 1.45; overflow-wrap: anywhere; }
.benny-benny .benny-bubble { background: var(--color-white); border: 1px solid var(--color-ink-12); border-radius: 18px 18px 18px 6px !important; }
.benny-you .benny-bubble { background: var(--color-ink); color: var(--color-paper); border-radius: 18px 18px 6px 18px !important; }
.benny-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--color-peri); }
.benny-bubble a:hover { color: var(--color-peri); }
.benny-bubble strong { font-weight: 400; font-family: var(--font-display); letter-spacing: -.01em; }
.benny-in { animation: benny-rise .35s cubic-bezier(.22, 1, .36, 1); }

/* typing: the brand's three dots */
.benny-typing .benny-bubble { display: flex; gap: .3125rem; padding: .875rem 1rem; }
.benny-typing span { width: .4375rem; height: .4375rem; border-radius: 2px !important; background: var(--color-ink); animation: benny-dot 1.2s ease-in-out infinite; }
.benny-typing span:nth-child(2) { animation-delay: .15s; }
.benny-typing span:nth-child(3) { animation-delay: .3s; }

/* course results */
.benny-courses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .375rem; width: 100%; }
.benny-courses a { display: flex; flex-direction: column; gap: .25rem; padding: .75rem .9375rem; background: var(--color-white); border: 1px solid var(--color-ink-12); border-radius: 14px !important; color: var(--color-ink); text-decoration: none; transition: border-color .2s, transform .2s; }
.benny-courses a:hover { border-color: var(--color-ink); transform: translateY(-1px); }
.benny-course-title { font-family: var(--font-display); font-size: 1rem; line-height: 1.2; letter-spacing: -.015em; }
.benny-course-meta { font-size: .8125rem; color: var(--color-ink-60); }
.benny-badge { align-self: flex-start; padding: .125rem .5rem; border-radius: 999px !important; background: var(--color-peri-12); font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--color-peri); }
.benny-links { margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding-left: .25rem; font-size: .875rem; }
.benny-links a { color: var(--color-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--color-peri); }

/* quick replies */
.benny-chips { display: flex; flex-wrap: wrap; gap: .375rem; padding-top: .25rem; }
.benny-chip { display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0 1rem; border: 1px solid var(--color-ink); border-radius: 999px !important; background: transparent; color: var(--color-ink); font: inherit; font-size: .875rem; text-decoration: none; cursor: pointer; transition: background-color .2s, color .2s; }
.benny-chip:hover { background: var(--color-ink); color: var(--color-paper); }

/* ---- input: a rounded field with a round lime send button ---- */
.benny-form { display: flex; align-items: center; gap: .5rem; margin: 0 .75rem; padding: .3125rem .3125rem .3125rem 1rem; border: 1px solid var(--color-ink-12); border-radius: 999px !important; background: var(--color-white); transition: border-color .2s, box-shadow .2s; }
.benny-form input { flex: 1; min-width: 0; height: 2.75rem; padding: 0; border: 0; background: transparent; font: inherit; font-size: 1rem; color: var(--color-ink); }
.benny-form input:focus { outline: none; }
.benny-form:focus-within { border-color: var(--color-peri); box-shadow: 0 0 0 3px var(--color-peri-12); }
.benny-send { display: grid; place-items: center; flex: none; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50% !important; background: var(--color-acid); color: var(--color-ink); cursor: pointer; transition: background-color .2s, color .2s; }
.benny-send:hover { background: var(--color-ink); color: var(--color-paper); }
.benny-send svg { width: 1.25rem; height: 1.25rem; }
.benny-foot { margin: 0; padding: .5rem 1rem .75rem; text-align: center; font-size: .75rem; color: var(--color-ink-60); }
.benny-foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---- motion ---- */
/* every 7s: a soft hop (squash, jump, land, little bounce), then halfway through a "ring" like a
   phone, each with a lime ripple */
@keyframes benny-attn {
  0%, 14%, 48%, 62%, 100% { transform: none; }
  2.5% { transform: scale(1.04, .96); }
  6% { transform: translateY(-12px) scale(.98, 1.03); }
  9.5% { transform: scale(1.03, .97); }
  12% { transform: translateY(-4px); }
  50% { transform: rotate(-7deg) scale(1.04); }
  52.5% { transform: rotate(7deg) scale(1.04); }
  55% { transform: rotate(-5deg) scale(1.03); }
  57.5% { transform: rotate(4deg) scale(1.02); }
  60% { transform: rotate(-2deg); }
}
@keyframes benny-ring {
  0%, 8% { opacity: 0; transform: scale(1); }
  10% { opacity: .75; transform: scale(1); }
  22% { opacity: 0; transform: scale(1.3, 1.7); }
  48% { opacity: 0; transform: scale(1); }
  51% { opacity: .75; transform: scale(1); }
  64%, 100% { opacity: 0; transform: scale(1.3, 1.7); }
}
@keyframes benny-attn-quiet {
  0%, 7%, 50%, 57%, 100% { transform: none; }
  1% { transform: rotate(-6deg) scale(1.03); }
  2.5% { transform: rotate(6deg) scale(1.03); }
  4% { transform: rotate(-4deg); }
  5.5% { transform: rotate(2deg); }
  51.5% { transform: scale(1.03, .97); }
  53.5% { transform: translateY(-8px) scale(.99, 1.02); }
  55.5% { transform: scale(1.02, .98); }
}
@keyframes benny-ring-quiet {
  0% { opacity: .7; transform: scale(1); }
  8%, 100% { opacity: 0; transform: scale(1.3, 1.7); }
}
@keyframes benny-wiggle {
  0%, 100% { transform: none; }
  20% { transform: rotate(-6deg) scale(1.04); }
  45% { transform: rotate(6deg) scale(1.04); }
  70% { transform: rotate(-3deg); }
}
@keyframes benny-wave-hand {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(18deg); }
  40% { transform: rotate(-10deg); }
  60% { transform: rotate(14deg); }
  80% { transform: rotate(-4deg); }
}
@keyframes benny-cheer {
  0%, 100% { transform: none; }
  35% { transform: translateY(-5px) rotate(-6deg); }
  65% { transform: translateY(0) rotate(4deg); }
}
@keyframes benny-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes benny-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes benny-pop { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes benny-dot { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .benny-launcher, .benny-launcher::after, .benny.is-quiet .benny-launcher, .benny.is-quiet .benny-launcher::after, .benny.benny-wave .benny-launcher,
  .benny-eyes, .benny-panel, .benny-nudge, .benny-in, .benny.is-typing .benny-head .benny-mouth rect, .benny.benny-cheer .benny-head .benny-avatar { animation: none; }
  .benny-look { transition: none; }
  .benny .benny-launcher:hover, .benny .benny-launcher:focus-visible { transform: none; }
  .benny-launcher:hover .benny-hand, .benny-launcher:focus-visible .benny-hand { animation: none; }
  .benny-l1, .benny-l2, .benny-launcher .benny-eyes rect, .benny-launcher .benny-mouth rect, .benny-head .benny-eyes rect, .benny-head .benny-mouth rect, .benny-head .benny-avatar { transition: none; }
  .benny-head .benny-avatar:hover { transform: none; }
  .benny-typing span { animation: none; opacity: .6; }
  .benny-log { scroll-behavior: auto; }
  .benny-courses a:hover { transform: none; }
}

/* Short laptop screens: keep the open chat between the site header and the bottom of the window. */
@media (min-width: 481px) {
  .benny-panel { height: min(38rem, calc(100dvh - var(--bga-header-bottom, 72px) - 2.75rem)); min-height: 17rem; }
}
