/* ---------- tokens ---------- */
:root {
  --bg: #0b0d12;
  --bg-2: #10131a;
  --surface: #161a23;
  --surface-2: #1d2230;
  --text: #e8ebf2;
  --muted: #98a0b3;
  --line: #2a3142;
  --accent: #7c8cff;
  --accent-2: #4ad7c8;
  --accent-3: #ff8a5c;
  --req: #7c8cff;
  --res: #4ad7c8;
  --ntf: #ff8a5c;
  --shadow: 0 20px 60px rgba(0,0,0,.45);
  --radius: 18px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-2: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #121521;
  --muted: #5c6577;
  --line: #d9dde8;
  --accent: #4f5fe6;
  --accent-2: #0fa99a;
  --accent-3: #e8683b;
  --req: #4f5fe6;
  --res: #0fa99a;
  --ntf: #e8683b;
  --shadow: 0 20px 50px rgba(20,30,60,.12);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7fb; --bg-2: #eef0f6; --surface: #ffffff; --surface-2: #f1f3f9;
    --text: #121521; --muted: #5c6577; --line: #d9dde8;
    --accent: #4f5fe6; --accent-2: #0fa99a; --accent-3: #e8683b;
    --req: #4f5fe6; --res: #0fa99a; --ntf: #e8683b;
    --shadow: 0 20px 50px rgba(20,30,60,.12); color-scheme: light;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); line-height: 1.55; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: .1em .4em; border-radius: 6px; }
pre { margin: 0; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -.02em; margin: 0; }
h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); font-weight: 800; }
h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); font-weight: 800; }
h3 { font-size: 1.1rem; font-weight: 600; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; z-index: 99; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand-thin { font-weight: 400; color: var(--muted); }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); animation: pulse 2.4s ease-in-out infinite; }
.nav nav { margin-left: auto; display: flex; gap: 14px; font-size: .92rem; color: var(--muted); }
.nav nav a:hover { color: var(--text); }
.theme-btn { background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 10px; width: 36px; height: 36px; cursor: pointer; font-size: 1rem; }
@media (max-width: 640px) { .nav nav { display: none; } }

/* ---------- hero ---------- */
.hero { position: relative; padding: clamp(64px, 12vw, 140px) 16px 48px; text-align: center; max-width: 1100px; margin: 0 auto; }
.hero-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.grid { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--line); opacity: .6; mask-image: radial-gradient(60% 60% at 50% 40%, #000 30%, transparent 100%); }
.orb { position: absolute; width: 42vw; height: 42vw; max-width: 520px; max-height: 520px; border-radius: 50%; filter: blur(70px); opacity: .45; animation: drift 14s ease-in-out infinite; }
.o1 { background: var(--accent); top: -10%; left: 5%; }
.o2 { background: var(--accent-2); top: 10%; right: 0; animation-delay: -5s; }
.o3 { background: var(--accent-3); bottom: -20%; left: 35%; animation-delay: -9s; opacity: .3; }
.eyebrow { font-family: var(--mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); margin: 0 0 14px; }
.grad { background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent)); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 6s linear infinite; }
.lede { font-size: clamp(1rem, 2vw, 1.25rem); color: var(--muted); max-width: 640px; margin: 20px auto 28px; }
.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); transition: transform .2s, box-shadow .2s, background .2s; cursor: pointer; color: var(--text); font-family: inherit; font-size: .95rem; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 6px 12px; font-size: .8rem; border-radius: 8px; }
.hero-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 44px; }
.hero-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px; min-width: 110px; }
.hero-stats b { display: block; font-size: 1.6rem; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats span { font-size: .8rem; color: var(--muted); }

/* ---------- sections ---------- */
.section { padding: clamp(56px, 9vw, 110px) 16px; max-width: 1100px; margin: 0 auto; }
.section.alt { max-width: none; background: var(--bg-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section.alt > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.section-head { max-width: 680px; margin-bottom: 36px; }
.section-head p:last-child { color: var(--muted); margin: 12px 0 0; }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- flow diagram ---------- */
.flow-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
#flowSvg { width: 100%; height: auto; display: block; font-family: var(--font); }
#flowSvg .node rect { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; transition: stroke .3s, filter .3s; }
#flowSvg .node rect.inner { fill: var(--surface); }
#flowSvg .node.active rect:first-child { stroke: var(--accent); filter: url(#glow); }
#flowSvg .t-title { fill: var(--text); font-weight: 800; font-size: 20px; text-anchor: middle; letter-spacing: .08em; }
#flowSvg .t-sub { fill: var(--muted); font-size: 12px; text-anchor: middle; }
#flowSvg .t-inner { fill: var(--text); font-size: 13px; text-anchor: middle; font-weight: 600; }
#flowSvg .t-inner.dim { fill: var(--muted); font-weight: 400; font-size: 11px; }
#flowSvg .t-lbl { fill: var(--muted); font-family: var(--mono); font-size: 11px; text-anchor: middle; }
#flowSvg .link { fill: none; stroke: var(--line); stroke-width: 2; stroke-dasharray: 6 6; animation: dash 1.2s linear infinite; }
#flowSvg .ticker-bg { fill: var(--bg); stroke: var(--line); }
#flowSvg .t-mono { fill: var(--accent-2); font-family: var(--mono); font-size: 14px; }
#flowSvg .packet { filter: url(#glow); }
#flowSvg .packet.req { fill: var(--req); }
#flowSvg .packet.res { fill: var(--res); }
#flowSvg .packet.ntf { fill: var(--ntf); }
.flow-legend { display: flex; gap: 18px; align-items: center; margin-top: 12px; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.flow-legend button { margin-left: auto; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.sw-req { background: var(--req); } .sw-res { background: var(--res); } .sw-ntf { background: var(--ntf); }

/* ---------- lifecycle ---------- */
.life { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
@media (max-width: 820px) { .life { grid-template-columns: 1fr; } }
.life-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.life-steps li { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; display: flex; gap: 12px; align-items: flex-start; transition: border-color .25s, transform .25s; }
.life-steps li:hover { transform: translateX(4px); }
.life-steps li.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.life-steps .n { font-family: var(--mono); font-size: .75rem; color: var(--accent-2); padding-top: 3px; min-width: 20px; }
.life-steps b { display: block; font-size: .92rem; }
.life-steps small { color: var(--muted); font-size: .8rem; }
.life-stage { position: relative; min-height: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); overflow: hidden; }
.lane { position: absolute; top: 24px; bottom: 24px; width: 2px; }
.lane:nth-child(1) { left: 22%; } .lane:nth-child(2) { left: 78%; }
.lane-line { position: absolute; inset: 36px 0 0; background: linear-gradient(var(--line), transparent); }
.lane-name { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: .8rem; color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); white-space: nowrap; }
.life-arrow { position: absolute; top: 50%; left: 22%; width: 56%; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; border-radius: 3px; }
.life-arrow::after { content: ""; position: absolute; right: -6px; top: -5px; border: 7px solid transparent; border-left: 10px solid var(--accent-2); }
.life-arrow.flip { transform-origin: right; left: 22%; }
.life-arrow.flip::after { right: auto; left: -6px; border-left: 7px solid transparent; border-right: 10px solid var(--accent); }
.life-arrow.go { animation: grow .6s cubic-bezier(.2,.8,.2,1) both; }
.life-msg { position: absolute; left: 50%; top: calc(50% + 18px); transform: translateX(-50%); max-width: 90%; }
.life-msg code { display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: .78rem; white-space: pre; overflow-x: auto; max-width: 100%; animation: fadeUp .5s ease both; }

/* ---------- build ---------- */
.build { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.build-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tab { background: transparent; border: 0; padding: 12px 20px; color: var(--muted); font-weight: 600; cursor: pointer; font-family: inherit; position: relative; }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.build-grid { display: grid; grid-template-columns: 320px 1fr; }
@media (max-width: 860px) { .build-grid { grid-template-columns: 1fr; } }
.build-steps { list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--line); }
@media (max-width: 860px) { .build-steps { border-right: 0; border-bottom: 1px solid var(--line); } }
.build-steps li { padding: 12px 14px; border-radius: 12px; cursor: pointer; display: flex; gap: 12px; transition: background .25s; }
.build-steps li:hover { background: var(--surface-2); }
.build-steps li.active { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); outline: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.build-steps .n { font-family: var(--mono); font-size: .75rem; color: var(--accent-2); padding-top: 3px; }
.build-steps b { display: block; font-size: .92rem; }
.build-steps small { color: var(--muted); font-size: .8rem; }
.code-card { background: var(--bg); min-height: 420px; display: flex; flex-direction: column; }
.code-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.code-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.code-bar span:nth-child(1) { background: #ff5f57; } .code-bar span:nth-child(2) { background: #febc2e; } .code-bar span:nth-child(3) { background: #28c840; }
.code-bar em { margin-left: 10px; font-style: normal; font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.code-card pre { padding: 18px; overflow: auto; flex: 1; }
.code-card code { background: none; padding: 0; font-size: .82rem; line-height: 1.6; color: var(--text); white-space: pre; }
.code-card .k { color: var(--accent); } .code-card .s { color: var(--accent-2); } .code-card .c { color: var(--muted); font-style: italic; } .code-card .f { color: var(--accent-3); }
.caret { display: inline-block; width: 8px; height: 1em; background: var(--accent-2); vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; position: relative; overflow: hidden; transition: transform .25s, border-color .25s; animation: fadeUp .6s ease both; animation-delay: calc(var(--i) * 80ms); }
.card::before { content: ""; position: absolute; inset: -1px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); opacity: 0; transition: opacity .3s; z-index: 0; }
.card:hover { transform: translateY(-4px); border-color: transparent; }
.card:hover::before { opacity: .12; }
.card > * { position: relative; z-index: 1; }
.card-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 1.1rem; margin-bottom: 12px; }
.card p { color: var(--muted); font-size: .92rem; margin: 8px 0 14px; }
.pill { font-family: var(--mono); font-size: .72rem; background: var(--surface-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; color: var(--accent-2); }

/* ---------- transports ---------- */
.transports { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.tp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.tp p { color: var(--muted); font-size: .92rem; margin: 12px 0 0; }
.pipe { position: relative; height: 10px; border-radius: 10px; background: var(--surface-2); margin: 14px 0; overflow: hidden; border: 1px solid var(--line); }
.pkt { position: absolute; top: 1px; left: -20px; width: 18px; height: 6px; border-radius: 6px; background: var(--accent); animation: slide 2.2s linear infinite; }
.pkt.d2 { animation-delay: .7s; background: var(--accent-2); } .pkt.d3 { animation-delay: 1.4s; background: var(--accent-3); }
.pipe.http .pkt { animation-duration: 3s; width: 30px; }

/* ---------- end ---------- */
.cta-end { text-align: center; }
.cta-end p { color: var(--muted); margin: 12px 0 22px; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 24px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; max-width: 1100px; margin: 0 auto; }

/* ---------- keyframes ---------- */
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@keyframes drift { 0%,100% { transform: translate(0,0); } 50% { transform: translate(6%, -5%); } }
@keyframes shimmer { to { background-position: 300% 0; } }
@keyframes dash { to { stroke-dashoffset: -12; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes slide { to { left: 105%; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}
