/* ===== Tour Design Tokens ===== */
:root {
    --tour-duration: 300ms;
    --tour-easing: ease-in-out;
    --tour-primary: var(--accent-cyan, #00c8ff);
    --tour-success: var(--accent-green, #39b54a);
    --tour-surface: var(--bg-panel, #1a2535);
    --tour-border: var(--border-color, #2a3f5a);
    --tour-text: var(--text-primary, #d3d3d3);
    --tour-text-muted: var(--text-muted, #8a9aaa);
    --tour-radius: 8px;
    --tour-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(42, 63, 90, 0.4);
}

/* ===== Driver.js Dark Theme Overrides ===== */
.driver-popover {
    background: var(--tour-surface) !important;
    border: 1px solid var(--tour-border) !important;
    border-radius: var(--tour-radius) !important;
    color: var(--tour-text) !important;
    font-family: 'Space Grotesk', sans-serif !important;
    box-shadow: var(--tour-shadow) !important;
    max-width: 340px !important;
    padding: 20px 24px !important;
    overflow: visible !important;
}

/* Left accent bar */
.driver-popover::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--tour-primary);
    border-radius: var(--tour-radius) 0 0 var(--tour-radius);
    pointer-events: none;
}

.driver-popover .driver-popover-title {
    color: var(--tour-primary) !important;
    font-family: 'Space Grotesk', sans-serif !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    margin-bottom: 6px !important;
}

.driver-popover .driver-popover-description {
    color: var(--tour-text) !important;
    font-family: 'Space Grotesk', sans-serif !important;
    font-size: 0.875rem !important;
    line-height: 1.6 !important;
}

.driver-popover .driver-popover-progress-text {
    color: var(--tour-text-muted) !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.03em !important;
}

/* === Footer layout — progress text above buttons === */
.driver-popover .driver-popover-footer {
    flex-wrap: wrap !important;
}

.driver-popover .driver-popover-footer .driver-popover-progress-text {
    width: 100% !important;
    margin-bottom: 8px !important;
}

.driver-popover .driver-popover-navigation-btns {
    display: flex !important;
    gap: 8px !important;
    justify-content: flex-end !important;
    width: 100% !important;
}

.driver-popover .driver-popover-navigation-btns button {
    font-family: 'Space Grotesk', sans-serif !important;
    font-size: 0.8rem !important;
    border-radius: 4px !important;
    padding: 6px 16px !important;
    transition: all var(--tour-duration) var(--tour-easing) !important;
    cursor: pointer !important;
    white-space: nowrap !important;
}

.driver-popover .driver-popover-next-btn {
    background: var(--tour-primary) !important;
    color: #0f1a2a !important;
    border: none !important;
    font-weight: 600 !important;
}

.driver-popover .driver-popover-next-btn:hover {
    background: #33d4ff !important;
    box-shadow: 0 0 12px rgba(0, 200, 255, 0.3) !important;
}

.driver-popover .driver-popover-next-btn:active {
    transform: scale(0.97) !important;
    filter: brightness(0.9) !important;
}

.driver-popover .driver-popover-prev-btn {
    background: transparent !important;
    color: var(--tour-primary) !important;
    border: 1px solid var(--tour-primary) !important;
    font-weight: 500 !important;
}

.driver-popover .driver-popover-prev-btn:hover {
    background: rgba(0, 200, 255, 0.08) !important;
    color: #33d4ff !important;
    border-color: #33d4ff !important;
}

.driver-popover .driver-popover-prev-btn:active {
    transform: scale(0.97) !important;
}

.driver-popover .driver-popover-close-btn {
    color: var(--tour-text-muted) !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    transition: all var(--tour-duration) var(--tour-easing) !important;
}

.driver-popover .driver-popover-close-btn:hover {
    color: var(--tour-primary) !important;
    background: rgba(0, 200, 255, 0.08) !important;
}

/* Arrow colours */
.driver-popover .driver-popover-arrow-side-left.driver-popover-arrow,
.driver-popover .driver-popover-arrow-side-right.driver-popover-arrow,
.driver-popover .driver-popover-arrow-side-top.driver-popover-arrow,
.driver-popover .driver-popover-arrow-side-bottom.driver-popover-arrow {
    border-color: var(--tour-surface) !important;
}

/* Driver overlay */
.driver-overlay {
    z-index: 100000 !important;
}

/* Highlight glow on active element */
.driver-active-element {
    box-shadow: 0 0 0 2px rgba(0, 200, 255, 0.35), 0 0 12px rgba(0, 200, 255, 0.1) !important;
    transition: box-shadow var(--tour-duration) var(--tour-easing) !important;
}

/* ===== Fake Cursor ===== */
#tourCursor {
    position: fixed;
    z-index: 100002;
    pointer-events: none;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    opacity: 0;
    transition: opacity var(--tour-duration) var(--tour-easing);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

#tourCursor.visible {
    opacity: 1;
}

/* Pulse: continuous breathing while waiting for user */
#tourCursor.clicking {
    animation: tour-cursor-pulse 1s var(--tour-easing) infinite;
}

@keyframes tour-cursor-pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
    }
    50% {
        transform: scale(1.12);
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 10px rgba(0, 200, 255, 0.5));
    }
}

/* Click: scale down then spring back */
#tourCursor.click-down {
    animation: tour-cursor-click 250ms ease-out forwards;
}

@keyframes tour-cursor-click {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.7); }
    100% { transform: scale(1); }
}

/* ===== Cursor Trail ===== */
#tourCursorTrail {
    position: fixed;
    z-index: 100001;
    pointer-events: none;
    width: 12px;
    height: 12px;
    margin-left: 2px;
    margin-top: 2px;
    border-radius: 50%;
    background: rgba(0, 200, 255, 0.25);
    opacity: 0;
    transition: left 100ms ease-out, top 100ms ease-out, opacity var(--tour-duration) var(--tour-easing);
}

#tourCursorTrail.visible {
    opacity: 0.35;
}

/* ===== Click Ripple ===== */
.tour-click-ripple {
    position: fixed;
    pointer-events: none;
    z-index: 100001;
    border-radius: 50%;
    background: rgba(0, 200, 255, 0.3);
    width: 0;
    height: 0;
    animation: tour-ripple 400ms ease-out forwards;
}

@keyframes tour-ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 56px;
        height: 56px;
        margin-left: -28px;
        margin-top: -28px;
        opacity: 0;
    }
}

/* ===== Role Chooser Modal ===== */
.tour-role-overlay {
    position: fixed;
    inset: 0;
    z-index: 100002;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: tour-fade-in 0.3s ease;
}

@keyframes tour-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tour-role-card {
    background: var(--bg-panel, #1a2535);
    border: 1px solid var(--border-color, #2a3f5a);
    border-radius: 12px;
    padding: 40px 48px;
    text-align: center;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
    max-width: 480px;
    animation: tour-slide-up 0.4s ease;
}

@keyframes tour-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tour-role-card h2 {
    color: var(--text-primary, #d3d3d3);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.tour-role-card p {
    color: var(--text-muted, #8a9aaa);
    font-size: 0.85rem;
    margin-bottom: 32px;
}

.tour-role-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.tour-role-btn {
    padding: 14px 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #2a3f5a);
    background: transparent;
    color: var(--text-primary, #d3d3d3);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 160px;
}

.tour-role-btn:hover {
    border-color: var(--accent-cyan, #00c8ff);
    color: var(--accent-cyan, #00c8ff);
    background: rgba(0, 200, 255, 0.05);
}

.tour-role-btn.primary {
    background: var(--accent-cyan, #00c8ff);
    color: #0f1a2a;
    border-color: var(--accent-cyan, #00c8ff);
    font-weight: 600;
}

.tour-role-btn.primary:hover {
    background: #33d4ff;
}

.tour-role-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tour-role-skip {
    display: block;
    margin: 20px auto 0;
    background: none;
    border: none;
    color: var(--text-muted, #8a9aaa);
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: 'Space Grotesk', sans-serif;
}

.tour-role-skip:hover {
    color: var(--text-primary, #d3d3d3);
}

/* ===== Restart Tour Button ===== */
.tour-restart-btn {
    font-family: 'Space Grotesk', sans-serif !important;
    font-size: 0.75rem !important;
    padding: 4px 12px !important;
    border-color: var(--border-color, #2a3f5a) !important;
    color: var(--text-muted, #8a9aaa) !important;
    background: transparent !important;
    margin-right: 8px;
    transition: all 0.2s !important;
}

.tour-restart-btn:hover {
    color: var(--accent-cyan, #00c8ff) !important;
    border-color: var(--accent-cyan, #00c8ff) !important;
}

/* ===== Email Animation (Step 19) ===== */
.tour-email-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
    margin: 16px 0 8px;
    position: relative;
}

.tour-file-icon {
    width: 28px;
    height: 34px;
    position: relative;
    animation: tour-file-fly 1.2s ease-in-out forwards;
    animation-delay: 0.3s;
    opacity: 0;
}

.tour-file-icon svg {
    width: 100%;
    height: 100%;
}

.tour-envelope-icon {
    width: 44px;
    height: 34px;
}

.tour-envelope-icon svg {
    width: 100%;
    height: 100%;
}

.tour-check-icon {
    position: absolute;
    right: calc(50% - 40px);
    top: 4px;
    opacity: 0;
    animation: tour-check-appear 0.4s ease forwards;
    animation-delay: 1.6s;
    color: var(--accent-green, #39b54a);
    font-size: 1.2rem;
    font-weight: 700;
}

@keyframes tour-file-fly {
    0% {
        opacity: 1;
        transform: translateX(-30px);
    }
    70% {
        opacity: 1;
        transform: translateX(8px);
    }
    100% {
        opacity: 0;
        transform: translateX(8px) scale(0.5);
    }
}

@keyframes tour-check-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== "Your Turn" badge ===== */
.tour-your-turn-badge {
    display: inline-block;
    background: var(--tour-primary);
    color: #0f1a2a;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 10px;
    margin-bottom: 6px;
}

/* ===== Tour step auto-advance indicator ===== */
.tour-auto-label {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--text-muted, #8a9aaa);
    font-style: italic;
    margin-top: 8px;
}

/* ===== Welcome popover (larger intro) ===== */
.driver-popover.tour-welcome-popover {
    max-width: 480px !important;
    padding: 32px 40px !important;
    text-align: center !important;
}

.driver-popover.tour-welcome-popover .driver-popover-title {
    font-size: 1.4rem !important;
}

.driver-popover.tour-welcome-popover .driver-popover-description {
    font-size: 1rem !important;
}

/* ===== Sidebar popover (forced right-side placement) ===== */
.driver-popover.tour-popover-sidebar {
    height: auto !important;
    min-height: unset !important;
    max-height: unset !important;
    position: fixed !important;
}

/* ===== Above-toggle popover (forced position above switches) ===== */
.driver-popover.tour-popover-above-toggle {
    height: auto !important;
    min-height: unset !important;
    max-height: unset !important;
    position: fixed !important;
}

/* ===== Hide Next button on auto-advance steps via CSS — no JS flash ===== */
.driver-popover.tour-auto-step .driver-popover-next-btn {
    display: none !important;
}

/* ===== Disabled next button during animation ===== */
.driver-popover .driver-popover-next-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

/* ===== "Your Turn" popover accent ===== */
.driver-popover.driver-step--your-turn {
    border-color: var(--tour-border) !important;
    box-shadow: var(--tour-shadow) !important;
}
