/* ============================================================================
   guild-tour.css — spotlight tour overlay (companion to assets/js/guild-tour.js)
   ----------------------------------------------------------------------------
   PLAN 2 Phase 3. Uses app.css design tokens; dark-theme overrides at bottom.
   z-index 9400 — above toasts (9000), BELOW the session-expired overlay (9500)
   so session expiry always outranks a tour.
   ============================================================================ */

#guild-tour-root {
    position: fixed;
    inset: 0;
    z-index: 9400;
    pointer-events: none;
}
#guild-tour-root[hidden] { display: none; }

/* Click shield: swallows every click that isn't on the popover. */
#guild-tour-root .gt-shield {
    position: absolute;
    inset: 0;
    pointer-events: auto;
}

/* Interactive ("do-it-with-me") steps: the full shield is replaced by four
   rects tiled around the spotlight, so the spotlight hole is genuinely
   click-through — the user performs the real action. Positioned by
   positionCurrent() in the same pass as the spotlight. */
#guild-tour-root .gt-shield-rect {
    position: absolute;
    display: none;
    pointer-events: auto;
}
#guild-tour-root.gt-interactive .gt-shield { display: none; }
#guild-tour-root.gt-interactive .gt-shield-rect { display: block; }

/* Spotlight: transparent window; the giant box-shadow paints the dim veil. */
#guild-tour-root .gt-spotlight {
    position: absolute;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(8, 10, 16, 0.72);
    outline: 2px solid rgba(255, 255, 255, 0.35);
    outline-offset: 2px;
    transition: left 0.32s ease, top 0.32s ease, width 0.32s ease,
        height 0.32s ease, opacity 0.32s ease;
}
/* Centered steps: the faded spotlight loses its shadow, so the veil moves to
   the shield (guild-tour.js toggles gt-no-target). */
#guild-tour-root.gt-no-target .gt-shield { background: rgba(8, 10, 16, 0.72); }

/* Interactive spotlight: inviting idle pulse + success flash on completion. */
#guild-tour-root.gt-interactive .gt-spotlight {
    outline-color: var(--accent, #d64545);
    animation: gt-spot-pulse 1.9s ease-in-out infinite;
}
@keyframes gt-spot-pulse {
    0%, 100% { outline-offset: 2px; outline-width: 2px; }
    50% { outline-offset: 6px; outline-width: 3px; }
}
#guild-tour-root .gt-spotlight.gt-spot-success {
    outline-color: var(--green, #047857);
    animation: gt-spot-success 0.55s ease-out;
}
@keyframes gt-spot-success {
    0% { outline-offset: 2px; }
    45% { outline-offset: 10px; outline-width: 4px; }
    100% { outline-offset: 2px; }
}

/* ── Popover ──────────────────────────────────────────────────────────────── */
#guild-tour-root .gt-popover {
    position: absolute;
    width: min(400px, calc(100vw - 24px));
    padding: 18px 20px 16px;
    border-radius: 14px;
    background: var(--surface, #fff);
    color: var(--ink, #1c2430);
    box-shadow: 0 18px 48px rgba(8, 10, 16, 0.35);
    border: 1px solid var(--line, #e3e7ee);
    pointer-events: auto;
    outline: none;
    /* No left/top transition: between steps the popover fades out, teleports,
       and pops in (gt-swap-out → gt-pop-in) — sliding a box whose size is
       changing mid-flight read as broken. Scroll-follow tracks per-frame. */
    transition: opacity 0.15s ease, transform 0.15s ease;
}
#guild-tour-root .gt-popover.gt-centered { box-shadow: 0 24px 64px rgba(8, 10, 16, 0.5); }

/* Step-change fade-out (added by showStep while the next target resolves). */
#guild-tour-root .gt-popover.gt-swap-out {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    pointer-events: none;
}

/* Spotlight snap: no slide across the screen when the step changed sections
   or the spotlight was hidden (renderPopover toggles this around reposition). */
#guild-tour-root .gt-spotlight.gt-snap { transition: none; }

/* Popover entrance — re-triggered on every step by guild-tour.js. */
#guild-tour-root .gt-popover.gt-pop-in { animation: gt-pop-in 0.34s cubic-bezier(0.2, 1.2, 0.4, 1); }
@keyframes gt-pop-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* "Try it" badge on do-it-with-me steps. */
#guild-tour-root .gt-live-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent, #d64545) 12%, transparent);
    color: var(--accent, #d64545);
    letter-spacing: 0.02em;
    animation: gt-badge-bounce 2.2s ease-in-out infinite;
}
#guild-tour-root .gt-live-badge[hidden] { display: none; }
@keyframes gt-badge-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* Waiting state (long milestone steps, e.g. panel generation). */
#guild-tour-root .gt-waiting-note {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent, #d64545) 8%, transparent);
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--ink, #1c2430);
}
#guild-tour-root .gt-waiting-note[hidden] { display: none; }
#guild-tour-root .gt-waiting-spinner {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2.5px solid color-mix(in srgb, var(--accent, #d64545) 30%, transparent);
    border-top-color: var(--accent, #d64545);
    animation: gt-spin 0.9s linear infinite;
}
@keyframes gt-spin { to { transform: rotate(360deg); } }

/* Animated progress bar (in addition to dots). */
#guild-tour-root .gt-progressbar {
    height: 4px;
    margin-bottom: 10px;
    border-radius: 2px;
    background: var(--line, #e3e7ee);
    overflow: hidden;
}
#guild-tour-root .gt-progressbar-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent, #d64545), color-mix(in srgb, var(--accent, #d64545) 55%, #8b5cf6));
    transition: width 0.45s cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* Completion confetti — appended to <body>, self-removing. */
.gt-confetti {
    position: fixed;
    inset: 0;
    z-index: 9450; /* above the tour, below session-expired (9500) */
    pointer-events: none;
}
.gt-confetti span {
    position: absolute;
    top: -14px;
    left: var(--gtc-x, 50%);
    width: 9px;
    height: 13px;
    border-radius: 2px;
    background: hsl(var(--gtc-hue, 200), 85%, 60%);
    opacity: 0;
    animation: gt-confetti-fall 2s ease-in var(--gtc-delay, 0s) forwards;
}
@keyframes gt-confetti-fall {
    0% { opacity: 1; transform: translate(0, 0) rotate(0); }
    100% { opacity: 0; transform: translate(var(--gtc-drift, 0px), 105vh) rotate(var(--gtc-spin, 540deg)); }
}

#guild-tour-root .gt-eyebrow {
    margin: 0 0 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted, #66707e);
}
#guild-tour-root .gt-title {
    margin: 0 0 8px;
    font-size: 1.08rem;
    line-height: 1.3;
}
#guild-tour-root .gt-body {
    margin: 0 0 12px;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--ink, #1c2430);
}
#guild-tour-root .gt-body strong { color: inherit; }

/* Progress dots */
#guild-tour-root .gt-dots {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
}
#guild-tour-root .gt-dots:empty { display: none; }
#guild-tour-root .gt-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--line, #e3e7ee);
}
#guild-tour-root .gt-dot.is-past { background: var(--muted, #66707e); }
#guild-tour-root .gt-dot.is-on { background: var(--accent, #d64545); transform: scale(1.25); }

/* Footer buttons */
#guild-tour-root .gt-footer {
    display: flex;
    align-items: center;
    gap: 8px;
}
#guild-tour-root .gt-footer-spacer { flex: 1; }
#guild-tour-root .gt-btn {
    padding: 7px 14px;
    border-radius: 9px;
    border: 1px solid var(--line, #e3e7ee);
    background: var(--paper, #f6f7f9);
    color: var(--ink, #1c2430);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
#guild-tour-root .gt-btn:hover { border-color: var(--muted, #66707e); }
#guild-tour-root .gt-btn:disabled { opacity: 0.45; cursor: default; }
#guild-tour-root .gt-btn.gt-primary {
    background: var(--accent, #d64545);
    border-color: var(--accent, #d64545);
    color: #fff;
}
#guild-tour-root .gt-btn.gt-primary:hover { filter: brightness(1.08); }
#guild-tour-root .gt-btn.gt-skip {
    background: transparent;
    border-color: transparent;
    color: var(--muted, #66707e);
    font-weight: 600;
}
#guild-tour-root .gt-btn.gt-skip:hover { color: var(--ink, #1c2430); border-color: transparent; }

/* Arrow */
#guild-tour-root .gt-arrow {
    position: absolute;
    width: 12px; height: 12px;
    background: var(--surface, #fff);
    border: 1px solid var(--line, #e3e7ee);
    transform: rotate(45deg);
    margin: -6px;
}
#guild-tour-root .gt-arrow[data-side="bottom"] { top: 0; border-right: none; border-bottom: none; }
#guild-tour-root .gt-arrow[data-side="top"] { bottom: 0; border-left: none; border-top: none; }
#guild-tour-root .gt-arrow[data-side="right"] { left: 0; border-top: none; border-right: none; }
#guild-tour-root .gt-arrow[data-side="left"] { right: 0; border-bottom: none; border-left: none; }
#guild-tour-root .gt-popover.gt-centered .gt-arrow { display: none; }

/* ── Per-section tour launcher (?) button ─────────────────────────────────── */
.tour-launch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    margin-left: 8px;
    border-radius: 50%;
    border: 1px solid var(--line, #e3e7ee);
    background: var(--paper, #f6f7f9);
    color: var(--muted, #66707e);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.tour-launch:hover { color: var(--accent, #d64545); border-color: var(--accent, #d64545); }

/* ── Dark theme (narrorift-mode) ──────────────────────────────────────────── */
body.narrorift-mode #guild-tour-root .gt-popover {
    background: #12172a;
    border-color: rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
}
body.narrorift-mode #guild-tour-root .gt-body { color: #cbd5e1; }
body.narrorift-mode #guild-tour-root .gt-eyebrow { color: #94a3b8; }
body.narrorift-mode #guild-tour-root .gt-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
    color: #e2e8f0;
}
body.narrorift-mode #guild-tour-root .gt-btn.gt-skip { background: transparent; border-color: transparent; color: #94a3b8; }
body.narrorift-mode #guild-tour-root .gt-btn.gt-skip:hover { color: #e2e8f0; }
body.narrorift-mode #guild-tour-root .gt-dot { background: rgba(255, 255, 255, 0.18); }
body.narrorift-mode #guild-tour-root .gt-dot.is-past { background: #94a3b8; }
body.narrorift-mode #guild-tour-root .gt-arrow {
    background: #12172a;
    border-color: rgba(255, 255, 255, 0.14);
}
body.narrorift-mode .tour-launch {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
    color: #94a3b8;
}

body.narrorift-mode #guild-tour-root .gt-waiting-note { color: #e2e8f0; }
body.narrorift-mode #guild-tour-root .gt-progressbar { background: rgba(255, 255, 255, 0.12); }

@media (prefers-reduced-motion: reduce) {
    #guild-tour-root .gt-spotlight,
    #guild-tour-root .gt-popover,
    #guild-tour-root .gt-btn,
    #guild-tour-root .gt-progressbar-fill,
    .tour-launch { transition: none; }
    #guild-tour-root.gt-interactive .gt-spotlight,
    #guild-tour-root .gt-spotlight.gt-spot-success,
    #guild-tour-root .gt-popover.gt-pop-in,
    #guild-tour-root .gt-live-badge,
    .gt-confetti span { animation: none; }
}
