/*
 * Analyze scroll tours - the layout half of analyze_tour.js. Stacked is
 * the base: the stage stuck on top, chapters passing beneath it. From lg
 * the stage stands beside its chapters instead. Scene-specific stage
 * content (the radar) is styled by its own scene.
 *
 * Every chapter keeps full-contrast text. The current one LEADS - a lit
 * card with the horizon's edge - instead of the others fading: faded body
 * text would fail WCAG 1.4.3, and nothing here is less true for being
 * off-centre. Chapters are tall enough that each gets its own moment, but
 * they're plain content: without JS, in print, or with reduced motion,
 * this is a readable list beside a picture.
 */
.scene-tour {
    /* Under the nav AND the fixed horizon dock (analyze_scenes.css's
       --dock-space), so the dock never slides over the stage - with a
       little air between them, which the stage covers (below). */
    --tour-gap: 0.75rem;
    --tour-top: calc(var(--nav-h, 4rem) + var(--dock-space, 3.5rem) + var(--tour-gap));
    --tour-accent: var(--color-horizon-swing, #a78bfa);
    display: grid;
    /* One column that never outgrows the page. An auto track grows to its
       widest item's min-content, and a chart's canvas starts life 300px
       wide (its intrinsic size): at 320px a chart's stage spilled
       off the screen, and Chart.js, measuring a box the canvas itself had
       stretched, never drew it any narrower. */
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
}
.scene-tour[data-horizon="day"] { --tour-accent: var(--color-horizon-day, #38bdf8); }
.scene-tour[data-horizon="invest"] { --tour-accent: var(--color-horizon-invest, #facc15); }

/* Stacked, the stage is solid with its fade OUTSIDE it (a base-coloured
   shadow below): a gradient fade inside it let passing text show through
   right at the dots. A hard shadow above covers the air under the dock,
   where passing chapters showed through too. It bleeds to the edges of
   main's px-4 sm:px-6 gutter. */
.scene-tour-stage {
    --tour-bleed: 1rem;
    position: sticky;
    top: var(--tour-top);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    background: var(--color-base, #080b10);
    box-shadow: 0 calc(-1 * var(--tour-gap)) 0 var(--color-base, #080b10), 0 1rem 1rem -0.25rem var(--color-base, #080b10);
    padding: 0 var(--tour-bleed) 0.75rem;
    margin-inline: calc(-1 * var(--tour-bleed));
}
/* Stuck under the dock (analyze_tour.js marks it), the cover reaches up to
   the nav: the dock is a floating pill, and chapters that slid under the
   stage re-emerged around it. Only while stuck - unstuck, it would hide
   whatever really sits above the tour. */
.scene-tour-stage.is-stuck {
    box-shadow: 0 calc(-1 * (var(--dock-space, 3.5rem) + var(--tour-gap))) 0 var(--color-base, #080b10), 0 1rem 1rem -0.25rem var(--color-base, #080b10);
}

.scene-tour-steps {
    list-style: none;
    margin: 0;
    padding: 0;
}
.scene-tour-step {
    /* Stacked, about the room left under the stage: the next chapter
       enters as the last one slides under, never an empty room. */
    min-height: 40vh;
    min-height: 40svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-block: 1rem;
}
.scene-tour-card {
    position: relative;
    border: 1px solid var(--color-border, #1c2431);
    border-radius: 1.25rem;
    background: var(--color-panel, #111722);
    padding: 1.25rem 1.25rem 1.25rem 1.5rem;
    transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
/* The horizon's edge, drawn in as the chapter takes the lead. */
.scene-tour-card::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 1.25rem;
    bottom: 1.25rem;
    width: 3px;
    border-radius: 3px;
    background: var(--tour-accent);
    transform: scaleY(0);
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.scene-tour-step.is-current .scene-tour-card {
    border-color: color-mix(in srgb, var(--tour-accent) 55%, var(--color-border, #1c2431));
    box-shadow: 0 24px 60px -32px var(--tour-accent);
    transform: translateY(-3px);
}
.scene-tour-step.is-current .scene-tour-card::before { transform: scaleY(1); }

/* "Where am I": one mark per chapter on the stage, mirroring the steps. */
.scene-tour-dots {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}
.scene-tour-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: var(--color-border, #1c2431);
    transition: background-color 0.3s ease, transform 0.3s ease;
}
.scene-tour-dot.is-read { background: color-mix(in srgb, var(--tour-accent) 55%, transparent); }
.scene-tour-dot.is-current { background: var(--tour-accent); transform: scale(1.5); }

@media (min-width: 640px) {
    .scene-tour-stage { --tour-bleed: 1.5rem; }
    /* Full-width chapters ran ~105 characters a line: keep a reading measure. */
    .scene-tour-steps {
        width: 100%;
        max-width: 40rem;
        margin-inline: auto;
    }
}

/* lg: side by side, the stage a full viewport tall so its picture sits
   mid-screen; the chapters start lower and leave room at the end, so the
   first and last each get to cross the reading line. */
@media (min-width: 1024px) {
    .scene-tour {
        grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
        gap: 3.5rem;
        align-items: start;
    }
    .scene-tour > .scene-tour-stage {
        height: calc(100vh - var(--tour-top) - 1rem);
        height: calc(100svh - var(--tour-top) - 1rem);
        justify-content: center;
        background: none;
        box-shadow: none;
        padding: 0;
        margin-inline: 0;
    }
    .scene-tour > .scene-tour-steps {
        max-width: none;
        padding-block: 8vh 22vh;
    }
    .scene-tour .scene-tour-step {
        min-height: 64vh;
        min-height: 64svh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .scene-tour-card,
    .scene-tour-card::before,
    .scene-tour-dot { transition: none; }
    .scene-tour-step.is-current .scene-tour-card { transform: none; }
}

@media print {
    .scene-tour { display: block; }
    .scene-tour-stage { position: static; height: auto; background: none; box-shadow: none; padding: 0; margin-inline: 0; }
    .scene-tour-dots { display: none; }
    .scene-tour-steps { padding: 0; }
    .scene-tour-step { min-height: 0; break-inside: avoid; }
}
