/* ==========================================================================
   ScienceHub - Interactive Guided Lab Tours (Talking Interactive Walkthroughs)
   Sleek floating HUD, spoken audio subtitles, quick-check quizzes, and spotlights
   ========================================================================== */

/* ===== Spotlight highlight around interactive elements ===== */
.tour-spotlight-active {
  box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.55), 0 0 20px rgba(79, 110, 247, 0.35) !important;
  border-radius: 8px !important;
  position: relative !important;
  z-index: 990 !important;
  outline: 2px solid rgba(79, 110, 247, 0.8) !important;
  outline-offset: 3px !important;
  animation: tourSpotlightPulse 2s infinite ease-in-out !important;
  transition: box-shadow 0.3s ease, outline 0.3s ease !important;
}

@keyframes tourSpotlightPulse {
  0% {
    box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.5), 0 0 16px rgba(79, 110, 247, 0.25);
    outline-color: rgba(79, 110, 247, 0.7);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(79, 110, 247, 0.8), 0 0 30px rgba(79, 110, 247, 0.5);
    outline-color: rgba(79, 110, 247, 1);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.5), 0 0 16px rgba(79, 110, 247, 0.25);
    outline-color: rgba(79, 110, 247, 0.7);
  }
}

/* ===== Floating Guided Tour Caption Bar ===== */
.tour-caption-bar {
  position: relative;
  margin: 1rem auto;
  max-width: 820px;
  width: calc(100% - 1.5rem);
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e0e4ef);
  border-radius: 16px;
  box-shadow: var(--shadow-xl, 0 20px 50px rgba(0, 0, 0, 0.15));
  overflow: hidden;
  z-index: 995;
  animation: tourSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

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

/* Progress bar along the very top */
.tour-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary, #edf0f7);
  overflow: hidden;
}

.tour-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f6ef7 0%, #7c3aed 50%, #22c55e 100%);
  transition: width 0.35s ease;
}

/* Header bar */
.tour-caption-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.1rem;
  background: var(--bg-secondary, #fafbfc);
  border-bottom: 1px solid var(--border-color, #e0e4ef);
  gap: 0.75rem;
}

.tour-caption-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.tour-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  background: rgba(79, 110, 247, 0.12);
  color: var(--accent-primary, #4f6ef7);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tour-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: tourPulse 1.8s infinite;
}

@keyframes tourPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.tour-step-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #8a90a8);
}

.tour-module-title {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text-primary, #141726);
}

.tour-caption-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tour-btn-icon {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: var(--text-secondary, #4a5068);
  transition: all 0.15s ease;
}

.tour-btn-icon:hover {
  background: var(--bg-tertiary, #edf0f7);
  color: var(--text-primary, #141726);
  border-color: var(--border-color, #e0e4ef);
}

.tour-voice-btn.is-muted {
  opacity: 0.6;
  filter: grayscale(1);
}

.tour-close-btn {
  font-size: 1.1rem;
  line-height: 1;
}

/* Content Area */
.tour-caption-content {
  padding: 1.1rem 1.25rem 0.9rem;
}

.tour-step-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #141726);
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.tour-step-narration {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-secondary, #4a5068);
  margin-bottom: 0.8rem;
}

/* Action hint callout */
.tour-action-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(79, 110, 247, 0.08);
  border-left: 3px solid var(--accent-primary, #4f6ef7);
  padding: 0.5rem 0.85rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-primary, #4f6ef7);
  margin-bottom: 0.8rem;
  width: 100%;
}

/* ===== Quick Check Question Dialog ===== */
.tour-check-dialog {
  margin-top: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: var(--bg-tertiary, #edf0f7);
  border: 1px solid var(--border-color, #e0e4ef);
  animation: tourCheckFade 0.25s ease;
}

@keyframes tourCheckFade {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.tour-check-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-primary, #4f6ef7);
  margin-bottom: 0.4rem;
  letter-spacing: 0.03em;
}

.tour-check-question {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text-primary, #141726);
  margin-bottom: 0.85rem;
  line-height: 1.45;
}

.tour-check-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.tour-opt-btn {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 1.5px solid var(--border-color, #d0d7e5);
  background: var(--bg-card, #ffffff);
  color: var(--text-primary, #141726);
  font-size: 0.88rem;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tour-opt-btn:hover:not(:disabled) {
  border-color: var(--accent-primary, #4f6ef7);
  background: rgba(79, 110, 247, 0.06);
  transform: translateY(-1px);
}

.tour-opt-correct {
  border-color: #22c55e !important;
  background: rgba(34, 197, 94, 0.14) !important;
  color: #15803d !important;
  font-weight: 700 !important;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3) !important;
}

.tour-opt-incorrect {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.12) !important;
  color: #b91c1c !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25) !important;
}

.tour-check-feedback {
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  display: none;
  margin-top: 0.5rem;
}

.tour-check-feedback.visible {
  display: block;
}

.tour-check-feedback.is-correct {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.3);
  font-weight: 600;
}

.tour-check-feedback.is-incorrect {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.25);
  font-weight: 550;
}

/* Footer / navigation */
.tour-caption-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.1rem;
  background: var(--bg-secondary, #fafbfc);
  border-top: 1px solid var(--border-color, #e0e4ef);
  gap: 0.75rem;
}

.tour-footer-dots {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tour-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-color, #c8cee0);
  transition: all 0.25s ease;
  cursor: default;
}

.tour-dot.active {
  width: 22px;
  border-radius: 4px;
  background: var(--accent-primary, #4f6ef7);
}

.tour-dot.completed {
  background: #22c55e;
}

.tour-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tour-btn-primary {
  background: var(--accent-primary, #4f6ef7);
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.3);
}

.tour-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover, #3b5ae0);
  transform: translateY(-1px);
}

.tour-btn-primary.pulse-ready {
  animation: tourNextReady 1.6s infinite ease-in-out;
}

@keyframes tourNextReady {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 110, 247, 0.7); }
  70% { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(79, 110, 247, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 110, 247, 0); }
}

.tour-btn-secondary {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #d0d7e5);
  color: var(--text-secondary, #4a5068);
}

.tour-btn-secondary:hover:not(:disabled) {
  background: var(--bg-tertiary, #edf0f7);
  color: var(--text-primary, #141726);
}

.tour-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Guided tour launch button styling */
.btn-guided-tour {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  background: linear-gradient(135deg, #4f6ef7 0%, #7c3aed 100%);
  color: #ffffff !important;
  border: none;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.25);
  transition: all 0.2s ease;
}

.btn-guided-tour:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.4);
  color: #ffffff !important;
}

/* Dark mode adjustments */
[data-theme="dark"] .tour-caption-bar {
  background: rgba(30, 36, 56, 0.95);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tour-caption-header,
[data-theme="dark"] .tour-caption-footer {
  background: rgba(22, 27, 46, 0.95);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .tour-check-dialog {
  background: rgba(20, 24, 40, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .tour-opt-btn {
  background: rgba(35, 42, 66, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f1f3f9;
}

[data-theme="dark"] .tour-opt-btn:hover:not(:disabled) {
  background: rgba(79, 110, 247, 0.25);
  border-color: #4f6ef7;
}

[data-theme="dark"] .tour-opt-correct {
  color: #4ade80 !important;
}

[data-theme="dark"] .tour-opt-incorrect {
  color: #f87171 !important;
}

/* Responsive queries */
@media (max-width: 768px) {
  .tour-caption-bar {
    width: calc(100% - 1rem);
    margin: 0.75rem auto;
  }
  .tour-module-title {
    display: none;
  }
  .tour-check-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .tour-caption-header,
  .tour-caption-footer {
    padding: 0.6rem 0.8rem;
  }
  .tour-caption-content {
    padding: 0.85rem 0.9rem;
  }
  .tour-step-title {
    font-size: 0.98rem;
  }
  .tour-step-narration {
    font-size: 0.88rem;
  }
  .tour-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .tour-spotlight-active,
  .tour-caption-bar,
  .tour-pulse-dot,
  .tour-check-dialog,
  .tour-btn-primary.pulse-ready {
    animation: none !important;
    transition: none !important;
  }
}
