/* ============================================================
   Onboarding Tour — first-run interactive product walkthrough
   Spotlight + glass tooltip + animated welcome / finale.
   Self-contained; only depends on variables.css design tokens.
   ============================================================ */

:root {
  --ob-z: 99000;                 /* above navbar(500)/modal(900)/toast(1000) */
  --ob-accent: #0071e3;
  --ob-accent-2: #5856d6;
  --ob-accent-3: #af52de;
  --ob-dim: rgba(14, 16, 24, 0.62);
}

/* Lock scroll while the tour runs */
body.ob-active { overflow: hidden; }

/* Root layer — everything the tour draws lives here */
.ob-root {
  position: fixed;
  inset: 0;
  z-index: var(--ob-z);
  font-family: var(--font-family-primary, 'Inter', sans-serif);
  -webkit-font-smoothing: antialiased;
}
.ob-root[hidden] { display: none; }

/* ---- Click-catcher backdrop (transparent; blocks page interaction) ---- */
.ob-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  cursor: default;
}

/* ============================================================
   SPOTLIGHT — a moving cut-out that dims everything else
   ============================================================ */
.ob-spotlight {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  border-radius: 18px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px var(--ob-dim);
  transition:
    top    600ms cubic-bezier(0.16, 1, 0.3, 1),
    left   600ms cubic-bezier(0.16, 1, 0.3, 1),
    width  600ms cubic-bezier(0.16, 1, 0.3, 1),
    height 600ms cubic-bezier(0.16, 1, 0.3, 1),
    border-radius 400ms ease,
    box-shadow 400ms ease;
  will-change: top, left, width, height;
}
/* Animated glow ring hugging the highlighted element */
.ob-spotlight::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  padding: 3px;
  background: linear-gradient(135deg, var(--ob-accent), var(--ob-accent-2), var(--ob-accent-3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0.95;
  animation: ob-ring-pulse 2.4s ease-in-out infinite;
}
.ob-spotlight::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  box-shadow: 0 0 26px 4px rgba(0, 113, 227, 0.45);
  animation: ob-ring-pulse 2.4s ease-in-out infinite;
}
@keyframes ob-ring-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.015); }
}
/* Full-dim state used for welcome / finale (no target) */
.ob-spotlight.is-center {
  box-shadow: 0 0 0 9999px var(--ob-dim);
}
.ob-spotlight.is-center::before,
.ob-spotlight.is-center::after { display: none; }

/* ============================================================
   TOOLTIP — the glass coaching card
   ============================================================ */
.ob-tip {
  position: absolute;
  width: min(360px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.88));
  -webkit-backdrop-filter: blur(24px);
          backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  box-shadow:
    0 20px 60px rgba(16, 18, 30, 0.28),
    0 2px 8px rgba(16, 18, 30, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  padding: 22px 22px 18px;
  color: var(--color-text-primary, #1a1a1a);
  max-height: calc(100vh - 24px);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 380ms ease, transform 520ms cubic-bezier(0.16, 1, 0.3, 1),
              top 520ms cubic-bezier(0.16, 1, 0.3, 1),
              left 520ms cubic-bezier(0.16, 1, 0.3, 1);
}
.ob-tip.is-shown { opacity: 1; transform: translateY(0) scale(1); }

/* Card taller than the viewport: scroll inside itself so the footer
   buttons are always reachable (overflow clips the arrow, so it hides). */
.ob-tip.is-scroll { overflow-y: auto; overscroll-behavior: contain; }
.ob-tip.is-scroll .ob-tip__arrow { display: none; }

/* Little pointer arrow */
.ob-tip__arrow {
  position: absolute;
  width: 16px; height: 16px;
  background: inherit;
  border: inherit;
  transform: rotate(45deg);
  box-shadow: -2px -2px 6px rgba(16,18,30,0.05);
}
.ob-tip[data-place="top"]    .ob-tip__arrow { bottom: -8px; border-top: 0; border-left: 0; }
.ob-tip[data-place="bottom"] .ob-tip__arrow { top: -8px; border-bottom: 0; border-right: 0; }
.ob-tip[data-place="left"]   .ob-tip__arrow { right: -8px; border-bottom: 0; border-left: 0; }
.ob-tip[data-place="right"]  .ob-tip__arrow { left: -8px; border-top: 0; border-right: 0; }
.ob-tip[data-place="center"] .ob-tip__arrow { display: none; }

/* Header: icon chip + step counter */
.ob-tip__top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.ob-tip__icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--ob-accent), var(--ob-accent-2));
  box-shadow: 0 6px 16px rgba(0, 113, 227, 0.35);
}
.ob-tip__icon svg { width: 22px; height: 22px; }
.ob-tip__count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary, #8a8a8a);
  font-variant-numeric: tabular-nums;
}
.ob-tip__title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.ob-tip__body {
  font-size: 0.925rem;
  line-height: 1.6;
  color: var(--color-text-secondary, #4a4a4a);
  margin: 0;
}

/* Progress dots */
.ob-tip__dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 16px 0 14px;
}
.ob-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(0,0,0,0.14);
  transition: all 320ms ease;
  cursor: pointer;
}
.ob-dot.is-active {
  width: 22px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--ob-accent), var(--ob-accent-2));
}
.ob-dot.is-done { background: rgba(0, 113, 227, 0.4); }

/* Footer buttons */
.ob-tip__foot {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ob-btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 11px;
  padding: 9px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 150ms ease, background 200ms ease, box-shadow 200ms ease, opacity 200ms ease;
  white-space: nowrap;
}
.ob-btn:active { transform: scale(0.96); }
.ob-btn--ghost {
  background: transparent;
  color: var(--color-text-tertiary, #8a8a8a);
  padding: 9px 10px;
}
.ob-btn--ghost:hover { color: var(--color-text-primary, #1a1a1a); }
.ob-btn--back {
  background: rgba(0,0,0,0.05);
  color: var(--color-text-secondary, #4a4a4a);
  border-color: rgba(0,0,0,0.06);
}
.ob-btn--back:hover { background: rgba(0,0,0,0.09); }
.ob-btn--next {
  margin-left: auto;
  color: #fff;
  background: linear-gradient(135deg, var(--ob-accent), var(--ob-accent-2));
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.32);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.ob-btn--next:hover { box-shadow: 0 10px 26px rgba(0, 113, 227, 0.45); transform: translateY(-1px); }
.ob-btn--next svg { width: 15px; height: 15px; }

/* ============================================================
   WELCOME / FINALE big card (uses .ob-tip.is-hero)
   ============================================================ */
.ob-tip.is-hero {
  width: min(440px, calc(100vw - 32px));
  padding: 30px 30px 24px;
  text-align: center;
  overflow: hidden;
}
.ob-tip.is-hero .ob-tip__top { flex-direction: column; margin-bottom: 18px; }
.ob-tip.is-hero .ob-tip__count { display: none; }
.ob-hero-badge {
  width: 76px; height: 76px;
  border-radius: 22px;
  margin: 4px auto 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--ob-accent), var(--ob-accent-2), var(--ob-accent-3));
  box-shadow: 0 14px 34px rgba(88, 86, 214, 0.4);
  position: relative;
  animation: ob-badge-in 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.ob-hero-badge svg { width: 40px; height: 40px; }
@keyframes ob-badge-in {
  from { opacity: 0; transform: scale(0.4) rotate(-12deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}
/* Orbiting sparkle */
.ob-hero-badge::after {
  content: "✦";
  position: absolute;
  top: -6px; right: -4px;
  font-size: 20px;
  color: #ffd66b;
  text-shadow: 0 0 10px rgba(255, 214, 107, 0.8);
  animation: ob-sparkle 2.2s ease-in-out infinite;
}
@keyframes ob-sparkle {
  0%, 100% { opacity: 0.3; transform: scale(0.7) rotate(0); }
  50%      { opacity: 1;   transform: scale(1.1) rotate(20deg); }
}
.ob-tip.is-hero .ob-tip__title { font-size: 1.65rem; margin-top: 14px; }
.ob-tip.is-hero .ob-tip__body { font-size: 0.98rem; max-width: 34ch; margin: 0 auto; }
.ob-tip.is-hero .ob-tip__foot { margin-top: 22px; flex-direction: column; }
.ob-tip.is-hero .ob-btn--next {
  margin-left: 0;
  width: 100%;
  justify-content: center;
  padding: 13px 16px;
  font-size: 0.95rem;
}
.ob-tip.is-hero .ob-btn--ghost { width: 100%; }

/* Soft decorative gradient blobs inside hero card */
.ob-hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.35;
  pointer-events: none;
}
.ob-hero-orb--1 { width: 160px; height: 160px; background: #0071e3; top: -50px; left: -40px; }
.ob-hero-orb--2 { width: 140px; height: 140px; background: #af52de; bottom: -50px; right: -30px; }

/* ============================================================
   CONFETTI (finale)
   ============================================================ */
.ob-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.ob-confetti i {
  position: absolute;
  top: -12px;
  width: 9px; height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: ob-fall linear forwards;
}
@keyframes ob-fall {
  0%   { opacity: 1; transform: translateY(-20px) rotate(0deg); }
  100% { opacity: 0.9; transform: translateY(102vh) rotate(720deg); }
}

/* ============================================================
   Pulse hint on a highlighted target (optional)
   ============================================================ */
@media (max-width: 640px) {
  .ob-tip { width: calc(100vw - 24px); }
}

/* Reduced motion — disable big movement/animation */
@media (prefers-reduced-motion: reduce) {
  .ob-spotlight,
  .ob-tip { transition: opacity 200ms ease; }
  .ob-spotlight::before,
  .ob-spotlight::after,
  .ob-hero-badge,
  .ob-hero-badge::after { animation: none; }
  .ob-confetti { display: none; }
}
