/* ── Motion ─────────────────────────────────────────────────────────────────
   Everything that hides or moves content is gated behind `html.motion`, which
   js/motion.js adds only when IntersectionObserver exists and the visitor has
   not asked for reduced motion. Without it the pages render as plain static
   layout. js/motion.js adds `.is-inview` as each element scrolls into view.

   Entrances use `animation … backwards` rather than transitions: the element
   holds its `from` state through the delay, then hands back to its normal
   styles, so hover effects on the same element keep working afterwards. */

:root {
    --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --pipe-notch: 22px;
}

@keyframes rise-in {
    from { opacity: 0; transform: translateY(20px); }
}
@keyframes slide-in {
    from { opacity: 0; transform: translateX(-22px); }
}
@keyframes fade-in {
    from { opacity: 0; }
}
@keyframes pop-in {
    from { opacity: 0; transform: scale(0.6); }
}
@keyframes ring-pulse {
    0%   { opacity: 0.6; transform: scale(1); }
    70%  { opacity: 0;   transform: scale(1.5); }
    100% { opacity: 0;   transform: scale(1.5); }
}
@keyframes glow-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(243, 112, 30, 0.45); }
    70%  { box-shadow: 0 0 0 9px rgba(243, 112, 30, 0); }
    100% { box-shadow: 0 0 0 0 rgba(243, 112, 30, 0); }
}
@keyframes dash-flow {
    to { stroke-dashoffset: -14; }
}
@keyframes drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(60px, 30px, 0) scale(1.15); }
}
@keyframes nudge-down {
    0%, 100% { transform: translateY(0);   opacity: 1; }
    50%      { transform: translateY(4px); opacity: 0.55; }
}
@keyframes grow-x {
    from { transform: scaleX(0); }
}

/* ── Generic scroll reveal ──
   Each block of a section, and each column of a row, rises in as it arrives.
   Keep this selector in sync with REVEAL_SELECTOR in js/motion.js. */
html.motion :is(
    .hero-section .row > [class*="col-"] > *,
    .page-header > .container > *,
    section:not(.page-header) > .container > :not(.row),
    section:not(.page-header) > .container > .row > *
):not([data-animate]):not(.is-inview):not(:focus-within) {
    /* !important: some of these carry an inline opacity of their own.
       :focus-within: never hide a block the keyboard has already reached. */
    opacity: 0 !important;
}
html.motion :is(
    .hero-section .row > [class*="col-"] > *,
    .page-header > .container > *,
    section:not(.page-header) > .container > :not(.row),
    section:not(.page-header) > .container > .row > *
):not([data-animate]).is-inview {
    animation: rise-in 0.65s var(--ease-out) var(--reveal-delay, 0ms) backwards;
}

/* Self-sequencing components stay hidden until they arrive. */
html.motion [data-animate]:not(.is-inview):not(:focus-within) {
    opacity: 0;
}

/* ── Micro-interactions ── */
@media (prefers-reduced-motion: no-preference) {
    .btn-lg {
        transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out),
            background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }
    .btn-lg:hover {
        transform: translateY(-2px);
    }
    /* Leave Bootstrap's focus ring alone when the button is also focused. */
    .btn-lg:hover:not(:focus-visible) {
        box-shadow: 0 10px 24px rgba(15, 30, 40, 0.22);
    }
    .btn-lg:active {
        transform: translateY(0);
    }
    .pipeline-stage:hover .pipeline-medallion {
        transform: translateY(-4px) scale(1.04);
    }
    .cap-icon {
        transition: transform 0.25s var(--ease-spring), background-color 0.2s ease;
    }
    .service-card:hover .cap-icon {
        transform: scale(1.1) rotate(-4deg);
        background: rgba(243, 112, 30, 0.18);
    }
}

/* ── Hero: slow ambient glow behind the copy ── */
html.motion .hero-section {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
html.motion .hero-section::before,
html.motion .hero-section::after {
    content: '';
    position: absolute;
    z-index: -1;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    pointer-events: none;
    animation: drift 16s ease-in-out infinite alternate;
}
html.motion .hero-section::before {
    top: -220px;
    right: -120px;
    background: radial-gradient(circle, rgba(243, 112, 30, 0.24), transparent 65%);
}
html.motion .hero-section::after {
    bottom: -300px;
    left: -160px;
    background: radial-gradient(circle, rgba(120, 180, 220, 0.20), transparent 65%);
    animation-duration: 22s;
    animation-direction: alternate-reverse;
}

/* ── Hero: Caia's card plays the exchange out ── */
html.motion .caia-hero-card.is-inview {
    animation: rise-in 0.7s var(--ease-out) 0.25s backwards;
}
html.motion .caia-hero-card.is-inview .caia-bubble-rep {
    transform-origin: bottom right;
    animation: pop-in 0.45s var(--ease-spring) 0.9s backwards;
}
html.motion .caia-hero-card.is-inview .caia-bubble-caia {
    transform-origin: bottom left;
    animation: pop-in 0.45s var(--ease-spring) 1.7s backwards;
}
html.motion .caia-hero-card.is-inview .caia-chip {
    animation: pop-in 0.35s var(--ease-spring) backwards;
}
html.motion .caia-hero-card.is-inview .caia-chip:nth-child(1) { animation-delay: 2.3s; }
html.motion .caia-hero-card.is-inview .caia-chip:nth-child(2) { animation-delay: 2.42s; }
html.motion .caia-hero-card.is-inview .caia-chip:nth-child(3) { animation-delay: 2.54s; }

/* Caia's mark breathes wherever it sits, so it reads as switched on. */
html.motion .caia-mark {
    position: relative;
}
html.motion .caia-mark::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    border: 1px solid rgba(243, 112, 30, 0.7);
    pointer-events: none;
    animation: ring-pulse 2.6s ease-out infinite;
}

/* ── Monolithic vs sovereign: rows land one after another ── */
html.motion .compare-card.is-inview {
    animation: rise-in 0.6s var(--ease-out) backwards;
}
html.motion .compare-card.is-inview .compare-cell,
html.motion .compare-card.is-inview .compare-closing {
    animation: fade-in 0.5s ease-out backwards;
}
html.motion .compare-card.is-inview .compare-cell.compare-right {
    animation-name: slide-in;
}
html.motion .compare-card.is-inview .compare-cell:nth-child(3)  { animation-delay: 0.30s; }
html.motion .compare-card.is-inview .compare-cell:nth-child(4)  { animation-delay: 0.42s; }
html.motion .compare-card.is-inview .compare-cell:nth-child(5)  { animation-delay: 0.54s; }
html.motion .compare-card.is-inview .compare-cell:nth-child(6)  { animation-delay: 0.66s; }
html.motion .compare-card.is-inview .compare-cell:nth-child(7)  { animation-delay: 0.78s; }
html.motion .compare-card.is-inview .compare-cell:nth-child(8)  { animation-delay: 0.90s; }
html.motion .compare-card.is-inview .compare-cell:nth-child(9)  { animation-delay: 1.02s; }
html.motion .compare-card.is-inview .compare-cell:nth-child(10) { animation-delay: 1.14s; }
html.motion .compare-card.is-inview .compare-closing            { animation-delay: 1.35s; }

/* ── Deployment spectrum: the bar draws, then each stop lights up ── */
html.motion .spectrum rect,
html.motion .spectrum circle {
    transform-box: fill-box;
}
html.motion .spectrum.is-inview rect {
    transform-origin: left center;
    animation: grow-x 0.9s var(--ease-out) backwards;
}
html.motion .spectrum.is-inview circle {
    transform-origin: center;
    animation: pop-in 0.4s var(--ease-spring) backwards;
}
html.motion .spectrum.is-inview circle:nth-of-type(1) { animation-delay: 0.35s; }
html.motion .spectrum.is-inview circle:nth-of-type(2) { animation-delay: 0.55s; }
html.motion .spectrum.is-inview circle:nth-of-type(3) { animation-delay: 0.75s; }
html.motion .spectrum.is-inview circle:nth-of-type(4) {
    animation: pop-in 0.4s var(--ease-spring) 0.95s backwards,
        spectrum-beat 2.4s ease-in-out 1.6s infinite;
}
html.motion .spectrum.is-inview line,
html.motion .spectrum.is-inview text:nth-of-type(n + 3) {
    animation: fade-in 0.5s ease-out 1.1s backwards;
}
@keyframes spectrum-beat {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.16); }
}

/* ── Pipeline: five stages, first conversation to signed contract ──────────
   Stacked timeline by default; interlocking chevrons across one row at xl. */
.pipeline-flow {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 22px;
}
.pipeline-stage {
    --stage: #233D4D;
    --tint: #E3ECF7;
    --i: 0;
    position: relative;
    display: grid;
    grid-template-columns: 56px 1fr;
    column-gap: 16px;
    align-items: start;
}
.pipeline-stage:nth-child(2) { --i: 1; }
.pipeline-stage:nth-child(3) { --i: 2; }
.pipeline-stage:nth-child(4) { --i: 3; }
.pipeline-stage:nth-child(5) { --i: 4; }

.pipeline-stage--discover { --stage: #F3701E; --tint: #FDE8D9; }
.pipeline-stage--scope    { --stage: #3A7BD5; --tint: #E1ECFB; }
.pipeline-stage--price    { --stage: #2F9E8A; --tint: #DDF3EC; }
.pipeline-stage--close    { --stage: #16263A; --tint: #E3E9F5; }

/* The rail that joins one medallion to the next in the stacked layout. */
.pipeline-stage:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 27px;
    top: 62px;
    bottom: -18px;
    width: 2px;
    background: #dbe3ea;
}

.pipeline-medallion {
    position: relative;
    grid-row: 1 / span 2;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--stage);
    color: #ffffff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(35, 61, 77, 0.18);
    transition: transform 0.25s var(--ease-spring);
}
.pipeline-num {
    position: absolute;
    left: -8px;
    bottom: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--stage);
    border: 2px solid #ffffff;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pipeline-banner {
    background: var(--tint);
    border-radius: 12px;
    padding: 14px 18px;
}
.pipeline-title {
    font-size: 1.05rem;
    line-height: 1.3;
    margin: 0;
}
.pipeline-desc {
    grid-column: 2;
    margin: 0;
    padding: 10px 18px 0;
    color: #64748b;
    font-size: 0.95rem;
}

@media (min-width: 1200px) {
    .pipeline-flow {
        grid-template-columns: repeat(5, 1fr);
        gap: 0;
    }
    .pipeline-stage {
        display: flex;
        flex-direction: column;
        padding-top: 44px;
    }
    /* Tuck each chevron's notch over the previous one's point. */
    .pipeline-stage + .pipeline-stage {
        margin-left: calc(8px - var(--pipe-notch));
    }
    .pipeline-stage:not(:last-child)::after {
        content: none;
    }
    .pipeline-medallion {
        position: absolute;
        top: 0;
        left: calc(50% - 44px);
        z-index: 1;
        width: 88px;
        height: 88px;
        font-size: 36px;
    }
    .pipeline-num {
        left: -14px;
        bottom: 6px;
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
    .pipeline-banner {
        position: relative;
        z-index: 0;
        min-height: 152px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        background: none;
        border-radius: 0;
        padding: 56px calc(var(--pipe-notch) + 10px) 22px calc(var(--pipe-notch) + 14px);
    }
    .pipeline-banner::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        background: var(--tint);
        clip-path: polygon(
            0 0,
            calc(100% - var(--pipe-notch)) 0,
            100% 50%,
            calc(100% - var(--pipe-notch)) 100%,
            0 100%,
            var(--pipe-notch) 50%
        );
    }
    .pipeline-title {
        font-size: 1rem;
    }
    .pipeline-desc {
        padding: 16px 18px 0 calc(var(--pipe-notch) + 6px);
    }
}

html.motion .pipeline-flow.is-inview .pipeline-stage {
    animation: slide-in 0.6s var(--ease-out) calc(var(--i) * 170ms) backwards;
}
html.motion .pipeline-flow.is-inview .pipeline-medallion {
    animation: pop-in 0.5s var(--ease-spring) calc(var(--i) * 170ms + 180ms) backwards;
}
html.motion .pipeline-flow.is-inview .pipeline-desc {
    animation: fade-in 0.5s ease-out calc(var(--i) * 170ms + 320ms) backwards;
}
/* Once everything has landed, a ring passes from stage to stage on a loop. */
html.motion .pipeline-medallion::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--stage);
    opacity: 0;
    pointer-events: none;
}
/* One cycle is a whole five-stage lap, so the visible part of the ring is
   squeezed into each stage's own two-second slot. */
@keyframes stage-ring {
    0%   { opacity: 0.6; transform: scale(1); }
    16%  { opacity: 0;   transform: scale(1.5); }
    100% { opacity: 0;   transform: scale(1.5); }
}
html.motion .pipeline-flow.is-inview .pipeline-medallion::after {
    animation: stage-ring 10s ease-out calc(1.8s + var(--i) * 2s) infinite;
}

/* ── Economics: value on the left, lock-in vs sovereign on the right ── */
.econ-point {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}
.econ-point + .econ-point {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid #e2e8f0;
}
.econ-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
    background: rgba(243, 112, 30, 0.12);
    color: #F3701E;
}
.econ-icon--shield {
    background: rgba(47, 158, 138, 0.14);
    color: #2F9E8A;
}
.econ-title {
    font-size: 1.25rem;
    line-height: 1.25;
    margin: 0 0 8px;
}
.econ-point p {
    color: #64748b;
    margin: 0;
}

.econ-versus {
    position: relative;
    display: grid;
    gap: 14px;
}
.econ-arch {
    --base: 200ms;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #F4F6F8;
    padding: 20px;
    text-align: center;
}
.econ-arch--caia {
    --base: 450ms;
    background: #ffffff;
    border-color: rgba(243, 112, 30, 0.45);
    box-shadow: 0 14px 36px rgba(35, 61, 77, 0.10);
}
.econ-eyebrow {
    font-family: var(--font-accent);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 2px;
}
.econ-arch--caia .econ-eyebrow {
    color: #F3701E;
}
.econ-arch-title {
    font-size: 1.05rem;
    margin: 0 0 16px;
}
.econ-layer {
    border-radius: 10px;
    background: #E5E9EE;
    color: #233D4D;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.35;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.econ-layer small {
    font-weight: 400;
    font-size: 0.8rem;
    opacity: 0.85;
}
.econ-layer--row {
    flex-direction: row;
    justify-content: center;
    gap: 10px;
}
.econ-layer--row > .bi {
    font-size: 1.4rem;
    color: #64748b;
}
.econ-arch--old .econ-layer--core {
    background: #5B6B7B;
    color: #ffffff;
}
.econ-arch--caia .econ-layer {
    background: #F0F4F8;
}
.econ-arch--caia .econ-layer--core {
    background: #233D4D;
    color: #ffffff;
}
.econ-arch--caia .econ-layer--row > .bi {
    color: #F3701E;
}
.econ-arrow {
    display: block;
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1;
    margin: 6px 0;
}
.econ-arch--caia .econ-arrow {
    color: #F3701E;
}
.econ-list {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    text-align: left;
    font-size: 0.9rem;
    color: #64748b;
}
.econ-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}
.econ-list .bi {
    color: #94a3b8;
    flex-shrink: 0;
}
.econ-arch--caia .econ-list {
    color: #233D4D;
    font-weight: 600;
}
.econ-arch--caia .econ-list .bi {
    color: #2F9E8A;
}
.econ-vs {
    justify-self: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #233D4D;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 4px #ffffff;
}

@media (min-width: 768px) {
    .econ-versus {
        grid-template-columns: 1fr 1fr;
        gap: 28px;
    }
    .econ-vs {
        position: absolute;
        z-index: 1;
        top: calc(50% - 22px);
        left: calc(50% - 22px);
    }
}

html.motion .econ.is-inview .econ-point {
    animation: rise-in 0.6s var(--ease-out) backwards;
}
html.motion .econ.is-inview .econ-point + .econ-point {
    animation-delay: 150ms;
}
html.motion .econ.is-inview .econ-arch {
    animation: rise-in 0.6s var(--ease-out) var(--base) backwards;
}
/* Each architecture builds top-down: data, what it runs on, what you get. */
html.motion .econ.is-inview .econ-arch > * {
    animation: rise-in 0.45s var(--ease-out) calc(var(--base) + var(--k) * 110ms) backwards;
}
.econ-arch > :nth-child(1) { --k: 1; }
.econ-arch > :nth-child(2) { --k: 2; }
.econ-arch > :nth-child(3) { --k: 3; }
.econ-arch > :nth-child(4) { --k: 4; }
.econ-arch > :nth-child(5) { --k: 5; }
.econ-arch > :nth-child(6) { --k: 6; }
.econ-arch > :nth-child(7) { --k: 7; }
.econ-arch > :nth-child(8) { --k: 8; }
html.motion .econ.is-inview .econ-list li {
    animation: slide-in 0.4s var(--ease-out) backwards;
}
html.motion .econ.is-inview .econ-list li:nth-child(1) { animation-delay: calc(var(--base) + 1000ms); }
html.motion .econ.is-inview .econ-list li:nth-child(2) { animation-delay: calc(var(--base) + 1110ms); }
html.motion .econ.is-inview .econ-list li:nth-child(3) { animation-delay: calc(var(--base) + 1220ms); }
html.motion .econ.is-inview .econ-list li:nth-child(4) { animation-delay: calc(var(--base) + 1330ms); }
html.motion .econ.is-inview .econ-vs {
    animation: pop-in 0.45s var(--ease-spring) 0.8s backwards;
}
/* Only the sovereign side keeps moving: data flowing down through your stack. */
html.motion .econ.is-inview .econ-arch--caia .econ-arrow {
    animation: rise-in 0.45s var(--ease-out) calc(var(--base) + var(--k) * 110ms) backwards,
        nudge-down 1.5s ease-in-out 2s infinite;
}
html.motion .econ.is-inview .econ-arch--caia .econ-layer--core {
    animation: rise-in 0.45s var(--ease-out) calc(var(--base) + var(--k) * 110ms) backwards,
        glow-pulse 2.6s ease-out 2.2s infinite;
}
