/* Integration flow page (developers/flows/<product>.html). Builds on developers.css' .dev-brand tokens. */

.flow { --flow-night: #0d1230; --flow-night-2: #151b45; --flow-line: color-mix(in srgb, var(--px-accent) 30%, transparent); }
.flow code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.flow-section { padding-bottom: 96px; scroll-margin-top: 80px; }
.flow-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 32px; }
.flow-head > div:first-child { max-width: 680px; }
.dev .flow-head h2 {
    margin: 10px 0 0;
    font-family: var(--px-font-display);
    font-size: clamp(26px, 2.8vw, 36px);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--px-ink);
}
.dev .flow-head p { margin: 12px 0 0; font-size: 16px; line-height: 1.6; color: var(--px-muted); }

/* ---------- Hero ---------- */
.flow-stats { display: flex; gap: 36px; margin: 36px 0 0; }
.flow-stats div { display: grid; gap: 2px; }
.flow-stats dt { font-family: var(--px-font-display); font-size: 30px; font-weight: 800; letter-spacing: -0.03em; color: var(--px-accent-deep); }
.flow-stats dd { margin: 0; font-size: 13.5px; color: var(--px-muted); }
.flow-stats code { font-size: 12.5px; }

.flow-arch {
    position: relative;
    aspect-ratio: 520 / 440;
    border-radius: var(--px-radius-lg);
    background:
        radial-gradient(420px circle at 80% 10%, color-mix(in srgb, var(--px-accent) 26%, transparent), transparent 60%),
        radial-gradient(360px circle at 10% 100%, color-mix(in srgb, var(--px-cyan) 30%, transparent), transparent 60%),
        var(--flow-night);
    box-shadow: 0 50px 100px -40px var(--px-accent-glow), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    overflow: hidden;
    color: color-mix(in srgb, var(--px-accent) 55%, #ffffff);
}
.flow-arch::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 22px 22px;
}
.flow-arch-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.flow-arch-path { fill: none; stroke: color-mix(in srgb, var(--px-accent) 45%, #ffffff); stroke-opacity: 0.45; stroke-width: 2; stroke-dasharray: 5 7; animation: flow-dash 1.6s linear infinite; }
.flow-dot { fill: #ffffff; filter: drop-shadow(0 0 8px currentColor) drop-shadow(0 0 3px #fff); opacity: 0; }
.flow-dot--media { fill: color-mix(in srgb, var(--px-cyan) 70%, #ffffff); }
.flow-dot--id { fill: #6ee7b7; }
@keyframes flow-dash { to { stroke-dashoffset: -24; } }

.flow-node {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 30%;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(6px);
    color: #fff;
    transform: translate(-50%, -50%);
    animation: flow-ping 8s infinite;
}
.flow-node strong { display: block; font: 700 14px/1.2 var(--px-font-display); }
.flow-node small { display: block; margin-top: 2px; font-size: 11.5px; color: #8f97c8; }
.flow-node-ico {
    flex: none;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--px-accent) 35%, transparent);
    color: #fff;
}
.flow-node-ico svg { width: 20px; height: 20px; }
.flow-node--backend { left: 22%; top: 20%; animation-delay: 6.2s; }
.flow-node--api { left: 78%; top: 20%; animation-delay: 4.8s; }
.flow-node--app { left: 50%; top: 82%; width: 38%; animation-delay: 2.5s; }
/* A ring when a message arrives; delays line up with the dots' 8 s loop. */
@keyframes flow-ping {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--px-accent) 70%, transparent); border-color: rgba(255, 255, 255, 0.4); }
    8% { box-shadow: 0 0 0 14px transparent; border-color: rgba(255, 255, 255, 0.1); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.flow-tag {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border-radius: 99px;
    background: rgba(13, 18, 48, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font: 600 11.5px var(--px-font);
    color: #c9cdf0;
    white-space: nowrap;
}
.flow-tag b {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--px-accent);
    font-size: 10.5px;
    color: #fff;
}
.flow-tag--1 { left: 50%; top: 13%; transform: translateX(-50%); }
.flow-tag--5 { left: 50%; top: 24%; transform: translateX(-50%); }
.flow-tag--2 { left: 6%; top: 52%; }
.flow-tag--4 { left: 10%; top: 61%; }
.flow-tag--3 { right: 5%; top: 56%; }

/* ---------- Platform switch ---------- */
.flow-switch {
    position: relative;
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 5px;
    border-radius: 99px;
    background: var(--px-bg-3);
    box-shadow: 0 0 0 1px var(--px-border) inset;
    flex: none;
}
.flow-switch button {
    position: relative;
    z-index: 1;
    padding: 9px 20px;
    border: 0;
    background: none;
    font: 700 14px var(--px-font);
    color: var(--px-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}
.flow-switch button[aria-checked="true"] { color: var(--px-ink); }
.flow-switch-thumb {
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 5px;
    width: calc((100% - 10px) / 3);
    border-radius: 99px;
    background: #fff;
    box-shadow: var(--px-shadow-sm), 0 0 0 1px var(--px-accent-line);
    transform: translateX(calc(var(--pos, 0) * 100%));
    transition: transform 0.45s var(--px-ease);
}

/* ---------- Journey ---------- */
.flow-journey { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 56px; align-items: start; }
.flow-stage { position: sticky; top: 96px; display: grid; justify-items: center; gap: 18px; }

.flow-phone {
    position: relative;
    width: min(300px, 100%);
    aspect-ratio: 9 / 18.5;
    padding: 12px;
    border-radius: 46px;
    background: linear-gradient(160deg, #1f2552, #0a0e26);
    box-shadow: 0 60px 120px -50px var(--px-accent-glow), 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 0 0 2px #070a1e;
}
.flow-phone-notch {
    position: absolute;
    z-index: 3;
    top: 22px;
    left: 50%;
    width: 84px;
    height: 24px;
    border-radius: 99px;
    background: #05071a;
    transform: translateX(-50%);
}
.flow-screens {
    position: relative;
    height: 100%;
    border-radius: 36px;
    overflow: hidden;
    background:
        radial-gradient(280px circle at 50% 0%, color-mix(in srgb, var(--px-accent) 30%, transparent), transparent 70%),
        var(--flow-night);
}
.flow-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 56px 22px 34px;
    color: #fff;
    text-align: center;
    opacity: 0;
    transform: translateX(24px) scale(0.98);
    transition: opacity 0.5s var(--px-ease), transform 0.6s var(--px-ease);
    pointer-events: none;
}
.flow-screen.is-active { opacity: 1; transform: none; }
.flow-screen.is-leaving { transform: translateX(-24px) scale(0.98); }
.flow-s-title { margin: 0; font: 700 17px/1.3 var(--px-font-display); }
.flow-s-hint { margin: 0; font-size: 13px; color: #aab1dd; }

/* start */
.flow-s-key {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--px-grad);
    box-shadow: 0 16px 40px -12px var(--px-accent-glow);
}
.flow-s-key svg { width: 30px; height: 30px; color: #fff; }
.is-active .flow-s-key { animation: flow-pop 0.7s var(--px-ease) both; }
.flow-s-tid { padding: 6px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); font-size: 12.5px; color: #6ee7b7; }
.is-active .flow-s-tid { animation: flow-type 1.4s steps(13) 0.4s both; overflow: hidden; white-space: nowrap; }
.flow-s-loader { display: flex; gap: 6px; }
.flow-s-loader i { width: 7px; height: 7px; border-radius: 50%; background: #8f97c8; animation: flow-bounce 1s infinite; }
.flow-s-loader i:nth-child(2) { animation-delay: 0.15s; }
.flow-s-loader i:nth-child(3) { animation-delay: 0.3s; }
@keyframes flow-pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes flow-type { from { max-width: 0; } to { max-width: 140px; } }
@keyframes flow-bounce { 50% { transform: translateY(-6px); background: #fff; } }

/* select */
.flow-s-list { display: grid; gap: 10px; width: 100%; margin: 0; padding: 0; list-style: none; }
.flow-s-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
    text-align: left;
}
.flow-s-list i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #5b6396; }
.is-active .flow-s-list .is-picked { animation: flow-pick 0.5s var(--px-ease) 0.7s both; }
.is-active .flow-s-list .is-picked i { animation: flow-pick-dot 0.5s var(--px-ease) 0.7s both; }
@keyframes flow-pick { to { background: color-mix(in srgb, var(--px-accent) 30%, transparent); border-color: var(--px-accent); } }
@keyframes flow-pick-dot { to { border-color: #fff; background: #fff; box-shadow: 0 0 0 3px var(--px-accent) inset; } }

/* document card */
.flow-s-frame { position: relative; padding: 18px; }
.flow-s-frame::before, .flow-s-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 3px solid var(--px-accent-2);
    border-radius: 14px;
    -webkit-mask: linear-gradient(#000 0 0) top left / 26px 26px no-repeat, linear-gradient(#000 0 0) top right / 26px 26px no-repeat,
        linear-gradient(#000 0 0) bottom left / 26px 26px no-repeat, linear-gradient(#000 0 0) bottom right / 26px 26px no-repeat;
    mask: linear-gradient(#000 0 0) top left / 26px 26px no-repeat, linear-gradient(#000 0 0) top right / 26px 26px no-repeat,
        linear-gradient(#000 0 0) bottom left / 26px 26px no-repeat, linear-gradient(#000 0 0) bottom right / 26px 26px no-repeat;
}
.flow-s-frame::after { border-color: #6ee7b7; opacity: 0; }
.is-active .flow-s-frame::after { animation: flow-lock 3s 1.8s both; }
@keyframes flow-lock { 0%, 100% { opacity: 0; } 10%, 90% { opacity: 1; } }

.flow-card {
    position: relative;
    width: 200px;
    aspect-ratio: 85.6 / 54;
    border-radius: 11px;
    background: linear-gradient(135deg, #e9ecfb, #c9d0f3);
    box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}
.flow-card i { position: absolute; display: block; border-radius: 4px; background: rgba(10, 16, 51, 0.18); }
.flow-card .ph { left: 8%; top: 18%; width: 26%; height: 62%; border-radius: 6px; background: linear-gradient(180deg, #9aa3d6, #7d86c0); }
.flow-card .l1 { left: 40%; top: 24%; width: 46%; height: 8%; }
.flow-card .l2 { left: 40%; top: 42%; width: 36%; height: 8%; }
.flow-card .l3 { left: 40%; top: 60%; width: 42%; height: 8%; }
.flow-card .chip { right: 8%; bottom: 14%; width: 15%; height: 22%; border-radius: 4px; background: linear-gradient(135deg, #f6d38a, #c99a3b); }
.flow-card--back { display: flex; align-items: flex-end; padding: 10px 10px 9px; background: linear-gradient(135deg, #eef0fb, #d6dbf5); }
.flow-card--back .mrz { font: 600 8.6px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.06em; color: #2a3168; text-align: left; }
.flow-s-scan {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 18px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, transparent, var(--px-accent-2), transparent);
    box-shadow: 0 0 18px 4px color-mix(in srgb, var(--px-accent) 60%, transparent);
    opacity: 0;
}
.is-active .flow-s-scan { animation: flow-scan 1.8s var(--px-ease) 0.3s 2 both; }
@keyframes flow-scan { 0% { top: 18px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: calc(100% - 21px); opacity: 0; } }

/* hologram */
.flow-s-tilt { perspective: 700px; }
.is-active .flow-card--holo { animation: flow-tilt 2.4s ease-in-out infinite; }
.flow-card .sheen {
    position: absolute;
    inset: -40%;
    background: linear-gradient(110deg, transparent 35%, rgba(255, 120, 200, 0.55) 44%, rgba(120, 220, 255, 0.6) 50%, rgba(160, 255, 160, 0.5) 56%, transparent 65%);
    mix-blend-mode: overlay;
    transform: translateX(-60%);
}
.is-active .flow-card .sheen { animation: flow-sheen 2.4s ease-in-out infinite; }
@keyframes flow-tilt { 0%, 100% { transform: rotateY(-18deg) rotateX(6deg); } 50% { transform: rotateY(18deg) rotateX(-4deg); } }
@keyframes flow-sheen { 0%, 100% { transform: translateX(-60%); } 50% { transform: translateX(40%); } }

/* nfc */
.flow-s-nfc { position: relative; display: grid; place-items: center; width: 170px; height: 170px; }
.flow-s-nfc .wave { position: absolute; inset: 30%; border-radius: 50%; border: 2px solid var(--px-accent-2); opacity: 0; }
.is-active .flow-s-nfc .wave { animation: flow-wave 2.1s ease-out infinite; }
.is-active .flow-s-nfc .wave:nth-child(2) { animation-delay: 0.7s; }
.is-active .flow-s-nfc .wave:nth-child(3) { animation-delay: 1.4s; }
.flow-s-nfc-ico {
    position: relative;
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    border-radius: 24px;
    background: var(--px-grad);
    box-shadow: 0 16px 40px -12px var(--px-accent-glow);
}
.flow-s-nfc-ico svg { width: 36px; height: 36px; color: #fff; }
@keyframes flow-wave { 0% { inset: 30%; opacity: 0.9; } 100% { inset: -6%; opacity: 0; } }
.flow-s-progress { width: 70%; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.flow-s-progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--px-accent), #6ee7b7); }
.is-active .flow-s-progress i { animation: flow-fill 3s var(--px-ease) 0.3s both; }
@keyframes flow-fill { to { width: 100%; } }

/* liveness */
.flow-s-face-svg { width: 150px; height: 187px; overflow: visible; }
.flow-s-face-svg .ring { fill: none; stroke: var(--px-accent-2); stroke-width: 3; stroke-dasharray: 6 8; transform-origin: 60px 75px; }
.is-active .flow-s-face-svg .ring { animation: flow-spin 6s linear infinite, flow-ring-ok 3.2s 2.2s both; }
.flow-s-face-svg .head { fill: rgba(255, 255, 255, 0.1); stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.5; }
.flow-s-face-svg .eyes { fill: #fff; }
.flow-s-face-svg .eyes ellipse { transform-box: fill-box; transform-origin: center; }
.is-active .flow-s-face-svg .eyes ellipse { animation: flow-blink 1.4s 0.6s 2; }
.flow-s-face-svg .mouth { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; }
@keyframes flow-spin { to { transform: rotate(360deg); } }
@keyframes flow-ring-ok { to { stroke: #6ee7b7; stroke-dasharray: 400 0; } }
@keyframes flow-blink { 0%, 40%, 60%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.1); } }

/* result */
.flow-s-ok {
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0.18);
    color: #fff;
}
.flow-s-ok svg { width: 34px; height: 34px; stroke-dasharray: 30; stroke-dashoffset: 30; }
.is-active .flow-s-ok { animation: flow-pop 0.6s var(--px-ease) both; }
.is-active .flow-s-ok svg { animation: flow-draw 0.5s ease 0.35s forwards; }
@keyframes flow-draw { to { stroke-dashoffset: 0; } }
.flow-s-checks { display: grid; gap: 8px; width: 100%; margin: 0; padding: 0; list-style: none; }
.flow-s-checks li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 11px;
    opacity: 0;
}
.flow-s-checks code { overflow: hidden; text-overflow: ellipsis; color: #c9cdf0; }
.flow-s-checks b { color: #6ee7b7; font-size: 12px; }
.is-active .flow-s-checks li { animation: flow-in 0.45s var(--px-ease) both; }
.is-active .flow-s-checks li:nth-child(1) { animation-delay: 0.6s; }
.is-active .flow-s-checks li:nth-child(2) { animation-delay: 0.85s; }
.is-active .flow-s-checks li:nth-child(3) { animation-delay: 1.1s; }
.is-active .flow-s-checks li:nth-child(4) { animation-delay: 1.35s; }
@keyframes flow-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.flow-play {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--px-border-2);
    border-radius: 99px;
    background: #fff;
    font: 600 13px var(--px-font);
    color: var(--px-muted);
    cursor: pointer;
}
.flow-play:hover { color: var(--px-ink); border-color: var(--px-accent-line); }
.flow-play-play, .flow-play[aria-pressed="true"] .flow-play-pause { display: none; }
.flow-play[aria-pressed="true"] .flow-play-play { display: inline; }

/* step list */
.flow-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.flow-step-btn {
    position: relative;
    display: flex;
    gap: 16px;
    width: 100%;
    padding: 18px 20px;
    border: 1px solid var(--px-border);
    border-radius: 18px;
    background: #fff;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.4s var(--px-ease), transform 0.4s var(--px-ease);
}
.flow-step-btn:hover { border-color: var(--px-accent-line); }
.flow-step.is-active .flow-step-btn { border-color: var(--px-accent-line); box-shadow: var(--px-shadow-accent); }
.flow-step-num {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--px-bg-3);
    font: 800 14px var(--px-font-display);
    color: var(--px-muted);
    transition: background 0.3s ease, color 0.3s ease;
}
.flow-step.is-active .flow-step-num { background: var(--px-accent); color: #fff; }
.flow-step-copy { display: grid; flex: 1; min-width: 0; }
.flow-step-copy strong {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    font: 700 16.5px/1.3 var(--px-font-display);
    letter-spacing: -0.015em;
    color: var(--px-ink);
}
/* Collapsed details that open on the active step (grid-rows 0fr → 1fr). */
.flow-step-more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.5s var(--px-ease); }
.flow-step-more > span { overflow: hidden; }
.flow-step.is-active .flow-step-more { grid-template-rows: 1fr; }
.flow-step-more small { display: block; padding-top: 6px; font-size: 14.5px; line-height: 1.6; color: var(--px-muted); }
.flow-code { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; }
.flow-code code {
    padding: 4px 9px;
    border-radius: 7px;
    background: var(--flow-night);
    font-size: 12.5px;
    color: color-mix(in srgb, var(--px-accent) 40%, #ffffff);
}
.flow-journey:not([data-platform="web"]) .flow-code [data-on="web"],
.flow-journey[data-platform="web"] .flow-code [data-on]:not([data-on~="web"]),
.flow-journey[data-platform="android"] .flow-code [data-on]:not([data-on~="android"]),
.flow-journey[data-platform="ios"] .flow-code [data-on]:not([data-on~="ios"]) { display: none; }

.flow-badge {
    padding: 3px 9px;
    border-radius: 99px;
    background: var(--px-bg-3);
    font: 600 11.5px var(--px-font);
    font-style: normal;
    letter-spacing: 0;
    color: var(--px-muted);
}
.flow-badge--server { background: color-mix(in srgb, #10b981 12%, #fff); color: #047857; }
.flow-badge--off { display: none; background: #fff1f2; color: #be123c; }
.flow-journey[data-platform="web"] [data-web="off"] .flow-badge--off { display: inline; }
.flow-journey[data-platform="web"] [data-web="off"] .flow-step-btn { background: repeating-linear-gradient(-45deg, #fff, #fff 10px, var(--px-bg) 10px, var(--px-bg) 20px); }
.flow-journey[data-platform="web"] [data-web="off"] .flow-step-copy strong { color: var(--px-muted); }

.flow-step-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--px-grad); }
.flow-step.is-active .flow-step-bar { animation: flow-fill var(--flow-step-ms, 4200ms) linear both; }
.flow-journey.is-paused .flow-step-bar { animation: none; width: 0; }

/* ---------- Controls picker ---------- */
.flow-config { padding: 32px; }
.flow-config-pickers { display: flex; flex-wrap: wrap; gap: 24px 32px; }
.flow-field { display: grid; gap: 10px; }
.flow-field-label { font: 700 12px var(--px-font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--px-dim); }
.flow-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.flow-seg button {
    padding: 9px 16px;
    border: 1px solid var(--px-border-2);
    border-radius: 12px;
    background: #fff;
    font: 600 14px var(--px-font);
    color: var(--px-text);
    cursor: pointer;
    transition: all 0.25s ease;
}
.flow-seg button:hover { border-color: var(--px-accent-line); }
.flow-seg button[aria-checked="true"] { background: var(--px-accent); border-color: var(--px-accent); color: #fff; box-shadow: 0 10px 24px -12px var(--px-accent-glow); }
.flow-seg button:disabled { opacity: 0.4; cursor: not-allowed; }

.flow-pipeline {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 32px 0 24px;
    padding: 22px;
    border-radius: 18px;
    background: var(--px-bg);
    box-shadow: 0 0 0 1px var(--px-border) inset;
}
.flow-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #fff;
    border: 1px dashed var(--px-border-2);
    font: 700 12.5px ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--px-dim);
    transition: all 0.45s var(--px-ease);
}
.flow-pill svg { width: 18px; height: 18px; }
.flow-pill.is-on {
    border: 1px solid var(--px-accent);
    background: var(--px-accent);
    color: #fff;
    box-shadow: 0 12px 26px -14px var(--px-accent-glow);
    transform: translateY(-2px);
}
.flow-pill.is-off { opacity: 0.45; text-decoration: line-through; }

.flow-config-out { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.flow-json {
    margin: 0;
    padding: 18px 20px;
    border-radius: 14px;
    background: var(--flow-night);
    font: 500 13.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #c9cdf0;
    white-space: pre-wrap;
}
.flow-json .k { color: #79c0ff; }
.flow-json .s { color: #a5d6ff; }
.flow-json .c { color: #6e7681; }
.flow-config-note { margin: 0; font-size: 15px; line-height: 1.6; color: var(--px-muted); }
.flow-config-note.is-warn { padding: 14px 16px; border-radius: 12px; background: #fff7ed; color: #9a3412; }

/* ---------- Sequence ---------- */
.flow-seq { padding: 28px 28px 34px; }
.flow-seq-lanes, .flow-seq-rows { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.flow-seq-lanes span {
    grid-column: span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    margin: 0 8px;
    border-radius: 14px;
    background: var(--px-bg-3);
    font: 700 14.5px var(--px-font-display);
    color: var(--px-ink);
}
.flow-seq-lanes svg { width: 18px; height: 18px; color: var(--px-accent); }
.flow-seq-rows {
    position: relative;
    margin: 0;
    padding: 18px 0 0;
    list-style: none;
    row-gap: 18px;
    /* Lifelines under each lane. */
    background:
        linear-gradient(var(--px-border-2), var(--px-border-2)) calc(100% / 6) 0 / 1px 100% no-repeat,
        linear-gradient(var(--px-border-2), var(--px-border-2)) 50% 0 / 1px 100% no-repeat,
        linear-gradient(var(--px-border-2), var(--px-border-2)) calc(500% / 6) 0 / 1px 100% no-repeat;
}
/* Lane n's centre is grid line 2n: an arrow spans the lines between its two lanes. */
.flow-msg { grid-column: calc(min(var(--from), var(--to)) * 2) / calc(max(var(--from), var(--to)) * 2); position: relative; padding-bottom: 14px; }
.flow-msg-label {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--px-text);
    text-align: center;
}
.flow-msg-label b {
    flex: none;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--px-accent);
    font-size: 11.5px;
    color: #fff;
}
.flow-msg-line {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--px-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.7s var(--px-ease) calc(0.25s + var(--i) * 0.22s);
}
.flow-msg-line::after {
    content: "";
    position: absolute;
    right: -1px;
    top: -5px;
    border: 6px solid transparent;
    border-left: 9px solid var(--px-accent);
    border-right: 0;
}
/* Answers travel right to left, in green. */
.flow-msg--back { --px-accent: #10b981; }
.flow-msg--back .flow-msg-line { transform-origin: right; }
.flow-msg--back .flow-msg-line::after { right: auto; left: -1px; border-left: 0; border-right: 9px solid var(--px-accent); }
.flow-msg--back .flow-msg-label b { background: #10b981; }
.flow-seq.is-in .flow-msg-line { transform: scaleX(1); }

/* ---------- Platforms & rules ---------- */
.flow-platforms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.flow-platform { display: flex; flex-direction: column; padding: 30px; text-decoration: none; color: inherit; }
.flow-platform:hover { transform: translateY(-4px); border-color: var(--px-accent-line); }
.flow-platform-kind { margin-top: 22px; font: 700 12px var(--px-font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--px-accent-deep); }
.flow-platform strong { margin-top: 6px; font: 800 22px var(--px-font-display); letter-spacing: -0.02em; color: var(--px-ink); }
.flow-platform-code { align-self: flex-start; margin-top: 12px; padding: 5px 10px; border-radius: 8px; background: var(--flow-night); font-size: 12.5px; color: color-mix(in srgb, var(--px-accent) 40%, #ffffff); }
.flow-platform ul { display: grid; gap: 10px; margin: 20px 0 24px; padding: 0; list-style: none; }
.flow-platform li { position: relative; padding-left: 26px; font-size: 14.5px; line-height: 1.5; color: var(--px-muted); }
.flow-platform li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: color-mix(in srgb, #10b981 14%, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4L18 8'/%3E%3C/svg%3E") center / 10px no-repeat;
}
.flow-platform li.is-off::before { background: #fff1f2 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e11d48' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E") center / 9px no-repeat; }
.flow-platform-go { display: inline-flex; align-items: center; gap: 8px; margin-top: auto; font-weight: 700; font-size: 14.5px; color: var(--px-accent-deep); }
.flow-platform-go svg { width: 18px; height: 18px; transition: transform 0.3s var(--px-ease); }
.flow-platform:hover .flow-platform-go svg { transform: translateX(4px); }

.flow-rules { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.flow-rule { padding: 28px; }
.dev .flow-rule h3 { margin: 20px 0 8px; font: 700 18px/1.3 var(--px-font-display); letter-spacing: -0.02em; color: var(--px-ink); }
.dev .flow-rule p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--px-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .flow-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .flow-platforms { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
    .flow-arch { max-width: 560px; }
    .flow-journey { grid-template-columns: 1fr; gap: 32px; }
    .flow-stage { position: static; }
    .flow-config-out { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .flow-head { flex-direction: column; align-items: flex-start; }
    .flow-section { padding-bottom: 64px; }
    .flow-phone { width: min(260px, 100%); }
    .flow-rules { grid-template-columns: 1fr; }
    .flow-config { padding: 22px; }
    /* Sequence becomes a numbered list with "from → to" chips. */
    .flow-seq-lanes { display: none; }
    .flow-seq-rows { display: grid; grid-template-columns: 1fr; background: none; padding: 0; row-gap: 12px; }
    .flow-msg { grid-column: 1 !important; padding: 0; }
    .flow-msg-line { display: none; }
    .flow-msg-label { justify-content: flex-start; text-align: left; }
}
@media (max-width: 560px) {
    .flow-tag { display: none; }
    .flow-node { width: 40%; padding: 9px 10px; gap: 8px; }
    .flow-node-ico { width: 30px; height: 30px; }
    .flow-node small { display: none; }
    .flow-stats { gap: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    .flow *, .flow *::before, .flow *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .flow-dot { display: none; }
}
