/* Animated Moon/Sun Theme Toggle Button */

.theme-toggle-wrapper {
  position: relative;
  display: inline-block;
}

#theme-toggle-checkbox {
  opacity: 0;
  height: 0;
  width: 0;
  position: absolute;
}

.theme-toggle {
  position: relative;
  cursor: pointer;
  display: inline-block;
  width: 55px;
  height: 28px;
  background: #211042;
  border-radius: 50px;
  transition: background 500ms;
  overflow: hidden;
  will-change: background;
  margin-top: 5px;
}

/* Prevent transition flash on initial page load */
.theme-toggle.no-transition,
.theme-toggle.no-transition .toggle-button,
.theme-toggle.no-transition .crater,
.theme-toggle.no-transition .star {
  transition: none !important;
}

.toggle-button {
  position: absolute;
  display: inline-block;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FAEAF1;
  overflow: hidden;
  box-shadow: 0 0 10px 1.5px rgba(255, 255, 255, 0.8);
  transition: all 500ms ease-out;
  will-change: transform, background, box-shadow;
}

.crater {
  position: absolute;
  display: inline-block;
  background: #FAEAF1;
  border-radius: 50%;
  transition: 500ms;
}

.crater-1 {
  background: #FFFFF9;
  width: 24px;
  height: 24px;
  left: 3px;
  bottom: 3px;
}

.crater-2 {
  width: 5.5px;
  height: 5.5px;
  top: -2px;
  left: 12px;
}

.crater-3 {
  width: 4px;
  height: 4px;
  top: 6px;
  right: -1px;
}

.crater-4 {
  width: 3px;
  height: 3px;
  top: 7px;
  left: 8.5px;
}

.crater-5 {
  width: 4px;
  height: 4px;
  top: 11px;
  left: 13.5px;
}

.crater-6 {
  width: 3px;
  height: 3px;
  top: 13.5px;
  left: 5.5px;
}

.crater-7 {
  width: 3.5px;
  height: 3.5px;
  bottom: 1.5px;
  left: 10px;
}

.star {
  position: absolute;
  display: inline-block;
  border-radius: 50%;
  background: #FFF;
  box-shadow: 0.5px 0 1px 1px rgba(255, 255, 255, 0.8);
  transition: all 500ms ease-out;
}

.star-1 {
  width: 2px;
  height: 2px;
  right: 25px;
  bottom: 11px;
}

.star-2 {
  width: 2.5px;
  height: 2.5px;
  right: 19px;
  top: 3px;
}

.star-3 {
  width: 1.5px;
  height: 1.5px;
  right: 16.5px;
  bottom: 4px;
}

.star-4 {
  width: 1px;
  height: 1px;
  right: 11px;
  bottom: 14px;
}

.star-5 {
  width: 1.5px;
  height: 1.5px;
  right: 3px;
  bottom: 10px;
}

.star-6, .star-7, .star-8 {
  width: 3px;
  height: 0.7px;
  border-radius: 1px;
  transform: rotate(-45deg);
  box-shadow: 1.5px 0px 1.5px 0.3px #FFF;
  animation-name: travel;
  animation-duration: 1.8s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  animation-iteration-count: infinite;
}

.star-6 {
  right: 8px;
  bottom: 8px;
  animation-delay: -2s;
}

.star-7 {
  right: 14px;
  bottom: 17px;
}

.star-8 {
  right: 25px;
  top: 3px;
  animation-delay: -4s;
}

@keyframes travel {
  0% {
    transform: rotate(-45deg) translateX(20px) scale(1);
  }

  50% {
    transform: rotate(-45deg) translateX(-5.5px) scale(1);
    box-shadow: 1.5px 0px 2px 0.3px #FFF;
  }

  100% {
    transform: rotate(-45deg) translateX(-8px) scale(0.23);
    opacity: 0;
    box-shadow: none;
  }
}

/* Checked state - Light mode (Sun) */
#theme-toggle-checkbox:checked + .theme-toggle {
  background: #24D7F7;
  transition: background 500ms;
}

#theme-toggle-checkbox:checked + .theme-toggle .toggle-button {
  background: #F7FFFF;
  transform: translateX(27px);
  box-shadow: 0 0 10px 1.5px rgba(255, 255, 255, 0.9);
  transition: all 500ms ease-out;
}

#theme-toggle-checkbox:checked + .theme-toggle .toggle-button .crater {
  transform: rotate(-45deg) translateX(20px);
  transition: transform 500ms;
}

#theme-toggle-checkbox:checked + .theme-toggle .star {
  animation: move 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  transform: none;
  box-shadow: none;
}

#theme-toggle-checkbox:checked + .theme-toggle .star-1 {
  width: 11px;
  height: 2.7px;
  border-radius: 2.7px;
  background: #FFF;
  left: 5.5px;
  top: 7px;
  box-shadow: none;
}

#theme-toggle-checkbox:checked + .theme-toggle .star-2 {
  width: 3.5px;
  height: 3.5px;
  background: #FFF;
  left: 7px;
  top: 6.3px;
  box-shadow: -0.3px 0 0.7px 0 rgba(0, 0, 0, 0.1);
}

#theme-toggle-checkbox:checked + .theme-toggle .star-3 {
  width: 4px;
  height: 4px;
  background: #FFF;
  left: 9.7px;
  top: 4.9px;
  box-shadow: -0.3px 0 0.7px 0 rgba(0, 0, 0, 0.1);
}

#theme-toggle-checkbox:checked + .theme-toggle .star-4 {
  width: 3.8px;
  height: 3.8px;
  background: #FFF;
  left: 12.5px;
  top: 5.6px;
  box-shadow: -0.3px 0 0.7px 0 rgba(0, 0, 0, 0.1);
}

#theme-toggle-checkbox:checked + .theme-toggle .star-5 {
  width: 16.5px;
  height: 4px;
  border-radius: 4px;
  background: #FFF;
  left: 8.3px;
  bottom: 5.6px;
  box-shadow: none;
}

#theme-toggle-checkbox:checked + .theme-toggle .star-6 {
  width: 4.8px;
  height: 4.8px;
  background: #FFF;
  border-radius: 50%;
  left: 10.4px;
  bottom: 5.6px;
  box-shadow: -0.3px 0 0.7px 0 rgba(0, 0, 0, 0.1);
}

#theme-toggle-checkbox:checked + .theme-toggle .star-7 {
  width: 7px;
  height: 7px;
  background: #FFF;
  border-radius: 50%;
  left: 14.6px;
  bottom: 5.6px;
  box-shadow: -0.3px 0 0.7px 0 rgba(0, 0, 0, 0.1);
}

#theme-toggle-checkbox:checked + .theme-toggle .star-8 {
  width: 5.5px;
  height: 5.5px;
  background: #FFF;
  border-radius: 50%;
  left: 19.4px;
  top: 16px;
  box-shadow: -0.3px 0 0.7px 0 rgba(0, 0, 0, 0.1);
}

@keyframes move {
  0% {
    transform: none;
  }

  25% {
    transform: translateX(0.7px);
  }

  100% {
    transform: translateX(-0.7px);
  }
}
