/*
 * The save-the-date as the website's opening (opening.js): until it hands over it lies over the
 * page on its own paper, and the page is out of sight and out of the keyboard's reach. Laid out
 * as: the settings, the page held back, the paper over its backdrop, the frame, its leaving.
 */

:root {
  --color-opening-paper: #efe7df; /* the save-the-date's own paper (--paper in its tokens.css) */
  --layer-opening: 3; /* over the bar and its menu (site.css: --layer-bar is 2) */
  --opening-leave-time: 0.9s; /* opening.js tells the save-the-date: its music fades over it */
}

html[data-opening],
html[data-opening] body {
  overflow: hidden;
  background: var(--color-opening-paper);
}

/* Nothing under the frame is revealed by a press inside it, until the frame is taken away (its
   fade too): Safari would scroll the page to keep a pressed control clear of the page's scroll
   padding, and Home would not open at its top. */
html[data-opening],
html[data-opening-leaving] {
  scroll-padding: 0;
}

/* The page's parts are out of sight and out of the keyboard's reach. Its backdrop alone stays
   drawn, under the paper laid over it below: it holds nothing to reach, and a browser times a
   page's first paint by the page's own content, never by a frame's. */
html[data-opening] body > :not(.opening-frame, .backdrop) {
  visibility: hidden;
}

/* The paper over the backdrop, from the first paint; the frame is laid over it once the page is
   read. It takes the backdrop's own box. */
html[data-opening] body::before {
  content: '';
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: var(--layer-opening);
  height: 100vh;
  height: 100lvh;
  background: var(--color-opening-paper);
}

.opening-frame {
  position: fixed;
  inset: 0;
  z-index: var(--layer-opening);
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--color-opening-paper);
  transition: opacity var(--opening-leave-time) ease;
}

/* The page is already itself underneath: the frame fades off it, then is taken away. */
.opening-frame--leaving {
  opacity: 0;
  pointer-events: none;
}

/* While the frame fades off, a press is taken by neither: the card under the finger is leaving,
   and the page beneath has its own buttons where the card had its menu. */
html[data-opening-leaving] body > :not(.opening-frame) {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .opening-frame {
    transition: none;
  }
}
