@import '../../common/modern-reset.css';
@import '../../common/theme.css';
@import '../../common/a11y.css';
@import '../../common/base.css';
@import '/src/ui/components/button/button.css';

:root {
  color-scheme: light dark;
}

body {
  margin: 20px;
  background: light-dark(#fff, #000);
  color: light-dark(#000, #fff);
}

.container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
  grid-auto-rows: 18.75rem;
  gap: 1.25rem;
}

.case {
  border: 1px solid light-dark(#000, #fff);
  padding: 2.5rem;

  button {
    border-radius: 0.5rem;
    padding: 0.5em 1em;
    color: white;
  }

  .toggle-animation {
    background-color: #4263eb;
  }

  .toggle-animation.paused {
    background-color: #e03131;
  }

  .reset-animation {
    background-color: #15aabf;
  }

  .target-animation {
    margin-top: 2.5rem;
    margin-block-start: 2.5rem;
    font-size: 2rem;
    text-align: center;
    align-content: center;
    padding: 0.625rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #37b24d, #2b8a3e);
  }
}

/* Fade Animation */
@keyframes fade {
  /* 0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  } */
  0% {
    background: red;
  }
  100% {
    background: blue;
  }
}
.case-01 .target-animation {
  animation-name: fade;
  animation-duration: 4s;
  animation-iteration-count: infinite;
  animation-delay: 1s;
  animation-timing-function: linear;
  /* animation-fill-mode: none; */
  /* animation-fill-mode: backwards; */
  /* animation-fill-mode: both; */
  animation-fill-mode: forwards;
  animation-direction: alternate;

  animation: fade 3s infinite 1s linear both;
  animation-play-state: paused;
}

/* Shrink Animation */
@keyframes shrink {
  0%,
  100% {
    width: 100%;
  }
  50% {
    width: 50%;
  }
}
.case-02 .target-animation {
  animation: shrink 2s infinite ease-in-out both;
  animation-play-state: paused;
}

/* Bounce Animation */
@keyframes bounce {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -20px;
  }
}
.case-03 .target-animation {
  animation: bounce 2s infinite ease-in-out;
  animation-play-state: paused;
}

/* Shake Animation */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-15px);
  }
}
.case-04 .target-animation {
  animation: shake 1.5s infinite ease-in-out;
  animation-play-state: paused;
}

/* Spin Animation */
@keyframes spin {
  0% {
    rotate: 0turn;
  }
  100% {
    rotate: 1turn;
  }
}
.case-05 .target-animation {
  animation: spin 1.5s infinite linear;
  animation-play-state: paused;
  width: 9.375rem;
  inline-size: 9.375rem;
  aspect-ratio: 1/1;
  border-radius: 50%;
  background-image: linear-gradient(red, green);
  background-image: conic-gradient(red, green, red);
}

/* Pulse Animation */
@keyframes pulse {
  0%,
  100% {
    transform: scale(1 1);
  }
  50% {
    transform: scale(1.1 1.1);
  }
}
.case-06 .target-animation {
  animation: pulse 1.5s infinite ease-in-out;
  animation-play-state: paused;
}

/* Flip Animation */
@keyframes flip {
  0% {
    transform: perspective(400px) rotateY(0);
  }
  100% {
    transform: perspective(400px) rotateY(360deg);
  }
}
.case-07 .target-animation {
  animation: flip 2s infinite ease-in-out;
  animation-play-state: paused;
}

/* Wobble Animation */
@keyframes wobble {
  0%,
  100% {
    transform: translateX(0%) rotate(0deg);
  }
  15% {
    transform: translateX(-15px) rotate(-5deg);
  }
  30% {
    transform: translateX(10px) rotate(3deg);
  }
  45% {
    transform: translateX(-10px) rotate(-3deg);
  }
  60% {
    transform: translateX(5px) rotate(2deg);
  }
  75% {
    transform: translateX(-5px) rotate(-1deg);
  }
}
.case-08 .target-animation {
  animation: wobble 2s infinite ease-in-out;
  animation-play-state: paused;
}

/* Glow Animation */
@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 5px light-dark(rgb(0 0 0 /0.5), rgb(255 255 255 /0.5));
  }
  50% {
    box-shadow: 0 0 10px light-dark(rgb(0 0 0 /0.6), rgb(255 255 255 /0.6));
  }
}
.case-09 .target-animation {
  animation: glow 2s infinite ease-in-out;
  animation-play-state: paused;
}

/* Rotate Animation */
@property --rotation {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
@keyframes rotate {
  from {
    --rotation: 0deg;
  }
  to {
    --rotation: 360deg;
  }
}
.case-10 .target-animation {
  width: 150px;
  aspect-ratio: 1/1;
  position: relative;

  &::before,
  &::after {
    --rotation: 0deg;
    box-sizing: content-box;
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    inset: 50%;
    translate: -50% -50%;
    background: conic-gradient(from var(--rotation), red, blue, red);
    padding: 1px;
    z-index: -1;
    border-radius: 8px;
    animation: rotate 1s infinite linear;
    animation-play-state: paused;
  }

  &::before {
    filter: blur(15px);
  }
}
