/**
 * Project TRACE - Step-by-step Tutorial / Guided Tour
 * Overlay-based callout system with spotlight effect
 */

/* ── Overlay ── */
.tut-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.tut-overlay.active {
    pointer-events: auto;
}

/* Dark backdrop with cutout hole */
.tut-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99991;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
}
.tut-overlay.active .tut-backdrop {
    background: rgba(0,0,0,0.55);
}

/* Spotlight cutout */
.tut-spotlight {
    position: fixed;
    z-index: 99992;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.55), 0 0 20px 4px rgba(124,58,237,0.35);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Pulse ring around spotlight */
.tut-spotlight::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid rgba(124,58,237,0.5);
    border-radius: 10px;
    animation: tut-pulse 2s ease-in-out infinite;
}

@keyframes tut-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

/* ── Callout Card ── */
.tut-callout {
    position: fixed;
    z-index: 99993;
    width: 380px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25), 0 0 0 1px rgba(124,58,237,0.15);
    padding: 0;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
    /* Mobile: allow internal scroll if card too tall */
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
}
.tut-callout.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Top accent bar */
.tut-callout::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, #7c3aed, #0b4aa2, #059669);
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.tut-callout-body {
    padding: 20px 20px 16px;
}

/* Step badge */
.tut-step-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

.tut-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px;
    line-height: 1.4;
}

.tut-desc {
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.65;
    margin: 0 0 16px;
}
.tut-desc strong {
    color: #7c3aed;
}

/* ── Navigation ── */
.tut-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #f9fafb;
    border-radius: 0 0 16px 16px;
    border-top: 1px solid #f3f4f6;
    flex-wrap: wrap;
    gap: 8px;
    position: sticky;
    bottom: 0;
    z-index: 1;
}

.tut-dots {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}
.tut-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    transition: all 0.25s ease;
}
.tut-dot.active {
    background: #7c3aed;
    width: 22px;
    border-radius: 4px;
}
.tut-dot.done {
    background: #059669;
}

.tut-nav-btns {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.tut-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tut-btn-skip {
    background: transparent;
    color: #6b7280;
}
.tut-btn-skip:hover, .tut-btn-skip:active {
    background: #f3f4f6;
    color: #374151;
}
.tut-btn-prev {
    background: #f3f4f6;
    color: #374151;
}
.tut-btn-prev:hover, .tut-btn-prev:active {
    background: #e5e7eb;
}
.tut-btn-next {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
}
.tut-btn-next:hover, .tut-btn-next:active {
    background: linear-gradient(135deg, #6d28d9, #5b21b6);
    box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}

/* ── Arrow/pointer ── */
.tut-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0,0,0,0.05);
    z-index: -1;
}
.tut-arrow.top    { top: -7px; left: 30px; }
.tut-arrow.bottom { bottom: -7px; left: 30px; }
.tut-arrow.left   { left: -7px; top: 30px; }
.tut-arrow.right  { right: -7px; top: 30px; }

/* ── Welcome/Finish modal (no spotlight) ── */
/*
 * Use margin auto + inset centering for reliable mobile centering.
 * Avoid translate(-50%) when combined with max-width constraints on small screens.
 */
.tut-callout.tut-center {
    position: fixed !important;
    top: 50% !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: 440px !important;
    /* Center horizontally using margin auto + left/right anchors */
    margin: 0 auto !important;
    transform: translateY(-50%) scale(0.95) !important;
}
.tut-callout.tut-center.visible {
    transform: translateY(-50%) scale(1) !important;
}
/* When viewport is wide enough, center it at a fixed width */
@media (min-width: 480px) {
    .tut-callout.tut-center {
        left: 50% !important;
        right: auto !important;
        width: 440px !important;
        margin-left: -220px !important;
        transform: translateY(-50%) scale(0.95) !important;
    }
    .tut-callout.tut-center.visible {
        transform: translateY(-50%) scale(1) !important;
    }
}

.tut-welcome-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(124,58,237,0.1), rgba(11,74,162,0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.5rem;
}

/* ── "Start Tutorial" floating button ── */
.tut-trigger {
    position: fixed;
    bottom: 80px; /* above mobile nav/bottom bars */
    right: 16px;
    z-index: 9999;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 10px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(124,58,237,0.35);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    animation: tut-bob 3s ease-in-out infinite;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tut-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(124,58,237,0.45);
}
.tut-trigger i {
    font-size: 1rem;
}

@keyframes tut-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ── "Don't show again" checkbox ── */
.tut-dontshow {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: 8px;
    cursor: pointer;
    padding: 4px 0;
    touch-action: manipulation;
}
.tut-dontshow input[type="checkbox"] {
    accent-color: #7c3aed;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 479.98px) {
    .tut-callout {
        border-radius: 14px;
        font-size: 0.9rem;
    }
    .tut-callout-body {
        padding: 16px 16px 12px;
    }
    .tut-nav {
        padding: 10px 16px;
    }
    .tut-btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
    .tut-trigger {
        bottom: 72px;
        right: 12px;
        padding: 9px 14px;
        font-size: 0.78rem;
    }
    .tut-title {
        font-size: 0.95rem;
    }
    .tut-desc {
        font-size: 0.82rem;
    }
}

