/* ============================================================
   HONDANA — La Presencia (avatar v4)
   Rostro sereno andrógino que emerge de la sombra. Se comporta
   como acompañante: grande en el hero, se aleja al hacer scroll,
   vuelve al hover o al iniciar sesión.
   ============================================================ */

#hondana-avatar {
  position: fixed;
  z-index: 40;
  pointer-events: auto;
  cursor: pointer;
  transition:
    top 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    right 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    bottom 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.7s ease;
  will-change: transform, width, height, top, right, bottom, opacity;
}

/* Hero — presente pero sin invadir el texto */
#hondana-avatar[data-state="hero"] {
  top: 88px;
  right: 24px;
  width: 340px;
  height: 460px;
  opacity: 1;
}

/* Retreated — pequeño en esquina inferior derecha al scrollear */
#hondana-avatar[data-state="retreated"] {
  top: auto;
  right: 24px;
  bottom: 24px;
  width: 96px;
  height: 128px;
  opacity: 0.78;
}

/* Focus — cuando el usuario interactúa (hover o click) */
#hondana-avatar[data-state="focus"] {
  top: 72px;
  right: 24px;
  width: 380px;
  height: 512px;
  opacity: 1;
}

/* Wrapper de las dos capas de imagen (cerrados / abiertos) */
.hondana-avatar-layers {
  position: relative;
  width: 100%;
  height: 100%;
  /* Animación viva: respiración + deriva muy sutil */
  animation: hondana-breath 5.5s ease-in-out infinite;
}

.hondana-avatar-layers img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  /* Cross-fade entre las dos imágenes */
  transition: opacity 0.85s cubic-bezier(0.4, 0, 0.2, 1);
}

.hondana-avatar-layers .is-closed { opacity: 1; }
.hondana-avatar-layers .is-open { opacity: 0; }

/* Estado focus/attention: abrir ojos */
#hondana-avatar[data-attention="on"] .is-closed { opacity: 0; }
#hondana-avatar[data-attention="on"] .is-open { opacity: 1; }

/* Parpadeo espontáneo: un frame casi imperceptible cada X segundos */
#hondana-avatar[data-blink="on"] .is-closed { opacity: 1; }
#hondana-avatar[data-blink="on"] .is-open { opacity: 0; }

/* Respiración: escala + deriva vertical muy lenta */
@keyframes hondana-breath {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.018) translateY(-3px); }
}

/* Halo dorado sutil (glow) alrededor del rostro cuando está en focus */
#hondana-avatar[data-state="focus"] .hondana-avatar-layers::before,
#hondana-avatar[data-state="hero"] .hondana-avatar-layers::before {
  content: "";
  position: absolute;
  inset: -8%;
  background: radial-gradient(
    ellipse 55% 45% at 50% 42%,
    rgba(212, 165, 84, 0.14) 0%,
    rgba(212, 165, 84, 0.06) 40%,
    rgba(212, 165, 84, 0) 75%
  );
  pointer-events: none;
  z-index: -1;
  filter: blur(24px);
}

/* Respeta reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .hondana-avatar-layers { animation: none; }
  #hondana-avatar { transition: opacity 0.3s ease; }
}

/* Mobile: tamaños reducidos */
@media (max-width: 768px) {
  #hondana-avatar[data-state="hero"] {
    top: 84px;
    right: 8px;
    width: 180px;
    height: 240px;
    opacity: 0.92;
  }
  #hondana-avatar[data-state="retreated"] {
    right: 10px;
    bottom: 10px;
    width: 64px;
    height: 86px;
  }
  #hondana-avatar[data-state="focus"] {
    top: 72px;
    right: 8px;
    width: 220px;
    height: 292px;
  }
}

/* Ocultar por completo si tiene .hidden */
#hondana-avatar.hidden {
  opacity: 0;
  pointer-events: none;
}
