/* Studio: three chapters share one pinned window on wide screens. */
.studio, .studio + .band {
  --studio-padding: clamp(110px, 12vw, 170px);
  --studio-pinned-end-gap: clamp(72px, calc(22svh - 80px), 128px);
}
.studio { position: relative; isolation: isolate; padding-block: var(--studio-padding); background: var(--paper); }
.studio__grid { position: relative; z-index: 1; display: grid; gap: 40px; }
.studio__head { display: grid; gap: 22px; }
.studio__intro { display: grid; gap: 18px; justify-items: start; }
.studio__intro .lede { margin: 0; }
.studio__stage { position: relative; min-width: 0; }
.studio__win { position: relative; }
.studio__bar { display: none; }
.studio__body { display: grid; gap: 22px; --bh: clamp(350px, 46svh, 420px); }
.ss { min-width: 0; border-radius: 22px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line), 0 30px 60px -44px rgba(31, 33, 36,.55); padding: 22px; }
.ss__cap { display: grid; gap: 6px; margin-bottom: 18px; }
.ss__t { margin: 0; display: flex; align-items: center; gap: 10px; font: 300 26px/1.1 var(--serif); letter-spacing: -0.015em; }
.ss__t svg { width: 18px; height: 18px; color: var(--umber); }
.ss__cap p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.studio__foot { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; margin-top: 16px; }
.studio__caps { display: none; }
.studio__note { margin: 0; font-size: 13px; color: var(--ink-3); }

.studio.is-pinned { height: 380svh; padding: 0; }
.studio.is-pinned .studio__pin { --se: var(--e, 1); position: sticky; top: 0; height: 100svh; overflow: clip; display: grid; align-items: center; padding-top: var(--nav-clear); }
.studio.is-pinned .studio__grid { gap: clamp(22px, 3.4svh, 36px);
  opacity: calc(1 - var(--x, 0) * .9); transform: translate3d(0, calc(var(--x, 0) * -60px), 0) scale(calc(1 - var(--x, 0) * .05)); transform-origin: 50% 30%; }
.studio.is-pinned .studio__head { grid-template-columns: minmax(0, 1fr) minmax(0, 470px); align-items: end; gap: 48px; }
.studio.is-pinned .studio__intro .lede { font-size: 16px; }
.studio__art { display: none; filter: grayscale(1); }
.studio__art-still { width: min(100%, 520px); height: auto; justify-self: center; margin-block: -8px -18px; }
.studio.is-pinned .studio__art-still { display: none; }
/* the engraving (--se is the room's entry; the print's own --e drives its reveal): shown whole as the room arrives, it sinks to a watermark once the window has risen over it and
   drifts up a little as the chapters turn */
.studio.is-pinned .studio__art { display: block; position: absolute; z-index: 0; left: 50%; bottom: -4svh; width: max(1500px, 112vw); max-width: none; translate: -50% 0;
  transform: translate3d(0, calc((1 - var(--se)) * 14svh - var(--p, 0) * 6svh), 0) scale(calc(1.04 - var(--se) * .04 + var(--x, 0) * .04)); opacity: calc((.2 + (1 - var(--se)) * .7) * (1 - var(--x, 0) * .6)); pointer-events: none; }
.studio.is-pinned .studio__stage { perspective: 1700px; }
.studio.is-pinned .studio__win { border-radius: 24px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line), 0 60px 100px -60px rgba(31,33,36,.6), 0 20px 40px -30px rgba(31,33,36,.4); overflow: hidden; transform-origin: 50% 100%;
  transform: translate3d(0, calc((1 - var(--e, 1)) * 110px), 0) rotateX(calc((1 - var(--e, 1)) * 14deg)) scale(calc(.95 + var(--e, 1) * .05)); }
.studio.is-pinned .studio__bar { display: flex; align-items: center; height: 52px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--paper-hi); }
.studio__tabs { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 470px); padding: 3px; border-radius: 999px; background: rgba(31,33,36,.05); }
.studio__tab { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 32px; border: 0; border-radius: 999px; background: none; font: 500 13px/1 var(--sans); color: var(--ink-3); white-space: nowrap; cursor: pointer; transition: color 260ms var(--out); }
.studio__tab svg { width: 14px; height: 14px; color: currentColor; opacity: .8; }
.studio__tab[data-on] { color: var(--ink); }
.studio__tab[data-on] svg { color: var(--umber); opacity: 1; }
@media (hover: hover) and (pointer: fine) { .studio__tab:not([data-on]):hover { color: var(--ink-2); } }
.studio__tabhl { position: absolute; left: 3px; top: 3px; width: calc((100% - 6px) / 3); height: 32px; border-radius: 999px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line), 0 2px 6px -3px rgba(31,33,36,.3); transform: translateX(calc(var(--s, 0) * 100%)); }
.studio.is-pinned .studio__body { display: block; position: relative; height: var(--bh); }
.studio.is-pinned + .band .band__copy { padding-top: var(--studio-pinned-end-gap); }
.studio.is-pinned .ss__scene { display: grid; height: 100%; min-height: 0; }
.studio.is-pinned .ss { display: grid; position: absolute; inset: 0; border-radius: 0; background: none; box-shadow: none; padding: 22px 26px;
  --din: clamp(0, var(--c) - var(--s, 0), 1);
  --dout: clamp(0, var(--s, 0) - var(--c), 1);
  /* played on the clock by pinned.jsx: the leaving scene lifts away and clears by the midpoint, the arriving one rises
     from below after it, so the two never stack; a light blur only while each is moving */
  opacity: clamp(0, 1 - (var(--din) + var(--dout)) * 2.1, 1);
  transform: translate3d(0, calc(var(--din, 0) * 26px - var(--dout, 0) * 18px), 0) scale(calc(1 - var(--dout, 0) * .03 + var(--din, 0) * .015));
  filter: blur(calc((var(--din) + var(--dout)) * 5px));
  overflow: auto; }
.studio.is-pinned .ss[inert] { pointer-events: none; }
/* pinned, each scene's own caption moves under the window (studio__caps); it stays for screen readers */
.studio.is-pinned .ss__cap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.studio.is-pinned .ss__cap * { white-space: nowrap; }
.studio.is-pinned .studio__caps { display: grid; flex: 1; min-width: 0; }
.studio__cap { grid-area: 1 / 1; margin: 0; text-wrap: balance; font: 300 19px/1.35 var(--serif); color: var(--ink); opacity: 0; transform: translate3d(0, 6px, 0); transition: opacity 360ms var(--out), transform 360ms var(--out); }
.studio__cap[data-on] { opacity: 1; transform: none; }
/* Playground: the answers stream in word by word as --k rises */
.pg { display: grid; gap: 14px; align-content: start; }
.studio.is-pinned .pg { grid-template-rows: auto auto 1fr; }
.pg__send { justify-content: space-between; text-decoration: none; align-self: end; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px 0 14px; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-3); font-size: 14px; }
.pg__send-icon {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px;
  border-radius: 10px; background: var(--ink); color: #fff; font: 500 19px/1 var(--sans);
  transition: background-color 180ms ease, transform 160ms var(--out);
}
.pg__send-icon svg { width: 14px; height: 14px; }
@media (hover: hover) {
  .pg__send:hover .pg__send-icon { background: #383a3d; }
}
.pg__send:active .pg__send-icon { transform: scale(.96); }
.pg__prompt { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 11px 14px; border-radius: 14px; background: var(--paper-lo); font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.pg__files { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; }
.pg__file { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 8px; background: rgba(255, 255, 255,.7); box-shadow: inset 0 0 0 1px var(--line); font: 400 11.5px/1 var(--mono); color: var(--ink-3); }
.pg__file b { font-weight: 400; color: var(--ink); }
.pg__file svg { width: 13px; height: 13px; color: var(--umber); }
.pg__you { flex: none; font: 500 12.5px/1 var(--sans); color: var(--ink-3); }
.pg__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pg__col { --wk: clamp(0, (var(--k, 1) - .86) * 12, 1); display: grid; align-content: start; gap: 10px; padding: 14px 15px 13px; border-radius: 16px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.pg__col--win { box-shadow: inset 0 0 0 1px var(--line), inset 0 0 0 calc(var(--wk) * 1.5px) rgba(88, 90, 93, .55); }
.pg__head { display: flex; align-items: center; gap: 8px; min-width: 0; font: 500 12.5px/1 var(--mono); color: var(--ink); }
.pg__head > span:not(.mono-mark) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg__head img, .pg__head .mono-mark { width: 16px; height: 16px; flex: none; }
.pg__case { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--paper-hi); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 3px; font: 400 12px/1.45 var(--mono); color: var(--ink-2); white-space: pre-wrap; opacity: clamp(0, (var(--k, 1) - .7) * 6, 1); transform: translate3d(0, calc((1 - clamp(0, (var(--k, 1) - .7) * 6, 1)) * 6px), 0); }
.pg__case .ok { color: var(--ok); } .pg__case .bad { color: var(--bad); } .pg__case .dim { color: var(--ink-3); }
.pg__body { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.sw { opacity: clamp(.06, (var(--k, 1) - var(--i)) * 16, 1); }
.pg__meta { display: flex; gap: 14px; font: 400 12px/1 var(--mono); color: var(--ink-3); opacity: clamp(0, (var(--k, 1) - .8) * 8, 1); }

/* API quickstart: each step fills its ring and shows its terminal output. */
.ag { display: grid; gap: 12px; }
.ag__goal { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 11px 14px; border-radius: 14px; background: var(--paper-lo); font-size: 14.5px; line-height: 1.45; }
.ag__k { font: 500 12.5px/1 var(--sans); color: var(--ink-3); }
.ag__rows { list-style: none; margin: 0; padding: 0; display: grid; }
.ag__row:last-child { border-bottom: 0; }
.ag__st { position: relative; width: 18px; height: 18px; --dn: clamp(0, (var(--r) - .97) * 40, 1); }
.ag__st svg { position: absolute; inset: 0; width: 18px; height: 18px; padding: 3px; border-radius: 50%; background: var(--umber); color: var(--white); opacity: var(--dn); transform: scale(calc(.6 + var(--dn) * .4)); }
.ag__st::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--umber) calc(var(--r) * 360deg), rgba(31,33,36,.12) 0); -webkit-mask: radial-gradient(circle, transparent 6px, #000 6.5px); mask: radial-gradient(circle, transparent 6px, #000 6.5px); }
.ag__ic { width: 15px; height: 15px; color: var(--ink-3); }
.ag__name { font-size: 14.5px; color: var(--ink); min-width: 0; }
.ag__foot { display: flex; gap: 16px; font: 400 12px/1 var(--mono); color: var(--ink-3); padding-top: 4px; }



.ag__split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.ag__row { --r: clamp(0, var(--k, 1) * var(--n) * 1.08 - var(--j), 1); display: grid; grid-template-columns: 18px 16px minmax(0, 1fr); gap: 10px; align-items: center; height: 42px; border-bottom: 1px solid var(--line); opacity: calc(.32 + .68 * clamp(0, var(--r) * 4, 1)); }
/* the live output of the step in progress; each step's log takes the pane until the next one starts */
.ag__out { position: relative; min-height: 180px; border-radius: 14px; background: var(--term); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); overflow: hidden; }
.ag__log { --r: clamp(0, var(--k, 1) * var(--n) * 1.08 - var(--j), 1); --in: clamp(0, (var(--k, 1) * var(--n) * 1.08 - var(--j)) * 6, 1); --gone: clamp(0, (var(--k, 1) * var(--n) * 1.08 - var(--j) - 1) * 6, 1);
  position: absolute; inset: 0; margin: 0; padding: 14px 16px; display: grid; align-content: start; gap: 4px; font: 400 12px/1.5 var(--mono); color: rgba(244,245,246,.82); white-space: pre-wrap; overflow-wrap: anywhere; opacity: calc(var(--in) * (1 - var(--gone))); transform: translate3d(0, calc((1 - var(--in)) * 8px), 0); }
.ag__log--last { opacity: var(--in); }
.ag__log::after { content: ''; width: 7px; height: 14px; margin-top: 2px; background: var(--gold); opacity: .8; animation: agCaret 1.1s steps(2, jump-none) infinite; }
@keyframes agCaret { 50% { opacity: 0; } }
.ag__ln { opacity: clamp(0, (var(--r) * 5 - var(--l)) * 1.5, 1); }
.ag__ln--k { color: var(--gold); }


/* Request log: reveal each part in order, then show one example request at a time. */
.fl { --a: clamp(0, (var(--k, 1) * 4.2 - var(--q, 0)) * 2, 1); display: grid; grid-template-rows: auto auto auto auto minmax(0, 1fr); gap: 12px; height: 100%; }
.fl > *, .fl__row > * { --a: clamp(0, (var(--k, 1) * 4.2 - var(--q, 0)) * 2, 1); }
.fl__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--ink-3); }
.fl__head b { font: 500 13.5px/1 var(--sans); color: var(--ink); }
.fl__row { display: grid; grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1.3fr) 18px minmax(0, .9fr); align-items: stretch; }
.fl__col { opacity: var(--a); transform: translate3d(0, calc((1 - var(--a)) * 10px), 0); min-width: 0; display: grid; align-content: start; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line), 0 10px 22px -18px rgba(31, 33, 36,.45); }
.fl__h { margin: 0; display: flex; align-items: center; gap: 7px; font: 500 12px/1 var(--sans); color: var(--ink-3); }
.fl__h svg { width: 13px; height: 13px; color: var(--umber); }
.fl__qv { height: calc(3 * 32px + 2 * 6px); overflow: hidden; }
.fl__inbox ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; transition: transform 560ms var(--inout) 140ms; }
.fl__inbox li { height: 32px; padding: 0 10px; border-radius: 9px; background: var(--paper-hi); font: 400 12.5px/32px var(--sans); color: var(--ink-3); white-space: nowrap; overflow: hidden; transition: opacity 360ms var(--out), transform 420ms var(--out), background-color 300ms ease, color 300ms ease; }
/* the ticket at the head of the queue is the one about to be sent */
.fl__inbox li span { display: block; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, #000000 calc(100% - 20px), transparent); mask-image: linear-gradient(90deg, #000000 calc(100% - 20px), transparent); }
.fl__inbox li:first-child { background: var(--flush-2); color: var(--ink); }
/* sent: it slides off toward the wire, and the queue moves up a row; at the next ticket both reset without a transition */
.fl:not([data-phase="0"]) .fl__inbox li:first-child { opacity: 0; transform: translate3d(22px, 0, 0); }
.fl:not([data-phase="0"]) .fl__inbox ol { transform: translate3d(0, -38px, 0); }
.fl[data-phase="0"] .fl__inbox ol { transition: none; }
.fl[data-phase="0"] .fl__inbox li:first-child { transition: background-color 300ms ease, color 300ms ease; }
.fl__body { margin: 0; font: 400 14px/1.5 var(--serif); color: var(--ink); opacity: 0; transition: opacity 280ms var(--out); }
.fl:not([data-phase="0"]) .fl__body { opacity: 1; }
.fl__note { font: 400 11.5px/1 var(--mono); color: var(--ink-3); opacity: 0; transition: opacity 240ms ease; }
.fl[data-phase="2"] .fl__note, .fl[data-phase="3"] .fl__note, .fl[data-phase="4"] .fl__note { opacity: 1; }
.fl__router dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; align-items: baseline; }
/* each value holds the last decision (quiet) and the new one; the new one takes over when the ticket is routed */
.fl__router dd > span { grid-area: 1 / 1; transition: opacity 280ms var(--out), transform 280ms var(--out), color 280ms ease; }
.fl__was { color: var(--ink-3); }
.fl__now { opacity: 0; transform: translateY(4px); }
.fl[data-phase="3"] .fl__was, .fl[data-phase="4"] .fl__was { opacity: 0; transform: translateY(-4px); }
.fl[data-phase="3"] .fl__now, .fl[data-phase="4"] .fl__now { opacity: 1; transform: none; }
.fl__router dd { overflow-wrap: anywhere; }
.fl__router dt { font: 400 11.5px/1 var(--sans); color: var(--ink-3); }
.fl__router dd { display: grid; margin: 0; font: 500 13px/1.25 var(--sans); color: var(--ink); }
.fl__router { background: var(--flush); box-shadow: inset 0 0 0 1px rgba(88, 90, 93,.35), 0 10px 22px -18px rgba(31, 33, 36,.45); }
/* wires: a line with an ink bead that runs along it each time something is sent */
.fl__wire { position: relative; align-self: center; height: 1px; background: rgba(31, 33, 36,.22); opacity: var(--a); }
.fl__wire[data-on]::after { content: ''; position: absolute; top: -2.5px; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--umber); animation: flBead 420ms var(--inout) both; }
@keyframes flBead { from { transform: translateX(-3px); opacity: 0; } 20% { opacity: 1; } to { transform: translateX(15px); opacity: 0; } }
.fl__fork { display: block; width: 100%; height: 40px; overflow: visible; opacity: var(--a); }
.fl__branch { fill: none; stroke: rgba(31, 33, 36,.22); stroke-width: 1; vector-effect: non-scaling-stroke; }
.fl__branch.is-on { stroke: var(--umber); stroke-width: 1.5; stroke-dasharray: 800; animation: flDraw 560ms var(--out) both; }
@keyframes flDraw { from { stroke-dashoffset: 800; } to { stroke-dashoffset: 0; } }
.fl__foot { align-self: end; }
.fl__lanes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; opacity: var(--a); transform: translate3d(0, calc((1 - var(--a)) * 10px), 0); }
.fl__lane { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line), 0 10px 22px -18px rgba(31, 33, 36,.45); transition: box-shadow 300ms var(--out); }
.fl__lane img, .fl__lane .mono-mark { width: 18px; height: 18px; }
.fl__lm { display: grid; gap: 3px; min-width: 0; }
.fl__lm b { font: 500 13.5px/1.1 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl__lm small { font: 400 11.5px/1 var(--sans); color: var(--ink-3); }
.fl__count { font: 400 22px/1 var(--serif); font-variant-numeric: tabular-nums; color: var(--ink); animation: flCount 520ms var(--out); }
@keyframes flCount { from { transform: translateY(-6px); opacity: .2; } }
.fl__lane.is-hit { box-shadow: inset 0 0 0 1.5px var(--umber), 0 12px 26px -18px rgba(31, 33, 36,.5); }

@media (max-width: 640px) {
  .ss { padding: 18px 16px; }
  .ag__split { grid-template-columns: minmax(0, 1fr); }
  .ag__out { min-height: 115px; }
  .pg__cols { grid-template-columns: minmax(0, 1fr); }
  .fl__head span { display: none; }
  .fl__row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .fl__inbox, .fl__wire, .fl__fork { display: none; }
  .fl__lanes { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .fl__lane { padding: 10px 12px; }
}

@media (max-height: 720px) {
  .studio.is-pinned .studio__grid { gap: 14px; }
  .studio.is-pinned .studio__head .h2 { font-size: clamp(32px, 5.7svh, 45px); }
  .studio.is-pinned .studio__body { --bh: clamp(310px, 49svh, 355px); }
  .studio.is-pinned .fl__fork { height: 27px; }
}
@media (prefers-reduced-motion: reduce) {
  .ag__log::after { animation: none; }
}
