/* =========================================================
   Home § 04 — How I build.
   Five agent cursors assemble a summary card inside a browser
   frame, scrubbed by scroll (assets/js/agentic.js).
   Every colour is a token from base.css. The card's resting CSS
   is its finished state, so no-JS and reduced-motion visitors
   see the completed build; JS drives these custom properties:
     --d     drag-out of a box's wireframe outline (0 → 1)
     --snap  wireframe → finished styling (0 → 1)
     --in    a piece of content arriving (0 → 1)
     --live  draft → live status pill (0 → 1)
   ========================================================= */

/* ---------- Scene frame ---------- */
.build { height: 240vh; position: relative; }
.build-sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; display: flex; flex-direction: column; }
.build-head { display: flex; justify-content: space-between; padding-top: calc(var(--header-h) + 20px); padding-bottom: 12px; }
.build-head > .label:first-of-type { display: inline-flex; }
.build-stage { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); grid-template-rows: minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px); padding-bottom: clamp(16px, 3vh, 32px); }

.build-copy { align-self: center; }
.build-title em { font-style: italic; color: var(--mark); }
.build-lede { margin: 18px 0 0; color: var(--ink-2); font-size: 16px; line-height: 1.55; max-width: 34ch; }
.build-steps { list-style: none; margin: clamp(20px, 4vh, 36px) 0 0; padding: 0; border-top: 1px solid var(--rule); max-width: 360px; }
.build-steps li { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--rule);
  font-size: 14px; color: var(--ink-3); transition: color .35s var(--ease); }
.build-steps li.has-b { display: block; padding: 0; }
.bs-b { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 6px 0; color: inherit; font: inherit; text-align: left;
  cursor: pointer; border-radius: 4px; transition: background-color .2s var(--ease); -webkit-tap-highlight-color: transparent; }
.bs-b:hover { color: var(--ink); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.bs-b:hover .bs-t { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.bs-b:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bs-n { font-size: 12px; transition: color .35s var(--ease); }
.bs-a { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; display: inline-flex; align-items: center; gap: 7px; }
.bs-a::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); opacity: .3; transition: opacity .35s var(--ease); }
.build-steps li.is-done { color: var(--ink-2); }
.build-steps li.is-on { color: var(--ink); }
.build-steps li.is-on .bs-n { color: var(--accent); }
.build-steps li.is-on .bs-a::before, .build-steps li.is-done .bs-a::before { opacity: 1; }

.build-demo { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }

/* ---------- Browser window ---------- */
.bw { position: relative; max-width: 100%; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 4%, transparent), 0 40px 90px -50px color-mix(in srgb, var(--ink) 45%, transparent); }
.bw-bar { height: 34px; display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; gap: 12px; padding: 0 12px;
  border-bottom: 1px solid var(--rule); background: var(--paper-2); border-radius: 11px 11px 0 0; }
.bw-dots { display: flex; gap: 6px; }
.bw-dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--rule); background: var(--paper); }
.bw-url { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  padding: 2px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.bw-peers { justify-self: end; display: flex; padding-left: 4px; }
.bw-peers i { width: 19px; height: 19px; margin-left: -4px; border-radius: 50%; border: 1.5px solid var(--paper-2); background: var(--c); color: var(--agent-on);
  font: 500 8px/16px var(--mono); text-align: center; font-style: normal; letter-spacing: 0; }
.bw-fit { position: relative; }
.bw-canvas { position: absolute; top: 0; left: 0; width: 720px; transform-origin: 0 0; }
html:not(.js) .bw-canvas { position: relative; width: auto; }

/* ---------- The card being built (720px design width; JS scales it) ---------- */
.mk { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 248px; grid-template-areas: "nav nav" "head head" "chart kpis" "act act";
  gap: 16px; padding: 16px 22px 22px; color: var(--ink); font-family: var(--sans); --live: 1; }
.mk-box { position: relative; --d: 1; --snap: 1; }
.mk-fade { --in: 1; opacity: var(--in); transform: translate3d(0, calc((1 - var(--in)) * 6px), 0); }
.mk-wf { position: absolute; inset: -2px; border: 1px dashed var(--ink-3); border-radius: 8px; transform-origin: 0 0; transform: scale(var(--d));
  opacity: calc(1 - var(--snap)); pointer-events: none; }
.mk-skin { position: absolute; inset: 0; border-radius: 10px; opacity: var(--snap); pointer-events: none; }

/* Nav */
.mk-nav { grid-area: nav; height: 36px; }
.mk-nav .mk-skin { border-radius: 0; border-bottom: 1px solid var(--rule); }
.mk-in { position: relative; height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 4px; }
.mk-brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 17px; font-variation-settings: "SOFT" 40, "WONK" 0; }
.mk-mark { width: 26px; height: 26px; border: 1px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.mk-meta { display: flex; align-items: center; gap: 12px; }
.mk-meta .label { font-size: 10px; }
.mk-status { display: grid; }
.mk-st { grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 20px; padding: 0 9px; border-radius: 999px;
  font: 500 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.mk-st--draft { border: 1px dashed var(--ink-3); color: var(--ink-3); opacity: calc(1 - var(--live)); }
.mk-st--live { border: 1px solid color-mix(in srgb, var(--up) 45%, transparent); color: var(--up); opacity: var(--live); }
.mk-st--live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--up); }

/* Headline */
.mk-head { grid-area: head; padding: 4px 2px 2px; }
.mk-h { position: relative; margin: 0; font-family: var(--serif); font-weight: 400; font-size: 31px; line-height: 1.12; letter-spacing: -.015em;
  font-variation-settings: "SOFT" 40, "WONK" 0; }
.mk-type .w { display: inline-block; white-space: nowrap; }
.mk-type em { font-style: italic; }
.mk-type .c.ag-off { opacity: 0; }
.mk-caret { position: absolute; left: 0; top: 0; width: 2px; height: 1.05em; opacity: 0; pointer-events: none; }
.mk-caret i { display: block; height: 100%; background: var(--agent-1); animation: mk-blink 1s steps(2, jump-none) infinite; }
@keyframes mk-blink { 50% { opacity: 0; } }
.mk-sub { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }

/* Chart */
.mk-chart { grid-area: chart; margin: 0; height: 206px; padding: 12px 14px; display: flex; flex-direction: column; }
.mk-chart .mk-skin { background: var(--paper-2); border: 1px solid var(--rule); }
.mk-ch-top { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mk-ch-top .label { font-size: 10px; }
.mk-legend { display: flex; gap: 12px; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.mk-legend i { display: inline-block; width: 12px; height: 1.5px; margin-right: 5px; vertical-align: middle; background: var(--ink); }
.mk-legend i.acc { background: var(--accent); }
.mk-plot { position: relative; flex: 1 1 auto; min-height: 0; margin-top: 12px; }
.mk-plot svg { width: 100%; height: 100%; max-width: none; overflow: visible; }
.mk-plot path, .mk-plot line { fill: none; vector-effect: non-scaling-stroke; }
.mk-grid line { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; }
.mk-base { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 5; }
.mk-l { stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.mk-l--wire { stroke: var(--ink-3); opacity: calc(1 - var(--snap)); }
.mk-l--bh { stroke: var(--ink); opacity: var(--snap); }
.mk-l--st { stroke: var(--accent); opacity: var(--snap); }
.mk-dot { position: absolute; left: 0; top: 0; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--ink); }
.mk-dot--st { background: var(--accent); }
.mk-end { position: absolute; left: 0; top: 0; font: 500 11px/1 var(--mono); white-space: nowrap; }
.mk-end--bh { color: var(--up); }
.mk-end--st { color: var(--down); }

/* KPI tiles */
.mk-kpis { grid-area: kpis; height: 206px; }
.mk-kgrid { margin: 0; height: 100%; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 10px; }
.mk-k { position: relative; padding: 12px 12px 10px; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.mk-k::before { content: ""; position: absolute; inset: 0; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--rule); opacity: var(--snap); }
.mk-k > * { position: relative; margin: 0; }
.mk-kl { font: 500 10px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.mk-kn { font-family: var(--mono); font-size: 27px; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.mk-ks { font-size: 11px; color: var(--ink-3); }

/* Actions */
.mk-act { grid-area: act; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 3px; }
.mk-btns { display: flex; gap: 10px; }
.mk-btn { position: relative; display: inline-grid; align-items: center; height: 38px; padding: 0 17px; border-radius: 999px;
  font-size: 14px; font-weight: 500; white-space: nowrap; color: var(--ink); }
.mk-btn-t, .mk-btn-tw { grid-area: 1 / 1; position: relative; display: inline-flex; align-items: center; gap: 8px; }
.mk-btn-skin, .mk-btn-wf { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.mk-btn-wf { border: 1px dashed var(--ink-3); opacity: calc(1 - var(--snap)); }
.mk-btn-skin { border: 1px solid var(--ink); opacity: var(--snap); transition: background .3s var(--ease), border-color .3s var(--ease); }
.mk-btn-tw { color: var(--ink-3); opacity: calc(1 - var(--snap)); }
.mk-btn--solid .mk-btn-skin { background: var(--ink); }
.mk-btn--solid .mk-btn-t { color: var(--paper); opacity: var(--snap); }
.mk-btn .arr { transition: transform .3s var(--ease); }
.mk-btn:hover .arr, .mk-btn:focus-visible .arr { transform: translateX(4px); }
.mk-btn--solid:hover .mk-btn-skin { background: var(--accent); border-color: var(--accent); }
.mk-btn:not(.mk-btn--solid):hover .mk-btn-skin { background: var(--accent-soft); }
.mk-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 999px; }
.mk-btns { flex: none; }
.mk-ships { flex: 1 1 auto; min-width: 0; max-width: 330px; margin: 0 0 0 auto; font-family: var(--mono); font-size: 10.5px; line-height: 1.45; color: var(--ink-2); text-align: right; white-space: normal; text-wrap: balance; }
.mk-ships .label { display: inline; margin-right: 6px; font-size: 10px; color: var(--ink-3); }

/* ---------- Agent cursors ---------- */
.ag-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.ag { position: absolute; left: 0; top: 0; color: var(--c); will-change: transform, opacity; }
.ag svg { width: 15px; height: 18px; overflow: visible; filter: drop-shadow(0 1px 1.5px color-mix(in srgb, var(--ink) 28%, transparent)); }
.ag svg path { fill: var(--c); stroke: var(--paper); stroke-width: 1.25; stroke-linejoin: round; }
.ag-tag { position: absolute; left: 12px; top: 17px; touch-action: none; padding: 2px 7px 3px; border-radius: 3px 8px 8px 8px; background: var(--c); color: var(--agent-on);
  font: 500 11px/1.35 var(--mono); letter-spacing: .02em; white-space: nowrap;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 18%, transparent); }
.ag-tag { transition: opacity .25s var(--ease); }
.ag.is-idle .ag-tag { opacity: 0; pointer-events: none; }
.ag-ripple { position: absolute; left: 0; top: 0; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  border: 1.5px solid var(--c); opacity: 0; pointer-events: none; }

/* ---------- Caption ---------- */
.build-cap { margin: 0; max-width: 100%; min-height: 20px; display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .02em; color: var(--ink-2); }
.build-cap-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-3)); transition: background .3s var(--ease), transform .3s var(--spring); }
.build-cap-btn { position: relative; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; margin-left: -8px; padding: 0 8px; border: 1px solid transparent; border-radius: 999px;
  color: var(--ink-3); cursor: pointer; transition: border-color .2s var(--ease), color .2s var(--ease); -webkit-tap-highlight-color: transparent; }
.build-cap-btn::before { content: ""; position: absolute; inset: -8px -2px; }
.build-cap-re { font-size: 13px; line-height: 1; }
.build-cap-btn:hover { border-color: var(--rule); color: var(--accent); }
.build-cap-btn:hover .build-cap-dot { transform: scale(1.4); }
.build-cap-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.build.is-static .build-cap-btn { display: none; }

/* ---------- Tiles link to their sources once the card is live ---------- */
.mk-k-a { color: inherit; }
.mk-k-a::after { content: ""; position: absolute; z-index: 1; inset: 0; border-radius: 10px; }
.mk:not(.is-live) .mk-k-a { pointer-events: none; }
.mk.is-live .mk-k::before { transition: border-color .2s var(--ease), background-color .2s var(--ease); }
.mk.is-live .mk-k:hover::before { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--paper-2)); }
.mk.is-live .mk-k:hover .mk-kl { color: var(--accent); }
.mk-k-a:focus-visible { outline: none; }
.mk-k-a:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Agent tags can be grabbed (mouse) and spring home ---------- */
@media (hover: hover) and (pointer: fine) {
  .ag-tag { pointer-events: auto; cursor: grab; }
  .ag.is-held .ag-tag { cursor: grabbing; }
}
.build-cap-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Reduced motion: the finished build, no pin, no cursors ---------- */
.build.is-static { height: auto; }
.build.is-static .build-sticky { position: relative; height: auto; padding-bottom: clamp(56px, 8vw, 112px); }
.build.is-static .ag-layer, .build.is-static .mk-caret { display: none; }

/* ---------- Mobile: 400px design width, single column ---------- */
@media (max-width: 699px) {
  .build { height: 150vh; }
  .build-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 14px; }
  .build-title { font-size: clamp(28px, 8.4vw, 36px); }
  .build-lede, .build-steps { display: none; }
  .build-demo { gap: 12px; }
  .bw-canvas { width: 400px; }
  .bw-peers { display: none; }
  .bw-bar { grid-template-columns: auto minmax(0, 1fr); }
  .mk { grid-template-columns: minmax(0, 1fr); grid-template-areas: "nav" "head" "chart" "kpis" "act"; gap: 12px; padding: 12px 16px 16px; }
  .mk-meta .label { display: none; }
  .mk-h { font-size: 24px; }
  .mk-sub { font-size: 12.5px; }
  .mk-chart { height: 150px; padding: 10px 12px; }
  .mk-plot { margin-top: 8px; }
  .mk-ch-top .label { font-size: 10.5px; }
  .mk-legend { display: none; }
  .mk-kpis { height: auto; }
  .mk-kgrid { gap: 8px; }
  .mk-k { gap: 6px; padding: 10px 11px; }
  .mk-kl { font-size: 10.5px; }
  .mk-kn { font-size: 24px; }
  .mk-ks { display: none; }
  .mk-ships { display: none; }
  .mk-btn { font-size: 14.5px; }
  .ag-tag { font-size: 10px; left: 11px; top: 15px; }
}

/* Longer closing caption: let it wrap on phones instead of clipping. */
@media (max-width: 480px) {
  .build-cap { min-height: 36px; align-items: flex-start; }
  .build-cap-dot { margin-top: 5px; }
  .build-cap-t { white-space: normal; overflow: visible; text-overflow: clip; }
}

/* ---------- Phones (agentic.js adds .is-flow): no pin; the build plays once on a clock when the card is in view ---------- */
.build.is-flow { height: auto; }
.build.is-flow .build-sticky { position: relative; height: auto; padding-bottom: 64px; }
.build.is-flow .build-head { padding-top: 56px; }
@media (max-width: 699px) {
  .build-stage { gap: 20px; }
  .build-lede { display: block; margin-top: 10px; font-size: 16px; }
  .build-cap { font-size: 12px; }
}
