/* ==========================================================================
   whatsapp.css — botón flotante de WhatsApp            prefijo: .wa-
   Con los colores de la marca (no el verde de WhatsApp). El globo con el
   mensaje aparece una vez por visita y se puede cerrar (main.js).
   ========================================================================== */

.wa {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 80;                       /* debajo del header (100) y del menú mobile (90) */
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  pointer-events: none;              /* el contenedor no tapa clics; solo el globo y el botón */
}

/* ---------- botón ---------- */
.wa-btn {
  pointer-events: auto;
  position: relative;
  flex-shrink: 0;
  width: 3.75rem;
  height: 3.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--grad-btn);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(227, 106, 240, .5), 0 14px 36px -8px rgba(193, 44, 229, .85);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease);
  animation: wa-in .6s .8s var(--ease-out) both;
}
.wa-btn:hover,
.wa-btn:focus-visible {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 0 0 1px rgba(227, 106, 240, .8), 0 18px 44px -8px rgba(193, 44, 229, 1);
}
.wa-btn:focus-visible { outline-offset: 4px; border-radius: 50%; }
.wa-btn svg { width: 1.75rem; height: 1.75rem; fill: currentColor; }

/* anillo que late: invita al clic sin ser invasivo */
.wa-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(227, 106, 240, .6);
  animation: wa-ring 2.6s var(--ease-out) 2s infinite;
  pointer-events: none;
}

/* ---------- globo con el mensaje ---------- */
.wa-bubble {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  max-width: 16.5rem;
  margin-bottom: .35rem;
  padding: .8rem .6rem .8rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md) var(--r-md) .3rem var(--r-md);   /* la punta mira al botón */
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .9);
  opacity: 0;
  visibility: hidden;
  transform: translateX(.75rem) scale(.96);
  transform-origin: bottom right;
  transition: opacity .3s var(--ease), transform .45s var(--ease-out), visibility 0s linear .45s;
}
/* visible: cuando main.js lo abre, al pasar el mouse por el BOTÓN o al
   enfocarlo con teclado. Una vez visible, se sostiene mientras el mouse
   está encima del globo (para poder hacer clic en el texto). */
.wa.is-open .wa-bubble,
.wa:has(.wa-btn:hover) .wa-bubble,
.wa:focus-within .wa-bubble,
.wa-bubble:hover {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .3s var(--ease), transform .45s var(--ease-out), visibility 0s;
}
/* recién cerrado con la ✕: oculto aunque el mouse siga encima (main.js
   quita la clase cuando el mouse sale) */
.wa.is-dismissed .wa-bubble {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateX(.75rem) scale(.96) !important;
}
.wa-bubble__link {
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.wa-bubble__link strong { display: block; color: var(--text); font-weight: 700; }
.wa-bubble__link:hover strong { color: var(--brand-hi); }
.wa-bubble__close {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  margin-top: -.2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  font-size: 1.1rem;
  line-height: 1;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.wa-bubble__close:hover { color: var(--text); background: rgba(255, 255, 255, .08); }

@keyframes wa-in {
  from { opacity: 0; transform: translateY(1rem) scale(.8); }
  to   { opacity: 1; transform: none; }
}
@keyframes wa-ring {
  0%   { transform: scale(1);   opacity: .8; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* ---------- pantallas angostas ---------- */
@media (max-width: 640px) {
  .wa { right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); gap: .5rem; }
  .wa-btn { width: 3.4rem; height: 3.4rem; }
  .wa-btn svg { width: 1.6rem; height: 1.6rem; }
  .wa-bubble { max-width: 13.5rem; padding: .65rem .5rem .65rem .85rem; }
  .wa-bubble__link { font-size: var(--fs-xs); }
}

/* con el menú mobile abierto el botón no se muestra */
body.is-locked .wa { display: none; }
