/* 
  The css for the pokeball sprites is quite long, but fairly simple.
  And the bouncing animation is cute, but again pretty straight-forward with
  some well-timed squash/stretch.

  But I am quite excited and proud of the throw/exit animations on the pokemon
  sprites. There's a few really cool techniques I dreamt up like using a color-dodge
  blend on the sprite over the top of a heavily blurred, hue-rotated and brightened
  animation of the pokemon sprite.

*/
/* pokeballs code */
.ball {
  margin: 1px;
  position: relative;
  bottom: -9px;
}

.ball.flip {
  transform: scaleX(-1);
}

.ball,
.ball .sprite {
  width: 41px;
  height: 41px;
  background-image: url(https://assets.codepen.io/13471/pokeballs.png);
  background-position: 0 0;
  transform-origin: center bottom;
}
.ball:before,
.ball .sprite:before {
  content: "";
  position: absolute;
  left: 30%;
  bottom: 8px;
  width: 40%;
  height: 3px;
  border-radius: 100%;
  background: black;
  box-shadow: 0 1px 2px black;
  opacity: 0.3;
}

.poke.ball, .poke.ball .sprite {
  background-position-x: 0px;
}

.great.ball, .great.ball .sprite {
  background-position-x: -41px;
}

.safari.ball, .safari.ball .sprite {
  background-position-x: -82px;
}

.ultra.ball, .ultra.ball .sprite {
  background-position-x: -123px;
}

.master.ball, .master.ball .sprite {
  background-position-x: -164px;
}

.net.ball, .net.ball .sprite {
  background-position-x: -205px;
}

.dive.ball, .dive.ball .sprite {
  background-position-x: -246px;
}

.nest.ball, .nest.ball .sprite {
  background-position-x: -287px;
}

.repeat.ball, .repeat.ball .sprite {
  background-position-x: -328px;
}

.timer.ball, .timer.ball .sprite {
  background-position-x: -369px;
}

.luxury.ball, .luxury.ball .sprite {
  background-position-x: -410px;
}

.premier.ball, .premier.ball .sprite {
  background-position-x: -451px;
}

.dusk.ball, .dusk.ball .sprite {
  background-position-x: -492px;
}

.heal.ball, .heal.ball .sprite {
  background-position-x: -533px;
}

.quick.ball, .quick.ball .sprite {
  background-position-x: -574px;
}

.cherish.ball, .cherish.ball .sprite {
  background-position-x: -615px;
}

.fast.ball, .fast.ball .sprite {
  background-position-x: -656px;
}

.level.ball, .level.ball .sprite {
  background-position-x: -697px;
}

.lure.ball, .lure.ball .sprite {
  background-position-x: -738px;
}

.heavy.ball, .heavy.ball .sprite {
  background-position-x: -779px;
}

.love.ball, .love.ball .sprite {
  background-position-x: -820px;
}

.friend.ball, .friend.ball .sprite {
  background-position-x: -861px;
}

.moon.ball, .moon.ball .sprite {
  background-position-x: -902px;
}

.sport.ball, .sport.ball .sprite {
  background-position-x: -943px;
}

.park.ball, .park.ball .sprite {
  background-position-x: -984px;
}

.dream.ball, .dream.ball .sprite {
  background-position-x: -1025px;
}

.beast.ball, .beast.ball .sprite {
  background-position-x: -1066px;
}

.ball.open {
  background-position-y: -401.5px;
}

.ball.side {
  background-position-y: -361.5px;
}

.ball.roll {
  animation: ball-roll 1s steps(1) infinite;
}

.ball.rock {
  animation: ball-rock 1.22s steps(1) infinite;
}

.ball.bounce {
  animation-name: bounce;
}
.ball.bounce:before {
  animation-name: bounce-shadow;
}
.ball.bounce, .ball.bounce:before {
  animation-duration: 1s;
  animation-iteration-count: infinite;
}

@keyframes ball-roll {
  0% {
    background-position-y: 0;
  }
  12.5% {
    background-position-y: -40px;
  }
  25% {
    background-position-y: -80px;
  }
  37.5% {
    background-position-y: -120px;
  }
  50% {
    background-position-y: -160px;
  }
  62.5% {
    background-position-y: -200px;
  }
  75% {
    background-position-y: -240px;
  }
  87.5% {
    background-position-y: -280px;
  }
  100% {
    background-position-y: -320px;
  }
}
@keyframes ball-rock {
  0% {
    background-position-y: 0;
  }
  8.33% {
    background-position-y: -440px;
  }
  16.66% {
    background-position-y: -480px;
  }
  25% {
    background-position-y: -520px;
  }
  33.33% {
    background-position-y: -480px;
  }
  41.66% {
    background-position-y: -440px;
  }
  50% {
    background-position-y: 0px;
  }
  58.33% {
    background-position-y: -560px;
  }
  66.66% {
    background-position-y: -600px;
  }
  75% {
    background-position-y: -640px;
  }
  83.33% {
    background-position-y: -600px;
  }
  91.66% {
    background-position-y: -560px;
  }
  100% {
    background-position-y: 0px;
  }
}
@keyframes bounce {
  0%, 100% {
    transform: translateY(0) scaleY(0.75) scaleX(1.15);
    animation-timing-function: ease-in;
  }
  10% {
    transform: translateY(-10%) scaleY(1) scaleX(1);
    animation-timing-function: ease-out;
  }
  50% {
    transform: translateY(-80%) scaleY(1.1) scaleX(0.95);
    animation-timing-function: ease-in;
  }
  90% {
    transform: translateY(-10%) scaleY(1) scaleX(1);
    animation-timing-function: ease-out;
  }
}
@keyframes bounce-shadow {
  0%, 100% {
    opacity: 0.4;
    transform: translateY(0) scaleY(1) scaleX(1);
  }
  10%, 90% {
    opacity: 0;
    transform: translateY(200%) scaleY(0.3) scaleX(0.3);
  }
}
/* pokemon throw/exit animation code */
:root {
  --poke1: url("https://img.pokemondb.net/sprites/black-white/anim/normal/eevee.gif");
  --poke2: url("https://img.pokemondb.net/sprites/black-white/anim/normal/pikachu.gif");
}

.pkmn {
  width: 160px;
  height: 140px;
  margin: 2px;
  position: relative;
}

.pkmn .mon {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.pkmn .mon:before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: center bottom;
  transform-origin: center 125px;
  background-image: var(--poke1);
}

.pkmn:nth-child(2) .mon:before {
  background-image: var(--poke2);
}

.pkmn .ball {
  position: absolute;
  left: 10%;
  bottom: -3px;
  top: auto;
  z-index: 1;
}

.pkmn .explode {
  will-change: opacity;
  overflow: hidden;
  z-index: 3;
}

.pkmn.exit .mon:before {
  animation-delay: 1.5s;
  animation-duration: 0.75s;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
  animation-iteration-count: 1;
  animation-direction: forwards;
}

.pkmn.exit .mon:before {
  animation-name: mon-poof;
}

.pkmn.exit:nth-child(2) .mon:before {
  animation-name: mon-poof-2;
}

.pkmn.left .mon {
  transform: scaleX(-1);
}

.pkmn.right .mon {
  transform: scaleX(1);
}

.pkmn.right .ball {
  transform: scaleX(-1);
  left: 63%;
}

@keyframes mon-poof {
  0% {
    opacity: 0;
    transform: scale(3);
    filter: blur(9px) contrast(0.25) brightness(0.65) sepia(1) saturate(3) hue-rotate(-90deg) contrast(2.2) brightness(5) blur(9px);
  }
  30% {
    opacity: 1;
  }
  75% {
    transform: scale(1);
    filter: blur(2px) contrast(0.25) brightness(0.65) sepia(1) saturate(4) hue-rotate(-90deg) contrast(2) brightness(4) blur(2px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0px) contrast(1) brightness(1) sepia(0) saturate(1) hue-rotate(0deg) contrast(1) brightness(1) blur(0px);
  }
}
@keyframes mon-poof-2 {
  0% {
    opacity: 0;
    transform: scale(3);
    filter: blur(9px) contrast(0.3) brightness(0.7) sepia(1) saturate(4) hue-rotate(140deg) contrast(2.2) brightness(6) blur(9px);
  }
  30% {
    opacity: 1;
  }
  75% {
    transform: scale(1);
    filter: blur(2px) contrast(0.1) brightness(0.66) sepia(1) saturate(1) hue-rotate(140deg) contrast(2.2) brightness(6) blur(2px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0px) contrast(1) brightness(1) sepia(0) saturate(1) hue-rotate(0deg) contrast(1) brightness(1) blur(0px);
  }
}
/* ball throwing / bouncing / opening code */
.ball.throw,
.pkmn.exit .ball {
  animation-duration: 5s;
  animation-iteration-count: 1;
  animation-fill-mode: both;
  animation-name: throw;
  background: none;
}

.ball.throw:before,
.pkmn.exit .ball:before {
  display: none;
}

.ball.throw *,
.pkmn.exit .ball *,
.ball.throw .sprite:before,
.pkmn.exit .ball .sprite:before {
  animation-duration: 1s;
  animation-iteration-count: 1;
  animation-fill-mode: both;
}

.ball.throw *,
.pkmn.exit .ball * {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.ball.throw .x,
.pkmn.exit .ball .x {
  animation-name: throw-x;
}

.ball.throw .y,
.pkmn.exit .ball .y {
  animation-name: throw-y;
}

.ball.throw .sprite,
.pkmn.exit .ball .sprite {
  animation-duration: 2.5s;
  animation-name: throw-sprite;
  animation-timing-function: steps(1);
}

.ball.throw .sprite:before,
.pkmn.exit .ball .sprite:before {
  animation-name: throw-shadow;
}

@keyframes throw {
  0%, 100% {
    opacity: 0;
    animation-timing-function: ease-out;
  }
  20%, 90% {
    opacity: 1;
  }
}
@keyframes throw-x {
  0% {
    transform: translateX(-240%);
    animation-timing-function: ease-out;
  }
  50% {
    transform: translateX(-45%);
  }
  100% {
    transform: translateX(0%);
  }
}
@keyframes throw-y {
  0% {
    transform: translateY(-140%) scaleY(1.05) scaleX(0.95);
    animation-timing-function: ease-in;
  }
  50% {
    transform: translateY(-6%) scaleY(0.95) scaleX(1.1);
    animation-timing-function: ease-out;
  }
  75% {
    transform: translateY(-50%) scaleY(1.05) scaleX(0.95);
    animation-timing-function: ease-in;
  }
  100% {
    transform: translateY(0%) scaleY(1) scaleX(1);
  }
}
@keyframes throw-sprite {
  0% {
    background-position-y: -40px;
  }
  3% {
    background-position-y: -80px;
  }
  6% {
    background-position-y: -120px;
  }
  9% {
    background-position-y: -160px;
  }
  12% {
    background-position-y: -200px;
  }
  18% {
    background-position-y: -240px;
  }
  23% {
    background-position-y: -320px;
  }
  28% {
    background-position-y: -360px;
  }
  35%, 90% {
    background-position-y: -400px;
  }
  95% {
    background-position-y: -320px;
  }
  100% {
    background-position-y: -360px;
  }
}
@keyframes throw-shadow {
  0% {
    opacity: 0;
    transform: translateY(1px) scaleY(1) scaleX(1);
    animation-timing-function: ease;
  }
  35%, 65%, 95% {
    opacity: 0;
    transform: translateY(200%) scaleY(0.3) scaleX(0.3);
  }
  52% {
    opacity: 0.3;
    transform: translateY(1px) scaleY(1) scaleX(1);
  }
  100% {
    opacity: 0.3;
    transform: translateY(1px) scaleY(1) scaleX(1);
  }
}
/* pokemon exiting animation code */
.explode {
  width: 240px;
  height: 240px;
  position: absolute;
  left: 50%;
  top: 87%;
  transform: translate(-50%, -50%);
  mix-blend-mode: color-dodge;
  will-change: opacity, filter;
  opacity: 0;
}

.explode:before {
  content: "";
  background-image: url("https://assets.codepen.io/13471/jimena-cuenca-changeworld-sprite.jpg");
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  will-change: opacity;
}

.exit .explode,
.exit .explode:before {
  animation-delay: 1.2s;
  animation-duration: 0.66s;
  animation-iteration-count: 1;
}

.pkmn.exit .explode {
  animation-name: explode-filters;
  animation-timing-function: linear;
  opacity: 0;
}

.pkmn.exit:nth-child(2) .explode {
  animation-name: explode-filters-2;
}

.exit .explode:before {
  animation-name: explode;
  animation-timing-function: steps(1);
}

.pkmn.exit .mon:before {
  animation-delay: 1.33s;
  animation-duration: var(--slowmo, 1s);
}

.pkmn.exit .explode,
.pkmn.exit .explode:before {
  animation-delay: 1s;
  animation-duration: var(--slowsplode, 0.75s);
}

.pkmn.exit .ball,
.pkmn.exit .ball *,
.pkmn.exit .ball .sprite:before {
  animation-delay: 0s;
}

@keyframes explode {
  0% {
    background-position: 0 0;
  }
  5% {
    background-position: -240px 0;
  }
  10% {
    background-position: -480px 0;
  }
  15% {
    background-position: -720px 0;
  }
  20% {
    background-position: -960px 0;
  }
  25% {
    background-position: -1200px 0;
  }
  30% {
    background-position: -1440px 0;
  }
  35% {
    background-position: -1680px 0;
  }
  40% {
    background-position: -240px -240px;
  }
  45% {
    background-position: -480px -240px;
  }
  50% {
    background-position: -720px -240px;
  }
  55% {
    background-position: -960px -240px;
  }
  60% {
    background-position: -1200px -240px;
  }
  65% {
    background-position: -1440px -240px;
  }
  70% {
    background-position: -240px -480px;
  }
  75% {
    background-position: -240px -480px;
  }
  80% {
    background-position: -480px -480px;
  }
  85% {
    background-position: -720px -480px;
  }
  90% {
    background-position: -960px -480px;
  }
  95% {
    background-position: -1200px -480px;
  }
  100% {
    background-position: -1440px -480px;
  }
}
@keyframes explode-filters {
  0% {
    filter: blur(0px) brightness(1) contrast(1) sepia(0.75) saturate(1) hue-rotate(270deg);
    opacity: 1;
  }
  40% {
    filter: blur(0px) brightness(1) contrast(1) sepia(0.75) saturate(1) hue-rotate(270deg);
  }
  50% {
    opacity: 1;
    filter: blur(2px) brightness(1) contrast(1) sepia(1) saturate(2) hue-rotate(270deg);
  }
  75% {
    opacity: 1;
  }
  100% {
    filter: blur(12px) brightness(0.5) contrast(1) sepia(1) saturate(0) hue-rotate(270deg);
    opacity: 0;
  }
}
@keyframes explode-filters-2 {
  0% {
    filter: blur(0px) brightness(1) contrast(1) sepia(0.75) saturate(1) hue-rotate(190deg);
    opacity: 1;
  }
  40% {
    filter: blur(0px) brightness(1) contrast(1) sepia(0.75) saturate(1) hue-rotate(190deg);
  }
  50% {
    opacity: 1;
    filter: blur(2px) brightness(1) contrast(1) sepia(1) saturate(2) hue-rotate(190deg);
  }
  75% {
    opacity: 1;
  }
  100% {
    filter: blur(12px) brightness(0.5) contrast(1) sepia(1) saturate(0) hue-rotate(190deg);
    opacity: 0;
  }
}
/* ui code, unrelated */
#app {
  padding: 20px;
  text-shadow: 0 0.15em 0 rgba(0, 0, 0, 0.6666666667);
  color: white;
  text-align: center;
  font-size: 14px;
  margin: 0;
  padding: 0;
  margin-top: 25px;
  margin-bottom: 30px;
}

.pokemon {
  display: flex;
  margin-bottom: 60px;
  margin-top: -40px;
  justify-content: center;
}

.pkmn {
  cursor: pointer;
}

.balls {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  max-width: 800px;
  margin: auto;
  margin-top: 30px;
  justify-items: center;
}

.balls:nth-of-type(1) .ball:nth-of-type(1) {
  grid-column: 7;
}

.balls:nth-of-type(2) .ball:nth-last-child(6) {
  grid-column: 13;
}

a {
  color: #00c0ff;
}

label {
  font-size: 12px;
  position: fixed;
  top: 15px;
  left: 15px;
}

/* p:last-child {
  margin-top: 50px;
  line-height: 1.4;
} */

@font-face {
  font-family: "pkmn";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("https://assets.codepen.io/13471/Pokemon-DPPt.woff2") format("woff2"), url("https://assets.codepen.io/13471/pokemon-DPPt.woff") format("woff");
}

/* @media (max-width) {
  #app h1 {
    font-size: 10px;
  }
} */