/* ==========================================================================
   Lab
   The page is one fixed surface the size of the viewport: no document
   scroll, no scrollbars, no footer. js/lab.js positions every card with a
   transform and owns all panning. Timings here are mirrored in js/lab.js.
   Switching views is a Web Animation on each card's media (js/lab.js); the
   cards themselves never transition.
   ========================================================================== */
html[data-view="lab"],
html[data-view="lab"] body{overflow:hidden;height:100%;overscroll-behavior:none}
[data-view="lab"] .footer{display:none}

/* Shared by the field and the opened view, which lives outside .lab. */
.lab,.lab-modal{
  --lab-ph:var(--line);                       /* placeholder card */
  --lab-r:var(--r-2);
}
.lab{
  --lab-slide:cubic-bezier(.32,.72,0,1);      /* the switch's thumb: quick to answer, long soft landing */
  --lab-enter:cubic-bezier(.22,1,.36,1);      /* arriving: ease-out */
  --lab-enter-ms:720ms;
  position:fixed;inset:0;overflow:hidden;background:var(--bg);
  touch-action:none;overscroll-behavior:none;
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
}
.lab-sr{
  position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;
  clip:rect(0 0 0 0);white-space:nowrap;border:0;
}
.lab-field{position:absolute;inset:0}

.lab-card{
  position:absolute;left:0;top:0;width:var(--lab-mw);height:var(--lab-mh);
  padding:0;border:0;background:none;border-radius:var(--lab-r);
  will-change:transform;-webkit-tap-highlight-color:transparent;
  transition:opacity 160ms ease-out;
}
/* the grid's cards are smaller; the size flips while the cards are hidden */
.lab[data-mode="grid"] .lab-card{width:var(--lab-cw);height:var(--lab-ch)}
.lab-card:focus-visible{outline-offset:4px;border-radius:var(--lab-r)}
.lab-card.is-lifted{visibility:hidden}
/* reduced motion: the switch is a cross-fade, never a move */
.lab.is-fading .lab-card{opacity:0}

.lab-media{position:absolute;inset:0;overflow:hidden;border-radius:inherit;background:var(--lab-ph)}
.lab-media video{display:block;width:100%;height:100%;max-width:none;object-fit:cover;pointer-events:none}

/* ------------------------------------------------------------------ switch
   Built like the site's other floating control, the phone chapter pill: white,
   a hairline, fully round, 48px tall, no shadow. Two words in the type every
   link, nav item and button uses (H4 metrics, 15px): the selected one black on
   a sliding thumb in the tag grey (--line), the other paragraph grey until
   hovered, when it gets the hover fill every button uses (--surface) and
   turns black. Both segments share one width, so the thumb only slides. */
.lab-switch{
  --lab-seg-h:40px;
  position:absolute;left:50%;bottom:calc(var(--s-5) + env(safe-area-inset-bottom, 0px));z-index:2;
  display:grid;grid-auto-flow:column;grid-auto-columns:1fr;padding:3px;
  border:1px solid var(--line);border-radius:var(--r-3);
  transform:translateX(-50%);background:var(--bg);
  transition:opacity 200ms ease-out;
}
/* Behind the opened view the switch would only be noise. */
.lab[data-open] .lab-switch{opacity:0}
.lab-switch-thumb{
  position:absolute;left:3px;top:3px;width:calc((100% - 6px) / 2);height:var(--lab-seg-h);border-radius:var(--r-3);
  background:var(--line);pointer-events:none;
  transition:transform 440ms var(--lab-slide);
}
.lab-switch[data-mode="grid"] .lab-switch-thumb{transform:translateX(100%)}
.lab-switch button{
  position:relative;z-index:1;display:grid;place-items:center;
  height:var(--lab-seg-h);margin:0;padding:0 var(--s-4);
  border:0;border-radius:var(--r-3);background:transparent;
  font-size:var(--fs-p2);line-height:1.5;font-weight:400;white-space:nowrap;
  color:var(--para);-webkit-tap-highlight-color:transparent;
  transition:background-color 150ms ease-out,color 240ms ease-out,scale 150ms ease-out;
}
.lab-switch button[aria-checked="true"]{color:var(--black)}
.lab-switch button:focus-visible{outline-offset:2px;border-radius:var(--r-3)}
@media (hover:hover){
  .lab-switch button[aria-checked="false"]:hover{background:var(--surface);color:var(--black)}
}
.lab-switch button[aria-checked="false"]:active{scale:.97}

/* ------------------------------------------------------------------- modal
   Above the app bar (60), below the dither (85) and the cursor (90). */
.lab-modal{
  --lab-open:cubic-bezier(.32,.72,0,1);
  --lab-open-ms:480ms;
  --lab-close-ms:360ms;
  --lab-side:var(--gutter);
  --lab-head:26px;
  position:fixed;inset:0;z-index:70;
}
.lab-modal[hidden]{display:none}
.lab-backdrop{
  position:absolute;inset:0;
  /* The field stays in sight, softly out of focus, under a white veil strong
     enough for the text below the stage: over the darkest card the black
     title keeps 13.8:1 and the grey date 4.6:1 (AA). */
  background:rgba(255,255,255,0.76);
  -webkit-backdrop-filter:blur(10px);
  backdrop-filter:blur(10px);
  opacity:0;transition:opacity var(--lab-open-ms) var(--lab-open);
}
.lab-dialog:focus{outline:none}
/* The stage sits dead centre in the window; the title and date hang below it
   (absolutely, so they never pull it off centre). The stage leaves room for
   them on both sides, so the space above and below stays even. */
.lab-dialog{
  position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  padding:0 var(--lab-side);pointer-events:none;
}
.lab-panel{
  --lab-room:calc(2 * var(--s-8) + 2 * (var(--lab-head) + var(--s-4)));
  position:relative;pointer-events:auto;
  width:min(
    calc(100vw - 2 * var(--lab-side)),
    calc((100vh - var(--lab-room)) * 1.5),
    1200px);
}
@supports (height:100dvh){
  .lab-panel{
    width:min(
      calc(100vw - 2 * var(--lab-side)),
      calc((100dvh - var(--lab-room)) * 1.5),
      1200px);
  }
}
/* Title left, date right, on one baseline: the case studies' section heading
   and its paragraph, both 17px. */
.lab-head{
  position:absolute;left:0;right:0;top:calc(100% + var(--s-4));
  display:flex;align-items:baseline;justify-content:space-between;gap:var(--s-4);min-height:var(--lab-head);
  opacity:0;transform:translateY(-6px);
  transition:opacity 150ms ease-out,transform 150ms ease-out;
}
.lab-date{flex:none;line-height:1.5}
/* No visible close: a click anywhere outside the stage closes it, and so
   does Esc. For keyboard and screen-reader users a close button still exists
   and still comes first in the tab order, but it only shows while focused
   from the keyboard, just above the stage's corner. It is styled like the
   site's one button (.btn). */
.lab-close{
  position:absolute;right:-8px;bottom:calc(100% + var(--s-2));z-index:1;display:grid;place-items:center;width:32px;height:32px;
  margin:0;padding:0;border:0;border-radius:var(--r-1);
  background:var(--surface);color:var(--black);
  opacity:0;pointer-events:none;transition:opacity 150ms ease-out;
}
.lab-close:focus-visible{opacity:1;pointer-events:auto;border-radius:var(--r-1)}
.lab-stage{
  position:relative;width:100%;aspect-ratio:3/2;
  border-radius:var(--lab-stage-r,var(--r-2));
  transform-origin:0 0;will-change:transform;
  transition:transform var(--lab-open-ms) var(--lab-open);
}
/* Lifted off the field, the stage casts a soft shadow. It lives on its own
   layer and fades, so the growing card never repaints a shadow per frame, and
   it starts from none, like the card it grows from. */
.lab-stage-shadow{
  position:absolute;inset:0;border-radius:inherit;pointer-events:none;
  box-shadow:0 1px 3px rgba(16,22,32,0.06),0 24px 64px -16px rgba(16,22,32,0.22);
  opacity:0;transition:opacity var(--lab-open-ms) var(--lab-open);
}
.lab-stage-clip{position:absolute;inset:0;overflow:hidden;border-radius:inherit}
.lab-stage-clip > .lab-media{border-radius:0}
.lab-demo{
  position:absolute;inset:0;opacity:0;pointer-events:none;touch-action:none;
  transition:opacity 220ms ease-out;
}
/* A loaded page (published from the Lab studio) cross-fades in slower, over
   the video, while the stage finishes growing. */
.lab-demo.is-page{transition:opacity 360ms cubic-bezier(.4,0,.2,1)}

.lab-modal.is-open .lab-backdrop,
.lab-modal.is-open .lab-stage-shadow{opacity:1}
.lab-modal.is-open .lab-head{
  opacity:1;transform:none;
  transition:opacity 260ms ease-out 120ms,transform 360ms var(--lab-open) 120ms;
}
.lab-modal.is-live .lab-demo{opacity:1;pointer-events:auto}
.lab-modal.is-closing .lab-backdrop,
.lab-modal.is-closing .lab-stage-shadow{transition-duration:var(--lab-close-ms)}
.lab-modal.is-closing .lab-stage{transition-duration:var(--lab-close-ms)}
.lab-modal.is-closing .lab-demo{transition-duration:120ms}

/* reduced motion: the opened view fades in place, nothing travels */
.lab-modal.is-reduced .lab-stage{opacity:0;transform:none;transition:opacity 160ms ease-out}
.lab-modal.is-reduced.is-open .lab-stage{opacity:1}
.lab-modal.is-reduced .lab-head{transform:none}
.lab-modal.is-reduced .lab-backdrop{transition-duration:160ms}

/* ----------------------------------------------------------------- cursors
   Where the site draws its own cursor it hides the system one with
   `.app * {cursor:none}` (site.css). These are wrapped in :where() so they
   carry no specificity and that rule always wins; they only apply where the
   system cursor is the one on screen. */
:where(.lab-switch button[aria-checked="false"], .lab-close){cursor:pointer}
:where(.lab-switch button[aria-checked="true"]){cursor:default}

/* Over the opened piece, the system cursor is back. :where() keeps this just
   strong enough to beat the site's cursor:none and weak enough for a demo's
   own cursor styles. */
@media (hover:hover) and (pointer:fine) and (min-width:769px){
  .app :where(.lab-modal.is-open .lab-stage, .lab-modal.is-open .lab-stage *){cursor:auto}
}

/* ---------------------------------------------------------------- entrance
   Played once on arrival (js/lab.js sets each card's --lab-d). The media
   moves, not the card, so the card's own transform keeps its place. */
@keyframes labCardIn{from{opacity:0;transform:translateY(28px) scale(.94)}}
@keyframes labSwitchIn{from{opacity:0;transform:translate(-50%,16px)}}
@keyframes labFade{from{opacity:0}}
.lab.is-entering .lab-card:not(.is-entered) .lab-media{
  animation:labCardIn var(--lab-enter-ms) var(--lab-enter) var(--lab-d,0ms) both;
}
.lab.is-entering .lab-switch{animation:labSwitchIn 560ms var(--lab-enter) var(--lab-sw-d,0ms) both}
.lab.is-entering.is-reduced .lab-card:not(.is-entered) .lab-media,
.lab.is-entering.is-reduced .lab-switch{animation:labFade 160ms ease-out both}

@media (max-width:768px){
  .lab-modal{--lab-side:var(--gutter)}
}
@media (prefers-reduced-motion:reduce){
  .lab-switch-thumb{transition:none}
  .lab-switch button:active{scale:1}
}
