/* ==========================================================================
   MCP Servers and APIs page only (mcp-servers-apis.html, _build/api_page.py).
   Loaded after systems.css and organic.css (whose generic assistant window,
   .og-chat__bar and .og-bubble, this page reuses); behaviour is in systems.js,
   the hero's in apihero.js.
   ========================================================================== */

#connect { padding-bottom: clamp(36px, 4.5vw, 60px); }

/* ---- hero -------------------------------------------------------------------------------
   One state on the section (data-state today | done, set by apihero.js) drives everything.
   Every .ap-swap holds the by-hand line (.ap-was) and the connected one (.ap-now) in one grid
   cell. Going to done runs a change-over, row by row in --k order: the line is struck through,
   its dashed ember link is drawn solid green and starts to flow, and the new text arrives;
   a green line sweeps the top of the card meanwhile, and once every row has turned (--turn)
   the verdict on the left changes. Going back is quick, since only the target state's delays
   apply. Ember means by hand, forest green (the brand's "solved") means connected. */
.ap-sec {
  --by: var(--orange); --ok: #154530; --card: #FFFFFF;
  --stag: 130ms; --turn: calc(var(--rows, 6) * var(--stag) + 520ms);
}
.ap-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: clamp(32px, 5vw, 76px); align-items: center; }
.ap-sec .display { font-size: clamp(40px, 5.3vw, 70px); }
.ap-sec .lede { max-width: 44ch; }

.ap-swap { display: inline-grid; position: relative; }
.ap-swap > * { grid-area: 1 / 1; transition: opacity 240ms var(--ease), transform 240ms var(--ease); }
.ap-now { opacity: 0; transform: translateY(6px); }
.ap-sec[data-state="done"] .ap-was { opacity: 0; transform: translateY(-5px); transition-delay: calc(var(--k, 0) * var(--stag) + 380ms); }
.ap-sec[data-state="done"] .ap-now { opacity: 1; transform: none; transition-duration: 420ms; transition-delay: calc(var(--k, 0) * var(--stag) + 500ms); }

/* the verdict, in the copy: the card's total, signed. Minus hours lost by hand (ember), plus
   hours of work done once connected (green). It turns halfway through the card's change-over
   (--vt), and its top rule is swept green in step with the card's own sweep */
.ap-verdict { --vt: calc(var(--turn) * .5); position: relative; margin-top: 30px; padding: 16px 0 18px; border-top: 2px solid var(--text); border-bottom: 1px solid var(--line); }
.ap-verdict__sweep { position: absolute; top: -2px; left: 0; right: 0; height: 2px; background: var(--ok); transform: scaleX(0); transform-origin: left; transition: transform 300ms var(--ease); }
.ap-sec[data-state="done"] .ap-verdict__sweep { transform: scaleX(1); transition: transform var(--turn) cubic-bezier(.45, 0, .3, 1); }
.ap-verdict p { margin: 0; }
.ap-verdict__k { font: 500 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); }
.ap-verdict__n { display: flex; align-items: flex-end; gap: 16px; margin-top: 8px !important; font-family: var(--font-display); font-size: clamp(21px, 2vw, 27px); line-height: 1.15; letter-spacing: -.01em; }
.ap-verdict__u { padding-bottom: .3em; }
.ap-num { overflow: hidden; padding: 4px 0; }
.ap-num b { display: flex; align-items: baseline; font-weight: 400; font-size: clamp(64px, 6.6vw, 96px); line-height: .9; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
/* the sign carries the message, so it is set heavy: the font's 700 plus a stroke in its own colour */
.ap-num i { margin-right: .06em; font-style: normal; font-weight: 700; -webkit-text-stroke: .045em currentColor; paint-order: stroke fill; }
.ap-num .ap-was { color: var(--by); }
.ap-num .ap-now { color: var(--ok); }
/* the number rolls: the minus figure out the top, the plus figure up from below */
.ap-num > * { transition: opacity 360ms var(--ease), transform 520ms cubic-bezier(.3, 1.3, .5, 1); }
.ap-num .ap-now { transform: translateY(70%); }
.ap-sec[data-state="done"] .ap-num .ap-was { transform: translateY(-70%); }
.ap-sec[data-state="done"] .ap-num .ap-now { transform: none; }
.ap-verdict__s { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 10px !important; font: 12.5px var(--font-mono); color: var(--text-2); }
.ap-point { color: var(--by); animation: ap-nudge 2.4s var(--ease) infinite; }
/* on the left the old words leave before the new ones arrive, so the two never overlap */
.ap-sec[data-state="done"] .ap-verdict .ap-was { transition-duration: 200ms; transition-delay: var(--vt); }
.ap-sec[data-state="done"] .ap-verdict .ap-now { transition-delay: calc(var(--vt) + 220ms); }
.ap-sec.is-empty .ap-verdict__n, .ap-sec.is-empty .ap-verdict__s .ap-swap { opacity: .3; }
@keyframes ap-nudge { 0%, 70%, 100% { transform: none; } 80% { transform: translateX(5px); } 90% { transform: translateX(1px); } }

/* the card */
.ap-fig { min-width: 0; }
.ap-card {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  box-shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 30px 60px -34px rgba(20, 20, 20, .3), 0 12px 24px -18px rgba(20, 20, 20, .12);
}
.ap-card__sweep { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ok); transform: scaleX(0); transform-origin: left; transition: transform 300ms var(--ease); }
.ap-sec[data-state="done"] .ap-card__sweep { transform: scaleX(1); transition: transform var(--turn) cubic-bezier(.45, 0, .3, 1); }
.ap-card__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; padding: 22px 26px 0; }
.ap-card__title { margin: 0; font-family: var(--font-display); font-size: 26px; letter-spacing: -.02em; }
.ap-card__meta { font: 11px var(--font-mono); letter-spacing: .06em; color: var(--text-3); }
.ap-card__body { display: grid; gap: 18px; padding: 18px 26px 10px; }
.ap-card__k { margin: 0; font: 500 11px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.ap-card__k b { margin-right: 8px; font-weight: 500; color: var(--text-3); }

/* the tools */
.ap-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-chip {
  display: inline-flex; align-items: center; gap: 9px; padding: 6px 14px 6px 6px; border: 1px dashed var(--line-2); border-radius: 100px;
  background: transparent; color: var(--text-3); font: inherit; font-size: 14.5px; cursor: pointer;
  transition: border-color 200ms var(--ease), color 200ms var(--ease), background 200ms var(--ease), transform 200ms var(--ease);
}
.ap-chip i {
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 5px; box-sizing: border-box; border-radius: 100px;
  background: rgba(var(--ov), .06); font: 600 10.5px/1 var(--font-mono); font-style: normal; transition: background 300ms var(--ease), color 300ms var(--ease);
}
.ap-chip:hover { border-color: var(--text-3); color: var(--text-2); transform: translateY(-1px); }
.ap-chip:focus-visible { outline: 2px solid var(--by); outline-offset: 2px; }
.ap-chip[aria-pressed="true"] { border-style: solid; border-color: var(--text); color: var(--text); background: var(--card); }
.ap-chip[aria-pressed="true"] i { background: var(--text); color: #fff; }
.ap-sec[data-state="done"] .ap-chip[aria-pressed="true"] i { background: var(--ok); transition-delay: var(--turn); }

/* the switch: by hand to connected */
.ap-card__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line); }
/* the switch: two halves and a coloured thumb that slides between them. While apihero.js
   counts down to the automatic flip (.is-arming), a green fill creeps across the Connected
   half; until the visitor has touched it, a soft ring pulses round it */
.ap-switch {
  position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 1px solid var(--line-2); border-radius: 100px;
  background: rgba(var(--ov), .05); cursor: pointer; font: 600 12px var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
}
.ap-switch__opt { position: relative; z-index: 2; padding: 11px 20px; text-align: center; white-space: nowrap; color: var(--text-2); transition: color 300ms var(--ease); }
.ap-switch__thumb, .ap-switch__fill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 100px; }
.ap-switch__thumb { z-index: 1; background: var(--by); box-shadow: 0 2px 8px -2px rgba(226, 82, 15, .55); transition: transform 460ms cubic-bezier(.4, 1.3, .5, 1), background 300ms var(--ease), box-shadow 300ms; }
.ap-switch__fill { left: 50%; background: rgba(21, 69, 48, .16); transform: scaleX(0); transform-origin: left; }
.ap-switch.is-arming .ap-switch__fill { animation: ap-arm var(--arm, 2s) linear both; }
.ap-switch[aria-checked="false"] .ap-switch__opt:first-of-type, .ap-switch[aria-checked="true"] .ap-switch__opt:last-of-type { color: #fff; }
.ap-switch[aria-checked="true"] .ap-switch__thumb { transform: translateX(100%); background: var(--ok); box-shadow: 0 2px 8px -2px rgba(21, 69, 48, .55); }
.ap-switch:hover { border-color: var(--text-3); }
.ap-switch:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.ap-sec:not(.is-touched) .ap-switch { animation: ap-ring 2.2s var(--ease) infinite; }
@keyframes ap-arm { to { transform: scaleX(1); } }
@keyframes ap-ring { 0% { box-shadow: 0 0 0 0 rgba(21, 69, 48, .28); } 70%, 100% { box-shadow: 0 0 0 10px rgba(21, 69, 48, 0); } }

/* the hand-offs */
.ap-hands { list-style: none; margin: 0; padding: 0; display: grid; }
.ap-hand { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.35; }
.ap-hand:last-child { border-bottom: 0; }
.sg-js .ap-hand:not([hidden]) { animation: sg-fade 320ms var(--ease); }
.ap-pair { display: flex; align-items: center; }
.ap-pair i {
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 5px; box-sizing: border-box; border-radius: 100px;
  border: 1px solid var(--line-2); background: var(--card); font: 600 10.5px/1 var(--font-mono); font-style: normal;
  transition: background 300ms, color 300ms, border-color 300ms;
}
/* the link: still ember dashes by hand; drawn solid green when connected, with data flowing along it */
.ap-pair em { position: relative; flex: 1; height: 2px; margin: 0 5px; background: repeating-linear-gradient(90deg, var(--by) 0 4px, transparent 4px 8px); }
.ap-pair em::after { content: ""; position: absolute; inset: 0; background: var(--ok); transform: scaleX(0); transform-origin: left; transition: transform 200ms var(--ease); }
.ap-pair em::before {
  content: ""; position: absolute; z-index: 1; left: 0; right: 0; top: -2px; height: 6px; opacity: 0;
  background: radial-gradient(circle, var(--ok) 2.4px, transparent 2.9px) 0 50% / 14px 6px repeat-x; transition: opacity 200ms;
}
.ap-sec[data-state="done"] .ap-pair em::after { transform: scaleX(1); transition: transform 460ms var(--ease) calc(var(--k, 0) * var(--stag) + 200ms); }
.ap-sec[data-state="done"] .ap-pair em::before { opacity: 1; animation: ap-flow 1.1s linear infinite; transition: opacity 400ms calc(var(--k, 0) * var(--stag) + 620ms); }
.ap-sec[data-state="done"] .ap-pair i { border-color: var(--ok); color: var(--ok); transition-delay: calc(var(--k, 0) * var(--stag) + 420ms); }
@keyframes ap-flow { from { background-position-x: 0; } to { background-position-x: 14px; } }

/* the strike: a line drawn through the by-hand text, across every line it wraps to */
.ap-x { background: linear-gradient(var(--text), var(--text)) no-repeat 0 58% / 0 1.5px; }
.ap-sec[data-state="done"] .ap-x { background-size: 100% 1.5px; transition: background-size 380ms var(--ease) calc(var(--k, 0) * var(--stag)); }

.ap-q { justify-items: end; font: 500 12px var(--font-mono); white-space: nowrap; }
.ap-q .ap-was { color: var(--by); }
.ap-q .ap-was small { font-size: 10px; opacity: .8; }
.ap-q .ap-now { color: var(--ok); }
.ap-hand--ai .ap-pair i { border-style: dashed; color: var(--text-3); }
.ap-sec[data-state="done"] .ap-hand--ai .ap-pair i { border-style: solid; border-color: var(--ok); background: var(--ok); color: #fff; }

.ap-more, .ap-empty { margin: -6px 0 0; font: 12px var(--font-mono); color: var(--text-3); }
.ap-empty { font: 15px var(--font-sans); color: var(--text-2); }
.ap-card__foot { margin: 0; padding: 14px 26px 18px; border-top: 1px solid var(--line); background: rgba(var(--ov), .02); font-size: 13.5px; color: var(--text-3); }

@media (max-width: 900px) {
  .ap-grid { grid-template-columns: 1fr; }
  .ap-point { display: none; }
}
@media (max-width: 560px) {
  .ap-card__head, .ap-card__body, .ap-card__foot { padding-inline: 18px; }
  .ap-hand { grid-template-columns: 84px minmax(0, 1fr); gap: 4px 12px; }
  .ap-q { grid-column: 2; justify-items: start; }
  .ap-switch { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ap-sec *, .ap-sec *::before, .ap-sec *::after { transition-duration: 0s !important; transition-delay: 0s !important; animation: none !important; }
}

.ap-ai { display: grid; gap: 8px; padding: 6px 14px 14px; font-size: 13px; line-height: 1.5; }
.ap-ai p { margin: 0; }
.ap-ai ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.ap-call { display: flex; align-items: center; gap: 7px; width: fit-content; max-width: 100%; padding: 5px 9px; border-radius: 7px; background: #eef1fb; color: #2F5BD3; font-size: 11px; box-sizing: border-box; }
.ap-call i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #2F5BD3; }
.ap-call code { font-family: Consolas, Menlo, monospace; font-size: 11px; color: #202124; }
.ap-ai__foot { font-family: var(--font-mono); font-size: 11px; color: #777; }

/* ---- ask your AI ---------------------------------------------------------------- */
#assistant .sy-win { min-height: 360px; }
#assistant .og-bubble { font-size: 14px; }
#assistant .ap-ai { font-size: 14.5px; gap: 10px; }
p.sy-hl:has(.ap-call) { width: fit-content; padding: 0; box-shadow: none; background: none; }
p.sy-hl.is-hot .ap-call { box-shadow: 0 0 0 2px #E2520F; }

/* the self-play (apiask.js): each answer builds line by line, the window changes over slowly
   and the cards light in turn. --ap-step matches STEP in apiask.js */
#assistant .sy-flip { --ap-step: 650ms; }
#assistant .sy-flip.is-playing .sy-view:not([hidden]) { animation: ap-view 900ms var(--ease) both; }
#assistant .sy-flip.is-playing .sy-view:not([hidden]) :is(.og-bubble, .ap-ai > *) {
  animation: ap-line 800ms var(--ease) both; animation-delay: calc(var(--i, 0) * var(--ap-step) + 350ms);
}
#assistant .sy-flip.is-playing .og-cite, #assistant .sy-flip.is-playing .sy-hl {
  transition: opacity 700ms var(--ease), background 700ms var(--ease), border-color 700ms var(--ease),
              box-shadow 700ms var(--ease), transform 700ms var(--ease);
}
#assistant .sy-flip.is-playing .sy-seg button { transition: background 600ms var(--ease), color 600ms var(--ease); }
@keyframes ap-view { from { opacity: 0; transform: translateY(10px) scale(.985); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes ap-line { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- the hub ----------------------------------------------------------------------- */
.ap-plan { fill: none; stroke: var(--text-3); stroke-width: 1.2; stroke-dasharray: 4 6; opacity: .6; }
.ap-spoke { fill: none; stroke: url(#syLine); stroke-width: 3; stroke-linecap: round; stroke-dasharray: var(--len); stroke-dashoffset: calc(var(--len) * (1 - var(--p))); }
.ap-spoke--ai { stroke: var(--cobalt); stroke-dasharray: 2 7; stroke-dashoffset: 0; opacity: calc(var(--p)); }
.ap-node circle { fill: var(--ink); stroke: var(--line-2); stroke-width: 1.5; transition: stroke var(--mid), fill var(--mid); }
.ap-node__l { fill: var(--text-3); font-size: 13px; font-weight: 600; transition: fill var(--mid); }
.ap-node.is-live circle { stroke: var(--orange); stroke-width: 2.5; fill: rgba(226, 82, 15, .08); }
.ap-node.is-live .ap-node__l { fill: var(--text); }
.ap-node--ai.is-live circle { stroke: var(--cobalt); fill: rgba(47, 91, 211, .08); }
.ap-node--ai .sy-lab { fill: var(--text-3); }
.ap-node--ai.is-live .sy-lab { fill: var(--cobalt); }
.ap-core { fill: var(--green-fill); }
.ap-core__t { fill: #fff; font-size: 11px; letter-spacing: .12em; }
.ap-ring circle { fill: none; stroke: #7FB8F0; stroke-width: 2; stroke-dasharray: 3 5; }
.ap-ring__t { fill: var(--cobalt); font-size: 10px; letter-spacing: .14em; }
.sg-js .ap-ring:not(.is-live) { opacity: 0; }
.ap-ring { transition: opacity .5s var(--ease); }
.ap-done { fill: none; stroke: url(#syLine); stroke-width: 4; stroke-linecap: round; }
