/* ==========================================================================
   We'll Assist — Guided tour (spotlight walkthrough)
   Vanilla overlay that dims the page, highlights one element at a time, and
   floats a text bubble beside it. Uses the shared design tokens from app.css.
   ========================================================================== */

.tour-active {
    overflow: hidden;
}

/* Full-screen dimmer. The "hole" over the target is punched with a large
   box-shadow spread on the highlight box, so this layer just catches clicks. */
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

/* The spotlight box sits over the target element. The enormous, semi-opaque
   box-shadow spreads outward to darken everything except this rectangle. */
.tour-spotlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-radius: var(--radius, 8px);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.68);
    transition: width 0.25s ease, height 0.25s ease, top 0.25s ease, left 0.25s ease;
    pointer-events: none;
}

/* Subtle ring around the highlighted element. */
.tour-spotlight::after {
    content: "";
    position: absolute;
    inset: -3px;
    border: 2px solid var(--color-primary, #0047ba);
    border-radius: calc(var(--radius, 8px) + 3px);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
}

/* Centered variant (steps with no target element). */
.tour-overlay.is-centered .tour-spotlight {
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.72);
}

.tour-overlay.is-centered .tour-spotlight::after {
    display: none;
}

/* -------------------------------------------------------------------------- */
/* Bubble                                                                     */
/* -------------------------------------------------------------------------- */

.tour-bubble {
    position: fixed;
    z-index: 4001;
    width: min(22rem, calc(100vw - 2rem));
    background: var(--color-surface, #fff);
    color: var(--color-text, #18181b);
    border: 1px solid var(--color-border, #e4e4e7);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
    padding: var(--space-5, 1.25rem);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, top 0.25s ease, left 0.25s ease;
}

.tour-bubble.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Little pointer triangle. Position class set by JS. */
.tour-bubble::before {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e4e4e7);
    transform: rotate(45deg);
}

.tour-bubble.tour-arrow-top::before {
    top: -7px;
    left: var(--tour-arrow-offset, 50%);
    margin-left: -6px;
    border-right: none;
    border-bottom: none;
}

.tour-bubble.tour-arrow-bottom::before {
    bottom: -7px;
    left: var(--tour-arrow-offset, 50%);
    margin-left: -6px;
    border-left: none;
    border-top: none;
}

.tour-bubble.tour-arrow-left::before {
    left: -7px;
    top: var(--tour-arrow-offset, 50%);
    margin-top: -6px;
    border-top: none;
    border-right: none;
}

.tour-bubble.tour-arrow-right::before {
    right: -7px;
    top: var(--tour-arrow-offset, 50%);
    margin-top: -6px;
    border-bottom: none;
    border-left: none;
}

.tour-bubble.tour-arrow-none::before {
    display: none;
}

.tour-bubble-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3, 0.75rem);
    margin-bottom: var(--space-2, 0.5rem);
}

.tour-bubble-title {
    margin: 0;
    font-size: var(--text-lg, 1.125rem);
    font-weight: 600;
    line-height: var(--leading-tight, 1.25);
}

.tour-bubble-body {
    margin: 0;
    font-size: var(--text-sm, 0.875rem);
    line-height: var(--leading-normal, 1.5);
    color: var(--color-text-secondary, #71717a);
}

.tour-close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.25rem -0.25rem 0 0;
    padding: 0;
    border: none;
    border-radius: var(--radius, 8px);
    background: transparent;
    color: var(--color-text-tertiary, #a1a1aa);
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}

.tour-close:hover {
    background: var(--color-surface-muted, #f4f4f5);
    color: var(--color-text, #18181b);
}

/* -------------------------------------------------------------------------- */
/* Footer / controls                                                          */
/* -------------------------------------------------------------------------- */

.tour-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 0.75rem);
    margin-top: var(--space-5, 1.25rem);
}

.tour-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tour-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-border-strong, #d4d4d8);
    transition: background 0.2s ease, transform 0.2s ease;
}

.tour-dot.is-active {
    background: var(--color-primary, #0047ba);
    transform: scale(1.25);
}

.tour-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
}

/* Fall back to sensible button styling if app.css .btn is unavailable. */
.tour-btn {
    font: inherit;
    font-size: var(--text-sm, 0.875rem);
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius, 8px);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tour-btn-ghost {
    background: transparent;
    color: var(--color-text-secondary, #71717a);
}

.tour-btn-ghost:hover {
    background: var(--color-surface-muted, #f4f4f5);
    color: var(--color-text, #18181b);
}

.tour-btn-primary {
    background: var(--color-primary, #0047ba);
    color: #fff;
}

.tour-btn-primary:hover {
    background: var(--color-primary-hover, #003a99);
}

.tour-step-count {
    font-size: var(--text-xs, 0.75rem);
    color: var(--color-text-tertiary, #a1a1aa);
    white-space: nowrap;
}

/* Tour help trigger — topbar and portal headers. */
.tour-help-btn,
.topbar-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: var(--radius, 8px);
    background: transparent;
    color: var(--color-text-secondary, #71717a);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.tour-help-btn:hover,
.topbar-help:hover {
    background: var(--color-surface-muted, #f4f4f5);
    color: var(--color-text, #18181b);
}

@media (prefers-reduced-motion: reduce) {
    .tour-overlay,
    .tour-spotlight,
    .tour-bubble {
        transition: none;
    }
}
