/* Luna avatars: 64px default display, with opt-in animation variants. */
.luna-avatar {
  display: inline-block;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: #fff8ef;
  vertical-align: middle;
}

.luna-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Smooth idle motion is separate from the compact WebP blink frames. */
.luna-avatar--lively img {
  transform-origin: 50% 80%;
  animation: luna-avatar-idle 6s ease-in-out infinite;
}

@keyframes luna-avatar-idle {
  0%, 100% { transform: translateY(0) rotate(-0.5deg) scale(0.97); }
  20% { transform: translateY(-1.2%) rotate(1.5deg) scale(0.985); }
  40% { transform: translateY(-0.5%) rotate(0.5deg) scale(0.98); }
  48% { transform: translateY(0.9%) rotate(0.2deg) scale(0.97); }
  56% { transform: translateY(0) rotate(0.5deg) scale(0.98); }
  75% { transform: translateY(-0.8%) rotate(-1.3deg) scale(0.985); }
}

@media (prefers-reduced-motion: reduce) {
  .luna-avatar--lively img {
    animation: none;
    transform: none;
  }
}

/* Separate head and shoulders for a readable, deliberate gesture at 64px. */
.luna-avatar--expressive {
  position: relative;
  isolation: isolate;
  background: radial-gradient(circle at 50% 36%, #fffdf7, #f7eede);
}
.luna-avatar--expressive .luna-avatar__body {
  position: absolute;
  left: 2.5%;
  bottom: -4%;
  width: 95%;
  height: 46.55%;
  object-fit: fill;
}
.luna-avatar__head {
  position: absolute;
  left: 20%;
  top: 0.5%;
  width: 60%;
  height: 70.3125%;
  overflow: hidden;
  transform-origin: 50% 96%;
  animation: luna-avatar-head-gesture 10.8s cubic-bezier(0.45, 0, 0.25, 1) infinite;
}
.luna-avatar--expressive .luna-avatar__face {
  width: 200%;
  max-width: none;
  height: 100%;
  object-fit: fill;
  animation: luna-avatar-expressive-blink 12.7s steps(1, end) infinite;
}
/* Unequal gestures and independent blink timing avoid a pendulum rhythm. */
@keyframes luna-avatar-head-gesture {
  0%, 9%, 43%, 53%, 82%, 100% {
    transform: rotate(0deg);
  }
  22%, 29% {
    transform: rotate(-4.5deg);
  }
  64%, 70% {
    transform: rotate(2.5deg);
  }
}
@keyframes luna-avatar-expressive-blink {
  0%, 15.1%, 50.1%, 82.1%, 100% { transform: translateX(0); }
  14%, 49%, 81% { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .luna-avatar__head,
  .luna-avatar--expressive .luna-avatar__face {
    animation: none;
    transform: none;
  }
}

/* Drawn Luna state cues: thinking while .ai-loading is on the answer box
   (or .luna-avatar--thinking), one nod when the answer arrives. Pure CSS, no JS. */
.luna-avatar--expressive .luna-avatar__thinking-face {
  position: absolute;
  left: 0;
  top: 0;
  width: 200%;
  max-width: none;
  height: 100%;
  object-fit: fill;
  visibility: hidden;
  pointer-events: none;
}
.luna-avatar--expressive.luna-avatar--thinking .luna-avatar__thinking-face,
.ai-loading .luna-avatar--expressive .luna-avatar__thinking-face {
  visibility: visible;
  animation: luna-avatar-expressive-blink 12.7s steps(1, end) infinite;
}
/* The sibling selector keeps existing one-image avatars working. */
.luna-avatar--expressive.luna-avatar--thinking .luna-avatar__thinking-face + .luna-avatar__face,
.ai-loading .luna-avatar--expressive .luna-avatar__thinking-face + .luna-avatar__face {
  visibility: hidden;
}
.luna-avatar--expressive .luna-avatar__think {
  position: absolute;
  z-index: 2;
  top: 13%;
  right: 5%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9%;
  width: 38%;
  height: 19%;
  border: 1px solid #c9d8cd;
  border-radius: 999px;
  background: #fff;
  opacity: 0;
  transform: scale(0.4);
  transform-origin: 0 100%;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.3, 1.6, 0.6, 1);
}
.luna-avatar__think i {
  display: block;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #2a7a45;
}
.luna-avatar--thinking .luna-avatar__think,
.ai-loading .luna-avatar--expressive .luna-avatar__think {
  opacity: 1;
  transform: scale(1);
}
.luna-avatar--thinking .luna-avatar__think i,
.ai-loading .luna-avatar--expressive .luna-avatar__think i {
  animation: luna-avatar-dot 1.2s ease-in-out infinite;
}
.luna-avatar__think i:nth-child(2) { animation-delay: 0.16s; }
.luna-avatar__think i:nth-child(3) { animation-delay: 0.32s; }
.luna-avatar--expressive.luna-avatar--thinking .luna-avatar__head,
.ai-loading .luna-avatar--expressive .luna-avatar__head {
  animation: luna-avatar-ponder 3.2s ease-in-out infinite;
}
.luna-avatar--expressive.luna-avatar--answered:not(.luna-avatar--thinking) .luna-avatar__head,
.ai-odgovor:not(.ai-loading):not(.preview-idle) .luna-avatar--expressive:not(.luna-avatar--thinking) .luna-avatar__head {
  animation: luna-avatar-nod 0.9s ease-in-out 0.1s 1 both,
    luna-avatar-head-gesture 10.8s cubic-bezier(0.45, 0, 0.25, 1) 1s infinite;
}
@keyframes luna-avatar-ponder {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(-4deg); }
}
@keyframes luna-avatar-nod {
  0%, 100% { translate: 0 0; }
  30% { translate: 0 4%; }
  55% { translate: 0 -1%; }
  75% { translate: 0 1.5%; }
}
@keyframes luna-avatar-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-35%); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .luna-avatar--expressive .luna-avatar__head,
  .luna-avatar--expressive .luna-avatar__thinking-face,
  .luna-avatar--expressive .luna-avatar__think,
  .luna-avatar--expressive .luna-avatar__think i {
    animation: none !important;
    transition: none;
  }
}

/* Vprasaj Luno answer box (vprasaj-ai.asp): 64px on desktop, 52px on phones. */
.ai-odgovor-head .luna-avatar {
  width: 64px;
  height: 64px;
}
.ai-odgovor .ai-odgovor-head:has(.luna-avatar) {
  gap: 10px;
  margin-bottom: 8px;
}
@media (max-width: 480px) {
  .ai-odgovor-head .luna-avatar {
    width: 52px;
    height: 52px;
  }
}

/* Vprasaj Luno intro: Luna beside the heading, visible before the first question. */
.ai-luna-intro {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 12px;
}
.ai-luna-intro .luna-avatar {
  width: 96px;
  height: 96px;
}
.ai-luna-intro-text {
  min-width: 0;
}
#recepti.seznam .ai-luna-intro-text h1 {
  margin: 0 0 10px;
}
.ai-luna-intro-text .ai-vprasaj-uvod {
  margin-bottom: 0;
}
@media (max-width: 480px) {
  .ai-luna-intro {
    gap: 12px;
  }
  .ai-luna-intro .luna-avatar {
    width: 72px;
    height: 72px;
  }
}

/* "Luna priporoča" on the recipe search results: thinks while .ai-loading is on #aiPredlogi. */
.ai-predlogi-naslov .luna-avatar {
  width: 48px;
  height: 48px;
}
.ai-predlogi-naslov:has(.luna-avatar) {
  gap: 10px;
}
