/* =====================================================================
   ONBOARDING TOUR (Aug 2026) -- scripts/onboarding_tour.js
   -----------------------------------------------------------------------
   A brand new user (company owner via verify_magic_link.php, or an
   invited team member via join.php) used to land on the dashboard with
   zero guidance -- no idea what a filter does, that Table/Kanban are two
   different views, or where the mega menu lives. This is the visual
   layer for the step-by-step spotlight tour that now walks them through
   it once, right after their first-ever login (?tour=1).

   Built custom (no new dependency) to match this app's own existing
   premium look -- same CSS custom properties (--td-primary etc.) and
   card/shadow language already used throughout header.php/style.css,
   rather than pulling in a generic tour library with its own separate
   visual identity.
   ===================================================================== */

#td-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    pointer-events: none;
}

#td-tour-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    pointer-events: auto;
    /* four-rectangle "frame" around the spotlight cutout, drawn via
       clip-path -- box-shadow spread is what actually renders the dim
       backdrop, the cutout itself is left fully transparent (see JS,
       which sets top/left/width/height per step). */
    transition: top .35s cubic-bezier(0.4, 0, 0.2, 1),
                left .35s cubic-bezier(0.4, 0, 0.2, 1),
                width .35s cubic-bezier(0.4, 0, 0.2, 1),
                height .35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity .25s ease;
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
}

#td-tour-backdrop.td-tour-centered {
    /* Welcome / completion screens -- no real target, just dim
       everything with no cutout. */
    top: 50% !important;
    left: 50% !important;
    width: 0 !important;
    height: 0 !important;
    border-radius: 0;
}

#td-tour-spotlight-ring {
    position: fixed;
    border: 2px solid var(--td-primary);
    border-radius: 12px;
    pointer-events: none;
    box-shadow: 0 0 0 4px rgba(97, 84, 242, 0.18);
    transition: top .35s cubic-bezier(0.4, 0, 0.2, 1),
                left .35s cubic-bezier(0.4, 0, 0.2, 1),
                width .35s cubic-bezier(0.4, 0, 0.2, 1),
                height .35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity .25s ease;
}

#td-tour-spotlight-ring.td-tour-hidden,
#td-tour-backdrop.td-tour-hidden { opacity: 0; }

#td-tour-card {
    position: fixed;
    z-index: 100001;
    width: 320px;
    max-width: calc(100vw - 32px);
    background: var(--td-surface);
    color: var(--td-text);
    border-radius: 14px;
    box-shadow: 0 20px 40px -8px rgba(15, 23, 42, 0.25), 0 8px 16px -4px rgba(15, 23, 42, 0.1);
    padding: 20px 22px;
    pointer-events: auto;
    font-family: inherit;
    transition: top .35s cubic-bezier(0.4, 0, 0.2, 1),
                left .35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: tdTourCardIn .3s cubic-bezier(0.16, 1, 0.3, 1);
}

#td-tour-card.td-tour-centered-card {
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: 380px;
    text-align: center;
    padding: 32px 28px;
}

@keyframes tdTourCardIn {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: scale(1); }
}

#td-tour-card .td-tour-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--td-primary), var(--td-primary-dark));
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
}

#td-tour-card .td-tour-icon-lg {
    font-size: 40px;
    background: linear-gradient(135deg, var(--td-primary), var(--td-primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 14px;
}

#td-tour-card h5 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px;
}

#td-tour-card p {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--td-text-muted);
    margin: 0 0 16px;
}

#td-tour-card .td-tour-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#td-tour-card .td-tour-dots {
    display: flex;
    gap: 5px;
}
#td-tour-card .td-tour-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--td-border);
    transition: background .2s ease, transform .2s ease;
}
#td-tour-card .td-tour-dots span.active {
    background: var(--td-primary);
    transform: scale(1.3);
}

#td-tour-card .td-tour-btn-group {
    display: flex;
    gap: 8px;
}

#td-tour-card button {
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s ease, transform .1s ease;
}
#td-tour-card button:active { transform: scale(.96); }

#td-tour-card .td-tour-btn-primary {
    background: var(--td-primary);
    color: #fff;
}
#td-tour-card .td-tour-btn-primary:hover { opacity: .9; }

#td-tour-card .td-tour-btn-ghost {
    background: transparent;
    color: var(--td-text-muted);
}
#td-tour-card .td-tour-btn-ghost:hover { color: var(--td-text); }

#td-tour-card .td-tour-skip {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: var(--td-text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
#td-tour-card .td-tour-skip:hover { color: var(--td-text); }

@media (max-width: 576px) {
    #td-tour-card { width: calc(100vw - 24px); }
    #td-tour-card.td-tour-centered-card { width: calc(100vw - 32px); }
}
