/* =============================================
   Guide Character - Interactive Onboarding Guide
   ============================================= */

/* --- Main container --- */
#guide-character {
  position: absolute;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  transition: top 0.5s ease, left 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

#guide-character.visible {
  pointer-events: auto;
}

#guide-character.hidden {
  opacity: 0;
  pointer-events: none;
}

/* --- Avatar --- */
.guide-avatar {
  flex-shrink: 0;
  animation: guideFloat 3s ease-in-out infinite;
}

/* --- Speech bubble --- */
.guide-bubble {
  position: relative;
  background: #fff;
  border: 2px solid #6470dc;
  border-radius: 16px;
  padding: 16px 36px 16px 16px;
  box-shadow: 0 4px 20px rgba(100, 112, 220, 0.2);
  max-width: 260px;
  min-width: 180px;
  opacity: 0;
  transform: scale(0.8) translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#guide-character.visible .guide-bubble {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Bubble arrow pointing right toward avatar */
.guide-bubble::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 24px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 10px solid #6470dc;
}

.guide-bubble::before {
  content: '';
  position: absolute;
  right: -7px;
  top: 25px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 9px solid #fff;
  z-index: 1;
}

/* --- Bubble text --- */
.guide-text {
  margin: 0 0 12px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  font-weight: 500;
}

/* --- Close button --- */
.guide-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.guide-close:hover {
  color: #333;
  background: #f0f0f0;
}

/* --- Next button --- */
.guide-next {
  display: inline-block;
  background: #6470dc;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.guide-next:hover {
  background: #5058c4;
}

.guide-next:active {
  transform: scale(0.95);
}

.guide-next.guide-hidden {
  display: none;
}

/* --- Recall button --- */
.guide-recall {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #6470dc;
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(100, 112, 220, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: guidePulse 2s ease-in-out infinite;
}

.guide-recall.visible {
  display: flex;
}

.guide-recall:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(100, 112, 220, 0.5);
}

.guide-recall-icon {
  font-size: 24px;
  font-weight: 700;
}

.guide-recall-label {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: #333;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.guide-recall:hover .guide-recall-label {
  opacity: 1;
}

/* --- Field highlight --- */
.guide-highlight {
  box-shadow: 0 0 0 3px rgba(100, 112, 220, 0.4) !important;
  border-color: #6470dc !important;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* --- Animations --- */
@keyframes guideFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes guidePulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(100, 112, 220, 0.4); }
  50% { box-shadow: 0 4px 24px rgba(100, 112, 220, 0.7); }
}

@keyframes guideFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Desktop layout: bubble left, avatar right --- */
@media (min-width: 769px) {
  #guide-character {
    flex-direction: row;
  }
}

/* --- Mobile layout --- */
@media (max-width: 768px) {
  #guide-character {
    position: fixed !important;
    bottom: 90px !important;
    right: 16px !important;
    top: auto !important;
    left: auto !important;
    flex-direction: column-reverse;
    align-items: flex-end;
  }

  .guide-avatar {
    width: 80px;
    height: 80px;
  }

  .guide-avatar lottie-player {
    width: 80px !important;
    height: 80px !important;
  }

  .guide-bubble {
    max-width: 240px;
    min-width: 160px;
  }

  /* Reposition arrow to point down toward avatar */
  .guide-bubble::after {
    right: 24px;
    top: auto;
    bottom: -10px;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #6470dc;
    border-bottom: none;
  }

  .guide-bubble::before {
    right: 25px;
    top: auto;
    bottom: -7px;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 9px solid #fff;
    border-bottom: none;
  }
}
