/* Restaurant Buddy — guest widget.
 *
 * Served statically on the public menu page, which is server-rendered HTML from
 * netlify/functions/redirect, NOT the SPA. There is no React, no framer-motion
 * and no lucide-react in this context: every animation here is CSS.
 *
 * THE THEME COMMANDS. Every colour, font and radius is a custom property that
 * redirect.js sets on #advisor-widget from the menu's own studioCatalog theme.
 * The only literal colours in this file are the fallbacks in the block below,
 * declared once, for the case where the widget somehow renders without them.
 * v1 had a hardcoded blue/violet gradient on every theme, and a FAB that bounced
 * for ever on a gold menu.
 */

#advisor-widget {
  --buddy-bg-from: #1e3a8a;
  --buddy-bg-to: #111827;
  --buddy-accent: #60a5fa;
  --buddy-btn-from: #3b82f6;
  --buddy-btn-mid: #334155;
  --buddy-btn-to: #1f2937;
  --buddy-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --buddy-radius: 14px;
  --buddy-text: #ffffff;
  --buddy-text-dim: rgba(255, 255, 255, 0.62);
  --buddy-border: rgba(255, 255, 255, 0.14);
  --buddy-surface: rgba(255, 255, 255, 0.07);
  --buddy-surface-2: rgba(255, 255, 255, 0.12);
  --buddy-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --buddy-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --buddy-dur: 200ms;
}

.advisor-fab,
.advisor-sheet-overlay {
  font-family: var(--buddy-font);
  color: var(--buddy-text);
  box-sizing: border-box;
}

.advisor-fab *,
.advisor-sheet-overlay * {
  box-sizing: border-box;
}

/* ── floating action button ───────────────────────────────────────────────── */
/* Above the safe area, inside thumb reach, and it settles: ONE entrance
 * animation, then still. The v1 `animation: advisor-bounce 3s infinite` had no
 * prefers-reduced-motion guard and never stopped. */
.advisor-fab {
  position: fixed;
  right: 16px;
  /* Clear of the iubenda padlock's footprint (38px tall, 16px margin) even if
   * the rule that moves it out of this corner ever stops winning: their
   * stylesheet is theirs to change, ours is not. Raising our own button is the
   * half of this fix that cannot be broken by somebody else's deploy, and 78px
   * is still comfortably inside thumb reach. */
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 20px 12px 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--buddy-btn-from), var(--buddy-btn-mid), var(--buddy-btn-to));
  color: var(--buddy-text);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--buddy-shadow);
  animation: advisor-fab-in 520ms var(--buddy-ease) both;
  transition: transform var(--buddy-dur) var(--buddy-ease), box-shadow var(--buddy-dur) var(--buddy-ease);
}

.advisor-fab:active {
  transform: scale(0.96);
}

.advisor-fab svg {
  flex: 0 0 auto;
}

@keyframes advisor-fab-in {
  0% { opacity: 0; transform: translateY(24px) scale(0.9); }
  60% { transform: translateY(-3px) scale(1.02); }
  100% { opacity: 1; transform: none; }
}

/* ── bottom sheet ─────────────────────────────────────────────────────────── */
/* Not a centred modal. The guest is standing, one-handed, in low light: the
 * sheet rises from the bottom, has a visible handle, and drags to dismiss.
 * Heights are dvh, never vh — with vh the iOS keyboard crops the content. */
.advisor-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  animation: advisor-fade-in var(--buddy-dur) var(--buddy-ease) both;
}

.advisor-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: min(88dvh, 780px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--buddy-border);
  background: linear-gradient(160deg, var(--buddy-bg-from), var(--buddy-bg-to));
  box-shadow: var(--buddy-shadow);
  animation: advisor-sheet-up 260ms var(--buddy-ease) both;
  overflow: hidden;
}

@media (min-width: 640px) {
  .advisor-sheet-overlay { align-items: center; }
  .advisor-sheet { border-radius: 22px; max-height: min(80dvh, 720px); }
}

@keyframes advisor-sheet-up {
  from { transform: translateY(28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes advisor-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.advisor-handle {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
  cursor: grab;
  touch-action: none;
}

.advisor-handle::before {
  content: "";
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--buddy-surface-2);
}

.advisor-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 12px;
}

.advisor-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.advisor-close {
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--buddy-border);
  border-radius: 999px;
  background: var(--buddy-surface);
  color: var(--buddy-text-dim);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--buddy-dur) var(--buddy-ease), background var(--buddy-dur) var(--buddy-ease);
}

.advisor-close:active {
  background: var(--buddy-surface-2);
  color: var(--buddy-text);
}

/* ── profile strip ────────────────────────────────────────────────────────── */
/* What Buddy understood, removable. Three jobs at once: the proof it listened,
 * the undo (a finger instead of a sentence), and the reason the AI call count
 * stays near zero — a correction never reaches the model. */
.advisor-profile {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.advisor-profile::-webkit-scrollbar { display: none; }

.advisor-profile-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px 6px 12px;
  border: 1px solid var(--buddy-border);
  border-radius: 999px;
  background: var(--buddy-surface-2);
  color: var(--buddy-text);
  font-size: 0.8rem;
  cursor: pointer;
  animation: advisor-chip-in 220ms var(--buddy-ease) both;
}

.advisor-profile-chip span {
  font-size: 1rem;
  line-height: 1;
  color: var(--buddy-text-dim);
}

/* ── body ─────────────────────────────────────────────────────────────────── */
.advisor-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
}

.advisor-step {
  animation: advisor-step-in 220ms var(--buddy-ease) both;
}

/* Cross-fade plus 8px of travel. Never a full-page slide. */
@keyframes advisor-step-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.advisor-question {
  margin: 6px 0 14px;
  font-size: 1.16rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

/* Chips on ONE row that scrolls, with a fade on the right edge saying there is
 * more. Never wrapped onto three lines. */
.advisor-chips {
  position: relative;
  display: flex;
  gap: 8px;
  padding-bottom: 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  /* #000 here is an alpha stop for the mask, not a colour anyone sees — a mask
   * gradient needs an opaque value and the theme tokens are irrelevant to it. */
  -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%);
  mask-image: linear-gradient(to right, #000 88%, transparent 100%);
}

.advisor-chips::-webkit-scrollbar { display: none; }

.advisor-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid var(--buddy-border);
  border-radius: 999px;
  background: var(--buddy-surface);
  color: var(--buddy-text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 140ms var(--buddy-ease), background var(--buddy-dur) var(--buddy-ease), border-color var(--buddy-dur) var(--buddy-ease);
  animation: advisor-chip-in 240ms var(--buddy-ease) both;
}

/* The stagger is the one animation worth noticing: it is what reads as
 * "I understood you". ~40ms apart, and it stops after the eighth chip. */
.advisor-chip:nth-child(1) { animation-delay: 0ms; }
.advisor-chip:nth-child(2) { animation-delay: 40ms; }
.advisor-chip:nth-child(3) { animation-delay: 80ms; }
.advisor-chip:nth-child(4) { animation-delay: 120ms; }
.advisor-chip:nth-child(5) { animation-delay: 160ms; }
.advisor-chip:nth-child(6) { animation-delay: 200ms; }
.advisor-chip:nth-child(7) { animation-delay: 240ms; }
.advisor-chip:nth-child(n + 8) { animation-delay: 280ms; }

@keyframes advisor-chip-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* No affordance lives in :hover alone — on the menu page there is no hover. */
.advisor-chip:active {
  transform: scale(0.97);
  background: var(--buddy-surface-2);
  border-color: var(--buddy-accent);
}

/* ── result cards ─────────────────────────────────────────────────────────── */
.advisor-card {
  margin-top: 12px;
  border: 1px solid var(--buddy-border);
  border-radius: var(--buddy-radius);
  background: var(--buddy-surface);
  overflow: hidden;
  animation: advisor-step-in 260ms var(--buddy-ease) both;
}

.advisor-card-slot {
  padding: 10px 14px 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--buddy-accent);
}

.advisor-card-image {
  display: block;
  width: 100%;
  height: 148px;
  object-fit: cover;
}

.advisor-card-body {
  padding: 12px 14px 14px;
}

.advisor-card-name {
  margin: 2px 0 4px;
  font-size: 1.06rem;
  font-weight: 650;
  line-height: 1.3;
}

.advisor-card-desc {
  margin: 0 0 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--buddy-text-dim);
}

.advisor-card-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--buddy-accent);
}

.advisor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.advisor-tag {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--buddy-surface-2);
  font-size: 0.7rem;
  color: var(--buddy-text-dim);
}

.advisor-alt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--buddy-border);
  border-radius: 12px;
  background: var(--buddy-surface);
  font-size: 0.86rem;
}

.advisor-alt-price {
  color: var(--buddy-text-dim);
  font-size: 0.8rem;
}

.advisor-subtitle {
  margin: 18px 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--buddy-text-dim);
}

.advisor-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--buddy-border);
  font-size: 0.9rem;
}

.advisor-total b {
  font-size: 1.16rem;
  color: var(--buddy-accent);
}

.advisor-note,
.advisor-disclaimer,
.advisor-ai-note {
  margin-top: 12px;
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--buddy-text-dim);
}

/* The AI Act art. 50(1) line sits between the opening question and the chips, so
 * it pulls up against the question's own bottom margin instead of adding a third
 * gap. Muted on purpose - required to be clear and distinguishable, not loud. */
.advisor-ai-note {
  margin: -8px 0 14px;
}

.advisor-caveat {
  margin-top: 10px;
  padding: 11px 13px;
  border: 1px solid var(--buddy-border);
  border-left: 3px solid var(--buddy-accent);
  border-radius: 10px;
  background: var(--buddy-surface);
  font-size: 0.86rem;
  line-height: 1.5;
}

/* ── skeleton, not a spinner ──────────────────────────────────────────────── */
/* The result surface appears in its final shape and fills in. At the same number
 * of seconds it is perceived as faster than a spinner. */
.advisor-skeleton {
  margin-top: 12px;
  border: 1px solid var(--buddy-border);
  border-radius: var(--buddy-radius);
  overflow: hidden;
}

.advisor-skeleton-line {
  height: 13px;
  margin: 12px 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--buddy-surface), var(--buddy-surface-2), var(--buddy-surface));
  background-size: 220% 100%;
  animation: advisor-shimmer 1.25s linear infinite;
}

.advisor-skeleton-line.wide { width: 78%; }
.advisor-skeleton-line.short { width: 42%; }
.advisor-skeleton-block {
  height: 108px;
  background: linear-gradient(90deg, var(--buddy-surface), var(--buddy-surface-2), var(--buddy-surface));
  background-size: 220% 100%;
  animation: advisor-shimmer 1.25s linear infinite;
}

@keyframes advisor-shimmer {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}

.advisor-thinking {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--buddy-text-dim);
}

/* ── buttons ──────────────────────────────────────────────────────────────── */
.advisor-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  padding: 13px 18px;
  border: none;
  border-radius: var(--buddy-radius);
  background: linear-gradient(135deg, var(--buddy-btn-from), var(--buddy-btn-mid), var(--buddy-btn-to));
  color: var(--buddy-text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms var(--buddy-ease);
}

.advisor-btn:active { transform: scale(0.985); }

.advisor-btn.outline {
  background: transparent;
  border: 1px solid var(--buddy-border);
  color: var(--buddy-text-dim);
}

.advisor-btn.small {
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 9px 14px;
  font-size: 0.82rem;
}

/* ── sticky footer with the free-text field ───────────────────────────────── */
/* The field lives in a sticky footer inside the sheet, kept in view by a
 * visualViewport listener in the JS. That is the difference between something
 * that feels like an app and something that feels like a web page. */
.advisor-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--buddy-border);
  background: linear-gradient(180deg, transparent, var(--buddy-bg-to) 40%);
}

.advisor-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--buddy-border);
  border-radius: var(--buddy-radius);
  background: var(--buddy-surface);
  color: var(--buddy-text);
  font-family: inherit;
  /* 16px minimum: anything smaller makes iOS Safari zoom the page on focus. */
  font-size: 16px;
}

.advisor-input::placeholder { color: var(--buddy-text-dim); }
.advisor-input:focus {
  outline: none;
  border-color: var(--buddy-accent);
}

.advisor-send {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--buddy-radius);
  background: linear-gradient(135deg, var(--buddy-btn-from), var(--buddy-btn-mid), var(--buddy-btn-to));
  color: var(--buddy-text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.advisor-send[disabled] { opacity: 0.5; cursor: default; }

.advisor-error {
  padding: 18px 2px;
  text-align: center;
  color: var(--buddy-text-dim);
  font-size: 0.9rem;
}

/* ── reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .advisor-fab,
  .advisor-sheet,
  .advisor-sheet-overlay,
  .advisor-chip,
  .advisor-profile-chip,
  .advisor-step,
  .advisor-card,
  .advisor-skeleton-line,
  .advisor-skeleton-block {
    animation: none !important;
    transition: none !important;
  }
}

/* ── the iubenda privacy padlock ──────────────────────────────────────────── */
/* It is `position: fixed; bottom: 0; right: 0; margin: 16px` with
 * `z-index: 2147483647` inline — the maximum, so it cannot be out-stacked. It
 * landed exactly on the FAB.
 *
 * Moving IT was tried and abandoned. Their `right: 0 !important` comes from an
 * injected <style>; a selector specific enough to win on `left` still lost on
 * `right`, so the button ended up anchored to both edges and stretched to 343px
 * across the screen. Fighting a third party's stylesheet from outside is a
 * fight you win until their next release.
 *
 * So the fix is entirely on our side of the line: the FAB sits above the
 * padlock's footprint (see `bottom` on .advisor-fab). The padlock keeps its
 * usual corner, its usual size, and every bit of its function — it is how a
 * guest withdraws consent, and the law wants withdrawing to be as easy as
 * giving, so hiding it was never on the table.
 *
 * While the sheet is open it does step aside: a floating control stacked on top
 * of a modal is simply wrong, and it comes straight back on close. */
body.advisor-sheet-open .iubenda-tp-btn.iubenda-cs-preferences-link {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 160ms var(--buddy-ease);
}

/* ── the FAB says there is something new here ─────────────────────────────── */
/* The brief: make it obvious this is worth a tap, WITHOUT going back to the
 * bounce that ran for ever on every menu. So the cue is finite and it is spent
 * once — the teaser opens, holds, collapses, and localStorage stops it ever
 * running again for that guest. */
.advisor-fab-teaser {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  vertical-align: middle;
  transition: max-width 520ms var(--buddy-ease), opacity 260ms var(--buddy-ease), margin-left 520ms var(--buddy-ease);
}

.advisor-fab.teasing .advisor-fab-teaser {
  max-width: 15rem;
  opacity: 1;
  margin-left: 2px;
}

/* One slow sweep of light across the pill, three times, then never again.
 * Enough to catch the eye of someone scanning a menu; short enough that it is
 * not a thing blinking at them while they read. */
.advisor-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  background-size: 220% 100%;
  background-position: 200% 0;
  opacity: 0;
}

.advisor-fab.teasing::after {
  animation: advisor-sheen 2.1s var(--buddy-ease) 3;
  opacity: 1;
}

@keyframes advisor-sheen {
  0% { background-position: 200% 0; }
  55%, 100% { background-position: -120% 0; }
}

.advisor-fab { position: fixed; overflow: hidden; }

/* A small live dot, so the button reads as an assistant rather than a label. */
.advisor-fab-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--buddy-accent);
  box-shadow: 0 0 0 0 var(--buddy-accent);
  flex: 0 0 auto;
  animation: advisor-pulse 2.4s var(--buddy-ease) infinite;
}

/* The one thing here that repeats is 7px wide and has no motion — it fades.
 * A guest reading a menu is not distracted by it; prefers-reduced-motion still
 * switches it off entirely, below. */
@keyframes advisor-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .advisor-fab-teaser { transition: none !important; }
  .advisor-fab::after { display: none !important; }
  .advisor-fab-dot { animation: none !important; opacity: 1; }
}

/* ══ Buddy v2.1 (2026-10-08) ═══════════════════════════════════════════════════
 * Feedback del proprietario sul menu demo: Buddy troppo piccolo e fermo, scheda
 * «bland», chip che continuavano a destra senza modo di prenderle col mouse,
 * attesa che sembrava un pannello vuoto, teaser tagliato dentro il bottone.
 * Tutto resta sui token del tema del menu (--buddy-*); le animazioni muovono solo
 * transform e opacity e si spengono con prefers-reduced-motion.
 * ════════════════════════════════════════════════════════════════════════════ */

/* Buddy vivo: galleggia e sbatte le palpebre. */
.buddy-mark { overflow: visible; animation: buddy-float 3.4s ease-in-out infinite; }
.buddy-eyes { transform-box: fill-box; transform-origin: center; animation: buddy-blink 5s ease-in-out infinite; }
@keyframes buddy-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(-3deg); }
}
@keyframes buddy-blink {
  0%, 90%, 100% { transform: scaleY(1); }
  93% { transform: scaleY(0.12); }
  96% { transform: scaleY(1); }
}

/* FAB: Buddy in primo piano, l'etichetta accanto. */
.advisor-fab {
  gap: 10px;
  min-height: 56px;
  padding: 6px 20px 6px 6px;
  max-width: calc(100vw - 32px);
}
.advisor-fab-avatar {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 0 18px rgba(255, 255, 255, 0.12);
}
.advisor-fab-avatar .advisor-fab-dot {
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--buddy-btn-to);
}
.advisor-fab-label {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Il teaser e' il fumetto di Buddy, sopra il bottone, mai tagliato. */
.advisor-bubble {
  position: fixed;
  right: 16px;
  bottom: calc(78px + 66px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  max-width: min(280px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: #ffffff;
  color: #111827;
  font-family: var(--buddy-font);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 260ms var(--buddy-ease), transform 320ms var(--buddy-ease);
  cursor: pointer;
}
.advisor-bubble.show { opacity: 1; transform: none; pointer-events: auto; }
.advisor-bubble:empty { display: none; }

/* La scheda: un alone del colore del menu dietro a Buddy. */
.advisor-sheet {
  background:
    radial-gradient(120% 55% at 50% -12%, color-mix(in srgb, var(--buddy-accent) 30%, transparent), transparent 62%),
    linear-gradient(160deg, var(--buddy-bg-from), var(--buddy-bg-to));
}
.advisor-head { gap: 12px; padding: 8px 16px 14px; }
.advisor-avatar {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.advisor-avatar::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--buddy-accent);
  opacity: 0.55;
  animation: buddy-ring 2.8s ease-out infinite;
}
@keyframes buddy-ring {
  0% { transform: scale(0.92); opacity: 0.6; }
  70%, 100% { transform: scale(1.18); opacity: 0; }
}
.advisor-title { font-size: 1.18rem; font-weight: 800; }
.advisor-question { font-size: 1.12rem; line-height: 1.35; }

/* Le chip vanno a capo: tutte visibili, prendibili anche col mouse. */
.advisor-chips {
  flex-wrap: wrap;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}
.advisor-chip { scroll-snap-align: none; }
.advisor-chip:hover { background: var(--buddy-surface-2); border-color: var(--buddy-accent); }

/* Attesa: Buddy grande al lavoro, con i puntini. */
.advisor-thinking-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 0 18px;
  text-align: center;
  animation: advisor-fade-in 200ms var(--buddy-ease) both;
}
.advisor-thinking-avatar {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.04));
  box-shadow: 0 0 40px color-mix(in srgb, var(--buddy-accent) 35%, transparent);
}
.advisor-thinking-avatar .buddy-mark { animation: buddy-think 1.1s ease-in-out infinite; }
@keyframes buddy-think {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(4deg); }
}
.advisor-dots { display: inline-flex; gap: 6px; }
.advisor-dots i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--buddy-accent);
  animation: buddy-dot 1s ease-in-out infinite;
}
.advisor-dots i:nth-child(2) { animation-delay: 150ms; }
.advisor-dots i:nth-child(3) { animation-delay: 300ms; }
@keyframes buddy-dot {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-6px); opacity: 1; }
}
.advisor-thinking { margin: 4px 0 0; font-size: 0.95rem; color: var(--buddy-text); opacity: 0.85; }

@media (prefers-reduced-motion: reduce) {
  .buddy-mark, .buddy-eyes, .advisor-avatar::after, .advisor-thinking-avatar .buddy-mark, .advisor-dots i, .advisor-bubble {
    animation: none !important;
    transition: none !important;
  }
}

/* Chip e campo di testo leggibili anche sui temi scuri (charcoal/midnight): sul
 * menu demo le chip si leggevano come testo semplice, senza bordo. */
.advisor-chip {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.advisor-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.24);
  text-overflow: ellipsis;
}
.advisor-send:not([disabled]) {
  background: var(--buddy-accent);
  color: #0b0d11;
}

/* Finche' il banner di consenso e' aperto, Buddy gli sta SOTTO (2026-10-08).
 * Il bottone v2.1 e' alto 56px e largo ~215px: su un telefono cadeva esattamente
 * sul tasto "Accetta" del banner (z-index 99999998), e l'ospite non poteva
 * rispondere. Il banner copre la pagina finche' non si sceglie: e' il suo lavoro,
 * e un nostro bottone sopra di lui e' un difetto, non una priorita'. */
body:has(#iubenda-cs-banner.iubenda-cs-visible) .advisor-fab,
body:has(#iubenda-cs-banner.iubenda-cs-visible) .advisor-bubble {
  z-index: 99999990;
}
