/* Context-aware, draggable Ludo guide shared across Lucido pages. */
.ludo-character {
  position: fixed;
  z-index: 2147483647;
  display: block;
  width: 96px;
  height: 96px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  box-shadow: none;
  cursor: grab;
  font: inherit;
  line-height: normal;
  appearance: none;
  touch-action: none;
  user-select: none;
  overflow: visible;
  transition: none;
  -webkit-tap-highlight-color: transparent;
  contain: layout style;
  isolation: isolate;
}

.ludo-character:hover {
  background: transparent;
  color: inherit;
  box-shadow: none;
  transform: none;
  filter: drop-shadow(0 5px 4px rgba(28, 31, 36, 0.2));
}

.ludo-character:focus-visible {
  outline: 3px solid #ff2c55;
  outline-offset: 3px;
  box-shadow: none;
  transform: none;
}

.ludo-character.is-dragging {
  cursor: grabbing;
  filter: drop-shadow(0 6px 5px rgba(28, 31, 36, 0.25));
}

.ludo-character.is-pacing {
  will-change: left, top;
}

.ludo-character.is-stumbling {
  cursor: default;
  transform-origin: 50% 78%;
  will-change: transform;
  animation: ludo-stumble-and-recover 1650ms steps(12, end) both;
}

.ludo-character.is-stumbling::before,
.ludo-character.is-stumbling::after {
  content: '';
  top: 13px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff2c55;
  opacity: 1;
  box-shadow: 11px -7px 0 #f4b942;
  animation: ludo-stumble-stars 520ms steps(4, end) 2;
}

.ludo-character.is-stumbling::before {
  left: 12px;
}

.ludo-character.is-stumbling::after {
  right: 12px;
  animation-delay: 110ms;
}

.ludo-character__image {
  display: block;
  width: 96px;
  height: 96px;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-user-drag: none;
}

.ludo-character[data-facing="left"] .ludo-character__image {
  transform: scaleX(-1);
}

/* Extra contextual emotions reuse Ludo's native loops and add crisp effects. */
.ludo-character::before,
.ludo-character::after {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
}

.ludo-character[data-action="excited"]:not(.is-dragging) {
  animation: ludo-excited-hop 480ms steps(2, end) infinite;
}

.ludo-character[data-action="excited"]::before,
.ludo-character[data-action="excited"]::after {
  content: '';
  width: 8px;
  height: 8px;
  background: #ff2c55;
  opacity: 1;
  box-shadow: 18px 8px 0 #d92346;
  animation: ludo-spark 760ms steps(2, end) infinite alternate;
}

.ludo-character[data-action="excited"]::before {
  top: 9px;
  left: 13px;
}

.ludo-character[data-action="excited"]::after {
  top: 17px;
  right: 17px;
  animation-delay: 180ms;
}

.ludo-character[data-action="focused"]::before {
  content: '';
  top: 13px;
  right: 13px;
  width: 19px;
  height: 19px;
  border: 3px solid #ff2c55;
  border-radius: 50%;
  opacity: 1;
  animation: ludo-focus-pulse 900ms steps(2, end) infinite alternate;
}

.ludo-character[data-action="focused"]::after {
  content: '';
  top: 33px;
  right: 8px;
  width: 14px;
  height: 3px;
  background: #ff2c55;
  opacity: 1;
  transform: rotate(48deg);
  transform-origin: left center;
  animation: ludo-focus-pulse 900ms steps(2, end) infinite alternate;
}

.ludo-character[data-action="loving"] {
  filter: drop-shadow(0 5px 4px rgba(255, 44, 85, 0.3));
}

.ludo-heart {
  position: absolute;
  z-index: 3;
  top: 22px;
  left: calc(50% + var(--heart-x));
  color: #ff2c55;
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 0) scale(var(--heart-scale));
  text-shadow: 1px 1px 0 #ffffff;
  animation: ludo-heart-rise 1500ms steps(8, end) var(--heart-delay) forwards;
}

@keyframes ludo-excited-hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes ludo-spark {
  from { transform: scale(0.65) rotate(0); }
  to { transform: scale(1.1) rotate(45deg); }
}

@keyframes ludo-focus-pulse {
  from { filter: brightness(0.9); }
  to { filter: brightness(1.25); }
}

@keyframes ludo-heart-rise {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.4); }
  15% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -72px) scale(var(--heart-scale)); }
}

@keyframes ludo-stumble-and-recover {
  0% { transform: translate(0, 0) rotate(0); }
  8% { transform: translate(-4px, 1px) rotate(-7deg); }
  17% { transform: translate(5px, 3px) rotate(12deg); }
  27% { transform: translate(-7px, 6px) rotate(-18deg); }
  39% { transform: translate(7px, 12px) rotate(34deg); }
  50% { transform: translate(12px, 22px) rotate(78deg); }
  61% { transform: translate(12px, 22px) rotate(78deg); }
  72% { transform: translate(8px, 15px) rotate(52deg); }
  82% { transform: translate(4px, 8px) rotate(25deg); }
  91% { transform: translate(-2px, 2px) rotate(-7deg); }
  96% { transform: translate(1px, 0) rotate(3deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

@keyframes ludo-stumble-stars {
  0%, 100% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  25% { transform: translate(-5px, -8px) scale(1); opacity: 1; }
  50% { transform: translate(3px, -14px) scale(0.75); opacity: 1; }
  75% { transform: translate(8px, -7px) scale(1); opacity: 0.65; }
}

@media (prefers-reduced-motion: reduce) {
  .ludo-character,
  .ludo-character::before,
  .ludo-character::after,
  .ludo-character__image {
    animation: none;
  }

  .ludo-character.is-stumbling {
    animation: none;
  }

  .ludo-heart {
    top: -5px;
    opacity: 1;
    animation: none;
  }
}

@media print {
  .ludo-character {
    display: none;
  }
}
