/* Wildhoney Games teaser. One screen, never scrolls.
   Without script the page shows its settled state; html.anim is the opening state. */

:root {
  --cream: #fcf7f1;
  --honey: #f9d9a4;
  --night: #120702;
  /* One unit is one pixel of the supplied logo. The lockup is 1223 wide and 723 tall. */
  --u: min(86vw / 1223, 50vh / 723, 1px);
  color-scheme: light;
}

@supports (height: 1dvh) {
  :root {
    --u: min(86vw / 1223, 50dvh / 723, 1px);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--cream);
}

html.anim,
html.anim body {
  background: var(--night);
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(to bottom, var(--cream) 45%, var(--honey) 100%);
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html.anim .stage {
  background: var(--night);
}

/* No WebGL: the ground itself turns from night to morning. */
html.anim.no-gl .stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--cream) 45%, var(--honey) 100%);
  opacity: 0;
  transition: opacity 3.6s ease-in-out;
}

html.anim.no-gl.dawn .stage::before {
  opacity: 1;
}

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

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

.lockup {
  position: relative;
  margin: 0;
  width: calc(1223 * var(--u));
  height: calc(723 * var(--u));
  transform: translate3d(var(--shift-x, 0px), calc(-5vh + var(--shift-y, 0px)), 0);
  font-size: 0;
}

.flower {
  position: absolute;
  top: 0;
  left: calc(420.4 * var(--u));
  width: calc(414 * var(--u));
  height: calc(414 * var(--u));
  display: block;
}

.flower-turn,
.flower-pulse {
  position: absolute;
  inset: 0;
  display: block;
}

.whole,
.petal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.petal {
  background: url('assets/flower.webp') center / 100% 100% no-repeat;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

.word {
  position: absolute;
  left: 0;
  top: calc(358 * var(--u));
  width: 100%;
  /* Taller than the wordmark, so the soft lower edge sits below it once it has risen. */
  height: calc(365 * var(--u) * 1.3);
  display: block;
}

.word img {
  width: 100%;
  height: auto;
  display: block;
}

/* Opening state */

html.anim .whole {
  opacity: 0;
}

html.anim .petal {
  opacity: 0;
  transform: scale(0.02) rotate(-70deg);
}

html.anim .bloom .petal {
  animation: petal 1.5s cubic-bezier(0.22, 1.32, 0.36, 1) both;
  animation-delay: calc(var(--i) * 0.17s);
}

html.anim .settled .whole {
  opacity: 1;
}

html.anim .settled .petal {
  display: none;
}

/* Once risen, the wordmark is whole: no soft lower edge left on the tail of the y. */
html.anim .settled .word {
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}

html.anim .word {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 0 74%, transparent 96%);
  mask-image: linear-gradient(to bottom, #000 0 74%, transparent 96%);
}

html.anim .word img {
  transform: translate3d(0, 104%, 0);
  opacity: 0;
}

html.anim .rise .word img {
  animation: rise 2.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

html.anim .settled .flower-turn {
  animation: breathe 9s ease-in-out infinite;
}

@keyframes petal {
  from {
    opacity: 0;
    transform: scale(0.02) rotate(-70deg);
  }
  18% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translate3d(0, 104%, 0);
  }
  35% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(1.6deg) scale(1.022);
  }
  75% {
    transform: rotate(-1.6deg) scale(1.022);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* 404: the flower alone, leading home. */
.lost {
  display: block;
  width: min(40vw, 30vh, 220px);
}

.lost img {
  width: 100%;
  height: auto;
  display: block;
}
