/* ============================================================
   Codember camera
   Content arrives out of the same depth the code field lives in,
   instead of sliding up from nowhere. Two treatments:

   .scene   a pinned scene that owns the screen while you scroll
            through it. Expensive in page height, so it is used
            where the motion IS the message.
   [data-depth]
            an ordinary block that flies in out of the field as it
            enters, then stays put. Costs no extra page height, so
            it can go on every section.

   Transforms and opacity only. Driven by scene.js.
   ============================================================ */

/* ---- pinned scenes ---- */
.scene{position:relative;height:300vh;background:none;padding:0;z-index:1}
.scene.tall{height:380vh}
/* A scene reaches the end of its travel while its hold is still pinned, and
   then takes one more screen to unpin and scroll away. Butted up, that screen
   is dead air: the outgoing scene has said its piece and the next has not
   started. Pulling each scene up by one screen spends that air on a dissolve
   instead, the incoming wash coming up over the outgoing words. */
.scene + .scene{margin-top:-100svh}
.hold{position:sticky;top:0;height:100svh;overflow:hidden;perspective:1000px;
  display:flex;align-items:center;justify-content:center;padding:0 1.5rem}

/* The field is beautiful and completely unreadable to set words on, so each
   scene lays its own dark over it for as long as it owns the screen. */
.wash{position:absolute;inset:0;background:#000;pointer-events:none;
  opacity:calc(.72 + var(--near,0) * .23)}

/* a line that flies the camera: far and faint, then still and lit, then past */
.fly{position:absolute;left:50%;top:50%;width:max-content;max-width:min(92vw,20ch);
  transform:translate(-50%,-50%) translateZ(calc(var(--z,0) * 1px));
  opacity:var(--o,1);will-change:transform,opacity;text-align:center;color:#fff;
  font-weight:800;font-stretch:118%;text-transform:uppercase;letter-spacing:-.035em;
  line-height:.92;font-size:clamp(2.1rem,7.6vw,6rem);
  text-shadow:0 0 .5rem #000,0 0 1.6rem rgba(0,0,0,.95)}
.fly.thin{font-weight:200}
.fly.sm{font-size:clamp(1.5rem,4.4vw,3.2rem);max-width:min(92vw,26ch)}

/* a block of real content riding the same camera */
.panel{position:relative;z-index:3;width:min(1020px,100%);color:#fff;
  transform:translateZ(calc(var(--pz,0) * 1px)) translateY(calc(var(--py,0) * 1px));
  opacity:var(--po,1);will-change:transform,opacity}
.panel .spec{color:#9d9d9d;display:block;margin-bottom:1rem}
.panel h2{font-weight:800;font-stretch:118%;text-transform:uppercase;letter-spacing:-.03em;
  line-height:.98;font-size:clamp(1.8rem,5vw,3.6rem);margin-bottom:1.1rem;
  text-shadow:0 0 .6rem #000,0 0 2rem rgba(0,0,0,.9)}
.panel p.lede{color:#c6c6c6;max-width:54ch;
  text-shadow:0 0 .5rem #000,0 0 1.4rem rgba(0,0,0,.9)}

/* a stack of layers that close up as the panel arrives: the thing, then the
   things that bolt onto it */
.stack{display:flex;flex-direction:column;gap:1px;margin-top:2.2rem;
  background:#2a2a2a;border:1px solid #2a2a2a}
.lay{background:rgba(0,0,0,.94);padding:1.15rem 1.4rem;display:flex;gap:1.2rem;
  align-items:baseline;
  transform:translateX(calc((1 - var(--join,1)) * var(--off,0) * 1vw));
  opacity:calc(.25 + var(--join,1) * .75)}
.lay b{font-weight:800;font-size:1.02rem;color:#fff;min-width:11rem}
.lay span{color:#b4b4b4;font-size:.95rem}
.lay.base{background:rgba(255,255,255,.93)}
.lay.base b{color:#000}
.lay.base span{color:#3a3a3a}
@media(max-width:620px){
  .lay{flex-direction:column;gap:.3rem}
  .lay b{min-width:0}
}

/* the way out of a scene: where a panel sends you next */
.pcta{display:flex;align-items:center;gap:1.6rem;flex-wrap:wrap;margin-top:2.2rem}
.panel .pcta .btn{background:#fff;color:#000;border-color:#fff}
.panel .pcta .btn:hover{background:#d9d9d9;border-color:#d9d9d9}

/* ---- the same arrival, for a block that is not pinned ----
   --dr is how far back it starts, in px of depth. */
[data-depth]{transform:perspective(1250px) translateZ(calc(var(--dz,0) * 1px));
  opacity:var(--do,1);will-change:transform,opacity}

.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;
  clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}

/* No camera, so the scenes stop being scenes: they unpin and become ordinary
   stacked blocks, instead of three screens of scrolling past a frozen frame. */
@media(prefers-reduced-motion:reduce){
  .scene,.scene.tall{height:auto}
  .hold{position:static;height:auto;perspective:none;padding:5rem 1.5rem;
    flex-direction:column;gap:1.4rem;align-items:flex-start}
  .wash{opacity:.9}
  .fly{position:static;transform:none;opacity:1;max-width:min(92vw,24ch);
    text-align:left}
  .panel,[data-depth],.lay{transform:none;opacity:1}
}
