/* ==========================================================================
   Mascota de Isa Dev: el punto verde del logo, con patitas.
   Pasea por el borde de abajo y de vez en cuando cuenta algo de la página.
   Usa los colores de styles.css (--accent, --ink, --orange…).
   ========================================================================== */

.mascota {
  --m-size: 64px;
  position: fixed; left: 0; bottom: 14px; z-index: 39;
  width: var(--m-size); height: calc(var(--m-size) * 1.125);
  transform: translate3d(-120px, 0, 0);
  pointer-events: none;
}
.mascota[hidden] { display: none; }

/* El botón es todo el personaje: se puede tocar o enfocar con Tab */
.mascota__btn {
  display: block; width: 100%; height: 100%; padding: 0;
  border: 0; border-radius: 50% 50% 40% 40%; background: none; cursor: pointer;
  pointer-events: auto; -webkit-tap-highlight-color: transparent;
}
.mascota__btn:focus-visible { outline: 3px solid var(--aqua-text); outline-offset: 4px; }

.mascota__giro { display: block; width: 100%; height: 100%; transition: transform 160ms var(--ease-out); }
.mascota.mira-izq .mascota__giro { transform: scaleX(-1); }

.mascota svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mascota .m-cuerpo  { fill: var(--accent); }
.mascota .m-brillo  { fill: #fff; opacity: .35; }
.mascota .m-sombra  { fill: var(--ink); opacity: .12; transform-box: fill-box; transform-origin: center; }
.mascota .m-tinta   { fill: var(--ink); }
.mascota .m-trazo   { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.mascota .m-mejilla { fill: var(--orange); opacity: .45; }
.mascota .m-boca-abierta { display: none; }

/* piezas que se mueven: cada una gira desde su unión con el cuerpo */
.mascota .m-pierna, .mascota .m-brazo { transform-box: fill-box; transform-origin: 50% 0; }
.mascota .m-ojos  { transform-box: fill-box; transform-origin: center; }
.mascota .m-sombra { transform-box: fill-box; transform-origin: center; }
/* todo el cuerpo se inclina hacia adelante al andar, apoyado en los pies */
.mascota .m-salto { transform-box: view-box; transform-origin: 32px 66px; transition: rotate 220ms var(--ease-out); }
.mascota .m-cuerpo-grupo { transform-box: view-box; transform-origin: 32px 56px; }

/* ---------- Caminar y correr ----------
   --m-d es lo que dura un paso; el JS lo calcula con la velocidad para que
   los pies no "patinen". Un ciclo = dos pasos (izquierdo y derecho).        */
.mascota { --m-d: 210ms; --m-ang: 24deg; --m-ang-brazo: 30deg; --m-alto: 2.4px; }
.mascota.is-running { --m-ang: 34deg; --m-ang-brazo: 55deg; --m-alto: 3.6px; }

.mascota.is-walking .m-salto  { rotate: 4deg; }
.mascota.is-running .m-salto  { rotate: 11deg; }

.mascota.is-walking .m-pierna--izq, .mascota.is-running .m-pierna--izq,
.mascota.is-walking .m-brazo--der,  .mascota.is-running .m-brazo--der  { animation: m-pendulo var(--m-d) ease-in-out infinite alternate; }
.mascota.is-walking .m-pierna--der, .mascota.is-running .m-pierna--der,
.mascota.is-walking .m-brazo--izq,  .mascota.is-running .m-brazo--izq  { animation: m-pendulo var(--m-d) ease-in-out infinite alternate-reverse; }
.mascota.is-walking .m-brazo, .mascota.is-running .m-brazo { --m-ang: var(--m-ang-brazo); }

/* un rebote por paso: arriba cuando la pierna pasa por debajo, abajo al pisar */
.mascota.is-walking .m-cuerpo-grupo, .mascota.is-running .m-cuerpo-grupo { animation: m-rebote var(--m-d) ease-in-out infinite; }
.mascota.is-walking .m-sombra,       .mascota.is-running .m-sombra       { animation: m-sombra var(--m-d) ease-in-out infinite; }

@keyframes m-pendulo { from { transform: rotate(var(--m-ang)); } to { transform: rotate(calc(var(--m-ang) * -1)); } }
@keyframes m-rebote  {
  0%, 100% { translate: 0 0; scale: 1.03 .97; }   /* al pisar se aplasta un poquito */
  50%      { translate: 0 calc(var(--m-alto) * -1); scale: .99 1.01; }
}
@keyframes m-sombra  { 50% { scale: .86 1; opacity: .08; } }

/* Parpadeo de vez en cuando */
.mascota .m-ojos { animation: m-parpadeo 4.2s infinite; }
@keyframes m-parpadeo { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }

/* Hablando: la boca se abre y se cierra, y saluda con el brazo de adelante */
.mascota.is-talking .m-boca { animation: m-boca-cerrada 360ms steps(1) infinite; }
.mascota.is-talking .m-boca-abierta { display: block; animation: m-boca-abierta 360ms steps(1) infinite; }
@keyframes m-boca-cerrada { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes m-boca-abierta { 0% { opacity: 0; } 50% { opacity: 1; } }
.mascota.is-waving .m-brazo--der { animation: m-saludo 900ms ease-in-out; }
@keyframes m-saludo {
  25%, 75% { transform: rotate(-140deg); }
  50%      { transform: rotate(-105deg); }
}

/* Al tocarla da un saltito (respuesta al clic) */
.mascota.is-hop .m-cuerpo-grupo { animation: m-salto 340ms var(--ease-out); }
@keyframes m-salto {
  0%   { translate: 0 0; scale: 1.06 .94; }
  40%  { translate: 0 -9px; scale: .96 1.04; }
  100% { translate: 0 0; scale: 1 1; }
}
.mascota__btn:active .m-cuerpo-grupo { scale: 1.04 .95; }

/* ---------- Globo de texto ---------- */
.mascota-globo {
  --tail: 32px;
  position: fixed; left: 0; bottom: 0; z-index: 41;
  width: max-content; max-width: min(260px, calc(100vw - 32px));
  padding: 12px 40px 12px 14px; border-radius: 16px;
  background: #fff; border: 1px solid var(--line-2);
  box-shadow: 0 18px 40px -18px rgba(36, 23, 15, .35);
  color: var(--ink); font: 400 14px/1.45 var(--font-body);
  transform-origin: var(--tail) 100%;
  opacity: 0; transform: translateY(6px) scale(.96); visibility: hidden;
  transition: opacity 150ms ease, transform 150ms ease, visibility 0s 150ms;
}
.mascota-globo.is-open {
  opacity: 1; transform: none; visibility: visible;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
/* la colita apunta a la mascota */
.mascota-globo::after {
  content: ""; position: absolute; top: 100%; left: calc(var(--tail) - 7px);
  width: 14px; height: 14px; margin-top: -7px; transform: rotate(45deg);
  background: #fff; border: solid var(--line-2); border-width: 0 1px 1px 0;
}
.mascota-globo__texto { margin: 0; }
.mascota-globo__texto b { font-weight: 600; }
.mascota-globo__accion {
  display: inline-flex; align-items: center; min-height: 36px; margin-top: 2px;
  color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.mascota-globo__cerrar {
  position: absolute; top: 2px; right: 2px; width: 36px; height: 36px;
  display: grid; place-items: center; border: 0; border-radius: 50%; background: none;
  color: var(--faint); cursor: pointer; transition: color 150ms ease, background-color 150ms ease;
}
.mascota-globo__cerrar svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mascota-globo__cerrar:focus-visible { outline: 3px solid var(--aqua-text); outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  .mascota-globo__cerrar:hover { color: var(--ink); background: var(--surface-2); }
  .mascota-globo__accion:hover { color: var(--ink); }
}

/* En el celular: más chica y por encima de la barra de WhatsApp */
@media (max-width: 767px) {
  .mascota { --m-size: 52px; bottom: calc(76px + 10px + env(safe-area-inset-bottom)); }
}

/* Movimiento reducido: se queda quieta en su rincón y el globo solo aparece con un fundido */
@media (prefers-reduced-motion: reduce) {
  .mascota .m-pierna, .mascota .m-brazo, .mascota .m-cuerpo-grupo, .mascota .m-ojos, .mascota .m-sombra { animation: none !important; }
  .mascota .m-salto { rotate: none !important; }
  .mascota-globo { transform: none !important; }
}

@media print { .mascota, .mascota-globo { display: none !important; } }
