/*
  OGL leap: a tiny astronaut carrying an OGL flag leaps across a button on hover.
  Drop-in layer for the existing site buttons. It does not restyle the button:
  it adds one layer *inside* it, under the label, so the button's own fill,
  rim, glow, shine sweep and border animation all keep running.

  Use: add data-leap to a button (or to a wrapper around the hero CTA) and load
  ogl-leap.js. Optional: data-leap-speed="2s".

  Trigger: ogl-leap.js adds .ogl-leap-on while the mouse is over the button, while
  it has keyboard focus, or on phones while a finger is resting on it (it stays
  on until the next touch elsewhere, like a sticky hover). A quick tap still
  just follows the link.
*/

.ogl-leap-host {
  position: relative;
  isolation: isolate;
  --leap-speed: 1.6s;
  --leap-delay: .25s;
}

/* The whole scene. z-index -1 inside the isolated host = above the button's
   own background, below its label text and arrow. */
.ogl-leap {
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

/* Arrow steps aside so the astronaut can land where it was */
.ogl-leap-host > svg { transition: opacity .25s ease, transform .25s ease; }
.ogl-leap-host.ogl-leap-on > svg{ opacity: 0; transform: translateX(8px); }

/* On touch screens, holding the button shows the leap instead of the
   long-press link menu or text selection. */
@media (hover: none) {
  .ogl-leap-press { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

/* Night sky in deep versions of the brand hues */
.ogl-leap__sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(88.3deg, #0d1a4a 0%, #221a5c 30%, #3a1850 60%, #45202f 100%);
  opacity: 0;
  transition: opacity .45s ease;
}
.ogl-leap-host.ogl-leap-on .ogl-leap__sky{ opacity: 1; }

.ogl-leap__stars {
  position: absolute;
  top: 0; left: 0;
  width: 1.5px; height: 1.5px;
  border-radius: 50%;
}
.ogl-leap__stars--a {
  box-shadow: 18px 9px #fff, 52px 20px #fff, 88px 6px #fff, 120px 16px #fff, 150px 8px #fff,
              176px 22px #fff, 200px 11px #fff, 36px 30px #fff, 108px 34px #fff, 164px 36px #fff;
  animation: ogl-leap-twinkle 1.8s ease-in-out infinite alternate;
}
.ogl-leap__stars--b {
  box-shadow: 30px 15px #cde8ff, 70px 10px #ffd6f0, 96px 26px #b7c7ff, 136px 4px #ffe1c2,
              190px 30px #cde8ff, 8px 24px #ffd6f0, 218px 14px #fff, 240px 24px #ffd6f0;
  animation: ogl-leap-twinkle 2.6s ease-in-out .8s infinite alternate;
}
@keyframes ogl-leap-twinkle { from { opacity: .25; } to { opacity: 1; } }

/* Moon surface rises from the bottom edge */
.ogl-leap__moon {
  position: absolute;
  left: -15%;
  bottom: -24px;
  width: 130%;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 20%, #f6f3fc 0%, #ded7f2 60%, #c8bfe6 100%);
  transform: translateY(100%);
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}
.ogl-leap-host.ogl-leap-on .ogl-leap__moon{ transform: translateY(0); }
.ogl-leap__moon i {
  position: absolute;
  top: 4px;
  width: 9px; height: 3px;
  border-radius: 50%;
  background: rgba(120, 105, 170, .35);
}
.ogl-leap__moon i:nth-child(1) { left: 30%; }
.ogl-leap__moon i:nth-child(2) { left: 52%; top: 6px; width: 6px; }
.ogl-leap__moon i:nth-child(3) { left: 68%; top: 3px; width: 11px; }

/* Astronaut: outer moves across, inner does the arc */
.ogl-leap__astro {
  position: absolute;
  left: 10px;
  bottom: 5px;
  width: 26px;
  height: 26px;
  opacity: 0;
  transition: opacity .2s ease;
}
.ogl-leap__astro-y { display: block; width: 100%; height: 100%; }
.ogl-leap__astro svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, .35));
}
.ogl-leap-host.ogl-leap-on .ogl-leap__astro{
  opacity: 1;
  animation: ogl-leap-x var(--leap-speed) linear var(--leap-delay) both;
}
.ogl-leap-host.ogl-leap-on .ogl-leap__astro-y{
  animation: ogl-leap-y var(--leap-speed) var(--leap-delay) both;
}
@keyframes ogl-leap-x {
  from { left: 10px; }
  to   { left: calc(100% - 42px); }
}
@keyframes ogl-leap-y {
  0%   { transform: translateY(0) rotate(-6deg) scaleY(.9); animation-timing-function: cubic-bezier(.3, .7, .6, 1); }
  50%  { transform: translateY(-14px) rotate(8deg) scaleY(1); animation-timing-function: cubic-bezier(.4, 0, .7, .3); }
  92%  { transform: translateY(0) rotate(0) scaleY(.88); }
  100% { transform: translateY(0) rotate(0) scaleY(1); }
}

/* The OGL flag he carries ripples the whole time, and waves harder once he lands */
.ogl-leap__cloth {
  transform-box: fill-box;
  transform-origin: 0% 50%;
  animation: ogl-leap-ripple .5s ease-in-out infinite alternate;
}
.ogl-leap-host.ogl-leap-on .ogl-leap__flag{
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: ogl-leap-wave .45s ease-in-out calc(var(--leap-delay) + var(--leap-speed)) 4 alternate;
}
@keyframes ogl-leap-ripple {
  from { transform: skewY(-4deg) scaleX(1); }
  to   { transform: skewY(4deg) scaleX(.94); }
}
@keyframes ogl-leap-wave {
  from { transform: rotate(-10deg); }
  to   { transform: rotate(12deg); }
}

/* Footprint left at take-off */
.ogl-leap__print {
  position: absolute;
  left: 15px;
  bottom: 4px;
  width: 9px; height: 3px;
  border-radius: 50%;
  background: rgba(90, 75, 150, .45);
  opacity: 0;
}
.ogl-leap-host.ogl-leap-on .ogl-leap__print{
  animation: ogl-leap-fade .3s ease calc(var(--leap-delay) + var(--leap-speed) * .1) both;
}
@keyframes ogl-leap-fade { from { opacity: 0; } to { opacity: 1; } }

/* Moon dust puff on landing */
.ogl-leap__dust {
  position: absolute;
  right: 22px;
  bottom: 5px;
  width: 20px;
  height: 8px;
}
.ogl-leap__dust i {
  position: absolute;
  bottom: 0;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #eee9f8;
  opacity: 0;
}
.ogl-leap__dust i:nth-child(1) { left: 0;    --dx: -9px; }
.ogl-leap__dust i:nth-child(2) { left: 7px;  --dx: 0px; }
.ogl-leap__dust i:nth-child(3) { left: 14px; --dx: 9px; }
.ogl-leap-host.ogl-leap-on .ogl-leap__dust i{
  animation: ogl-leap-puff .6s ease-out calc(var(--leap-delay) + var(--leap-speed) * .92) both;
}
@keyframes ogl-leap-puff {
  0%   { opacity: .9; transform: translate(0, 0) scale(.4); }
  100% { opacity: 0;  transform: translate(var(--dx), -7px) scale(1.4); }
}

/* People who turn off motion see him standing on the moon with his flag */
@media (prefers-reduced-motion: reduce) {
  .ogl-leap-host.ogl-leap-on .ogl-leap__astro{ animation: none; left: calc(100% - 42px); }
  .ogl-leap-host.ogl-leap-on .ogl-leap__astro-y,
  .ogl-leap-host.ogl-leap-on .ogl-leap__flag,
  .ogl-leap-host.ogl-leap-on .ogl-leap__dust i,
  .ogl-leap__cloth,
  .ogl-leap__stars { animation: none; }
  .ogl-leap-host.ogl-leap-on .ogl-leap__print { animation: none; opacity: 1; }
}
