/* ============================================================
 * Monoloci — Animated Welcome Tour
 * Self-contained, full-screen first-launch walkthrough.
 * No live DOM targeting, so it never breaks on UI changes.
 * ============================================================ */

#welcome-tour {
    position: fixed;
    inset: 0;
    z-index: 9995;
    display: flex;
    flex-direction: column;
    color: #f8fafc;
    overflow: hidden;
    /* Matches the Mystery Journey ready/live screens (logo palette: teal → dark). */
    background: radial-gradient(120% 120% at 50% 0%, #0d5c65 0%, #0f172a 60%, #020617 100%);
    font-family: 'Poppins', 'Fredoka', system-ui, -apple-system, sans-serif;
    opacity: 0;
    transition: opacity 0.35s ease;
}
#welcome-tour.wt-visible { opacity: 1; }
#welcome-tour.wt-hidden { display: none; }

/* Soft moving aurora glow behind the scenes */
#welcome-tour .wt-aurora {
    position: absolute;
    inset: -20%;
    background:
        radial-gradient(40% 40% at 20% 30%, rgba(21,164,145,0.38), transparent 70%),
        radial-gradient(45% 45% at 80% 20%, rgba(63,197,163,0.28), transparent 70%),
        radial-gradient(50% 50% at 60% 80%, rgba(123,169,193,0.22), transparent 70%);
    filter: blur(20px);
    animation: wt-aurora 18s ease-in-out infinite alternate;
    pointer-events: none;
}
@keyframes wt-aurora {
    0%   { transform: translate3d(0,0,0) scale(1); }
    100% { transform: translate3d(0,-4%,0) scale(1.08); }
}

/* Top bar: progress + skip */
#welcome-tour .wt-top {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px 6px 18px;
}
#welcome-tour .wt-progress {
    flex: 1;
    display: flex;
    gap: 6px;
}
#welcome-tour .wt-progress-seg {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    overflow: hidden;
}
#welcome-tour .wt-progress-seg > i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #3fc5a3, #15a491);
}
#welcome-tour .wt-progress-seg.is-done > i { width: 100%; }
#welcome-tour .wt-progress-seg.is-active > i {
    width: 100%;
    transition: width var(--wt-dur, 4500ms) linear;
}
#welcome-tour .wt-skip {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
}
#welcome-tour .wt-skip:hover { color: #fff; }

/* Scene stage. The active scene is a normal in-flow block that fills the
   stage (no absolute positioning), so it always takes the full frame width and
   text wraps/centres correctly regardless of viewport or webview quirks. */
#welcome-tour .wt-stage {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    padding: 8px 24px;
    box-sizing: border-box;
}
#welcome-tour .wt-scene {
    display: none;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
#welcome-tour .wt-scene.is-active {
    display: flex;
    animation: wt-scene-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes wt-scene-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

#welcome-tour .wt-art {
    width: 180px;
    height: 180px;
    margin: 0 auto 22px auto;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
#welcome-tour .wt-art svg { width: 100%; height: 100%; overflow: visible; }

#welcome-tour .wt-title {
    width: 100%;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 10px 0;
    letter-spacing: -0.01em;
}
#welcome-tour .wt-sub {
    width: 100%;
    font-size: 0.98rem;
    line-height: 1.45;
    color: rgba(248,250,252,0.82);
    max-width: 22rem;
    margin: 0 auto;
}
#welcome-tour .wt-badge {
    align-self: center;
    display: inline-block;
    margin-top: 14px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fde68a;
    background: rgba(253,230,138,0.12);
    border: 1px solid rgba(253,230,138,0.35);
    border-radius: 999px;
    padding: 4px 10px;
}

/* Bottom controls */
#welcome-tour .wt-bottom {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 22px calc(env(safe-area-inset-bottom, 0px) + 22px) 22px;
}
#welcome-tour .wt-back {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 6px;
    min-width: 64px;
    text-align: left;
    visibility: hidden;
}
#welcome-tour .wt-back.is-shown { visibility: visible; }
#welcome-tour .wt-dots { display: flex; gap: 7px; }
#welcome-tour .wt-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.28);
    transition: background 0.2s ease, transform 0.2s ease;
}
#welcome-tour .wt-dot.is-active { background: #15a491; transform: scale(1.25); }
#welcome-tour .wt-next {
    flex: 0 0 auto;
    background: linear-gradient(135deg, #15a491 0%, #058870 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
    border: none;
    border-radius: 999px;
    padding: 12px 26px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(5,136,112,0.45);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    min-width: 96px;
}
#welcome-tour .wt-next:hover { box-shadow: 0 10px 26px rgba(5,136,112,0.55); }
#welcome-tour .wt-next:active { transform: scale(0.96); }

/* --- Per-scene art animations --- */
.wt-pulse { transform-box: fill-box; transform-origin: center; animation: wt-pulse 2.4s ease-in-out infinite; }
@keyframes wt-pulse { 0%,100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.12); opacity: 1; } }

.wt-ring { transform-box: fill-box; transform-origin: center; animation: wt-ring 2.6s ease-out infinite; }
@keyframes wt-ring { 0% { transform: scale(0.4); opacity: 0.7; } 100% { transform: scale(1.6); opacity: 0; } }

.wt-float { transform-box: fill-box; transform-origin: center; animation: wt-float 3.2s ease-in-out infinite; }
@keyframes wt-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.wt-pop { transform-box: fill-box; transform-origin: center; animation: wt-pop 0.6s cubic-bezier(0.16,1,0.3,1) both; }
@keyframes wt-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.wt-spin { transform-box: fill-box; transform-origin: center; animation: wt-spin 9s linear infinite; }
@keyframes wt-spin { to { transform: rotate(360deg); } }

.wt-dash {
    stroke-dasharray: 8 6;
    animation: wt-dash 1.2s linear infinite;
}
@keyframes wt-dash { to { stroke-dashoffset: -28; } }

.wt-delay-1 { animation-delay: 0.12s; }
.wt-delay-2 { animation-delay: 0.24s; }
.wt-delay-3 { animation-delay: 0.36s; }
.wt-delay-4 { animation-delay: 0.48s; }
.wt-delay-5 { animation-delay: 0.60s; }

@media (prefers-reduced-motion: reduce) {
    #welcome-tour, #welcome-tour * { animation: none !important; transition: opacity 0.2s ease !important; }
    #welcome-tour .wt-progress-seg.is-active > i { width: 100% !important; }
}

@media (min-width: 640px) {
    #welcome-tour .wt-stage { max-width: 480px; margin: 0 auto; }
    #welcome-tour .wt-art { width: 210px; height: 210px; }
    #welcome-tour .wt-title { font-size: 1.7rem; }
}
