/* ==========================================================
   PRELOADER  (home page)
   A full-screen curtain: the DZIGNZ wordmark in the middle, a
   progress bar low across it. The wordmark rises in letter by letter
   and waits there while the page loads, the bar filling underneath
   it. At full the curtain lifts and carries the wordmark and the bar
   up with it, uncovering the hero.

   Motion lives in /js/preloader.js. The .dz-preloading class is
   set on <html> before first paint by the inline script in
   index.html, so nothing of the page is ever seen underneath.
========================================================== */

.dz-preloader {
  position: fixed;
  inset: 0;

  /* above everything the page puts on top: the fixed header sits at
     9999999 (header.css) and the cursor dot at 999999 (main.css). The
     curtain has to cover them, so the lift uncovers the header rather
     than the header popping in over a curtain still on its way out. */
  z-index: 10000000;

  display: grid;
  place-items: center;

  /* A step off the page's own --dz-bg rather than matching it: the
     curtain then reads as its own surface, and you can see it lift
     away from the page underneath instead of black on black. */
  background: #0e0e0e;

  /* nothing should spill out of the curtain as it leaves */
  overflow: hidden;

  /* the curtain is not content — never let it catch a click */
  pointer-events: none;
}

/* In light mode #0c0c0c would be a black flash — the curtain goes a
   step darker than the light page (#f2f2f2) instead, so it still
   reads as its own surface as it lifts. */
html[data-theme="light"] .dz-preloader {
  background: #e7e7e7;
}

/* No .dz-preloading on <html> means there is no intro to play (JS off,
   a scroll-restoring refresh, a #hash arrival) — the curtain must not
   show at all. .is-leaving is the exception: the class comes off <html>
   the moment the page is released, while the curtain itself is still
   lifting away, and hiding it there would turn that lift into a cut.
   js/preloader.js removes the element when the lift ends. */
html:not(.dz-preloading) .dz-preloader:not(.is-leaving) {
  display: none;
}

/* ===============================
   WORDMARK
   The mask is a fixed window the wordmark moves through: the letters
   rise into it from below on arrival and then stay put — the curtain
   itself takes them away. Every letter sits in the same horizontal
   band, so this one window masks them all.
================================ */
.dz-preloader__mask {
  width: clamp(220px, 46vw, 760px);
  overflow: hidden;

  /* a little air above and below the glyphs so the mask window is
     not flush with the artwork (which would clip the reveal tight
     against the letters) */
  padding: 0.12em 0;
}

.dz-preloader__logo {
  display: block;
}

.dz-preloader__logo svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* ===============================
   THE THREE BEATS
   All of it is CSS transitions on transform and opacity, which the
   compositor runs on its own thread. That matters here: the page is
   doing its heaviest work (fonts landing, every heading being split
   into masked lines) behind this curtain, and a JS-driven timeline
   would stall on it and then jump to catch up. The letters are
   staggered off --i, set on each <g> in the markup.

   js/preloader.js adds the classes: .is-in on arrival, then .is-lifting
   to take the curtain — and everything on it — away.
================================ */

/* letters wait below the window (130 units clears the 76.3-tall
   artwork and the window's padding) */
/* Speed, curve and spacing all match the big page titles (0.9s,
   power4.out, 0.055s apart — js/about-hero-animations.js and its
   siblings) and the footer wordmark. The curve is written out as a
   bezier because this runs before GSAP has loaded; it is the same
   quartic ease-out that power4.out applies. */
.dz-preloader__letter {
  transform: translateY(130px);
  transition: transform 0.9s cubic-bezier(0.165, 0.84, 0.44, 1);
  transition-delay: calc(var(--i, 0) * 0.055s);
  will-change: transform;
}

/* …rise into it, left to right */
.dz-preloader.is-in .dz-preloader__letter {
  transform: translateY(0);
}

/* …and that is the only move they make. There is no exit of their own:
   at full the whole curtain lifts and the wordmark and the bar ride up
   with it, each staying exactly where it sits. (The wordmark used to
   leave through the top of its window while the old percentage counter
   dropped away below — both are gone, along with the pause the curtain
   had to take while they played.) */

/* the curtain takes everything up with it, uncovering the hero from the
   bottom of the screen to the top */
/* 0.75s matches LIFT in js/preloader.js, which removes the curtain
   when this finishes — a longer duration here and it gets cut off */
.dz-preloader.is-lifting {
  transform: translateY(-100%);
  transition: transform 0.75s cubic-bezier(0.76, 0, 0.24, 1);
}

/* the artwork carries no fill of its own here — follow the theme */
.dz-preloader__logo svg :is(polygon, path) {
  fill: var(--dz-fg, #fff);
}

/* ===============================
   PROGRESS BAR — low on the curtain
   A rule sitting 3rem off the bottom with a 2rem margin either side,
   so it reads as a line drawn on the curtain rather than a widget
   stuck to the edge of the screen.
================================ */
.dz-preloader__progress {
  position: absolute;
  left: 2rem;
  right: 2rem;
  bottom: 3rem;

  /* a hairline, not a UI bar — the same weight as the rules the rest
     of the site draws, so the wordmark stays the only thing you look
     at. Fixed, not fluid: a hairline is a hairline at every size. */
  height: 1px;

  /* the part still to fill: the same ink, dropped to a whisper */
  background: rgba(var(--dz-fg-rgb, 255, 255, 255), 0.12);
}

.dz-preloader__bar {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--dz-fg, #fff);

  /* Scaled rather than widened: scaleX is a compositor job, and this
     is being driven every frame while the main thread is busy behind
     the curtain. js/preloader.js writes the scale, 0 to 1. */
  transform: scaleX(0);
  transform-origin: left center;

  /* The main thread does stall back there (fonts landing, every
     heading split into lines), and rAF stalls with it. Without this
     the bar would sit dead and then jump; with it, the compositor
     slides it across whatever gap the stall left. Short enough that
     the bar is still full before the curtain moves (LAND, 0.2s). */
  transition: transform 0.12s linear;

  will-change: transform;
}

/* ===============================
   PAGE UNDERNEATH
   Held still and hidden until the curtain lifts, so the hero
   never plays its reveal behind the curtain and the visitor
   cannot scroll the page out from under it.
================================ */
html.dz-preloading,
html.dz-preloading body {
  overflow: hidden;
  height: 100%;
}

html.dz-preloading .hero-content,
html.dz-preloading #header {
  opacity: 0;
}

/* the custom cursor dot is above everything on the page (z-index
   999999 in main.css) — keep it off the intro, where it would read as
   a speck floating over the wordmark */
html:has(.dz-preloader) .cursor,
html:has(.dz-preloader) .cursor-open {
  opacity: 0;
}

/* The hero text's own safety net (home.css) makes it visible after 3s
   in case JS never splits it. Hold that off for as long as the curtain
   exists, or a slow load means the text is already sitting there when
   the curtain clears — and then jumps back to replay its reveal.

   Keyed on the curtain being in the DOM rather than on .dz-preloading:
   the class comes off when the page is released, which is before the
   curtain has finished getting out of the way. */
html:has(.dz-preloader) .dz-hero-heading:not([data-reveal-done]),
html:has(.dz-preloader) .dz-hero-paragraph:not([data-reveal-done]) {
  animation-delay: 12s;
}

@media (prefers-reduced-motion: reduce) {
  .dz-preloader,
  .dz-preloader__letter,
  .dz-preloader__bar {
    transition: none;
  }
}
