/* ═══════════════════════════════════════════════════════════════════
   AUTO-TOUR — Spotlight + floating panel for the automatic guided tour.
   Ported from the demo tour (demo.css Section 28) but using tenant
   design tokens from :root in style.css.
   ═══════════════════════════════════════════════════════════════════ */


/* ── 1. SPOTLIGHT ──────────────────────────────────────────────────
   Fixed-position overlay + gold ring. JS sets inline clip-path on
   the overlay and inline position/size on the ring every step,
   scroll, and resize. */

.auto-tour-spotlight {
    position: fixed;
    inset: 0;
    z-index: 2147483380;     /* below panel (2147483400), above page content */
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}

.auto-tour-spotlight.is-active {
    opacity: 1;
}

.auto-tour-spotlight[hidden] {
    display: none !important;
}

/* Dim overlay — frosted glass + clip-path hole at the target */
.auto-tour-spotlight__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px) saturate(0.85) brightness(0.92);
    -webkit-backdrop-filter: blur(3px) saturate(0.85) brightness(0.92);
    transition: clip-path 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Gold ring — positioned by JS inline styles */
.auto-tour-spotlight__ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border: 3px solid var(--accent);
    border-radius: 12px;          /* fallback — JS overrides per element */
    background: transparent;
    box-shadow: 0 0 0 1px rgba(196, 149, 16, 0.85);
    transform: scale(1);
    transform-origin: center center;
    transform-box: fill-box;
    transition:
        top         0.42s cubic-bezier(0.4, 0, 0.2, 1),
        left        0.42s cubic-bezier(0.4, 0, 0.2, 1),
        width       0.42s cubic-bezier(0.4, 0, 0.2, 1),
        height      0.42s cubic-bezier(0.4, 0, 0.2, 1),
        border-radius 0.42s cubic-bezier(0.4, 0, 0.2, 1),
        transform   0.42s cubic-bezier(0.34, 1.56, 0.64, 1);   /* spring overshoot */
}

/* Spring scale-in entrance */
.auto-tour-spotlight__ring.is-entering {
    transform: scale(0.96);
}

/* Crisp pulse — alpha-only modulation on the hairline spread */
@keyframes auto-tour-spotlight-pulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(196, 149, 16, 0.85); }
    50%      { box-shadow: 0 0 0 1px rgba(196, 149, 16, 1); }
}

.auto-tour-spotlight.is-active .auto-tour-spotlight__ring {
    animation: auto-tour-spotlight-pulse 2.4s ease-in-out infinite;
}

/* Pause pulse during entrance so it doesn't fight the scale */
.auto-tour-spotlight__ring.is-entering {
    animation: none;
}


/* ── 2. PANEL ──────────────────────────────────────────────────────
   Fixed bottom-right floating card with progress, step content,
   and navigation buttons. */

.auto-tour-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 360px;
    max-width: calc(100vw - 48px);
    z-index: 2147483400;
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--rule-strong);
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.20), 0 6px 14px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    animation: auto-tour-slide-in 0.30s cubic-bezier(0.2, 0.9, 0.4, 1);
    isolation: isolate;
}

.auto-tour-panel[hidden] {
    display: none !important;
}

/* Accent bar at the top of the panel */
.auto-tour-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
    z-index: 1;
}

/* ── 2a. Header ── */

.auto-tour-panel__header {
    padding: 18px 20px 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.auto-tour-panel__progress-wrap {
    flex: 1;
    min-width: 0;
}

.auto-tour-panel__progress-text {
    display: block;
    font-family: Inter, system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin: 0 0 8px;
}

.auto-tour-panel__progress-track {
    height: 5px;
    border-radius: 999px;
    background: var(--rule);
    overflow: hidden;
}

.auto-tour-panel__progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    border-radius: 999px;
    transition: width 0.32s ease;
    box-shadow: 0 0 8px rgba(196, 149, 16, 0.42);
}

.auto-tour-panel__close {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 0;
    background: var(--rule);
    color: var(--ink-3);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.auto-tour-panel__close:hover {
    background: var(--rule-strong);
    color: var(--ink);
}

/* ── 2b. Body ── */

.auto-tour-panel__body {
    padding: 4px 20px 18px;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.auto-tour-panel__body.is-fading {
    opacity: 0;
    transform: translateY(6px);
}

.auto-tour-panel__eyebrow {
    margin: 0 0 8px;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.auto-tour-panel__title {
    margin: 0 0 10px;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.012em;
    line-height: 1.22;
    color: var(--ink);
}

.auto-tour-panel__copy {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.58;
    color: var(--ink-3);
}

/* ── 2b-ii. Loading state ── */

.auto-tour-panel.is-loading .auto-tour-panel__title::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid var(--rule);
    border-top-color: var(--accent);
    border-radius: 999px;
    animation: auto-tour-spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes auto-tour-spin {
    to { transform: rotate(360deg); }
}

/* ── 2b-iii. Keyboard hint ── */

.auto-tour-panel__kbd-hint {
    margin: 10px 0 0;
    font-size: 11px;
    color: var(--ink-4);
}

.auto-tour-panel__kbd-hint[hidden] {
    display: none !important;
}

.auto-tour-panel__kbd-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ink-3);
    background: var(--surface-inset);
    border: 1px solid var(--rule);
    border-radius: 4px;
}

/* ── 2c. Jump-to menu ── */

.auto-tour-panel__jump {
    border-top: 1px solid var(--rule);
}

.auto-tour-panel__jump-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-4);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.auto-tour-panel__jump-toggle::-webkit-details-marker {
    display: none;
}

.auto-tour-panel__jump-toggle::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--ink-4);
    border-bottom: 1.5px solid var(--ink-4);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.auto-tour-panel__jump[open] > .auto-tour-panel__jump-toggle::after {
    transform: rotate(-135deg);
}

.auto-tour-panel__jump-list {
    display: flex;
    flex-direction: column;
    padding: 0 12px 10px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.auto-tour-panel__jump-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-3);
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.auto-tour-panel__jump-btn:hover {
    background: var(--rule);
    color: var(--ink);
}

.auto-tour-panel__jump-btn.is-current {
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 600;
}

.auto-tour-panel__jump-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-4);
    min-width: 18px;
    text-align: center;
}

.auto-tour-panel__jump-btn.is-current .auto-tour-panel__jump-badge {
    color: var(--accent-strong);
}

/* ── 2d. Footer ── */

.auto-tour-panel__footer {
    padding: 14px 20px 18px;
    border-top: 1px solid var(--rule);
    background: rgba(26, 24, 21, 0.02);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.auto-tour-panel__nav {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.auto-tour-panel__btn {
    min-height: 38px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    gap: 6px;
}

.auto-tour-panel__btn svg {
    width: 14px;
    height: 14px;
}

.auto-tour-panel__btn--skip {
    padding: 0 12px;
    font-size: 12px;
    font-weight: 500;
}

.auto-tour-panel__btn[disabled] {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}


/* ── 3. PICKER SECTION ─────────────────────────────────────────────
   The "Automatic guided tour" card inside the existing guided-tour
   picker modal. */

.guided-tour-picker__auto-section {
    padding: 20px;
    background: var(--surface-subtle, #f2efe9);
    border-radius: var(--radius-md);
    border: 1px solid var(--rule);
    margin-bottom: 16px;
}

.guided-tour-picker__auto-heading {
    margin: 0 0 4px;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}

.guided-tour-picker__auto-sub {
    margin: 0 0 16px;
    font-size: 13px;
}

.guided-tour-picker__auto-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.guided-tour-picker__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.guided-tour-picker__divider::before,
.guided-tour-picker__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rule);
}

.guided-tour-picker__divider-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}


/* ── 3a. PICKER — Active banner ───────────────────────────────────*/

.guided-tour-picker__active-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--surface-card);
    border: 1px solid var(--accent-soft);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.guided-tour-picker__active-banner[hidden] {
    display: none !important;
}

.guided-tour-picker__active-banner-content {
    flex: 1 1 auto;
    min-width: 0;
}

.guided-tour-picker__active-banner-label {
    margin: 0;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.guided-tour-picker__active-banner-name {
    margin: 2px 0 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 3b. PICKER — Manual intro + search ──────────────────────────*/

.guided-tour-picker__manual-intro {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.5;
}

.guided-tour-picker__search-wrap {
    margin-bottom: 14px;
}

.guided-tour-picker__search {
    width: 100%;
    min-height: 40px;
    padding: 9px 13px;
    border: 1px solid rgba(26, 24, 21, 0.14);
    border-radius: 9px;
    background: var(--surface-card);
    font-size: 13.5px;
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.guided-tour-picker__search:focus {
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

.guided-tour-picker__suggestions {
    margin-top: 10px;
}

.guided-tour-picker__suggestions[hidden] {
    display: none !important;
}

.guided-tour-picker__suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.guided-tour-picker__suggestion-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--rule);
    background: var(--surface-card);
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.guided-tour-picker__suggestion-pill:hover {
    background: var(--surface-subtle);
    border-color: var(--rule-strong);
    color: var(--ink);
}

.guided-tour-picker__search-empty {
    margin: 8px 0 0;
    font-size: 12px;
}

.guided-tour-picker__search-empty[hidden] {
    display: none !important;
}

/* ── 3c. ILLUSTRATION INFRASTRUCTURE ─────────────────────────────*/

.guided-tour__illustration {
    margin: 8px 0;
}

.guided-tour__illustration[hidden] {
    display: none !important;
}

.guided-tour__illustration-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--rule);
}

.help-interactive__illustration {
    margin: 0;
}

.help-interactive__illustration[hidden] {
    display: none !important;
}

.help-interactive__illustration-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--rule);
}


/* ── 4. IN-MODAL SPOTLIGHT ─────────────────────────────────────────
   When spotlighting inside an open modal, the spotlight must render
   ABOVE the modal overlay. JS adds this modifier class. */

.auto-tour-spotlight--in-modal {
    z-index: 2147483390;   /* above modal overlays (~2100), below tour panel */
}

.auto-tour-spotlight--in-modal .auto-tour-spotlight__overlay {
    z-index: 2147483390;
}

.auto-tour-spotlight--in-modal .auto-tour-spotlight__ring {
    z-index: 2147483392;
}


/* ── 5. ANIMATIONS ─────────────────────────────────────────────────*/

@keyframes auto-tour-slide-in {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ── 6. RESUME PILL ───────────────────────────────────────────────
   Fixed bottom-right pill that appears when the tour is dismissed
   mid-way. Clicking it resumes from where the user left off. */

.auto-tour-resume-pill {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483400;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px 10px 14px;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: var(--surface-card);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
    font-family: Inter, system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
    animation: auto-tour-slide-in 0.30s cubic-bezier(0.2, 0.9, 0.4, 1);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.auto-tour-resume-pill:hover {
    background: var(--surface-subtle);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.auto-tour-resume-pill:active {
    transform: translateY(0);
}

.auto-tour-resume-pill[hidden] {
    display: none !important;
}

.auto-tour-resume-pill__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    flex-shrink: 0;
}

.auto-tour-resume-pill__icon svg {
    width: 12px;
    height: 12px;
}


/* ── 7. DARK MODE ──────────────────────────────────────────────────*/

html[data-theme="dark"] .auto-tour-spotlight__overlay {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px) saturate(0.7) brightness(0.8);
    -webkit-backdrop-filter: blur(3px) saturate(0.7) brightness(0.8);
}

html[data-theme="dark"] .auto-tour-spotlight__ring {
    border-color: var(--accent-on-dark);
    box-shadow: 0 0 0 1px var(--accent-on-dark);
}

html[data-theme="dark"] .auto-tour-spotlight.is-active .auto-tour-spotlight__ring {
    animation-name: auto-tour-spotlight-pulse-dark;
}

@keyframes auto-tour-spotlight-pulse-dark {
    0%, 100% { box-shadow: 0 0 0 1px rgba(227, 176, 8, 0.85); }
    50%      { box-shadow: 0 0 0 1px rgba(227, 176, 8, 1); }
}

html[data-theme="dark"] .auto-tour-panel {
    background: var(--card);
    border-color: var(--border);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45), 0 6px 14px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .auto-tour-panel__close {
    background: rgba(148, 163, 184, 0.12);
    color: rgba(148, 163, 184, 0.72);
}

html[data-theme="dark"] .auto-tour-panel__close:hover {
    background: rgba(148, 163, 184, 0.22);
    color: #f1f5f9;
}

html[data-theme="dark"] .auto-tour-panel__eyebrow {
    color: var(--accent-on-dark);
}

html[data-theme="dark"] .auto-tour-panel__jump {
    border-color: var(--border);
}

html[data-theme="dark"] .auto-tour-panel__jump-btn:hover {
    background: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .auto-tour-panel__jump-btn.is-current {
    background: rgba(227, 176, 8, 0.12);
    color: var(--accent-on-dark);
}

html[data-theme="dark"] .auto-tour-panel__footer {
    border-color: var(--border);
    background: rgba(148, 163, 184, 0.04);
}

html[data-theme="dark"] .guided-tour-picker__auto-section {
    background: rgba(148, 163, 184, 0.08);
    border-color: var(--border);
}

html[data-theme="dark"] .guided-tour-picker__active-banner {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(227, 176, 8, 0.3);
    border-left-color: #e3b008;
}

html[data-theme="dark"] .guided-tour-picker__active-banner-label {
    color: #e3b008;
}

html[data-theme="dark"] .guided-tour-picker__active-banner-name {
    color: #e2e8f0;
}

html[data-theme="dark"] .guided-tour-picker__search {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(71, 85, 105, 0.58);
    color: #e2e8f0;
}

html[data-theme="dark"] .guided-tour-picker__suggestion-pill {
    background: rgba(2, 6, 23, 0.62);
    border-color: rgba(148, 163, 184, 0.24);
    color: rgba(226, 232, 240, 0.94);
}

html[data-theme="dark"] .guided-tour-picker__suggestion-pill:hover {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.28);
}

html[data-theme="dark"] .guided-tour__illustration-img,
html[data-theme="dark"] .help-interactive__illustration-img {
    border-color: rgba(148, 163, 184, 0.22);
    opacity: 0.92;
}

html[data-theme="dark"] .auto-tour-panel.is-loading .auto-tour-panel__title::before {
    border-color: rgba(148, 163, 184, 0.22);
    border-top-color: var(--accent-on-dark);
}

html[data-theme="dark"] .auto-tour-panel__kbd-hint {
    color: rgba(148, 163, 184, 0.58);
}

html[data-theme="dark"] .auto-tour-panel__kbd-hint kbd {
    color: rgba(148, 163, 184, 0.72);
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .auto-tour-resume-pill {
    background: var(--card);
    border-color: var(--border);
    color: #e2e8f0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] .auto-tour-resume-pill:hover {
    background: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .auto-tour-resume-pill__icon {
    background: rgba(227, 176, 8, 0.15);
    color: var(--accent-on-dark);
}


/* ── 8. REDUCED MOTION ─────────────────────────────────────────────*/

@media (prefers-reduced-motion: reduce) {
    .auto-tour-spotlight,
    .auto-tour-spotlight__overlay,
    .auto-tour-spotlight__ring,
    .auto-tour-panel,
    .auto-tour-panel__body,
    .auto-tour-resume-pill {
        animation: none !important;
        transition: none !important;
    }
    .auto-tour-panel.is-loading .auto-tour-panel__title::before {
        animation: none !important;
    }
}


/* ── 8. MOBILE (≤ 900px) ──────────────────────────────────────────*/

@media (max-width: 900px) {
    .auto-tour-panel {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        max-width: none;
        border-radius: var(--radius-md);
    }

    .auto-tour-panel__header {
        padding: 14px 16px 10px;
    }

    .auto-tour-panel__body {
        padding: 4px 16px 14px;
    }

    .auto-tour-panel__footer {
        padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .auto-tour-panel__jump-toggle {
        padding: 10px 16px;
    }

    .auto-tour-panel__jump-list {
        padding: 0 8px 10px;
        max-height: 160px;
    }

    .guided-tour-picker__auto-options {
        flex-direction: column;
    }

    .guided-tour-picker__auto-options .btn {
        width: 100%;
        justify-content: center;
    }

    .auto-tour-resume-pill {
        right: 12px;
        bottom: 12px;
    }

    .guided-tour-picker__search {
        min-height: 44px;
        font-size: 16px;
    }
}
