/* ============================================================
   Bob — Mascota guía (FAB + burbuja + tours coach-mark)
   Blueprint: DESIGN.md §Guided Onboarding. Tokens del sistema,
   nada hardcodeado. Z-order: FAB 900 < bubble 901 < help 950 <
   overlay 1000 < wrap 1001.
   ============================================================ */

/* ---- FAB flotante ---- */
.bob-fab {
  position: fixed;
  right: 14px;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-fab);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--c-border-glass-strong);
  background: var(--c-glass-strong);
  -webkit-backdrop-filter: var(--blur-glass);
  backdrop-filter: var(--blur-glass);
  box-shadow: var(--glow-primary);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  /* El float vive en la imagen; el botón queda libre para hover/física. */
  animation: bob-fab-glow 3.4s ease-in-out infinite;
  transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out);
  touch-action: none; /* arrastre táctil sin scroll de fondo */
}
.bob-fab:hover {
  transform: scale(1.12);
  box-shadow: var(--glow-primary-strong);
}
.bob-fab.is-dragging {
  animation: none;
  cursor: grabbing;
  transform: scale(1.06);
  box-shadow: var(--glow-primary-strong);
}
.bob-fab.is-dragging .bob-fab-img { animation: none; }
.bob-fab.is-flying {
  animation: none;
  box-shadow: var(--glow-primary-strong);
}
/* Squash & stretch al rebotar contra un borde */
.bob-fab.bob-boing { animation: bob-boing .45s var(--ease-out); }
@keyframes bob-boing {
  0% { transform: scale(1.25, 0.75); }
  40% { transform: scale(0.85, 1.15); }
  70% { transform: scale(1.08, 0.94); }
  100% { transform: scale(1); }
}
@media (min-width: 900px) { .bob-fab { bottom: 22px; } }
/* Móvil: mientras se scrollea hacia abajo el FAB se aparta (tapaba inputs y
   botones al final de las vistas); vuelve al subir o al detenerse el scroll. */
.bob-fab.bob-fab--away {
  transform: translateY(calc(100% + 120px));
  opacity: 0;
  pointer-events: none;
}
.bob-fab-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  object-position: top;
  border-radius: 50%;
  pointer-events: none;
}
.bob-fab-pulse {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c-ok);
}
.bob-fab-pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--c-ok);
  animation: beacon-pulse 1.8s var(--ease-out) infinite;
}
@keyframes bob-fab-glow {
  0%, 100% { box-shadow: 0 0 15px var(--c-primary-glow); }
  50% { box-shadow: 0 0 22px rgba(56, 189, 248, 0.42); }
}

/* ---- Burbuja de diálogo ---- */
.bob-bubble {
  position: fixed;
  right: 14px;
  bottom: calc(158px + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-bubble);
  max-width: min(78vw, 300px);
  padding: 12px 16px;
  background: var(--c-glass-strong);
  -webkit-backdrop-filter: var(--blur-glass);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--c-border-glass-strong);
  border-radius: 16px 16px 0 16px;
  box-shadow: var(--glow-primary);
  color: var(--c-text);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-spring);
}
@media (min-width: 900px) { .bob-bubble { bottom: 96px; } }
.bob-bubble.is-open { opacity: 1; transform: none; pointer-events: auto; }

/* ---- Menú de ayuda ---- */
.bob-help {
  position: fixed;
  right: 14px;
  bottom: calc(158px + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-help);
  width: min(84vw, 280px);
  background: var(--c-glass-strong);
  -webkit-backdrop-filter: var(--blur-glass);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--c-border-glass-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--glow-primary-strong);
  padding: var(--sp-sm);
  display: none;
}
@media (min-width: 900px) { .bob-help { bottom: 96px; } }
.bob-help.is-open { display: block; animation: menu-in var(--t-base) var(--ease-spring-soft) both; }
.bob-help-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--c-primary);
  padding: 4px 10px 10px;
}
.bob-help-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--c-text);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
}
.bob-help-item:hover { background: rgba(56, 189, 248, 0.12); }

/* ---- Overlay del tour ---- */
.bob-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-tour);
  pointer-events: none;
}
.bob-tour-spotlight {
  position: absolute;
  border-radius: var(--r-md);
  border: 2px solid var(--c-primary-bright);
  box-shadow:
    0 0 0 9999px rgba(2, 6, 15, 0.82),
    0 0 18px var(--c-primary-glow),
    inset 0 0 14px rgba(56, 189, 248, 0.2);
  pointer-events: none;
  transition: top var(--t-slow) var(--ease-out), left var(--t-slow) var(--ease-out),
              width var(--t-slow) var(--ease-out), height var(--t-slow) var(--ease-out);
}

/* ---- Wrapper posicionado: figura + tarjeta ---- */
.bob-tour-wrap {
  position: absolute;
  z-index: var(--z-tour-card);
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 2px;
  max-width: min(480px, calc(100vw - 24px));
  pointer-events: auto;
}
.bob-tour-figure {
  width: 130px;
  flex: 0 0 auto;
  margin-bottom: -6px;
  filter: drop-shadow(0 0 14px var(--c-primary-glow));
  animation: bob-float 3.2s ease-in-out infinite;
  user-select: none;
  pointer-events: none;
}
@keyframes bob-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.bob-tour-card {
  min-width: 0;
  flex: 1 1 auto;
  background: var(--c-glass-strong);
  -webkit-backdrop-filter: var(--blur-glass);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--c-border-glass-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--glow-primary);
  padding: var(--sp-md);
}
.bob-tour-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--c-primary);
  text-shadow: 0 0 10px var(--c-primary-text-shadow);
  margin-bottom: 6px;
}
.bob-tour-text { font-size: 13.5px; line-height: 1.55; color: var(--c-text); }
.bob-tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: var(--sp-sm);
  flex-wrap: wrap;
}
.bob-tour-count {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--c-text-muted);
  white-space: nowrap;
  flex: 0 0 auto;
}
.bob-tour-btns { display: flex; gap: 8px; }

.bob-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-full);
  background: linear-gradient(100deg, var(--c-primary-container), var(--c-secondary-container));
  color: #001a24;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 14px var(--c-primary-glow);
}
.bob-btn:hover { filter: brightness(1.06); }
.bob-btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: var(--c-text);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

/* ---- Animación entrada/salida de cada paso ---- */
.bob-anim-in { animation: bob-step-in 0.34s var(--ease-spring) both; }
.bob-anim-out { animation: bob-step-out 0.24s var(--ease-in) both; }
@keyframes bob-step-in { from { opacity: 0; transform: translateY(16px) scale(0.93); } }
@keyframes bob-step-out { to { opacity: 0; transform: translateY(16px) scale(0.93); } }

/* ---- Paso centrado (bienvenida / selector ausente) ---- */
.bob-tour-wrap.is-center { flex-direction: column; align-items: center; }
.bob-tour-wrap.is-center .bob-tour-figure { margin-bottom: -16px; }
.bob-tour-wrap.is-center .bob-tour-card { width: 100%; text-align: center; }
.bob-tour-wrap.is-center .bob-tour-foot { justify-content: center; }

/* ---- Móvil ≤600px: figura ARRIBA de tarjeta a lo ancho ---- */
@media (max-width: 600px) {
  .bob-tour-wrap { flex-direction: column; align-items: center; }
  .bob-tour-figure { width: 120px; max-width: 42vw; margin-bottom: -16px; }
  .bob-tour-card { width: 100%; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .bob-fab, .bob-fab-img, .bob-tour-figure { animation: none !important; }
  .bob-fab { transition: none; }
  .bob-fab:hover { transform: none; }
  .bob-fab-pulse::after { animation: none; }
}
