/* ==========================================================================
   Regalo Digital - Character & Dialogue Bubble CSS
   ========================================================================== */

/* Character Wrapper - Pops out of the box on top of everything */
.character-stage {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%) translateY(140px) scale(0);
  width: 200px;
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  z-index: 40 !important; /* Above box lid and body */
  opacity: 0;
  pointer-events: none;
  overflow: visible !important; /* No clipping for ears, head crown, or dialogue */
  transition: opacity 0.3s ease;
}

.character-stage.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Dialogue Bubble Container - High Z-Index & Larger Size */
.dialogue-bubble {
  position: absolute;
  top: -95px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  width: max-content;
  max-width: 330px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  color: var(--text-main);
  padding: 16px 24px;
  border-radius: 22px;
  box-shadow: 
    0 14px 36px rgba(0, 0, 0, 0.22),
    0 0 0 3.5px rgba(255, 255, 255, 0.7);
  z-index: 100 !important; /* Highest layer */
  text-align: center;
  font-family: var(--font-heading);
  transform-origin: bottom center;
  transition: transform 0.4s var(--transition-bounce), opacity 0.3s ease;
  opacity: 0;
  overflow: visible !important;
}

.dialogue-bubble.is-visible {
  transform: translateX(-50%) scale(1);
  opacity: 1;
}

/* Bubble Arrow Tail */
.dialogue-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0 10px;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.97) transparent transparent transparent;
}

/* Larger Readable Phrase Text */
.phrase-content {
  font-size: 1.25rem !important;
  font-weight: 700;
  color: #2b124c;
  line-height: 1.35;
  transition: all 0.35s ease-in-out;
}

.phrase-counter {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Animation presets for phrases */
.phrase-anim-fade-in {
  opacity: 0;
  transform: translateY(6px);
}

.phrase-anim-fade-active {
  opacity: 1;
  transform: translateY(0);
}

.phrase-anim-slide-in {
  opacity: 0;
  transform: translateX(-20px);
}

.phrase-anim-slide-active {
  opacity: 1;
  transform: translateX(0);
}

.phrase-anim-scale-in {
  opacity: 0;
  transform: scale(0.8);
}

.phrase-anim-scale-active {
  opacity: 1;
  transform: scale(1);
}

/* Next / Tap Hint */
.dialogue-tap-hint {
  font-size: 0.72rem;
  color: var(--primary);
  margin-top: 6px;
  font-weight: 700;
  animation: pulseHint 1.5s infinite alternate;
  cursor: pointer;
}

@keyframes pulseHint {
  0% { opacity: 0.55; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}
