/* NIGHTFALLCOIN — scroll motion for the home page.
 *
 * Rules this file keeps:
 *   - Only transform and opacity move. Nothing here changes layout on scroll.
 *   - Every effect has a resting state that reads correctly with no
 *     JavaScript and with "reduce motion" switched on.
 *   - Live network numbers are never animated: they are shown as reported.
 *   - Scroll position is handed in by motion.js as custom properties
 *     (--hp on the hero, 0 → 1 as night falls). No timers run while the
 *     reader is not scrolling.
 */

/* ------------------------------------------------------- 1. nightfall -- */

.hero-sky,
.hero-sky i {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-sky {
    z-index: 0;
    overflow: hidden;
    --p: var(--hp, 0);
}

/* The last light on the horizon, behind the live card on the right — away
   from the headline and copy. It sinks and fades as the page is scrolled. */
.sky-dusk {
    background:
        radial-gradient(ellipse 46% 42% at 78% 104%, rgba(231, 156, 239, 0.34), transparent 72%),
        radial-gradient(ellipse 60% 30% at 70% 100%, rgba(255, 200, 92, 0.10), transparent 70%);
    opacity: calc(1 - var(--p));
    transform: translate3d(0, calc(var(--p) * 120px), 0);
}

/* Night itself: darker only, so text contrast can only improve. */
.sky-night {
    background: linear-gradient(180deg, rgba(14, 9, 26, 0.58) 0%,
            rgba(14, 9, 26, 0.46) 55%, rgba(14, 9, 26, 0.2) 100%);
    opacity: var(--p);
}

.sky-stars {
    opacity: calc(var(--p) * 0.95);
    background-size: 340px 300px;
    background-image:
        radial-gradient(1.5px 1.5px at 8% 18%, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 22% 62%, #fff 50%, transparent 52%),
        radial-gradient(1.8px 1.8px at 37% 12%, #f3e9ff 50%, transparent 52%),
        radial-gradient(1px 1px at 48% 44%, #fff 50%, transparent 52%),
        radial-gradient(1.3px 1.3px at 61% 8%, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 73% 36%, #e9dcff 50%, transparent 52%),
        radial-gradient(1.6px 1.6px at 86% 16%, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 93% 58%, #fff 50%, transparent 52%),
        radial-gradient(1.2px 1.2px at 30% 84%, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 67% 78%, #fff 50%, transparent 52%);
    transform: translate3d(0, calc(var(--p) * -36px), 0);
    /* Few stars behind the copy on the left, so no speck sits between words. */
    -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.18) 50%, #000 66%);
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.18) 50%, #000 66%);
}

/* The coin settles like a moon going down, and its halo comes up. */
.coin-holder {
    position: relative;
    transform: translate3d(0, calc(var(--hp, 0) * 22px), 0);
}

.coin-holder::after {
    content: "";
    position: absolute;
    inset: -40%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(222, 196, 255, 0.36), transparent 62%);
    opacity: calc(var(--hp, 0) * 0.9);
    pointer-events: none;
    z-index: -1;
}

/* The copy drifts up a touch and the live card lags behind it: two layers,
   so the hero has depth while it leaves. */
.hero-grid > :first-child {
    transform: translate3d(0, calc(var(--hp, 0) * -34px), 0);
}

.hero .live-stack {
    transform: translate3d(0, calc(var(--hp, 0) * 46px), 0) rotate(calc(var(--hp, 0) * -1.2deg));
}

@media (max-width: 760px) {
    .sky-stars {
        -webkit-mask-image: none;
        mask-image: none;
        opacity: calc(var(--p) * 0.5);
    }

    .hero-grid > :first-child,
    .hero .live-stack {
        transform: none;
    }
}

/* -------------------------------------------- 3. privacy: one payment -- */

.ledger {
    margin: 0 0 40px;
    padding: 26px 28px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    position: relative;
    overflow: hidden;
}

.ledger-head {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 10px;
}

.ledger-head::before {
    content: "";
}

.ledger-tag {
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 650;
    color: var(--text-dim);
}

.ledger-tag-sealed {
    color: var(--violet-hi);
}

.ledger-rows {
    margin: 0;
}

.ledger-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: baseline;
    padding: 11px 0;
    border-top: 1px solid rgba(102, 87, 119, 0.6);
}

.ledger-row dt {
    font-size: 0.86rem;
    color: var(--text-dim);
}

.ledger-row dd {
    display: contents;
    margin: 0;
}

.ledger .lp,
.ledger .ls {
    font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.88rem;
    min-width: 0;
}

.ledger .lp {
    color: var(--text);
}

.ledger .ls {
    color: var(--violet-hi);
}

.ledger figcaption {
    margin-top: 16px;
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.5;
}

/* Animated mode, switched on by motion.js: one column, and each value turns
   from what a public chain shows into what Nightfall stores. */
.ledger.is-live .ledger-head,
.ledger.is-live .ledger-row {
    grid-template-columns: 160px minmax(0, 1fr);
}

.ledger.is-live .ledger-tag {
    grid-column: 2;
    grid-row: 1;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.ledger.is-live .ledger-tag-sealed {
    opacity: 0;
    transform: translateY(6px);
}

.ledger.is-live.is-sealed .ledger-tag-plain {
    opacity: 0;
    transform: translateY(-6px);
}

.ledger.is-live.is-sealed .ledger-tag-sealed {
    opacity: 1;
    transform: none;
}

.ledger.is-live .ls {
    display: none;
}

.ledger.is-live .lp.is-sealed {
    color: var(--violet-hi);
}

.ledger.is-live .ledger-public .lp {
    color: var(--warn);
}

.ledger.is-live::after {
    /* A scan line that follows the sealing down the rows. */
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--grad-bright);
    opacity: calc(min(var(--lp, 0) * 4, 1) * (1 - var(--lp, 0)));
    transform: translate3d(0, calc(var(--lp, 0) * var(--lh, 300px)), 0);
    pointer-events: none;
}

@media (max-width: 760px) {
    .ledger {
        padding: 20px 18px 18px;
    }

    .ledger-head,
    .ledger-row,
    .ledger.is-live .ledger-head,
    .ledger.is-live .ledger-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .ledger-head::before {
        display: none;
    }

    .ledger.is-live .ledger-tag {
        grid-column: 1;
    }

    .ledger-row {
        padding: 9px 0;
    }

}

/* -------------------------------------------- 2. mining, step by step -- */

.mine-story {
    margin-top: 34px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr);
    gap: 34px;
    align-items: start;
}

.mine-story .steps {
    grid-column: 1;
    grid-row: 1;
}

.mine-demo-wrap {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 118px;
}

.step.is-active {
    border-color: var(--border-hi);
    box-shadow: 0 0 0 1px rgba(189, 162, 255, 0.25), var(--shadow);
}

.mine-demo {
    position: relative;
    padding: 22px;
    border-radius: var(--r-lg);
    background: var(--bg-2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: grid;
    gap: 14px;
}

.md-top,
.md-status,
.md-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.md-title {
    font-size: 1.15rem;
    font-weight: 650;
}

.md-peers {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.md-peer-dots {
    display: inline-flex;
    gap: 3px;
}

.md-peer-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--surface-2);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.md-peer-n {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.md-status {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    justify-content: flex-start;
}

.md-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-faint);
    flex: none;
    transition: background 0.3s ease;
}

.md-state {
    flex: 1;
    font-size: 0.92rem;
}

.md-btn {
    padding: 7px 14px;
    border-radius: var(--r-pill);
    background: var(--grad-bright);
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 650;
    white-space: nowrap;
    transition: transform 0.2s ease, background 0.3s ease, color 0.3s ease;
}

.md-on {
    display: none;
}

.md-stats > div {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 14px;
}

.md-stats small,
.md-mature small,
.md-reward small {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.md-stats b {
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
}

.md-work {
    color: var(--text-faint);
    font-weight: 500;
    font-size: 0.9rem !important;
}

.md-chain {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
    opacity: 0.45;
    transition: opacity 0.4s ease;
}

.md-blk {
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font: 0.78rem ui-monospace, Menlo, monospace;
    color: var(--text);
}

.md-link {
    width: 22px;
    height: 2px;
    background: linear-gradient(90deg, var(--border), var(--violet), var(--border));
}

.md-blk-new {
    opacity: 0;
    transform: translate3d(18px, 0, 0) scale(0.92);
    transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2),
        box-shadow 0.45s ease, border-color 0.45s ease;
}

.md-reward {
    position: absolute;
    top: -18px;
    right: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 8px;
    border-radius: 14px;
    background: rgba(45, 34, 69, 0.96);
    border: 1px solid rgba(222, 196, 255, 0.45);
    box-shadow: 0 10px 28px rgba(18, 12, 32, 0.4);
    opacity: 0;
    transform: translate3d(0, -8px, 0) scale(0.96);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.md-reward img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
}

.md-reward small {
    color: var(--violet-hi);
    font-size: 0.64rem;
    text-transform: none;
    letter-spacing: 0.02em;
}

.md-reward b {
    font-size: 0.98rem;
    color: #fff;
    white-space: nowrap;
}

.md-mature {
    opacity: 0.45;
    transition: opacity 0.4s ease;
}

.md-bar {
    display: block;
    height: 5px;
    margin-top: 8px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
}

.md-bar i {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: var(--grad-bright);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 1.6s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.md-cap {
    margin: 10px 4px 0;
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* Stage 1 — Start mining was pressed. */
.mine-demo[data-stage="1"] .md-on,
.mine-demo[data-stage="2"] .md-on,
.mine-demo[data-stage="3"] .md-on,
.mine-demo[data-stage="4"] .md-on {
    display: inline;
}

.mine-demo:not([data-stage="0"]) .md-off {
    display: none;
}

.mine-demo:not([data-stage="0"]) .md-dot {
    background: var(--success);
    animation: md-pulse 1.8s ease-in-out infinite;
}

.mine-demo:not([data-stage="0"]) .md-btn {
    background: var(--surface-2);
    color: var(--text);
}

@keyframes md-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 224, 168, 0.55); }
    50% { box-shadow: 0 0 0 6px rgba(74, 224, 168, 0); }
}

/* Stage 2 — peers found. Dots light one after another. */
.mine-demo[data-stage="2"] .md-peer-dots i,
.mine-demo[data-stage="3"] .md-peer-dots i,
.mine-demo[data-stage="4"] .md-peer-dots i {
    background: var(--teal);
    box-shadow: 0 0 6px rgba(120, 219, 236, 0.6);
}

.md-peer-dots i:nth-child(2) { transition-delay: 0.06s; }
.md-peer-dots i:nth-child(3) { transition-delay: 0.12s; }
.md-peer-dots i:nth-child(4) { transition-delay: 0.18s; }
.md-peer-dots i:nth-child(5) { transition-delay: 0.24s; }
.md-peer-dots i:nth-child(6) { transition-delay: 0.3s; }
.md-peer-dots i:nth-child(7) { transition-delay: 0.36s; }
.md-peer-dots i:nth-child(8) { transition-delay: 0.42s; }

/* Stage 3 — a new block joins the heaviest chain. */
.mine-demo[data-stage="3"] .md-chain,
.mine-demo[data-stage="4"] .md-chain {
    opacity: 1;
}

.mine-demo[data-stage="3"] .md-blk-new,
.mine-demo[data-stage="4"] .md-blk-new {
    opacity: 1;
    transform: none;
    border-color: var(--violet);
    box-shadow: 0 0 22px rgba(124, 92, 255, 0.45);
}

.mine-demo[data-stage="3"] .md-work,
.mine-demo[data-stage="4"] .md-work {
    color: var(--violet-hi);
}

/* Stage 4 — the reward, and the wait before it can be spent. */
.mine-demo[data-stage="4"] .md-reward {
    opacity: 1;
    transform: none;
}

.mine-demo[data-stage="4"] .md-mature {
    opacity: 1;
}

.mine-demo[data-stage="4"] .md-bar i {
    transform: scaleX(0.35);
}

@media (max-width: 940px) {
    .mine-story {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .mine-demo-wrap,
    .mine-story .steps {
        grid-column: 1;
        grid-row: auto;
    }

    .mine-demo-wrap {
        position: relative;
        top: auto;
    }

    .live-tile.tick,
    .supply-card.tick {
        animation: none;
    }
}

@media (max-width: 420px) {
    .md-reward {
        right: 12px;
    }

    .md-peers {
        font-size: 0.74rem;
    }
}


/* ------------------------------------------- 6. more scroll motion -- */

/* The proof assembles itself: each term of the equation, then the verdict. */
.eq-live .eq > * {
    opacity: 0.12;
    transform: translate3d(0, 14px, 0);
    filter: blur(3px);
    transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.55s ease;
}

.eq-live .eq > .on {
    opacity: 1;
    transform: none;
    filter: none;
}

.eq-live .verdict {
    opacity: 0.2;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4);
    transform: scale(0.94);
}

.eq-live .verdict.on {
    opacity: 1;
    transform: none;
}

/* Mining steps: a line that fills down the numbered circles as you read. */
.mine-story .steps {
    position: relative;
}

.mine-story .steps::after {
    content: "";
    position: absolute;
    left: 43px;
    top: 30px;
    bottom: 30px;
    width: 2px;
    border-radius: 2px;
    background: var(--grad-bright);
    transform-origin: top center;
    transform: scaleY(var(--sp, 0));
    opacity: 0.85;
    z-index: 0;
    pointer-events: none;
}

.mine-story .steps::before {
    content: "";
    position: absolute;
    left: 43px;
    top: 30px;
    bottom: 30px;
    width: 2px;
    background: rgba(102, 87, 119, 0.6);
    z-index: 0;
}

.mine-story .step {
    position: relative;
    z-index: 1;
}

@media (max-width: 760px) {
    .mine-story .steps::after,
    .mine-story .steps::before {
        left: 41px;
    }
}

/* A new block: the live cards glow once, the numbers stay as reported. */
@keyframes live-tick {
    0% { box-shadow: 0 0 0 0 rgba(120, 219, 236, 0); }
    25% { box-shadow: 0 0 0 1px rgba(120, 219, 236, 0.55), 0 0 26px rgba(120, 219, 236, 0.28); }
    100% { box-shadow: 0 0 0 0 rgba(120, 219, 236, 0); }
}

.live-tile.tick,
.supply-card.tick {
    animation: live-tick 1.6s ease-out var(--tick-d, 0s) 1;
}

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

@media (prefers-reduced-motion: reduce) {
    .eq-live .eq > *,
    .eq-live .verdict {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }

    .mine-story .steps::after {
        transform: scaleY(1);
    }

    .mine-demo-wrap {
        position: relative;
        top: auto;
    }

    .live-tile.tick,
    .supply-card.tick {
        animation: none;
    }
}
