/* os-jcurve.css: the J curve section on /os (#os-jcurve). Every rule here is anchored to #os-jcurve.

   Two frames pin over the same four screens of scroll, the second lying exactly over the first. The first holds
   heading, chart, the three companies and the source; the second holds the jenga's close view, its own heading and five
   callouts. As the visitor scrolls through the pin the script writes what shows: the curve draws, the jenga on it grows
   into the close view while the first frame fades, then each block fades in red with its callout and stays red: on
   wide screens every callout stays on its level, capped leader, on phones one callout at a time with a ring on its
   block. Scrolling back writes the earlier frame. A phone too short to pin the first frame lets the section scroll
   with the page instead. Type comes from the page's /os heading and body tokens, the side margins from the page gutter. Without the script the section is plain text:
   heading, source, the three companies, the second heading and the five callouts. */

#os-jcurve{
  --jc-gap:calc(var(--tl-b) * .6);
  --jc-obj:calc(300 * var(--u));         /* a 3D still's side */
  --jc-sw:calc(var(--stroke) * 5);       /* the curve's stroke */
  --jc-dot:calc(var(--stroke) * 8);      /* a point's radius */
  --jc-vh:100svh;                        /* a screen; touch screens hold it in px (os-jcurve.js) so a height-only resize keeps the pin */
  --jc-stage-h:calc(var(--jc-vh) - var(--navH));
  --jc-wide:1;                           /* read by the script: 1 hangs labels by their points, 0 stacks them */
  --jc-pin:var(--jc-steps-pin,var(--jc-vh));   /* the scroll both frames stay pinned for: the dial's four held screens (os-jcurve.js), else one */
  --jc-fade:calc(var(--dur-1) * 1.5);    /* a phone's ring showing or leaving */
}
@media (max-width:767px),(max-width:1023px) and (max-aspect-ratio:9999/10000),(max-width:1023px) and (max-height:499px){
  #os-jcurve{--jc-wide:0; --jc-obj:min(calc(56 * var(--u)),calc(var(--jc-vh) * .08)); --jc-sw:calc(var(--stroke) * 4); --jc-dot:calc(var(--stroke) * 7)}
}
@media (min-width:1024px),(min-width:768px) and (min-aspect-ratio:1/1) and (min-height:500px){
  #os-jcurve{--jc-obj:min(calc(300 * var(--u)),calc(var(--jc-vh) * .12))}
}

/* the section, on the page gutter every /os section uses */
.page #os-jcurve{display:block;padding-inline:var(--gutter)}
#os-jcurve .jc-stage{position:relative;display:flex;flex-direction:column}
#os-jcurve .jc-head{flex:none;padding-top:var(--line)}
#os-jcurve :is(.jc-h,.jc-zh){margin:0;max-width:16em;color:var(--ink)}
#os-jcurve .jc-src{margin:calc(var(--tl-b) * .75) 0 0;max-width:44em;font-size:var(--fs-s);line-height:var(--tl-s);letter-spacing:var(--s-tr);color:var(--text)}
#os-jcurve .jc-chart{position:relative;display:flex;flex-direction:column;margin-top:calc(var(--tl-b) * 1.5)}
#os-jcurve .jc-plot{position:relative;flex:1 1 auto;min-height:0}
#os-jcurve .jc-svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
/* the script's measures: a dot (width), a gap (height), and 100svh in px as a max-height that never binds */
#os-jcurve .jc-ruler{position:absolute;left:0;top:0;width:var(--jc-dot);height:var(--jc-gap);max-height:100svh;visibility:hidden;pointer-events:none}

/* the points as text. A still is a square on its label's left, its centre on the figure's line: the box the chart
   measures. The text is then shown centred on the still's object (below) */
#os-jcurve .jc-pts{list-style:none;margin:0;padding:0;display:grid;gap:var(--jc-gap)}
#os-jcurve .jc-pt{display:grid;grid-template-columns:var(--jc-obj) minmax(0,1fr);column-gap:var(--jc-gap);align-items:start}
#os-jcurve .jc-obj{display:block;width:var(--jc-obj);height:var(--jc-obj)}
#os-jcurve.jc-nogl :is(.jc-obj,.jc-zobj,.jc-zrest){visibility:hidden}
#os-jcurve:not(.jc-on) .jc-obj{display:none}
#os-jcurve:not(.jc-on) .jc-pt{display:block}
#os-jcurve .jc-txt{display:block;min-width:0;margin-top:calc((var(--jc-obj) - var(--tl-b)) / 2)}
/* the text block is shown centred on its still's object, three quarters of a line from the object's own edge. It moves
   by translate alone, so the chart, which reads the labels' boxes, never sees it: x trades the column gap (.6 of a
   line) for .75 of one measured from the object, --jc-in being the share of the square the object leaves empty on its
   right (set by the script as it shoots the still); y takes the text from its first line on the still's centre (the
   margin above) to its middle there */
#os-jcurve.jc-on .jc-txt{translate:calc(var(--tl-b) * .15 - var(--jc-obj) * var(--jc-in,0)) calc(var(--tl-b) / 2 - 50%)}
#os-jcurve :is(.jc-fig,.jc-lab,.jc-cl){display:block;font-size:var(--fs-b);letter-spacing:var(--b-tr);text-wrap:pretty}
#os-jcurve .jc-cl{line-height:var(--tl-b)}
#os-jcurve :is(.jc-fig,.jc-lab){line-height:var(--b-ui-lr)}
#os-jcurve .jc-ct{display:block;font-size:var(--fs-b);line-height:var(--b-ui-lr);letter-spacing:var(--b-tr);text-wrap:pretty}
#os-jcurve :is(.jc-fig,.jc-ct){color:var(--ink);font-weight:var(--title-wt)}
#os-jcurve :is(.jc-lab,.jc-cl){color:var(--text);font-weight:var(--body-wt)}
#os-jcurve .jc-fig{font-variant-numeric:tabular-nums}
#os-jcurve .jc-tag{display:none}
#os-jcurve.jc-flat :is(.jc-svg,.jc-tag){visibility:hidden}

/* the second frame: the jenga close up and what goes wrong. Without the script it is a heading and five callouts */
#os-jcurve .jc-zstage{display:flex;flex-direction:column;padding-top:calc(var(--line) * 2)}
#os-jcurve .jc-zart{position:relative}
#os-jcurve :is(.jc-zobj,.jc-zrest,.jc-zsvg,.jc-steps){display:none}
#os-jcurve .jc-calls{list-style:none;margin:calc(var(--tl-b) * 1.5) 0 0;padding:0;display:grid;gap:var(--tl-b);max-width:44em}
#os-jcurve .jc-call{min-width:0}

/* drawn by the script. Frame two's track lies over frame one's, so both stages pin and let go together */
#os-jcurve.jc-on .jc-track{height:calc(var(--jc-stage-h) + var(--jc-pin))}
#os-jcurve.jc-on .jc-stage{position:sticky;top:var(--navH);height:var(--jc-stage-h)}
#os-jcurve.jc-on .jc-chart{flex:1 1 auto;min-height:0}
#os-jcurve.jc-on .jc-ztrack{margin-top:calc((var(--jc-stage-h) + var(--jc-pin)) * -1);height:calc(var(--jc-stage-h) + var(--jc-pin));pointer-events:none}
#os-jcurve.jc-on .jc-zstage{position:sticky;top:var(--navH);height:var(--jc-stage-h);padding-top:var(--line)}
#os-jcurve.jc-on .jc-zh{opacity:0}
#os-jcurve.jc-on .jc-zh.is-on{opacity:1;pointer-events:auto}
#os-jcurve.jc-on .jc-zart{flex:1 1 auto;min-height:0;margin-top:calc(var(--tl-b) * 1.5);display:grid;gap:var(--tl-b) calc(var(--jc-gap) * 3)}
#os-jcurve.jc-on .jc-calls{display:contents}
#os-jcurve.jc-on .jc-zobj{display:block;grid-area:art;place-self:center;width:var(--jc-J);height:var(--jc-J);transform-origin:0 0;visibility:hidden}
#os-jcurve.jc-on .jc-zobj.is-on{visibility:visible}
/* a block that is not red yet: its own shot, resting white, laid over the close view's red. The script fades the shot
   out whole as its block's share of the dial passes, so the block fades in red. Positioned, so it lies over the zoomed (transformed) close view; it shows and flies
   with the close view */
#os-jcurve.jc-on .jc-zrest{display:block;grid-area:art;place-self:center;width:var(--jc-J);height:var(--jc-J);position:relative;
  opacity:0;transform-origin:0 0}
#os-jcurve.jc-on .jc-zrest.is-on{opacity:1}
#os-jcurve.jc-on .jc-zobj:not(.is-on) ~ .jc-zrest{visibility:hidden}
#os-jcurve.jc-on .jc-zsvg{display:block;position:absolute;inset:0;width:100%;height:100%;overflow:visible}
#os-jcurve.jc-on :is(.jc-call,.jc-lead){opacity:0}
#os-jcurve.jc-on .jc-call.is-on{opacity:1;pointer-events:auto}
#os-jcurve.jc-on .jc-lead.is-on{opacity:1}
#os-jcurve.jc-on .jc-pt.is-lifted .jc-obj{visibility:hidden}
#os-jcurve .jc-lead line{stroke:var(--ink);stroke-width:var(--stroke)}
#os-jcurve .jc-mark{opacity:0}
#os-jcurve .jc-mark.is-on{opacity:1}
#os-jcurve .jc-mark circle{fill:none;stroke:var(--paper);stroke-width:calc(var(--stroke) * 2)}
#os-jcurve .jc-mark circle + circle{fill:var(--paper);stroke:none}
#os-jcurve.jc-nogl .jc-mark{display:none}
#os-jcurve .jc-base{fill:none;stroke:var(--ink);stroke-opacity:.22;stroke-width:var(--stroke)}
#os-jcurve .jc-curve{fill:none;stroke-width:var(--jc-sw);stroke-linecap:round;stroke-linejoin:round}
#os-jcurve .jc-stop-ink{stop-color:var(--ink)}
#os-jcurve .jc-stop-red{stop-color:var(--story-red)}
#os-jcurve .jc-area{fill:var(--story-red);fill-opacity:.07}
#os-jcurve .jc-dot{r:var(--jc-dot);fill:var(--paper);stroke:var(--ink);stroke-width:var(--jc-sw);opacity:0}
#os-jcurve .jc-dot[data-k="1"]{stroke:var(--story-red)}
#os-jcurve .jc-dot.is-on{opacity:1}
#os-jcurve .jc-pen{r:calc(var(--jc-dot) * .7);fill:var(--ink);opacity:0}
#os-jcurve .jc-pen.is-on{opacity:1}
#os-jcurve.jc-on .jc-pt{opacity:0}
#os-jcurve.jc-on .jc-pt.is-on{opacity:1;translate:none}

/* wide: every label hangs the same way from its point, its still's corner one dot and one gap right and one dot and two
   gaps below the point's centre. --x and --y are the point, --w the room it has */
@media (min-width:1024px),(min-width:768px) and (min-aspect-ratio:1/1) and (min-height:500px){
  /* both headings start below the header's blur, which reaches 40 px under the header, and a line stays free under
     the lowest label */
  #os-jcurve.jc-on :is(.jc-head,.jc-zstage){padding-top:calc(var(--line) * 2.5)}
  #os-jcurve.jc-on .jc-stage{padding-bottom:var(--line)}
  /* padding gives the source back the room of its two old 18px lines, so the chart under it keeps its size (WEB-135) */
  #os-jcurve .jc-src{order:1;padding-block:calc(var(--os-tl-s) - 1lh)}
  #os-jcurve .jc-chart{order:2}
  #os-jcurve.jc-on .jc-pts{position:absolute;inset:0;display:block}
  #os-jcurve.jc-on .jc-pt{position:absolute;left:var(--x);top:var(--y);width:max-content;max-width:var(--w);
    transform:translate(calc(var(--jc-dot) + var(--jc-gap)),calc(var(--jc-dot) + var(--jc-gap) * 2))}
  /* two callout columns flank the jenga, every text set on one left edge per column and one width. The script steps the
     five titles down on one rhythm, right and left in turn, and draws each leader level to its bar's open end. No ring:
     the leader names the block */
  #os-jcurve.jc-on .jc-zart{grid-template-columns:minmax(0,1fr) var(--jc-J) minmax(0,1fr);grid-template-rows:minmax(0,1fr);
    grid-template-areas:"cl art cr"}
  #os-jcurve.jc-on .jc-call{align-self:start;width:min(100%,19em);text-align:left;translate:0 var(--jc-cdy,0%)}
  #os-jcurve.jc-on .jc-call:is([data-k="1"],[data-k="3"]){grid-area:cl;justify-self:end}
  #os-jcurve.jc-on .jc-call:is([data-k="0"],[data-k="2"],[data-k="4"]){grid-area:cr;justify-self:start}
  #os-jcurve .jc-mark{display:none}
}

/* compact: the heading sits in the chart's empty corner, above Baseline and left of the rise; the three companies stack
   under the chart and the source closes the frame, each a body line or three quarters of one apart. Frame two stacks
   the jenga, the steps and the one callout */
@media (max-width:767px),(max-width:1023px) and (max-aspect-ratio:9999/10000),(max-width:1023px) and (max-height:499px){
  #os-jcurve.jc-on.jc-corner .jc-head{position:absolute;left:0;top:var(--jc-ht,var(--jc-gap));width:var(--jc-hw,70%);padding:0;z-index:var(--z-raise)}
  #os-jcurve.jc-on .jc-stage{padding-top:var(--jc-gap)}
  #os-jcurve.jc-on .jc-chart{margin-top:0}
  /* padding gives the source back the room of its three old 18px lines, so the chart and the companies above it stay put (WEB-135) */
  #os-jcurve.jc-on .jc-src{margin:var(--tl-b) 0 calc(var(--jc-gap) + env(safe-area-inset-bottom,0px));padding-block:calc((var(--os-tl-s) - 1lh) * 1.5)}
  #os-jcurve .jc-pt{align-items:center;column-gap:var(--tl-b)}
  #os-jcurve .jc-txt{margin-top:0}
  /* phones: a full body line from each object's own edge to its text: the column gap is that line from the square, and the
     text comes back by the square's empty right margin. A margin, not a translate or offset: either of those changes how
     the curve above is drawn, and the rows keep their heights all the same */
  #os-jcurve.jc-on .jc-txt{translate:none;margin-left:calc(var(--jc-obj) * var(--jc-in,0) * -1)}
  #os-jcurve.jc-on .jc-pts{flex:none;margin-top:var(--tl-b);gap:calc(var(--tl-b) * .75)}
  #os-jcurve.jc-on .jc-tag{display:block;position:absolute;left:var(--x);top:var(--y);font-size:var(--fs-s);line-height:var(--tl-s-ui);
    letter-spacing:var(--s-tr);color:var(--ink);white-space:nowrap;opacity:0}
  #os-jcurve.jc-on .jc-tag.is-on{opacity:1}
  #os-jcurve .jc-tag[data-k="0"]{transform:translate(calc(var(--jc-dot) * -1),calc(var(--jc-dot) + var(--jc-gap) * .6))}
  #os-jcurve .jc-tag[data-k="1"]{transform:translate(-50%,calc(var(--jc-dot) + var(--jc-gap) * .6))}
  #os-jcurve .jc-tag[data-k="2"]{transform:translate(calc(-100% - var(--jc-dot) - var(--jc-gap)),-50%)}
  /* one at a time: the newest callout stands alone under the jenga, the five callouts sharing one place, with five
     short steps above it saying which of the five it is and a small ring on its block; the blocks before it stay lit.
     No leaders */
  #os-jcurve.jc-on .jc-zart{grid-template-columns:minmax(0,1fr);grid-template-rows:var(--jc-J) auto auto;row-gap:var(--jc-gap);
    grid-template-areas:"art" "steps" "calls";align-content:start;padding-bottom:calc(var(--jc-gap) + env(safe-area-inset-bottom,0px))}
  #os-jcurve.jc-on .jc-calls{grid-area:calls;margin:0;display:grid;max-width:none}
  #os-jcurve.jc-on .jc-call{grid-area:1/1;align-self:start}
  #os-jcurve.jc-on .jc-ct{font-size:var(--fs-l);line-height:var(--tl-l);letter-spacing:var(--l-tr);text-wrap:balance}
  #os-jcurve.jc-on .jc-cl{margin-top:calc(var(--tl-b) * .5);max-width:30em}
  #os-jcurve.jc-on .jc-steps{grid-area:steps;display:flex;gap:calc(var(--jc-gap) * .4);opacity:0;
    --jc-dw:calc(var(--jc-gap) * 1.6);--jc-dh:calc(var(--stroke) * 3)}
  #os-jcurve.jc-on .jc-steps.is-on{opacity:1}
  #os-jcurve .jc-steps i{display:block;width:var(--jc-dw);height:var(--jc-dh);background:var(--rule)}
  #os-jcurve .jc-steps [aria-current] i{background:var(--story-red)}
  /* a hairline over --tap, because layout truncates to its unit and could leave it short */
  #os-jcurve .jc-steps button{--jc-px:calc((var(--tap) + var(--stroke) - var(--jc-dw)) / 2);--jc-py:calc((var(--tap) + var(--stroke) - var(--jc-dh)) / 2);
    position:relative;display:block;box-sizing:content-box;padding:var(--jc-py) var(--jc-px);margin:calc(var(--jc-py) * -1) calc(var(--jc-px) * -1);
    border:0;border-radius:0;background:none;-webkit-appearance:none;appearance:none;cursor:pointer}
  #os-jcurve.jc-on .jc-steps.is-on button{pointer-events:auto}
  #os-jcurve .jc-steps button:focus-visible{outline:none}
  #os-jcurve .jc-steps button:focus-visible i{outline:var(--focus-w) solid var(--ink);outline-offset:calc((var(--jc-gap) * .4 - var(--focus-w)) / 2)}
  #os-jcurve .jc-lead{display:none}
  #os-jcurve .jc-mark{display:none}
  /* every callout at once where the frame cannot step (reduced motion, or a phone too short to pin it): a plain list */
  #os-jcurve.jc-on.jc-zall .jc-calls{gap:var(--tl-b)}
  #os-jcurve.jc-on.jc-zall .jc-call{grid-area:auto;opacity:1;translate:none;transition:none}
  #os-jcurve.jc-on.jc-zall .jc-ct{font-size:var(--fs-b);line-height:var(--b-ui-lr);letter-spacing:var(--b-tr)}
  #os-jcurve.jc-on.jc-zall :is(.jc-zrest,.jc-steps,.jc-mark){display:none}
  /* a short phone: frame two closes its spacing to one gap so the close view keeps its size */
  #os-jcurve.jc-on.jc-ztight .jc-zstage{padding-top:var(--jc-gap)}
  #os-jcurve.jc-on.jc-ztight .jc-zart{margin-top:var(--jc-gap);gap:var(--jc-gap);padding-bottom:calc(var(--jc-gap) + env(safe-area-inset-bottom,0px))}
  /* a phone too short for the pinned frame: nothing pins, the chart takes its reduced-motion height, and the close view
     stands finished under it. As a last resort the heading leaves the corner for the chart's top */
  #os-jcurve.jc-on.jc-flow :is(.jc-track,.jc-ztrack){height:auto;margin-top:0}
  #os-jcurve.jc-on.jc-flow :is(.jc-stage,.jc-zstage){position:relative;top:auto;height:auto}
  #os-jcurve.jc-on.jc-flow .jc-plot{flex:none;height:min(100vw,calc(var(--jc-vh) * .6))}
  #os-jcurve.jc-on.jc-flow:not(.jc-corner) .jc-chart{margin-top:var(--tl-b)}
}

/* a screen with no room for the close view at its tightest: frame two stands whole and still after frame one */
#os-jcurve.jc-on.jc-zstill .jc-ztrack{height:auto;margin-top:0}
#os-jcurve.jc-on.jc-zstill .jc-zstage{position:relative;top:auto;height:auto}
#os-jcurve.jc-on.jc-zstill :is(.jc-zh,.jc-call,.jc-lead){transition:none}

/* a pinned frame's heading takes the shared gap under the header; a frame that scrolls keeps its spacing above.
   os-jcurve.js sets the corner heading on the plot's top, so the corner stage's padding is that gap */
@media (prefers-reduced-motion:no-preference){
  /* the script's dial fades blocks, callouts and leaders; a phone's ring only shows or leaves, so it fades here */
  #os-jcurve.jc-on .jc-mark{transition:opacity var(--jc-fade) var(--soft)}
  #os-jcurve.jc-on:not(.jc-flow):not(.jc-corner) .jc-head{padding-top:var(--pin-gap)}
  #os-jcurve.jc-on.jc-corner:not(.jc-flow) .jc-stage{padding-top:var(--pin-gap)}
  #os-jcurve.jc-on:not(.jc-flow):not(.jc-zstill) .jc-zstage{padding-top:var(--pin-gap)}
  /* heading-pin.js's --pin-shift: the first line on How it works', whose type sits it a pixel lower or higher */
  #os-jcurve.jc-on:not(.jc-flow) .jc-h,#os-jcurve.jc-on:not(.jc-flow):not(.jc-zstill) .jc-zh{translate:0 calc(var(--pin-shift,0) * var(--pin-unit))}
}

/* phones show one ring at a time: a ring waits for the leaving one to fade before it fades in */
@media (prefers-reduced-motion:no-preference) and (max-width:767px),(prefers-reduced-motion:no-preference) and (max-width:1023px) and (max-aspect-ratio:9999/10000),(prefers-reduced-motion:no-preference) and (max-width:1023px) and (max-height:499px){
  #os-jcurve.jc-on:not(.jc-zall) .jc-mark.is-on{transition-delay:var(--jc-fade)}
}

/* reduced motion: nothing pins, draws or zooms. The finished chart, then the close view with every callout */
@media (prefers-reduced-motion:reduce){
  #os-jcurve.jc-on :is(.jc-track,.jc-ztrack){height:auto;margin-top:0}
  #os-jcurve.jc-on :is(.jc-stage,.jc-zstage){position:relative;top:auto}
  #os-jcurve.jc-on :is(.jc-pt,.jc-dot,.jc-tag,.jc-zh,.jc-call,.jc-lead,.jc-zrest,.jc-steps,.jc-mark){transition:none}
}
@media (prefers-reduced-motion:reduce) and (max-width:767px),(prefers-reduced-motion:reduce) and (max-width:1023px) and (max-aspect-ratio:9999/10000),(prefers-reduced-motion:reduce) and (max-width:1023px) and (max-height:499px){
  #os-jcurve.jc-on :is(.jc-stage,.jc-zstage){height:auto}
  #os-jcurve.jc-on .jc-plot{flex:none;height:min(100vw,calc(var(--jc-vh) * .6))}
}
