/* Lens Flash homepage intro: the mechanism, from web/intro.css (its placeholder styles removed; the site is site.css).
   <html data-intro> states, set by the head script and by intro.js:
     (none) / still   the site: the film's final frame sits docked in the masthead as the header
     play             the film runs full screen over the site
     held             the film has settled; its final frame (the brand frame) is on screen at full size
     dock             the brand frame glides into the masthead while the site fades in underneath
     welcome          onboarding in the centre stage, before the landing hero (only with data-welcome)
   The hand-off is quick: the final frame holds 0.15 s and glides in 0.7 s (Inceptron: 0.7 s and 1.3 s). */

:root {
  --page: #FFFFFF;          /* the site; the header's frame (mark-*) has its floor lifted to pure white to match */
  --night: #000000;         /* the film opens on black, until the flash at data-light-at */
  /* From media/manifest.json */
  --floor: #EFEEEE;          /* the film's floor after the flash: the intro layer only */
  --lock-cy: .5053;          /* lockup centre, as a fraction of the frame's height */
  --band: .541;              /* the masthead band: lockup height plus margin (the stacked lockup is tall) */
  --band-max: clamp(96px, 13vw, 200px);
  /* docked frame height: the band stays under --band-max, and the lockup (82% of the frame's width) keeps 24 px a side */
  --fh: min(calc(var(--band-max) / var(--band)), calc((100vw - 48px) / .82 * .5625));
  /* the hand-off: the final frame holds, then glides into the masthead while the layer behind it and the film's grey
     floor fade together (so the frame's edges never show); the page fades in late in the glide, the welcome after it */
  --ease: cubic-bezier(.37, 0, .63, 1);   /* in-out sine: no lurch, no jump at either end */
  --t-hold: .26s;
  --t-dock: .95s;
  --ink: #6E0504;
}
html { scrollbar-gutter: stable; background: var(--page); }

/* ---- the masthead: the docked frame -------------------------------------------------------- */

.masthead { background: var(--page); }
.brand { position: relative; height: calc(var(--fh) * var(--band)); }
.brand-frame {
  position: absolute; left: 50%; top: 50%; z-index: 20;
  width: calc(var(--fh) * 16 / 9); height: var(--fh); max-width: none;
  translate: -50% calc(var(--lock-cy) * -100%);          /* lockup centre on the band's centre */
  transform-origin: 0 0;
  clip-path: inset(calc((var(--lock-cy) - var(--band) / 2) * 100%) 0 calc((1 - var(--lock-cy) - var(--band) / 2) * 100%) 0);
  /* feather every edge into the floor, so the frame has no visible border at any size */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent), linear-gradient(transparent, #000 15%, #000 85%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent), linear-gradient(transparent, #000 15%, #000 85%, transparent);
  mask-composite: intersect;
  pointer-events: none;
}
.brand-frame img { position: absolute; inset: 0; width: 100%; height: 100%; }
.brand-photo { display: none; }
[data-intro=play] .brand-photo, [data-intro=held] .brand-photo, [data-intro=dock] .brand-photo { display: block; }
/* film frame to white: it dissolves as it glides, while the intro layer fades to the page behind it */
[data-intro=dock] .brand-photo { opacity: 0; transition: opacity var(--t-dock) var(--ease); }

/* ---- the intro layer ----------------------------------------------------------------------- */

.intro { display: none; position: fixed; inset: 0; z-index: 10; background: var(--night); transition: background-color .25s ease; }
.intro.is-light { background-color: var(--floor); }
[data-intro=play] .intro, [data-intro=held] .intro, [data-intro=dock] .intro { display: block; }
[data-intro=play], [data-intro=held], [data-intro=dock] { overflow: hidden; }
.intro-film { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* the frame waits, scaled over the film (intro.js sets the transform), and fades in when the film settles */
[data-intro=play] .brand-frame, [data-intro=held] .brand-frame { clip-path: inset(0); }
[data-intro=play] .brand-frame { opacity: 0; }
[data-intro=held] .brand-frame { transition: opacity .16s ease-out; }   /* opaque well before the glide (intro.js holds --t-hold) */
[data-intro=dock] .brand-frame { transition: transform var(--t-dock) var(--ease), clip-path var(--t-dock) var(--ease); }
[data-intro=dock] .intro { opacity: 0; transition: opacity var(--t-dock) var(--ease); pointer-events: none; }
/* the final frame now covers the film; after a skip the paused film may be mid-flash and must not show around the glide */
[data-intro=dock] .intro-film { visibility: hidden; }

/* fade reveal: the frame stays docked under the layer, and the film's last frame fades to the site */
[data-reveal=fade] .brand-photo { display: none !important; }
[data-reveal=fade] .brand-frame { z-index: auto; opacity: 1 !important; clip-path: inset(calc((var(--lock-cy) - var(--band) / 2) * 100%) 0 calc((1 - var(--lock-cy) - var(--band) / 2) * 100%) 0) !important; }

/* the site waits under the layer, then fades in as the frame docks */
.site-ui { transition: opacity .5s ease .25s; }
[data-intro=play] .site-ui, [data-intro=held] .site-ui { opacity: 0; transition: none; }
/* the page comes in once the frame is well on its way, not under the large frame */
[data-intro=dock] .site-ui { transition: opacity calc(var(--t-dock) * .45) ease-out calc(var(--t-dock) * .55); }
/* Prepared during the hold, where nothing moves: the browser paints a layer only once it can be seen, so the page waits
   at an imperceptible opacity rather than none, and the film is hidden (under the now opaque frame) before the glide. */
[data-intro=held] .site-ui { opacity: .002; }
[data-intro=held] .site-ui, [data-intro=dock] .site-ui { will-change: opacity; }
[data-intro=held] .intro-film { visibility: hidden; transition: visibility 0s .2s; }
[data-intro=held] .brand-frame, [data-intro=dock] .brand-frame { will-change: transform, opacity; }
.welcome { display: none; }
[data-welcome] .welcome { display: grid; }
[data-welcome] .landing { display: none; }

/* Narrower than 16:10 the sides would crop the lockup: letterbox the film instead, feathered into the layer,
   which is black for the dark opening and the floor colour after the flash. */
@media (max-aspect-ratio: 8/5) {
  .intro-film {
    object-fit: contain;
    -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
    mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  }
}
/* Reduced motion (the film plays only when asked for): no glide. The paused film holds its last frame, then cross-fades
   to the page while the header fades in where it belongs. */
@media (prefers-reduced-motion: reduce) {
  :root { --t-dock: .6s; --t-hold: .2s; }
  [data-intro=held] .brand-frame { opacity: .002; transform: none !important; clip-path: inset(calc((var(--lock-cy) - var(--band) / 2) * 100%) 0 calc((1 - var(--lock-cy) - var(--band) / 2) * 100%) 0); }
  [data-intro=held] .intro-film { visibility: visible; transition: none; }
  [data-intro=dock] .brand-frame { transform: none !important; clip-path: inset(calc((var(--lock-cy) - var(--band) / 2) * 100%) 0 calc((1 - var(--lock-cy) - var(--band) / 2) * 100%) 0); transition: opacity var(--t-dock) ease; }
  [data-intro=dock] .brand-photo { display: none; }
  [data-intro=dock] .intro-film { visibility: visible; }
  [data-intro=dock] .intro { transition: opacity var(--t-dock) ease; }
  [data-intro=dock] .site-ui { transition: opacity var(--t-dock) ease; }
}

/* light on the dark opening, oxblood once the film flashes to white */
.intro-skip {
  display: none; position: absolute; right: 24px; bottom: 24px; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 999px; background: rgb(255 255 255 / .12); color: #fff;
  font: 500 14px system-ui, sans-serif; cursor: pointer; transition: background-color .25s, color .25s;
}
.intro.is-light .intro-skip { background: rgb(110 5 4 / .08); color: var(--ink); }
[data-intro=play] .intro-skip { display: block; }
.intro-skip:hover, .intro-skip:focus-visible { background: rgb(255 255 255 / .22); }
.intro.is-light .intro-skip:hover, .intro.is-light .intro-skip:focus-visible { background: rgb(110 5 4 / .16); }
.intro-skip:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

