/* NIGHTFALLCOIN — motion shared by every page.
 *
 * Rules this file keeps:
 *   - Only transform, opacity, filter and clip-path move. Layout never does.
 *   - Without JavaScript, everything is visible: elements are hidden only
 *     after site-motion.js has prepared them, and only if they start below
 *     the fold — nothing already on screen ever blinks.
 *   - "Reduce motion" turns every effect off; the page is simply there.
 *   - Live network figures are never animated.
 */

/* ---------------------------------------------------------- page intro -- */
/* Plain CSS, so it runs on first paint with no flash. `backwards` (not
   `both`) hands control back as soon as each intro ends, so scroll effects
   that also use transform keep working afterwards. */

@keyframes sm-intro {
    from {
        opacity: 0;
        transform: translate3d(0, 28px, 0);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

@keyframes sm-intro-mask {
    from {
        clip-path: inset(0 0 100% 0);
        transform: translate3d(0, 0.45em, 0);
    }
    to {
        clip-path: inset(-0.25em -0.2em -0.3em -0.2em);
        transform: none;
    }
}

@keyframes sm-intro-zoom {
    from {
        opacity: 0;
        transform: translate3d(0, 24px, 0) scale(0.94) rotate(-1.2deg);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

@media (prefers-reduced-motion: no-preference) {
    /* Reading pages: kicker, title, lede. */
    .doc .wrap > .kicker,
    .doc .wrap > .lede,
    .doc .wrap > .e-lede-cards,
    .wp-hero-copy > :not(h1),
    .hero .eyebrow,
    .hero .lede,
    .hero-cta,
    .hero-meta,
    .hero-mark,
    .box > :not(.code) {
        animation: sm-intro 0.95s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    }

    .doc .wrap > h1,
    .wp-hero h1,
    .hero h1 {
        animation: sm-intro-mask 1.05s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
        animation-delay: 0.08s;
    }

    .wp-cover,
    .rm-cover,
    .cmp-cover,
    .hero .live-stack,
    .box > .code {
        animation: sm-intro-zoom 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
        animation-delay: 0.25s;
    }

    .hero-mark { animation-delay: 0s; }
    .hero .eyebrow { animation-delay: 0.05s; }
    .doc .wrap > .kicker { animation-delay: 0s; }
    .doc .wrap > .lede { animation-delay: 0.22s; }
    .doc .wrap > .lede + .lede { animation-delay: 0.32s; }
    .doc .wrap > .e-lede-cards { animation-delay: 0.42s; }
    .hero .lede { animation-delay: 0.2s; }
    .hero-cta { animation-delay: 0.3s; }
    .hero-meta { animation-delay: 0.4s; }
    .wp-hero-copy > :nth-child(1) { animation-delay: 0s; }
    .wp-hero-copy > :nth-child(3) { animation-delay: 0.2s; }
    .wp-hero-copy > :nth-child(4) { animation-delay: 0.3s; }
    .wp-hero-copy > :nth-child(5) { animation-delay: 0.38s; }
    .wp-hero-copy > :nth-child(n + 6) { animation-delay: 0.45s; }
    .box > :nth-child(1) { animation-delay: 0s; }
    .box > :nth-child(3) { animation-delay: 0.3s; }
    .box > :nth-child(4) { animation-delay: 0.4s; }
    .box > :nth-child(5) { animation-delay: 0.5s; }

    /* The roadmap's three ambitions arrive one after another. */
    .rm-orbit li {
        animation: sm-intro 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    }
    .rm-orbit li:nth-child(1) { animation-delay: 0.55s; }
    .rm-orbit li:nth-child(2) { animation-delay: 0.68s; }
    .rm-orbit li:nth-child(3) { animation-delay: 0.81s; }
    .rm-orbit li:nth-child(4) { animation-delay: 0.94s; }
}

/* ------------------------------------------------- arrive on scroll -- */

.sm {
    transition:
        opacity 0.9s cubic-bezier(0.2, 0.8, 0.2, 1),
        transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1),
        filter 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
    transition-delay: var(--sm-d, 0s);
}

.sm:not(.sm-in) {
    opacity: 0;
    transform: translate3d(0, 38px, 0) scale(0.985);
    filter: blur(6px);
}

.sm[data-sm="zoom"]:not(.sm-in) {
    transform: scale(0.93);
}

.sm[data-sm="left"]:not(.sm-in) {
    transform: translate3d(-42px, 0, 0);
}

.sm[data-sm="right"]:not(.sm-in) {
    transform: translate3d(42px, 0, 0);
}

.sm[data-sm="fade"]:not(.sm-in) {
    transform: none;
}

/* Table rows slide in one after another. */
.sm-row {
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    transition-delay: var(--sm-d, 0s);
}

.sm-row:not(.sm-in) {
    opacity: 0;
    transform: translate3d(-16px, 0, 0);
}

/* Emission bars fill as their row arrives. */
.e-bar i {
    transform-origin: left center;
    transition: transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
    transition-delay: calc(var(--sm-d, 0s) + 0.15s);
}

.sm-row:not(.sm-in) .e-bar i {
    transform: scaleX(0);
}

/* Headings rise out of a mask instead of fading in. */
.h-rise {
    clip-path: inset(0 0 100% 0);
    transform: translate3d(0, 0.5em, 0);
    transition: clip-path 0.95s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.95s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.h-rise.is-up {
    clip-path: inset(-0.25em -0.2em -0.35em -0.2em);
    transform: none;
}

/* A hairline that draws itself across the top of a section as it arrives. */
.sm-line-host {
    position: relative;
}

.sm-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: min(1180px, 92%);
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(222, 196, 255, 0.75), rgba(120, 219, 236, 0.6), transparent);
    transform: translateX(-50%) scaleX(0);
    transition: transform 1.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
}

.sm-line.is-drawn {
    transform: translateX(-50%) scaleX(1);
}

/* Gradient words catch the light once when they come into view. */
@keyframes sm-shine {
    from {
        background-size: 260% auto;
        background-position: 100% 50%;
    }
    to {
        background-size: 100% auto;
        background-position: 0% 50%;
    }
}

.grad-text.sm-shine {
    animation: sm-shine 2.2s cubic-bezier(0.2, 0.8, 0.2, 1) 1 both;
}

/* ---------------------------------------------------- pointer finish -- */

/* Cards lean toward the pointer and catch a little light. */
.tilt {
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.32s, box-shadow 0.32s;
}

.tilt.is-tilting {
    transition: transform 0.12s linear, border-color 0.32s, box-shadow 0.32s;
}

.tilt-host {
    position: relative;
}

.tilt::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(420px circle at var(--sx, 50%) var(--sy, 0%),
            rgba(222, 196, 255, 0.12), transparent 46%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.tilt.is-lit::after {
    opacity: 1;
}

.magnetic {
    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.25s, background 0.25s;
}

/* A soft light that follows the pointer across the page. */
.sm-glow {
    position: fixed;
    left: 0;
    top: 0;
    width: 720px;
    height: 720px;
    margin: -360px 0 0 -360px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(189, 162, 255, 0.075), rgba(189, 162, 255, 0.025) 40%, transparent 68%);
    pointer-events: none;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.6s ease;
    will-change: transform;
}

.sm-glow.on {
    opacity: 1;
}

/* Links in running text: the underline draws instead of snapping on. */
.doc p a:not(.btn),
.wp-chapter p a:not(.btn),
.rm-card p a:not(.btn),
.doc li a:not(.btn) {
    background-image: linear-gradient(90deg, var(--violet-hi), var(--teal));
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: 0 100%;
    transition: background-size 0.35s ease;
}

.doc p a:not(.btn):hover,
.wp-chapter p a:not(.btn):hover,
.rm-card p a:not(.btn):hover,
.doc li a:not(.btn):hover {
    background-size: 100% 1px;
    text-decoration: none;
}

/* The bar tucks away while reading down, and returns on the way up. */
nav {
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.3s, background 0.3s;
}

nav.nav-tucked {
    transform: translate3d(0, calc(-100% - 24px), 0);
}

/* ---------------------------------------------- stars behind the page -- */

/* Fixed behind everything, drifting slower than the content (the layers are
   moved by a fraction of the scroll, wrapped to the tile size). */
.page-stars {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
    opacity: 0.55;
}

.page-stars i {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: calc(100% + 640px);
    background-repeat: repeat;
    will-change: transform;
}

.stars-far {
    background-size: 320px 320px;
    background-image:
        radial-gradient(1px 1px at 12% 22%, rgba(255, 255, 255, 0.7) 50%, transparent 52%),
        radial-gradient(1px 1px at 58% 8%, rgba(255, 255, 255, 0.55) 50%, transparent 52%),
        radial-gradient(1px 1px at 81% 64%, rgba(236, 224, 255, 0.6) 50%, transparent 52%),
        radial-gradient(1px 1px at 34% 77%, rgba(255, 255, 255, 0.5) 50%, transparent 52%);
}

.stars-near {
    background-size: 560px 560px;
    background-image:
        radial-gradient(1.6px 1.6px at 20% 40%, rgba(255, 255, 255, 0.75) 50%, transparent 52%),
        radial-gradient(1.3px 1.3px at 72% 18%, rgba(240, 228, 255, 0.7) 50%, transparent 52%),
        radial-gradient(1.5px 1.5px at 48% 88%, rgba(255, 255, 255, 0.6) 50%, transparent 52%);
}

/* ------------------------------------------------ asked not to move --- */

@media (prefers-reduced-motion: reduce) {
    .sm,
    .sm-row,
    .h-rise,
    .grad-text.sm-shine {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        clip-path: none !important;
        animation: none !important;
    }

    .sm-line {
        transform: translateX(-50%) scaleX(1);
    }

    .page-stars,
    .sm-glow {
        display: none;
    }

    nav.nav-tucked {
        transform: none;
    }
}
