/* Reveal on scroll and the entry animation of the front page.

   Driven by assets/js/reveal.js. The head script (inc/assets.php) adds
   js-reveal to <html> before the first paint, so nothing flashes; it is left
   out for reduced motion, and removed again if the script never reports back
   (data-reveal-ready), so content can never stay hidden.

   Images wipe up from their bottom edge, text and buttons rise and fade in.
   --theme-reveal-delay (set per element by reveal.js) staggers the items that
   enter together. The clip is on the image itself. */

@media (prefers-reduced-motion: no-preference) {
  /* The clip goes on the image, not on the frame: a clipped-away frame would
     count as out of view for the observer and never be revealed. */

  /* The frames keep their subtle tint (.media in base.css), so the places are
     there ahead of the pictures, which wipe in over them. */

  .js-reveal
    :is(.media, .front-intro__image):not(
      .hero-slider *,
      [data-no-reveal],
      [data-reveal-track] *,
      .is-revealed
    )
    img {
    clip-path: inset(100% 0 0 0);
  }

  /* A row that scrolls sideways comes in as one piece, once. */

  .js-reveal [data-reveal-track] {
    transition:
      opacity 1.1s cubic-bezier(0.4, 0, 0.6, 1),
      translate 1.3s cubic-bezier(0.65, 0, 0.25, 1);
  }

  .js-reveal [data-reveal-track]:not(.is-revealed) {
    opacity: 0;
    translate: 0 1.5rem;
  }

  .js-reveal :is(.media, .front-intro__image).is-revealed img {
    animation:
      reveal-wipe 1.5s cubic-bezier(0.65, 0, 0.25, 1) var(--theme-reveal-delay, 0s) backwards,
      reveal-fade 1.1s cubic-bezier(0.4, 0, 0.6, 1) var(--theme-reveal-delay, 0s) backwards;
  }

  /* The theme's signature curve is a hard ease-out (most of the move happens in
     the first fraction of the time), which makes a reveal pop. The wipe uses a
     gentle ease-in-out and the fade runs on its own, slower curve. */

  /* The end is written out: animating to the unset value (clip-path: none) is
     not interpolated, it flips half way, which is what made the pictures pop. */

  @keyframes reveal-wipe {
    from {
      clip-path: inset(100% 0 0 0);
    }

    to {
      clip-path: inset(0 0 0 0);
    }
  }

  @keyframes reveal-fade {
    from {
      opacity: 0;
    }
  }

  .js-reveal
    :is(
      .heading-section,
      .heading-display,
      .heading-large,
      .heading-medium,
      .section__head .link-arrow,
      .project-intro__text,
      .cta__box
    ):not(.hero-slider *, [data-no-reveal], [data-reveal-track] *, .is-revealed) {
    opacity: 0;
    translate: 0 1.75rem;
  }

  .js-reveal
    :is(
      .heading-section,
      .heading-display,
      .heading-large,
      .heading-medium,
      .section__head .link-arrow,
      .project-intro__text,
      .cta__box
    ):not(.hero-slider *, [data-no-reveal], [data-reveal-track] *) {
    transition:
      opacity 1.1s cubic-bezier(0.4, 0, 0.6, 1) var(--theme-reveal-delay, 0s),
      translate 1.4s cubic-bezier(0.22, 0.8, 0.3, 1) var(--theme-reveal-delay, 0s);
  }

  /* The hero's own entry: the headline and the bar rise in once the intro
     (if any) is on its way out, or straight away without one. */

  @keyframes hero-in {
    from {
      opacity: 0;
      translate: 0 2rem;
    }
  }

  .js-reveal:not(.show-intro) :is(.hero-slider__headline, .hero-slider__bar),
  .js-reveal.intro-leaving :is(.hero-slider__headline, .hero-slider__bar) {
    animation: hero-in 1.2s var(--theme-ease-signature) 0.25s backwards;
  }

  .js-reveal:not(.show-intro) .hero-slider__bar,
  .js-reveal.intro-leaving .hero-slider__bar {
    animation-delay: 0.5s;
  }

  /* Intro: a dark screen with the logo, shown on the front page when the
     visitor arrives from outside the site (once per visit). The logo builds up,
     then the screen lifts away. */

  /* Scrolling is held without hiding the scrollbar: its track stays (empty), so
     the page does not shift when it comes back. The extra selector beats
     Lenis's own overflow: clip while it is stopped. */

  html.show-intro,
  html.show-intro.lenis.lenis-stopped {
    overflow: hidden scroll;
  }

  html.show-intro.js-reveal body {
    height: 100svh;
    overflow: hidden;
  }

  .show-intro .intro {
    display: grid;
  }

  /* The logo: the ring appears in white, centred. The wordmark slides out from
     inside it (it is visible inside the ring's disc and beyond its right edge, so
     it travels through the ring, which is drawn over it) while the ring moves left to its place. A copy
     in the logo's colours fades in over the white one, then the buildings rise.
     Distances are in the logo's units (its viewBox is 568 wide): the ring moves
     230 (it starts at the middle), the word travels 570 (its right end starts left of
     the ring's disc, so nothing shows at first). */

  .intro-move {
    animation: intro-move 1s cubic-bezier(0.76, 0, 0.24, 1) 0.5s backwards;
  }

  .intro-word {
    animation: intro-word 1s cubic-bezier(0.76, 0, 0.24, 1) 0.5s backwards;
  }

  .intro-ring {
    animation: intro-fade 0.4s var(--theme-ease-signature) backwards;
  }

  .intro__layer--color {
    animation: intro-fade 0.5s var(--theme-ease-signature) 1.3s backwards;
  }

  @keyframes intro-move {
    from {
      translate: 230px 0;
    }
  }

  @keyframes intro-word {
    from {
      translate: -570px 0;
    }
  }

  @keyframes intro-fade {
    from {
      opacity: 0;
    }
  }

  /* The same logo in the footer waits (its animations are paused at the start)
     until it scrolls into view and reveal.js marks it is-playing. */

  [data-build-logo]:not(.is-playing)
    :is(.intro__layer, .intro-move, .intro-word, .intro-ring, .intro-building, .intro-whole) {
    animation-play-state: paused;
  }

  /* The front (smaller) building and then the back building rise into the ring
     (the ring clips them, so they come up from its bottom edge). */

  .intro-cover {
    fill: var(--theme-color-inverse);
  }

  .intro-building {
    animation: intro-gone 0.01s linear 2.7s forwards;
  }

  /* When both buildings are up, the whole symbol takes over and the pieces go,
     so the cut between them leaves no seam and no edge is drawn twice. */

  .intro-whole {
    animation: intro-whole 0.01s linear 2.7s backwards;
  }

  @keyframes intro-gone {
    to {
      opacity: 0;
    }
  }

  /* The white logo under the copper one goes once the copper has faded in, so
     its edges do not show as a fringe around the copper letters. */

  .intro__layer--white {
    animation: intro-gone 0.01s linear 1.85s forwards;
  }

  @keyframes intro-whole {
    from {
      opacity: 0;
    }
  }

  .intro.is-leaving {
    translate: 0 -100%;
    transition: translate 1.1s cubic-bezier(0.76, 0, 0.24, 1);
  }

  .intro.is-leaving .intro__logo {
    translate: 0 -3rem;
    transition: translate 1.1s cubic-bezier(0.76, 0, 0.24, 1);
  }
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  place-items: center;
  color: var(--theme-color-text-inverse);
  background: var(--theme-color-inverse);
}

.intro__logo {
  position: relative;
  width: clamp(11rem, 24vw, 18rem);
}

.intro__layer {
  display: block;
}

.intro__layer--color {
  position: absolute;
  inset: 0;
}

.intro__layer--white path {
  fill: #fff;
}

.intro__logo .logo {
  display: block;
  width: 100%;
  height: auto;
}
