/*
Module intro tour - animated mockups + dialog chrome.
See apps/web/module_intro_content.py's module docstring for why this
is a SEPARATE file from style.css: a genuinely standalone new visual
subsystem (not a tweak to something already in style.css), loaded
globally via base.html same as tailwind_built.css/style.css.

Six reusable animated "kind"s, mixed and matched across every module's
steps (module_intro_content.py) instead of one bespoke animation per
step - same "few reusable building blocks" principle the rest of this
app's UI already follows:
  - search    - typing ticker + a score meter filling in
  - list-add  - a new row sliding into a list, checkmark pulse
  - sync      - a spinning refresh icon + a "Synced" label
  - signal    - a dot travelling across a bear->neutral->bull gauge
  - progress  - a row of checklist nodes filling in in sequence
  - game      - bouncing candle-style bars + a floating score pop

All ambient step animation is pure CSS (`animation-iteration-count:
infinite`) - no scroll-triggering or per-frame JS needed, so a step
looks equally alive whether the visitor lingers 2 seconds or 20.
module_intro.js only handles dialog open/close, step navigation
(toggling the `hidden` attribute), and the mark-seen network call.
*/

/* ---------- Dialog chrome ---------- */

.module-intro-dialog {
    max-width: 34rem;
    width: calc(100% - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    background: var(--color-panel);
    color: #fff;
}

.module-intro-dialog::backdrop {
    background: rgba(4, 6, 10, 0.72);
    backdrop-filter: blur(3px);
}

.module-intro-dialog[open] {
    animation: bx-intro-pop 0.25s ease-out;
}

@keyframes bx-intro-pop {
    from { opacity: 0; transform: scale(0.96) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.module-intro-inner {
    position: relative;
    padding: 2rem;
}

.module-intro-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 1.3rem;
    line-height: 1;
    background: transparent;
    border: none;
    cursor: pointer;
}
.module-intro-close:hover { color: #fff; background: rgba(255,255,255,0.06); }

.module-intro-inner h2 { font-size: 1.35rem; font-weight: 800; color: #fff; margin: 0 0.5rem 0.25rem 0; }
.module-intro-inner .module-intro-subtitle { font-size: 0.92rem; color: #94a3b8; margin: 0 0 1.25rem; }
.module-intro-inner h3 { font-size: 1.05rem; font-weight: 700; color: #fff; margin: 1.1rem 0 0.4rem; }
.module-intro-inner .module-intro-body { font-size: 0.9rem; color: #cbd5e1; line-height: 1.6; margin: 0; }

.module-intro-anim {
    height: 10rem;
    border-radius: 0.75rem;
    background: var(--color-base);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.module-intro-anim-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Real screen-recorded feature clip (see module_intro_content.py's
   `video` key + templates/partials/module_intro_modal.html) - fills
   the exact same box a CSS mockup would, so a module can mix real
   video for some steps and the CSS fallback for others with zero
   layout shift either way. Taller than the plain CSS-mockup box
   (roughly the dialog's own content width at a 16:9 ratio) since a
   real recording needs to show actual on-screen UI legibly, not just
   an abstract animated icon. */
.module-intro-anim.has-video {
    height: 17rem;
}

.module-intro-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: inherit;
    background: var(--color-base);
}

.module-intro-dots { display: flex; gap: 0.45rem; justify-content: center; margin: 1.25rem 0 0.25rem; }
.module-intro-dot { width: 0.45rem; height: 0.45rem; border-radius: 9999px; background: var(--color-border); transition: background 0.2s, transform 0.2s; }
.module-intro-dot.is-active { background: var(--color-accent); transform: scale(1.3); }

.module-intro-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 1.25rem; gap: 0.5rem; }
.module-intro-skip { font-size: 0.82rem; color: #64748b; background: none; border: none; cursor: pointer; }
.module-intro-skip:hover { color: #94a3b8; }
.module-intro-next, .module-intro-done {
    font-size: 0.88rem; font-weight: 700; padding: 0.6rem 1.25rem; border-radius: 0.55rem;
    background: var(--color-accent); color: var(--color-base); border: none; cursor: pointer;
}
.module-intro-back {
    font-size: 0.88rem; font-weight: 600; padding: 0.6rem 1.1rem; border-radius: 0.55rem;
    background: transparent; color: #cbd5e1; border: 1px solid var(--color-border); cursor: pointer;
}

/* Small "?" help launcher each module page gets for free from a
   single macro call - deliberately FIXED/bottom-right rather than
   inline next to a page's own H1: 8 different module pages have 8
   different header layouts, and hunting for "a good inline spot" in
   each one is far more fragile than one consistent, always-findable
   corner button every visitor learns once. Only rendered on pages
   that actually call the module_intro() macro, so it never appears
   on pages with nothing to explain. */
.module-intro-replay {
    position: fixed; bottom: 1.1rem; right: 1.1rem; z-index: 45;
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.5rem; height: 2.5rem; border-radius: 9999px;
    font-size: 1rem; font-weight: 800; color: #94a3b8;
    border: 1px solid var(--color-border); background: var(--color-panel); cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.module-intro-replay:hover { color: var(--color-accent); border-color: var(--color-accent); }

/* ---------- kind: search ---------- */

.bx-anim-search { display: flex; flex-direction: column; gap: 0.5rem; width: 80%; }
.bx-anim-search-bar {
    display: flex; align-items: center; height: 1.75rem; padding: 0 0.6rem; border-radius: 0.4rem;
    background: var(--color-panel); border: 1px solid var(--color-border); font-family: "JetBrains Mono", monospace; font-size: 0.75rem;
}
.bx-anim-search-text {
    display: inline-block; overflow: hidden; white-space: nowrap; width: 4ch; color: var(--color-accent);
    animation: bx-type 3s steps(4) infinite;
}
@keyframes bx-type {
    0%, 15% { width: 0; }
    45%, 85% { width: 4ch; }
    100% { width: 4ch; }
}
.bx-anim-cursor { display: inline-block; width: 2px; height: 0.9em; background: var(--color-accent); margin-left: 2px; animation: bx-blink 0.8s step-end infinite; }
@keyframes bx-blink { 50% { opacity: 0; } }
.bx-anim-search-card {
    height: 1.5rem; border-radius: 0.4rem; background: var(--color-panel); border: 1px solid var(--color-border);
    display: flex; align-items: center; padding: 0 0.5rem;
    opacity: 0; animation: bx-search-reveal 3s ease-in-out infinite;
}
@keyframes bx-search-reveal {
    0%, 45% { opacity: 0; transform: translateY(4px); }
    60%, 100% { opacity: 1; transform: translateY(0); }
}
.bx-anim-meter { flex: 1; height: 5px; border-radius: 9999px; background: var(--color-border); overflow: hidden; }
.bx-anim-meter-fill {
    display: block; height: 100%; width: 0%; border-radius: 9999px; background: var(--color-bull);
    animation: bx-meter-fill 3s ease-in-out infinite;
}
@keyframes bx-meter-fill {
    0%, 55% { width: 0%; }
    90%, 100% { width: 78%; }
}

/* ---------- kind: list-add ---------- */

.bx-anim-list { display: flex; flex-direction: column; gap: 0.35rem; width: 78%; }
.bx-anim-list-row { height: 1.15rem; border-radius: 0.3rem; background: var(--color-panel); border: 1px solid var(--color-border); }
.bx-anim-list-row-faint { opacity: 0.5; }
.bx-anim-list-row-new {
    display: flex; align-items: center; justify-content: flex-end; padding: 0 0.4rem;
    border-color: var(--color-bull); opacity: 0; transform: translateX(12px);
    animation: bx-row-in 3s ease-in-out infinite;
}
@keyframes bx-row-in {
    0%, 40% { opacity: 0; transform: translateX(12px); }
    65%, 100% { opacity: 1; transform: translateX(0); }
}
.bx-anim-check {
    color: var(--color-bull); font-size: 0.65rem; font-weight: 800;
    opacity: 0; animation: bx-check-pulse 3s ease-in-out infinite;
}
@keyframes bx-check-pulse {
    0%, 60% { opacity: 0; transform: scale(0.6); }
    75%, 100% { opacity: 1; transform: scale(1); }
}

/* ---------- kind: sync ---------- */

.bx-anim-sync { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.bx-anim-sync-icon {
    width: 2.1rem; height: 2.1rem; border-radius: 9999px;
    border: 3px solid var(--color-border); border-top-color: var(--color-accent);
    animation: bx-spin 1.4s linear infinite;
}
@keyframes bx-spin { to { transform: rotate(360deg); } }
.bx-anim-sync-label {
    font-size: 0.7rem; font-weight: 700; color: var(--color-bull);
    opacity: 0; animation: bx-fade-hold 2.8s ease-in-out infinite;
}
@keyframes bx-fade-hold {
    0%, 20% { opacity: 0; }
    45%, 85% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---------- kind: signal ---------- */

.bx-anim-signal { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; width: 75%; }
.bx-anim-signal-track {
    position: relative; width: 100%; height: 6px; border-radius: 9999px;
    background: linear-gradient(90deg, var(--color-bear), var(--color-border) 50%, var(--color-bull));
}
.bx-anim-signal-dot {
    position: absolute; top: 50%; left: 0; width: 0.7rem; height: 0.7rem; border-radius: 9999px;
    background: #fff; box-shadow: 0 0 0 3px var(--color-base);
    animation: bx-signal-travel 3s ease-in-out infinite;
}
@keyframes bx-signal-travel {
    0% { left: 0%; transform: translate(-50%, -50%) scale(1); }
    70% { left: 100%; transform: translate(-50%, -50%) scale(1); }
    85%, 100% { left: 100%; transform: translate(-50%, -50%) scale(1.3); }
}
.bx-anim-signal-badge {
    font-size: 0.7rem; font-weight: 700; color: var(--color-bull);
    opacity: 0; animation: bx-fade-hold 3s ease-in-out infinite;
}

/* ---------- kind: progress ---------- */

.bx-anim-progress { display: flex; align-items: center; gap: 0.6rem; }
.bx-anim-progress-node {
    width: 1.1rem; height: 1.1rem; border-radius: 9999px; border: 2px solid var(--color-border);
    position: relative;
}
.bx-anim-progress-node::after {
    content: "\2713"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; color: var(--color-base); opacity: 0;
}
.bx-anim-progress-node { animation: bx-node-fill 3s ease-in-out infinite; }
.bx-anim-progress-node:nth-child(1) { animation-delay: 0s; }
.bx-anim-progress-node:nth-child(2) { animation-delay: 0.5s; }
.bx-anim-progress-node:nth-child(3) { animation-delay: 1s; }
@keyframes bx-node-fill {
    0%, 20% { background: transparent; border-color: var(--color-border); }
    35%, 100% { background: var(--color-accent); border-color: var(--color-accent); }
}
.bx-anim-progress-node:nth-child(1)::after, .bx-anim-progress-node:nth-child(2)::after, .bx-anim-progress-node:nth-child(3)::after {
    animation: bx-node-check 3s ease-in-out infinite;
}
.bx-anim-progress-node:nth-child(2)::after { animation-delay: 0.5s; }
.bx-anim-progress-node:nth-child(3)::after { animation-delay: 1s; }
@keyframes bx-node-check {
    0%, 20% { opacity: 0; }
    35%, 100% { opacity: 1; }
}

/* ---------- kind: game ---------- */

.bx-anim-game { position: relative; display: flex; align-items: flex-end; gap: 0.35rem; height: 4rem; }
.bx-anim-bar { width: 0.5rem; border-radius: 0.15rem 0.15rem 0 0; animation: bx-bar-bounce 1.6s ease-in-out infinite; }
.bx-anim-bar-1 { background: var(--color-bull); animation-delay: 0s; }
.bx-anim-bar-2 { background: var(--color-bear); animation-delay: 0.15s; }
.bx-anim-bar-3 { background: var(--color-bull); animation-delay: 0.3s; }
.bx-anim-bar-4 { background: var(--color-bear); animation-delay: 0.45s; }
@keyframes bx-bar-bounce {
    0%, 100% { height: 30%; }
    50% { height: 90%; }
}
.bx-anim-score-pop {
    position: absolute; top: -0.2rem; right: -0.5rem; font-size: 0.7rem; font-weight: 800; color: var(--color-accent);
    opacity: 0; animation: bx-score-float 1.6s ease-out infinite;
}
@keyframes bx-score-float {
    0% { opacity: 0; transform: translateY(6px); }
    30% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

@media (prefers-reduced-motion: reduce) {
    .module-intro-dialog[open],
    .bx-anim-search-text, .bx-anim-cursor, .bx-anim-search-card, .bx-anim-meter-fill,
    .bx-anim-list-row-new, .bx-anim-check,
    .bx-anim-sync-icon, .bx-anim-sync-label,
    .bx-anim-signal-dot, .bx-anim-signal-badge,
    .bx-anim-progress-node, .bx-anim-progress-node::after,
    .bx-anim-bar, .bx-anim-score-pop {
        animation: none !important;
    }
}
