:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  background-color: #10251a;
  --content-color: #d2ff7b;
  --scene-height: 100vh;
  --scroll-distance: 145vh;
}

@supports (height: 100lvh) {
  :root {
    /* Keep the artwork still while the phone browser's toolbar slides. */
    --scene-height: 100lvh;
    --scroll-distance: 145svh;
  }
}

@supports (height: round(145svh, 1px)) {
  :root {
    /* Match the browser's integer scroll range at the end of the scene. */
    --scroll-distance: round(145svh, 1px);
  }
}

body {
  margin: 0;
}

.page {
  margin-inline: auto;
}

@media (min-width: 600px), (orientation: landscape) {
  .page {
    max-width: calc(var(--scene-height) * 0.5625);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.scene {
  position: sticky;
  top: 0;
  isolation: isolate;
  height: var(--scene-height);
  overflow: hidden;
}

.scene::after {
  --fade-mask: linear-gradient(to bottom,
    transparent,
    rgb(0 0 0 / 3%) 20%,
    rgb(0 0 0 / 7%) 27%,
    rgb(0 0 0 / 14%) 34%,
    rgb(0 0 0 / 23%) 41%,
    rgb(0 0 0 / 36%) 48%,
    rgb(0 0 0 / 51%) 55%,
    rgb(0 0 0 / 67%) 62%,
    rgb(0 0 0 / 80%) 69%,
    rgb(0 0 0 / 90%) 76%,
    rgb(0 0 0 / 96%) 83%,
    rgb(0 0 0 / 99%) 93%,
    black 98%);
  position: absolute;
  inset: auto 0 0;
  height: 30%;
  background: var(--content-color);
  -webkit-mask-image: var(--fade-mask);
  mask-image: var(--fade-mask);
  content: '';
  pointer-events: none;
}

/* The supplied images share a single 1080 × 1920 coordinate space. */
.artwork {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, calc(var(--scene-height) * 0.5625));
  aspect-ratio: 9 / 16;
  transform: translate(-50%, -50%);
}

.layer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.upper-leaves {
  transform: translateY(-56%);
}

.left-leaves {
  transform: translateX(-69%);
}

.right-leaves {
  transform: translateX(68%);
}

.content,
.footer {
  color-scheme: light;
  color: #10251a;
  background: var(--content-color);
}

.content {
  aspect-ratio: 1080 / 988;
}

.footer {
  position: relative;
}

.footer-art {
  display: block;
  width: 100%;
  height: auto;
}

.loading-screen {
  display: none;
}

@property --light-spread {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

@media (prefers-reduced-motion: no-preference) {
  .loading-screen {
    position: fixed;
    inset: 0;
    z-index: 1;
    display: block;
    overflow: hidden;
    background: #10251a;
    color: #fff;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 980ms ease-in-out, visibility 0s linear 980ms;
  }

  .is-loading .loading-screen {
    opacity: 1;
    visibility: visible;
    transition: none;
  }

  .is-landed .loading-screen {
    --tint: leaf-tint 1250ms ease-in-out both;
    animation: var(--tint);
  }

  .is-expanding .loading-screen {
    animation: var(--tint), forest-reveal 980ms ease-in-out 850ms forwards;
  }

  .loading-drift {
    position: absolute;
    inset: 0;
  }

  .loading-light {
    --halo-radius: clamp(105px, 31vw, 155px);
    --light-spread: 0px;
    /* Move the stops of a single gradient outward as the light expands. */
    --halo-mask: radial-gradient(circle,
      #000 calc(var(--light-spread) + 5px),
      rgb(0 0 0 / 96%) calc(var(--light-spread) + 9px),
      rgb(0 0 0 / 59%) calc(var(--light-spread) + var(--halo-radius) * 0.19),
      rgb(0 0 0 / 29%) calc(var(--light-spread) + var(--halo-radius) * 0.39),
      rgb(0 0 0 / 11%) calc(var(--light-spread) + var(--halo-radius) * 0.63),
      transparent calc(var(--light-spread) + var(--halo-radius)));
    position: absolute;
    inset: -5%;
    background: currentColor;
    -webkit-mask-image: var(--halo-mask);
    mask-image: var(--halo-mask);
    transform: scale(0.95);
  }

  .is-loading .loading-drift {
    --drift-time: 3650ms;
    animation:
      feather-fall var(--drift-time) cubic-bezier(0.36, 0.18, 0.3, 1) both,
      feather-sway var(--drift-time) ease-in-out both;
  }

  .is-loading .loading-light {
    --breath: breathe 2800ms ease-in-out infinite;
    animation: var(--breath);
  }

  .is-expanding .loading-light {
    animation: var(--breath), expand-light 1200ms cubic-bezier(0.46, 0, 0.27, 1) both;
  }

  .waiting-image {
    visibility: hidden;
  }

  .arriving-image {
    animation: image-arrival 650ms ease-out;
  }

  .has-motion .journey {
    min-height: calc(var(--scene-height) + var(--scroll-distance));
  }

  .has-motion .character {
    transform: translateY(var(--character-y, 3.4%));
  }

  .has-motion .logo {
    opacity: var(--logo-opacity, 0);
    transform: translateY(var(--logo-y, 44%));
  }

  .lower-leaves {
    transform-origin: center bottom;
    --breeze: breeze 13s ease-in-out infinite;
    animation: var(--breeze);
  }

  .lower-leaves.arriving-image {
    animation: var(--breeze), image-arrival 650ms ease-out;
  }

  .has-motion .upper-leaves {
    transform: translateY(var(--upper-y, 0%));
  }

  .has-motion .left-leaves {
    transform: translateX(var(--left-x, 0%));
  }

  .has-motion .right-leaves {
    transform: translateX(var(--right-x, 0%));
  }
}

@keyframes breathe {
  50% { transform: scale(1.06); }
}

@keyframes feather-fall {
  from { transform: translateY(-52vh); }
  to { transform: translateY(0); }
}

@keyframes feather-sway {
  0% { translate: calc(-10vw * var(--drift-bias)) 0; }
  24% { translate: calc(15vw * var(--drift-bias)) 0; }
  51% { translate: calc(-13vw * var(--drift-bias)) 0; }
  76% { translate: calc(7vw * var(--drift-bias)) 0; }
  100% { translate: 0 0; }
}

@keyframes leaf-tint {
  from { color: #fff; }
  to { color: var(--content-color); }
}

@keyframes expand-light {
  to { --light-spread: 80vmax; }
}

@keyframes forest-reveal {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes image-arrival {
  from { opacity: 0; }
}

@keyframes breeze {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  27% { transform: scale(1.013, 1.008) skewX(-0.32deg); }
  52% { transform: scale(1.002, 1.003) skewX(0.05deg); }
  76% { transform: scale(1.011, 1.006) skewX(0.27deg); }
}
