/* ══════════════════════════════════════════════
   tour.css
   Interactive onboarding tour — spotlight + tooltip.

   Architecture:
   - .tour-overlay: fixed full-screen canvas that dims everything
     except a transparent spotlight cutout (clip-path inset technique).
     z-index 480 — above all celebration overlays (max 270) and
     normal modals (200), below signup (500) and onboarding slides (600).
   - .tour-tooltip: the instruction card, absolutely positioned by JS
     relative to the spotlight target.
   - .tour-pulse: faint animated ring drawn around the spotlight to
     draw the eye without being distracting.

   Reuses existing design tokens only (--gold, --gold-glow,
   --surface-deep, --border, --text-bright, --text-muted, --font,
   --font-mono, --radius-lg, --radius-sm, --radius-full,
   --space-*, --ink, --transition).

   Reduced-motion: all decorative animations are disabled.
   The overlay and tooltip remain fully visible and readable.
   ══════════════════════════════════════════════ */

/* ── Overlay canvas ── */
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 480;
    pointer-events: none;    /* transparent areas pass events through */
}

/* The dark veil surrounding the spotlight.
   JS writes --tour-spot-x/y/w/h and repaints on scroll/resize via
   a CSS custom property + clip-path, avoiding a repaint of the overlay
   element itself on every frame. */
.tour-overlay__veil {
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 18, 0.82);
    clip-path: polygon(
        /* outer rectangle */
        0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%,
        /* spotlight cut-out (clockwise hole) */
        var(--tour-x, 40%) var(--tour-y, 30%),
        var(--tour-x, 40%) var(--tour-y2, 40%),
        var(--tour-x2, 60%) var(--tour-y2, 40%),
        var(--tour-x2, 60%) var(--tour-y, 30%),
        var(--tour-x, 40%) var(--tour-y, 30%)
    );
    transition:
        clip-path 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        opacity   0.25s ease;
    animation: tourVeilIn 0.28s ease-out both;
}

@keyframes tourVeilIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tour-overlay.tour-exit .tour-overlay__veil {
    animation: tourVeilOut 0.22s ease-in forwards;
}

@keyframes tourVeilOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ── Spotlight border / pulse ring ──
   An absolutely positioned element that mirrors the spotlight
   rect. JS sets its top/left/width/height inline. */
.tour-spotlight-ring {
    position: absolute;
    border-radius: var(--radius-sm);
    box-shadow:
        0 0 0 2px var(--gold),
        0 0 0 2px rgba(226, 176, 74, 0.35),
        0 0 24px rgba(226, 176, 74, 0.25);
    pointer-events: none;
    transition:
        top    0.35s cubic-bezier(0.22, 1, 0.36, 1),
        left   0.35s cubic-bezier(0.22, 1, 0.36, 1),
        width  0.35s cubic-bezier(0.22, 1, 0.36, 1),
        height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    animation: tourRingPulse 2.4s ease-in-out 0.4s infinite;
}

@keyframes tourRingPulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 0 0 2px rgba(226,176,74,0.35), 0 0 18px rgba(226,176,74,0.20); }
    50%       { box-shadow: 0 0 0 2px var(--gold), 0 0 0 5px rgba(226,176,74,0.22), 0 0 32px rgba(226,176,74,0.38); }
}

/* ── Tooltip card ──
   Positioned by JS. pointer-events: auto so buttons inside are clickable. */
.tour-tooltip {
    position: absolute;
    z-index: 481;
    width: 300px;
    max-width: calc(100vw - 32px);
    background: var(--surface-deep);
    border: 1.5px solid var(--gold);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-5) var(--space-4);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.60),
        0 0 28px rgba(226, 176, 74, 0.18);
    pointer-events: auto;
    animation: tourTooltipIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tourTooltipIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tour-overlay.tour-exit .tour-tooltip {
    animation: tourTooltipOut 0.2s ease-in forwards;
}

@keyframes tourTooltipOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-6px); }
}

/* ── Tooltip arrow ── */
.tour-tooltip::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--surface-deep);
    border-left: 1.5px solid var(--gold);
    border-top: 1.5px solid var(--gold);
    border-radius: 2px 0 0 0;
}

.tour-tooltip[data-arrow="up"]::before {
    top: -7px;
    left: 24px;
    transform: rotate(45deg);
}

.tour-tooltip[data-arrow="down"]::before {
    bottom: -7px;
    left: 24px;
    transform: rotate(225deg);
}

.tour-tooltip[data-arrow="none"]::before {
    display: none;
}

/* ── Tooltip step counter ── */
.tour-step-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.tour-step-dots {
    display: flex;
    gap: var(--space-1);
}

.tour-step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s, transform 0.2s;
}

.tour-step-dot.active {
    background: var(--gold);
    transform: scale(1.25);
}

.tour-step-dot.done {
    background: rgba(226, 176, 74, 0.45);
}

/* ── Tooltip body ── */
.tour-tooltip-title {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--text-bright);
    line-height: 1.3;
    margin-bottom: var(--space-2);
}

.tour-tooltip-body {
    font-size: var(--text-lg);
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: var(--space-4);
}

/* Inline action cue — the highlighted instruction telling users what to do */
.tour-action-cue {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: rgba(226, 176, 74, 0.10);
    border: 1px solid rgba(226, 176, 74, 0.30);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--gold);
    margin-top: var(--space-2);
    letter-spacing: 0.02em;
}

/* ── Tooltip footer ── */
.tour-tooltip-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
}

.tour-skip-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    padding: var(--space-1) 0;
    transition: color 0.18s;
    flex-shrink: 0;
}

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

.tour-skip-btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
    border-radius: 3px;
}

.tour-next-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-sm);
    border: 2px solid var(--gold);
    background: var(--gold);
    color: var(--ink);
    font-family: var(--font);
    font-weight: 700;
    font-size: var(--text-lg);
    cursor: pointer;
    transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
    flex-shrink: 0;
}

.tour-next-btn:hover {
    background: var(--gold-glow);
    border-color: var(--gold-glow);
    box-shadow: 0 0 16px rgba(226, 176, 74, 0.38);
    transform: translateY(-1px);
}

.tour-next-btn:active {
    transform: scale(0.97);
}

.tour-next-btn:focus-visible {
    outline: 3px solid rgba(226, 176, 74, 0.55);
    outline-offset: 3px;
}

/* Hidden while waiting for user action — the button appears only for
   observe-only steps, not action-required steps */
.tour-next-btn.hidden {
    display: none;
}

/* ── "Done" final step button ── */
.tour-done-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-sm);
    border: 2px solid var(--gold);
    background: var(--gold);
    color: var(--ink);
    font-family: var(--font);
    font-weight: 700;
    font-size: var(--text-xl);
    cursor: pointer;
    margin-top: var(--space-3);
    transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
}

.tour-done-btn:hover {
    background: var(--gold-glow);
    border-color: var(--gold-glow);
    box-shadow: 0 0 20px rgba(226, 176, 74, 0.40);
    transform: translateY(-1px);
}

.tour-done-btn:active { transform: scale(0.97); }

.tour-done-btn:focus-visible {
    outline: 3px solid rgba(226, 176, 74, 0.55);
    outline-offset: 3px;
}

/* ── Waiting indicator — animated dot shown when tour waits for user action ── */
.tour-waiting-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-style: italic;
}

.tour-waiting-dots {
    display: flex;
    gap: 4px;
}

.tour-waiting-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: tourWaitBounce 1.2s ease-in-out infinite;
}

.tour-waiting-dot:nth-child(2) { animation-delay: 0.15s; }
.tour-waiting-dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes tourWaitBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%           { transform: translateY(-4px); opacity: 1; }
}

/* ── Spotlight border for nav buttons (circular / pill targets) ── */
.tour-spotlight-ring.tour-spotlight-ring--round {
    border-radius: var(--radius-full);
}

/* ── Responsive: very narrow phones ── */
@media (max-width: 360px) {
    .tour-tooltip { width: 280px; padding: var(--space-4); }
    .tour-tooltip-title { font-size: var(--text-lg); }
}

/* ══════════════════════════════════════════════
   PREFERS-REDUCED-MOTION
   Kill all decorative animations. The overlay,
   spotlight ring, and tooltip remain visible and
   fully functional — only motion is removed.
   ══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .tour-overlay__veil {
        animation: none;
        opacity: 1;
        transition: clip-path 0s, opacity 0s;
    }

    .tour-overlay.tour-exit .tour-overlay__veil {
        animation: none;
        opacity: 0;
    }

    .tour-spotlight-ring {
        animation: none;
        transition: none;
    }

    .tour-tooltip {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .tour-overlay.tour-exit .tour-tooltip {
        animation: none;
        opacity: 0;
    }

    .tour-waiting-dot {
        animation: none;
        opacity: 0.6;
    }

    .tour-step-dot {
        transition: none;
    }

    .tour-next-btn,
    .tour-done-btn {
        transition: none;
    }

    .tour-next-btn:hover,
    .tour-done-btn:hover {
        transform: none;
    }
}
