/* tour.css - Web App Tour System Styles (v4 - Gold Theme with Purple Buttons) */

:root {
  --tour-accent: #ffb800; /* Neon Golden Yellow */
  --tour-accent-soft: #ffe494; /* Soft yellow for subtitle/subtext */
  --tour-accent-glow: rgba(255, 184, 0, 0.65);
  --tour-accent-glow-soft: rgba(255, 184, 0, 0.25);
  --tour-accent-rays: rgba(255, 184, 0, 0.035);
  /* Purple Brand Buttons */
  --tour-gradient: linear-gradient(135deg, var(--accent) 0%, #8b85ff 100%);
  --tour-gradient-hover: linear-gradient(135deg, #7c75ff 0%, #9a94ff 100%);
  --tour-brand-glow: rgba(108, 99, 255, 0.4);
  --tour-brand-glow-soft: rgba(108, 99, 255, 0.2);
}

/* Tour Overlay Backdrop */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 12, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: auto; /* Blocks clicks on underlying elements */
}

.tour-overlay.visible {
  opacity: 1;
}

.tour-parent-stacking {
  z-index: 1000000 !important;
  overflow: visible !important;
}

/* Specificity overrides for layout elements with high specificity */
.bottom-nav.sidebar-nav.tour-parent-stacking,
.app-top-bar.tour-parent-stacking,
.topbar.tour-parent-stacking {
  z-index: 10000000 !important;
  overflow: visible !important;
}

/* Highlighted Element Pop-out Zoom with Gold Outline and Glow */
.tour-highlighted-element {
  z-index: 10000001 !important;
  pointer-events: auto !important; /* Keep interactive */
  transform: scale(1.03) !important;
  box-shadow: 0 0 30px var(--tour-accent-glow), 0 0 80px var(--tour-accent-glow-soft) !important;
  outline: 2px solid var(--tour-accent) !important;
  outline-offset: 4px !important;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

/* Tour Dialog Box - Glassmorphic design with Ray Pulse animation */
.tour-popup {
  position: absolute;
  width: min(380px, 90vw);
  z-index: 10000002;
  display: flex;
  flex-direction: column;
  overflow: visible; /* Let rays overflow */
  pointer-events: none; /* Clicks on empty ray space pass through */
  opacity: 0;
  transform: scale(0.9) translateY(15px);
  animation: tourPopupBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Sibling card holding content to overlay rays */
.tour-popup-card {
  background: rgba(18, 18, 26, 0.96);
  border: 1.5px solid var(--tour-accent-glow);
  border-radius: 16px;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5), 
    0 0 30px var(--tour-accent-glow-soft),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  pointer-events: auto; /* enable interactions on actual card */
  position: relative;
  z-index: 2; /* Render strictly in front of rays */
}

/* Moving/Rotating Conic Light Rays in the Background */
.tour-popup-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 600px;
  height: 600px;
  transform: translate(-50%, -50%) rotate(0deg);
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 15deg,
    var(--tour-accent-rays) 15deg 30deg,
    transparent 30deg 45deg
  );
  animation: tourRaysRotate 25s linear infinite;
  z-index: 1; /* Render behind card */
  pointer-events: none;
  border-radius: 50%;
  transform-origin: center center;
}

@keyframes tourPopupBounce {
  0% {
    transform: scale(0.9) translateY(15px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes tourRaysRotate {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Popup Header with Mascot Face SVG */
.tour-popup-header {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.tour-mascot-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  border: 2px solid var(--tour-accent);
  box-shadow: 0 0 15px var(--tour-accent-glow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.tour-mascot-avatar svg {
  width: 88%;
  height: 88%;
  display: block;
}

.tour-popup-title-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tour-popup-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.tour-popup-subtitle {
  margin: 0;
  font-size: 0.72rem;
  color: var(--tour-accent-soft);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Close/Cross Button */
.tour-popup-close-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 1.4rem;
  font-weight: 300;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  position: absolute;
  top: -2px;
  right: -2px;
  transition: color 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tour-popup-close-btn:hover {
  color: var(--danger);
  transform: scale(1.1);
}

/* Description Body */
.tour-popup-body {
  font-size: 0.88rem;
  line-height: 1.5;
  color: rgba(240, 240, 245, 0.9);
}

.tour-popup-body p {
  margin: 0;
}

/* Auto-Advance Timer Progress Bar */
.tour-progress-bar-wrap {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.tour-progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--tour-accent) 0%, #ffe494 100%);
  transform-origin: left center;
}

/* Footer / Navigation Row */
.tour-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
  margin-top: 4px;
}

.tour-popup-skip-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s ease;
}

.tour-popup-skip-btn:hover {
  color: var(--text);
}

.tour-popup-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tour-popup-step-indicator {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  font-family: monospace;
}

.tour-popup-next-btn {
  background: var(--tour-gradient);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--tour-brand-glow-soft);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tour-popup-next-btn:hover {
  transform: translateY(-1px);
  background: var(--tour-gradient-hover);
  box-shadow: 0 6px 16px var(--tour-brand-glow);
}

.tour-popup-next-btn:active {
  transform: translateY(1px);
}

/* Bottom-Left Fixed Floating Tour Launch Button (Symmetrical to Browse Sessions) */
.floating-tour-btn {
  position: fixed;
  bottom: 92px;
  left: 18px;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background: var(--tour-gradient);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 32px var(--tour-brand-glow), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  z-index: 99998; /* Under tour overlay */
  white-space: nowrap;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), padding 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
}

.floating-tour-btn .tour-btn-text {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  transition: max-width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease, margin 0.3s ease;
  margin-left: 0;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Pulsing Ray Effect on the Button (Purple standard branding) */
.floating-tour-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid var(--tour-brand-glow);
  animation: floatingBtnRayPulse 2.2s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes floatingBtnRayPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0;
  }
}

.floating-tour-btn:hover {
  width: 150px;
  padding: 0 16px;
  transform: translateY(-4px);
  box-shadow: 0 12px 40px var(--tour-brand-glow);
}

.floating-tour-btn:hover .tour-btn-text {
  max-width: 100px;
  opacity: 1;
  margin-left: 8px;
}

.floating-tour-btn:active {
  transform: translateY(-1px);
}

.floating-tour-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* Mascot Speech Bubble Card */
.tour-mascot-bubble {
  position: fixed;
  bottom: 160px; /* Sits above the floating button */
  left: 18px;
  width: min(340px, 85vw);
  z-index: 99997;
  opacity: 0;
  transform: translateY(15px) scale(0.9);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.tour-mascot-bubble.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.tour-mascot-bubble-card {
  background: rgba(18, 18, 26, 0.96);
  border: 1.5px solid var(--tour-accent-glow);
  border-radius: 14px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 20px var(--tour-accent-glow-soft);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  cursor: pointer;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Little triangle pointer at the bottom of the card pointing to the button */
.tour-mascot-bubble-card::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--tour-accent);
  opacity: 0.8;
}

.tour-mascot-bubble-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.tour-mascot-bubble-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--tour-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tour-mascot-bubble-msg {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.tour-mascot-bubble-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.tour-mascot-bubble-close:hover {
  color: var(--danger);
}

@media (max-width: 767px) {
  .floating-tour-btn {
    bottom: 88px; /* Symmetrical to mobile sticky-voice-cta level */
    left: 8px;    /* Opposite of right: 8px */
    width: 54px;
    height: 54px;
  }
  .tour-mascot-bubble {
    bottom: 154px;
    left: 8px;
  }
}

/* === Mobile Responsive (additive) — <=768px only === */
@media (max-width: 768px) {
  /* The 600px decorative sunburst extends past the popup and forces
     horizontal page scroll on phones */
  .tour-popup-rays {
    display: none;
  }

  .tour-popup {
    max-width: calc(100vw - 24px);
  }
}
