/* ──────────────────────────────────────────────────────────
   HOW IT WORKS — floating-icons flow with curved SVG arrows on a
   subtle grid canvas. Steps 1 / 2 / 4 / 5 are icon + caption columns.
   Step 3 (the branch) replaces its icon with the stacked service pills
   and a caption beneath. Two curves leave step 2: violet (over the top
   through Local) + cyan (under the bottom through Cloud), both converge
   at step 4. Straight cyan arrows on the linear segments.
   Canonical = cyan version (mcp + mcp-cloud). mcp-local keeps its
   2-rule violet-tinted .howitworks-neurons .nn-line / .nn-node override
   inline. Per-page #how-it-works { background: ... } stays on pages.
   ────────────────────────────────────────────────────────── */
#how-it-works {
    position: relative;
    overflow: hidden;
}

.howitworks-canvas {
    --row1-h: 80px;
    --canvas-pad-y: 2rem;
    --canvas-pad-x: 1.5rem;
    position: relative;
    padding: var(--canvas-pad-y) var(--canvas-pad-x);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 24px;
    background-color: rgba(8, 12, 22, 0.45);
    overflow: hidden;
}

/* SVG overlay sits ONLY over the icon row, not the full canvas — so the
   curves' y-coordinates map 1:1 to icon positions instead of stretching
   with caption height. */
.howitworks-arrows {
    position: absolute;
    top: var(--canvas-pad-y);
    left: var(--canvas-pad-x);
    right: var(--canvas-pad-x);
    height: var(--row1-h);
    width: auto;
    pointer-events: none;
    z-index: 0;
}

.howitworks-arrows path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.howitworks-arrows .arrow-line {
    stroke: #2BC0E0;
    stroke-width: 1.8;
}

.howitworks-arrows .arrow-cyan {
    stroke: #2BC0E0;
    stroke-width: 1.8;
}

.howitworks-arrows .arrow-violet {
    stroke: #A78BFA;
    stroke-width: 1.8;
}

.howitworks-flow {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: var(--row1-h) auto;
    column-gap: 0.75rem;
    row-gap: 1rem;
    align-items: stretch;
}

.howitworks-step {
    position: relative;
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 2;
    justify-items: center;
    text-align: center;
}

.howitworks-step__icon {
    align-self: center;
    width: 48px;
    height: 48px;
    color: #2BC0E0;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 12px rgba(43, 192, 224, 0.25));
}

.howitworks-step__icon svg {
    width: 100%;
    height: 100%;
}

/* Explicit fill for Figma-capture safety — currentColor sometimes fails to
   resolve through deep cascades, rendering icons as white squares. */
.howitworks-step__icon svg path, .howitworks-step__icon svg circle {
    fill: #2BC0E0;
}

.howitworks-step__title {
    align-self: start;
    color: #D5DCEA;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
    /* Generous max-width so titles spread horizontally and match the breathing-room
       of the longest step ("LLM presents results to user or agent"). Per Jeremy 2026-05-23. */
    max-width: 34ch;
}

/* Step 3 branching — pills stretch to fill row 1 vertically, with Local
   at top + Cloud at bottom so they sit on the violet/cyan curves. Width
   is auto-sized to content and centered in the column. */
.howitworks-step--branch .howitworks-step__paths {
    align-self: stretch;
    justify-self: center;
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    gap: 8px;
    width: auto;
}

.howitworks-path {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.005em;
    line-height: 1.2;
    white-space: nowrap;
}

.howitworks-path__text {
    display: flex;
}

.howitworks-path svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

/* Explicit fill for Figma-capture safety on path-pill icons. */
.howitworks-path--local svg path {
    fill: #C4B5FD;
}

.howitworks-path--cloud svg path {
    fill: #6FD8EE;
}

.howitworks-path--local {
    background: rgba(20, 14, 36, 0.92);
    border: 1px solid rgba(139, 92, 246, 0.60);
    color: #C4B5FD;
}

.howitworks-path--cloud {
    background: rgba(8, 22, 30, 0.92);
    border: 1px solid rgba(43, 192, 224, 0.60);
    color: #6FD8EE;
}

.howitworks-step--branch .howitworks-step__title {
    color: #D5DCEA;
}

/* Floating-neuron particles — layered behind the canvas. Keeps the
   section alive without competing with the diagram. */
.howitworks-neurons {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    mask-image: radial-gradient(ellipse at center, black 55%, transparent 90%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 55%, transparent 90%);
}

.howitworks-neurons svg {
    width: 100%;
    height: 100%;
}

.howitworks-neurons .nn-line {
    stroke: rgba(43, 192, 224, 0.18);
    stroke-width: 0.8;
    fill: none;
}

.howitworks-neurons .nn-node {
    fill: rgba(43, 192, 224, 0.55);
    animation: nn-pulse 4s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

.howitworks-neurons .nn-node--violet {
    fill: rgba(139, 92, 246, 0.55);
}

.howitworks-neurons .nn-group {
    animation: nn-drift 28s ease-in-out infinite alternate;
}

.howitworks-neurons .nn-group--b {
    animation-duration: 36s;
    animation-direction: alternate-reverse;
}

.howitworks-neurons .nn-node:nth-of-type(2n) {
    animation-delay: -0.8s;
}

.howitworks-neurons .nn-node:nth-of-type(3n) {
    animation-delay: -1.6s;
}

.howitworks-neurons .nn-node:nth-of-type(5n) {
    animation-delay: -2.4s;
}

@keyframes nn-pulse {
    0%, 100% {
        opacity: 0.30;
        r: 1.6;
    }

    50% {
        opacity: 0.90;
        r: 2.4;
    }
}

@keyframes nn-drift {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(18px, -14px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .howitworks-neurons .nn-node, .howitworks-neurons .nn-group {
        animation: none;
    }
}

/* Responsive — stack the flow vertically on tablet/mobile. The curved
   SVG hides since the horizontal-curve metaphor doesn't translate to
   a vertical stack; cards align centered, captions left-aligned. */
/* Mobile arrow SVGs (between-steps flow indicators) — hidden on desktop. */
.hiw-mobile-arrow {
    display: none;
}

/* Pill text hierarchy — colors inherit from parent pill, hierarchy via weight only. */
.path-main {
    font-weight: 600;
}

.path-sub {
    font-weight: 400;
}

.path-sep {
    /*margin: 0 6px;*/
    opacity: 0.5;
}

@media (max-width: 1024px) {
    .howitworks-flow {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
        min-height: 0;
        position: relative;
    }

    .howitworks-step {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        width: 100%;
        max-width: 480px;
    }

    .howitworks-step__title {
        align-self: center;
        max-width: 280px;
    }

    .howitworks-canvas {
        background-size: 30px 30px;
        padding: 2rem 1rem;
    }

    .howitworks-arrows path {
        display: none;
    }

    .hiw-mobile-arrow {
        display: block;
        width: 100%;
        max-width: 480px;
        margin: 8px 0;
    }

    .howitworks-step--branch .howitworks-step__paths {
        flex-direction: row;
        width: 100%;
        gap: 16px;
        align-items: stretch;
    }

    .howitworks-path {
        flex: 1;
        flex-direction: column;
        justify-content: flex-start;
        padding: 20px 16px;
        border-radius: 16px;
        background-image: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0) 100%);
        box-shadow: 0 8px 24px -8px rgba(0,0,0,0.5);
        text-align: center;
        gap: 12px;
    }

    .howitworks-path__text {
        display: revert;
    }

    .howitworks-path svg {
        margin-bottom: 2px;
        flex: 0 0 24px;
        width: 24px;
        height: 24px;
    }

    .path-main {
        display: block;
        font-size: 15px;
        margin-bottom: 4px;
    }

    .path-sep {
        display: none;
    }

    .path-sub {
        display: block;
        font-size: 0.75rem;
        line-height: 1.4;
        white-space: normal;
    }
}
