/* ============================================================
   Visual Reality — Eco Wizard "Ecoverius" (image edition)
   Fixed inside the hero banner: stands at the bottom-left of the
   hero illustration, right beside the "Our mission" button row.
   Not floating: no position:fixed, he belongs to the banner.
   ============================================================ */

.hero-wizard {
  position: absolute;
  left: -0.75rem;
  bottom: 0.5%;
  width: clamp(170px, 19vw, 250px);
  z-index: 3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: 28px;
  outline: none;
}

.hero-wizard:focus-visible {
  outline: 3px solid rgba(13, 148, 136, 0.6);
  outline-offset: 6px;
}

/* --- the character --- */
.wizard-img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 94%;
  filter: drop-shadow(0 16px 22px rgba(11, 31, 22, 0.2));
  animation: wiz-idle 5.4s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

/* gentle idle bob (he still breathes — he just doesn't float away) */
@keyframes wiz-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-6px) scale(1.004); }
}

/* squash & stretch on click */
.hero-wizard.is-bounce .wizard-img {
  animation: wiz-bounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes wiz-bounce {
  0%   { transform: scale(1, 1); }
  30%  { transform: scale(1.06, 0.9) translateY(4px); }
  60%  { transform: scale(0.96, 1.06) translateY(-8px); }
  100% { transform: scale(1, 1) translateY(0); }
}

/* while TTS is speaking: the staff-crystal aura pulses */
.hero-wizard.is-speaking .wizard-img {
  animation: wiz-idle 5.4s ease-in-out infinite,
             wiz-glow 1.15s ease-in-out infinite;
}

@keyframes wiz-glow {
  0%, 100% { filter: drop-shadow(0 16px 22px rgba(11, 31, 22, 0.2))
                    drop-shadow(0 0 10px rgba(16, 185, 129, 0.28)); }
  50%      { filter: drop-shadow(0 16px 22px rgba(11, 31, 22, 0.2))
                    drop-shadow(0 0 26px rgba(16, 185, 129, 0.62)); }
}

/* ground shadow, breathing with the bob */
.wizard-shadow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 62%;
  height: 16px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(11, 31, 22, 0.22) 0%, transparent 70%);
  animation: wiz-shadow 5.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes wiz-shadow {
  0%, 100% { transform: translateX(-50%) scale(1);     opacity: 0.9; }
  50%      { transform: translateX(-50%) scale(0.84);  opacity: 0.6; }
}

/* --- magic sparkles around staff crystal & seedling hand --- */
.wizard-sparkle {
  position: absolute;
  font-size: 15px;
  color: #10b981;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.75);
  animation: wiz-twinkle 2.8s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

.wizard-sparkle.s1 { top: 13%; left: 4%;  animation-delay: 0s; }
.wizard-sparkle.s2 { top: 4%;  right: 22%; color: #f5b940; text-shadow: 0 0 10px rgba(245, 185, 64, 0.75); animation-delay: 0.9s; }
.wizard-sparkle.s3 { top: 34%; right: -4%; animation-delay: 1.7s; }

@keyframes wiz-twinkle {
  0%, 100% { opacity: 0;   transform: scale(0.4) rotate(0deg); }
  50%      { opacity: 1;   transform: scale(1.15) rotate(24deg); }
}

/* --- speech bubble --- */
.wizard-bubble {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-56%) translateY(10px) scale(0.96);
  width: min(340px, 82vw);
  background: #ffffff;
  border: 1.5px solid rgba(13, 148, 136, 0.28);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 18px 44px rgba(11, 31, 22, 0.16);
  padding: 12px 15px 10px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), visibility 0.28s;
  z-index: 40;
}

.wizard-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, #10b981, #0d9488);
}

.wizard-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 26px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-left: 1.5px solid rgba(13, 148, 136, 0.28);
  border-bottom: 1.5px solid rgba(13, 148, 136, 0.28);
  transform: rotate(-45deg);
}

.wizard-bubble.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-56%) translateY(0) scale(1);
}

.bubble-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.bubble-name {
  font-family: var(--font-display, "Sora", sans-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: #0b7a5c;
  letter-spacing: 0.02em;
}

.bubble-mute {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 14px;
  border: none;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.bubble-mute:hover { background: rgba(16, 185, 129, 0.24); transform: scale(1.08); }

.bubble-mute[aria-pressed="true"] { opacity: 0.55; filter: grayscale(1); }

.bubble-text {
  font-size: 0.92rem;
  line-height: 1.55;
  color: #23423a;
  min-height: 4.6em;
  overflow-wrap: break-word;
}

.bubble-text.typing::after {
  content: "▍";
  color: #0d9488;
  animation: wiz-caret 0.8s steps(1) infinite;
}

@keyframes wiz-caret {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

.bubble-hint {
  margin-top: 5px;
  font-size: 0.76rem;
  color: #64807a;
}

/* --- responsive --- */
@media (max-width: 1180px) and (min-width: 1025px) {
  .hero-wizard { width: 185px; left: -0.5rem; }
  .wizard-bubble { width: 300px; }
}

/* hero collapses to one column — wizard stands centered under the art */
@media (max-width: 1024px) {
  .hero-wizard {
    position: relative;
    left: auto;
    bottom: auto;
    width: 168px;
    margin: 0.4rem auto 0;
  }

  .wizard-bubble {
    left: 50%;
    transform: translateX(-50%) translateY(10px) scale(0.96);
  }

  .wizard-bubble.show {
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@media (max-width: 560px) {
  .hero-wizard { width: 132px; }
  .wizard-bubble { width: min(300px, 88vw); }
  .bubble-text { font-size: 0.86rem; min-height: 5em; }
  .wizard-sparkle { font-size: 12px; }
}

/* --- reduced motion: a calm, still wizard --- */
@media (prefers-reduced-motion: reduce) {
  .wizard-img,
  .wizard-shadow,
  .wizard-sparkle,
  .hero-wizard.is-speaking .wizard-img {
    animation: none !important;
  }

  .wizard-bubble,
  .wizard-bubble.show {
    transition: opacity 0.2s ease;
    transform: translateX(-56%) translateY(0) scale(1);
  }

  @media (max-width: 1024px) {
    .wizard-bubble,
    .wizard-bubble.show {
      transform: translateX(-50%) translateY(0) scale(1);
    }
  }
}
