/* =========================
   TOUR THEME TOKENS
   Uses your existing site variables
   ========================= */

:root{
  /* Fallbacks only, in case a var isn't defined in your main CSS */
  --tour-surface: var(--surface, #ffffff);
  --tour-surface2: var(--surface2, #f8fafc);
  --tour-text: var(--text, #0f172a);
  --tour-muted: var(--muted, #64748b);
  --tour-border: var(--border, rgba(15,23,42,.12));

  --tour-primary: var(--primary, #4F2185);
  --tour-primary-contrast: var(--primaryText, #ffffff);

  --tour-shadow: 0 18px 60px rgba(0,0,0,.22);
  --tour-ring: color-mix(in srgb, var(--tour-primary) 85%, transparent);

  /* Overlay */
  --tour-overlay: rgba(0,0,0,.55);

  /* Card radius */
  --tour-radius: 16px;
}

/* If your dark mode is based on html[data-theme="dark"], this is optional.
   Keep it if your variables don't fully shift in dark mode. */
html[data-theme="dark"]{
  --tour-overlay: rgba(0,0,0,.65);
  --tour-shadow: 0 22px 70px rgba(0,0,0,.45);
  --tour-border: var(--border, rgba(255,255,255,.14));
}

/* =========================
   TOUR OVERLAY
   ========================= */

#tourOverlay{
  position: fixed;
  inset: 0;
  background: var(--tour-overlay);
  z-index: 9998;
  cursor: pointer;
}

/* Prevent background scrolling while tour is open */
body.tour-open{
  overflow: hidden;
}

/* =========================
   TOUR BUBBLE WRAPPER
   ========================= */

#tourBubble{
  position: fixed;
  z-index: 9999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* Card container injected by JS */
#tourBubble .tourCard{
  background: var(--tour-surface);
  color: var(--tour-text);
  border-radius: var(--tour-radius);
  box-shadow: var(--tour-shadow);
  border: 1px solid var(--tour-border);
  overflow: hidden;
  animation: tour-pop .18s ease-out;
}

/* =========================
   HEADER
   ========================= */

#tourBubble .tourHeader{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--tour-surface2);
  border-bottom: 1px solid var(--tour-border);
}

#tourBubble .tourTitle{
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .2px;
}

#tourBubble .tourX{
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--tour-muted);
}

#tourBubble .tourX:hover{
  background: color-mix(in srgb, var(--tour-border) 30%, transparent);
  color: var(--tour-text);
}

#tourBubble .tourX:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--tour-ring);
  border-color: color-mix(in srgb, var(--tour-primary) 60%, transparent);
}

/* =========================
   BODY
   ========================= */

#tourBubble .tourBody{
  padding: 14px;
  font-size: 14px;
  line-height: 1.55;
  color: color-mix(in srgb, var(--tour-text) 82%, var(--tour-muted));
}

/* =========================
   FOOTER / CONTROLS
   ========================= */

#tourBubble .tourFooter{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--tour-surface2);
  border-top: 1px solid var(--tour-border);
}

#tourBubble .tourCount{
  font-size: 12px;
  color: var(--tour-muted);
}

#tourBubble .tourBtns{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Match your existing .btn feel without relying on it */
#tourBubble .tourBtn{
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--tour-border);
  background: var(--tour-surface);
  color: var(--tour-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .04s ease, background-color .12s ease, border-color .12s ease;
}

#tourBubble .tourBtn:hover{
  background: color-mix(in srgb, var(--tour-surface2) 55%, var(--tour-surface));
}

#tourBubble .tourBtn:active{
  transform: translateY(1px);
}

#tourBubble .tourBtn.primary{
  background: var(--tour-primary);
  border-color: color-mix(in srgb, var(--tour-primary) 80%, #000);
  color: var(--tour-primary-contrast);
}

#tourBubble .tourBtn.primary:hover{
  background: color-mix(in srgb, var(--tour-primary) 92%, #000);
}

#tourBubble .tourBtn.danger{
  background: color-mix(in srgb, #ef4444 86%, var(--tour-surface));
  border-color: color-mix(in srgb, #ef4444 65%, transparent);
  color: #fff;
}

#tourBubble .tourBtn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* =========================
   TARGET HIGHLIGHT
   ========================= */

.tour-target{
  position: relative;
  z-index: 9999;
  border-radius: 12px;
  box-shadow:
    0 0 0 3px var(--tour-ring),
    0 0 0 9999px var(--tour-overlay);
}

/* Optional: better highlight if target has sharp corners */
.tour-target.tour-square{
  border-radius: 10px;
}

/* =========================
   ANIMATIONS
   ========================= */

@keyframes tour-pop{
  from{ transform: scale(.98) translateY(6px); opacity: 0; }
  to{ transform: scale(1) translateY(0); opacity: 1; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  #tourBubble .tourCard{ animation: none; }
  #tourBubble .tourBtn{ transition: none; }
}