/* ==========================================================
   Rockbu · Línea directa por WhatsApp (botón flotante)
   ========================================================== */
@property --wa-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.wa {
  --wa-green: #25D366;
  position: fixed; z-index: 80;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
  font-family: var(--f, system-ui, sans-serif);
  opacity: 0; transform: translateY(24px) scale(.96); pointer-events: none;
  transition: opacity .6s var(--ease, ease), transform .7s var(--ease, ease);
}
.wa.is-in { opacity: 1; transform: none; pointer-events: auto; }
body.quiz-open .wa, .wa.is-wait { opacity: 0; transform: translateY(24px) scale(.96); pointer-events: none; }

/* ---------- Píldora ---------- */
.wa-btn {
  position: relative; isolation: isolate;
  display: flex; align-items: center; gap: 12px;
  padding: 6px 6px 6px 6px; border-radius: 999px;
  background: rgba(11, 14, 20, .88);
  -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%);
  color: #fff; text-decoration: none;
  box-shadow: 0 22px 44px -20px rgba(37, 99, 235, .7), 0 10px 28px -14px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .09);
  transition: transform .45s var(--ease, ease), box-shadow .45s var(--ease, ease);
}
/* borde de gradiente que gira */
.wa-btn::before, .wa-btn::after {
  content: ""; position: absolute; inset: -1.5px; border-radius: inherit; z-index: -1;
  background: conic-gradient(from var(--wa-a), #2563EB, #26BDDF, var(--wa-green), #8FB4FF, #2563EB);
  animation: wa-spin 6s linear infinite;
}
.wa-btn::before {
  padding: 1.5px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.wa-btn::after { z-index: -2; filter: blur(16px); opacity: .32; transition: opacity .45s; }
.wa-btn:hover { transform: translateY(-3px); }
.wa-btn:hover::after { opacity: .6; }
.wa-btn:focus-visible { outline: 2px solid var(--cyan, #26BDDF); outline-offset: 4px; }
@keyframes wa-spin { to { --wa-a: 360deg; } }

/* brillo que cruza al pasar el ratón */
.wa-shine { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.wa-shine::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .16), transparent);
  transform: skewX(-18deg); transition: left .8s var(--ease, ease);
}
.wa-btn:hover .wa-shine::before { left: 120%; }

/* avatar con punto "en línea" */
.wa-av { position: relative; flex: none; width: 44px; height: 44px; }
.wa-av img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px rgba(255, 255, 255, .14); }
.wa-live { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--wa-green); box-shadow: 0 0 0 2.5px #0B0E14; }
.wa-live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--wa-green); animation: wa-ping 2.2s cubic-bezier(0, 0, .2, 1) infinite; }
@keyframes wa-ping { 70%, 100% { transform: scale(2.6); opacity: 0; } }

/* texto */
.wa-txt {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  max-width: 220px; overflow: hidden; white-space: nowrap;
  transition: max-width .55s var(--ease, ease), opacity .35s, margin .55s var(--ease, ease);
}
.wa-txt b { font-size: 14.5px; font-weight: 700; letter-spacing: -.005em; line-height: 1.15; }
.wa-txt small { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; line-height: 1.2; color: #A6B0C4; letter-spacing: .02em; }
.wa-txt small i { width: 6px; height: 6px; border-radius: 50%; background: var(--wa-green); box-shadow: 0 0 8px var(--wa-green); }

/* icono */
.wa-ic {
  position: relative; flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(120% 120% at 30% 20%, #4BE88A, var(--wa-green) 45%, #0FA968);
  box-shadow: 0 8px 18px -6px rgba(37, 211, 102, .65), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .45s var(--ease, ease);
}
.wa-ic svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.wa-btn:hover .wa-ic { transform: rotate(-12deg) scale(1.06); }

/* ---------- Globo de mensaje ---------- */
.wa-bubble {
  position: relative; width: min(300px, calc(100vw - 32px));
  padding: 14px 16px 12px; border-radius: 22px 22px 6px 22px;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--line, #E1E6F2);
  box-shadow: 0 30px 60px -28px rgba(16, 19, 24, .35), 0 2px 6px rgba(16, 19, 24, .05);
  color: var(--ink, #101318); cursor: pointer;
  transform-origin: 100% 100%;
  animation: wa-pop .55s var(--ease, ease) both;
}
.wa-bubble[hidden] { display: none; }
@keyframes wa-pop { from { opacity: 0; transform: translateY(10px) scale(.92); } }
.wa-b-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted, #4B5263); }
.wa-b-head i { width: 7px; height: 7px; border-radius: 50%; background: var(--wa-green); box-shadow: 0 0 0 3px rgba(37, 211, 102, .18); }
.wa-b-head span { font-weight: 500; color: var(--faint, #8A91A3); }
.wa-msg { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--ink-2, #2A3040); }
.wa-msg b { color: var(--ink, #101318); }
.wa-typing { display: inline-flex; gap: 4px; padding: 6px 0 4px; }
.wa-typing i { width: 7px; height: 7px; border-radius: 50%; background: #B6C0D4; animation: wa-dot 1s infinite ease-in-out; }
.wa-typing i:nth-child(2) { animation-delay: .15s; }
.wa-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes wa-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.wa-bubble.is-typing .wa-msg { display: none; }
.wa-bubble:not(.is-typing) .wa-typing { display: none; }
.wa-bubble:not(.is-typing) .wa-msg { animation: wa-pop .4s var(--ease, ease) both; }
.wa-x {
  position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; padding: 0; cursor: pointer;
  background: #fff; border: 1px solid var(--line, #E1E6F2); color: var(--muted, #4B5263);
  box-shadow: 0 6px 14px -6px rgba(16, 19, 24, .25);
}
.wa-x svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.wa-x:hover { color: var(--ink, #101318); }

/* ---------- Móvil: compacta, se abre al tocar el globo ---------- */
@media (max-width: 640px) {
  .wa-txt { max-width: 0; opacity: 0; margin-right: -12px; }
  .wa-btn { gap: 12px; }
  .wa.is-open .wa-txt { max-width: 200px; opacity: 1; margin-right: 0; }
  .wa-av, .wa-ic { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .wa, .wa-btn, .wa-txt, .wa-ic { transition: none; }
  .wa-btn::before, .wa-btn::after, .wa-live::after, .wa-typing i { animation: none; }
  .wa-bubble, .wa-bubble .wa-msg { animation: none; }
}
