/* Loading screen: a sheet of note paper over the whole screen. A pushpin
   drops in and pins it, "loading..." writes itself in the handwriting font,
   then the note is pulled away to show the page (js/loader.js). About 1.5 s,
   once per browser session. Then the goldfish pops up into its corner
   (site.css, "Bubbles"). */

#dg-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  overflow: hidden;
  /* Failsafe: if the script never runs, don't leave the site covered. */
  animation: dg-failsafe 0.3s ease-in-out 10s forwards;
}
/* Already seen this session (set in <head> before first paint) */
.dg-loader-seen #dg-loader { display: none; }
@keyframes dg-failsafe {
  to { opacity: 0; visibility: hidden; }
}
/* Once the note is being pulled away, clicks reach the page */
#dg-loader.is-opening { pointer-events: none; }

.ld-sheet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .35 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 40%, #fffaf0 0%, #f6efdd 60%, #eadfc6 100%);
  transform-origin: 50% 9vh;
  will-change: transform;
}
/* The pin and the word start hidden, so the first paint is blank paper: the
   script shows them only as their animations begin. (Without this, a cached
   pin and word showed at rest for a frame or two before the script ran.) */
.ld-word {
  width: clamp(190px, 34vmin, 340px);
  height: auto;
  translate: 0 -4vh;
  clip-path: inset(-10% 100% -10% 0);
}
/* The pin goes in at 80% down its image, at the top centre of the sheet */
.ld-pin {
  --pw: clamp(30px, 4.6vmin, 46px);
  position: absolute;
  width: var(--pw);
  left: 50%;
  top: 9vh;
  margin: calc(var(--pw) * -1.15) 0 0 calc(var(--pw) * -0.5);
  filter: drop-shadow(2px 4px 3px rgb(0 0 0 / 0.35));
  opacity: 0;
  will-change: transform;
}
/* Reduced motion: no animation, so the note is shown pinned and written,
   then fades */
@media (prefers-reduced-motion: reduce) {
  .ld-word { clip-path: none; }
  .ld-pin { opacity: 1; }
}
