/* ═══════════════════════════════════════════════════════════════════════
   PetCompanionSystem — estilos de las mascotas virtuales de Edalst Pets
   Todo es aditivo: no modifica reglas existentes del sitio.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Escenario del hero (reemplaza la ilustración SVG) ─────────────── */
.pets-hero-stage {
  position: relative;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 560 / 480;
  margin-inline: auto;
  overflow: hidden;
}
.pets-hero-stage::before {
  content: "";
  position: absolute;
  inset: 6% 4% 10% 4%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.28) 58%, rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
}
.pets-hero-stage::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 7%;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(232, 178, 125, 0.28) 0%, rgba(232, 178, 125, 0) 70%);
  pointer-events: none;
}
.pets-stage-deco {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

/* ── Mascota (unidad reutilizable en todas las zonas) ──────────────── */
.pet {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 96px;
  height: 96px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;               /* presión larga táctil: sin menú nativo */
  outline-offset: 4px;
  transition: width 0.25s ease, height 0.25s ease;   /* cambio de tamaño suave entre zonas */
}
.pet:focus-visible { outline: 3px solid #f37b21; border-radius: 12px; }
.pet .pet-sprite {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  image-rendering: pixelated;
  transform-origin: 50% 88%;
  will-change: transform;
  backface-visibility: hidden;               /* sin destello al espejar el frame */
  transition: transform 0.13s ease;          /* giro suave al cambiar de dirección */
}
.pet .pet-shadow {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 2px;
  height: 9%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(60, 40, 20, 0.20) 0%, rgba(60, 40, 20, 0) 72%);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.pet .pet-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.pet.dragging { z-index: 30; }
.pet.dragging .pet-sprite { filter: drop-shadow(0 10px 10px rgba(60, 40, 20, 0.25)); }
.pet.dragging .pet-shadow { opacity: 0.4; transform: scale(1.25); }
.pet.dragging, .pet.dragging * { cursor: grabbing !important; }
.pet.no-pointer { pointer-events: none; }
/* Durante un arrastre, ninguna otra parte de la página selecciona texto */
body.pets-dragging { user-select: none; -webkit-user-select: none; }
body.pets-dragging .pet { cursor: grabbing; }

/* Aparición suave al entrar en una zona (en .pet-body para no pisar
   el transform de posición del nodo raíz) */
.pet.pet-enter .pet-body { animation: petPop 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) both; }
@keyframes petPop {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.pet.pet-leave .pet-body { animation: petBye 0.35s ease both; }
@keyframes petBye {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}

/* Corazones / estrellas de celebración */
.pet-heart {
  position: absolute;
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  animation: petFloatUp 1.15s ease-out forwards;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
@keyframes petFloatUp {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.5); }
  15%  { opacity: 1; transform: translate(calc(var(--dx) * 0.2), -10px) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), -52px) scale(0.85); }
}

/* ── Zona HERO ─────────────────────────────────────────────────────── */
.pets-hero-stage .pet { z-index: 2; }

/* ── Zona CATÁLOGO: pasarela (playground) ──────────────────────────── */
.pets-playground {
  position: relative;
  height: 150px;
  margin-top: 40px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 100%, rgba(243, 123, 33, 0.07) 0%, rgba(243, 123, 33, 0) 42%),
    radial-gradient(circle at 88% 0%, rgba(32, 175, 169, 0.07) 0%, rgba(32, 175, 169, 0) 45%),
    linear-gradient(180deg, #ffffff 0%, #fff8f0 100%);
  border: 1.5px solid rgba(224, 200, 175, 0.55);
}
.pets-playground::before {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 14px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(232, 178, 125, 0.22) 0%, rgba(232, 178, 125, 0) 70%);
  pointer-events: none;
}
.pets-playground .pet { z-index: 2; }

/* ── Zona CATÁLOGO: asomo por el borde inferior del viewport ───────── */
.pets-peek-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  z-index: 320;
  pointer-events: none;
}
.pets-peek-layer .pet {
  pointer-events: none;           /* nunca intercepta clics comerciales */
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* ── Zona CARRITO + CHECKOUT: mascota anclada sobre los botones ────── */
/* Los paneles comercian con posición estática: solo les damos un
   contexto de anclaje (sin cambio visual alguno). */
#cart-drawer .side-panel-inner,
#panel-checkout .side-panel-inner { position: relative; }

.pet-in-cart {
  z-index: 6;
  pointer-events: none !important;   /* los botones siguen siendo 100% clicables */
  transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1), top 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.pet-in-cart.pet-hide { opacity: 0; }

/* ── Objetos interactivos ──────────────────────────────────────────── */
.pet-object {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  image-rendering: auto;
  will-change: transform;
}

/* ── Botón y panel de ajustes (discreto) ───────────────────────────── */
#pets-settings-btn {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 450;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(224, 200, 175, 0.8);
  background: rgba(255, 255, 255, 0.92);
  color: var(--orange, #f37b21);
  font-size: 15px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(22, 32, 42, 0.12);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#pets-settings-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 18px rgba(22, 32, 42, 0.16); }
#pets-settings-btn.pets-off { color: #b9a898; }

#pets-settings-pop {
  position: fixed;
  left: 14px;
  bottom: 62px;
  z-index: 451;
  width: 208px;
  background: #fff;
  border: 1.5px solid rgba(224, 200, 175, 0.8);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(22, 32, 42, 0.16);
  padding: 12px;
  display: none;
}
#pets-settings-pop.open { display: block; }
#pets-settings-pop .psp-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink, #22303c);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
#pets-settings-pop .psp-title i { color: var(--orange, #f37b21); }
.psp-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.psp-btn {
  flex: 1 1 auto;
  border: 1.5px solid rgba(224, 200, 175, 0.9);
  background: #fff;
  color: var(--ink, #22303c);
  font-weight: 600;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 5px 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.psp-btn:hover { background: #fff4ea; }
.psp-btn.active { background: var(--orange, #f37b21); border-color: var(--orange, #f37b21); color: #fff; }
.psp-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink, #22303c);
  padding: 4px 2px;
  cursor: pointer;
  user-select: none;
}
.psp-toggle input { accent-color: var(--orange, #f37b21); width: 14px; height: 14px; cursor: pointer; }
.psp-vol {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: var(--ink, #22303c);
  padding: 3px 2px 1px;
}
.psp-vol i { color: var(--orange, #f37b21); width: 14px; text-align: center; }
.psp-vol input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: var(--orange, #f37b21);
  cursor: pointer;
}
.psp-vol.psp-vol-off { opacity: 0.45; }

/* ── Responsividad ─────────────────────────────────────────────────── */
@media (max-width: 1020px) {
  .pets-playground { height: 132px; margin-top: 28px; }
}
@media (max-width: 640px) {
  .pets-playground { height: 112px; margin-top: 22px; }
  #pets-settings-btn { width: 36px; height: 36px; font-size: 13px; }
  .pet-heart { font-size: 11px; }
}

/* ── Accesibilidad: menos movimiento ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pet.pet-enter, .pet.pet-leave, .pet-heart { animation: none; }
  .pets-peek-layer .pet, .pet-in-cart { transition: none; }
  #pets-settings-btn { transition: none; }
  .pet .pet-sprite { transition: none; }
}

/* El sistema pausado congela el fotograma actual */
.pets-frozen .pet-sprite { animation-play-state: paused; }
