/* =========================================================
   Chess — Animation styles
   Lelele Games
   ========================================================= */

/*
 * Animation classes are designed to be added and removed by the
 * game UI. The chess rules must update independently of animation.
 */

/* Square feedback */
@keyframes square-pulse {
  0% {
    box-shadow: inset 0 0 0 0 rgba(246, 202, 105, 0);
  }
  50% {
    box-shadow: inset 0 0 0 5px rgba(246, 202, 105, 0.42);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(246, 202, 105, 0);
  }
}

.chess-square.is-move-feedback {
  animation: square-pulse 360ms ease-out;
}

/* Piece movement */
@keyframes piece-arrive {
  0% {
    transform: scale(0.86);
    opacity: 0.65;
  }
  72% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.chess-piece.is-arriving {
  animation: piece-arrive 190ms ease-out both;
}

/* Captured piece: playful split and fall */
@keyframes captured-piece-split-left {
  0% {
    transform: translate(0, 0) rotate(0) scale(1);
    opacity: 1;
  }
  35% {
    transform: translate(-7px, -5px) rotate(-12deg) scale(0.94);
    opacity: 1;
  }
  100% {
    transform: translate(-17px, 27px) rotate(-48deg) scale(0.35);
    opacity: 0;
  }
}

@keyframes captured-piece-split-right {
  0% {
    transform: translate(0, 0) rotate(0) scale(1);
    opacity: 1;
  }
  35% {
    transform: translate(7px, -5px) rotate(12deg) scale(0.94);
    opacity: 1;
  }
  100% {
    transform: translate(17px, 27px) rotate(48deg) scale(0.35);
    opacity: 0;
  }
}

.capture-fragment {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: center;
}

.capture-fragment--left {
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.capture-fragment--right {
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}

.capture-fragment--left.is-splitting {
  animation: captured-piece-split-left 420ms cubic-bezier(0.4, 0, 0.8, 0.4) forwards;
}

.capture-fragment--right.is-splitting {
  animation: captured-piece-split-right 420ms cubic-bezier(0.4, 0, 0.8, 0.4) forwards;
}

/* Gravestone entrance */
@keyframes gravestone-pop-in {
  0% {
    transform: translateY(12px) scale(0.72);
    opacity: 0;
  }
  65% {
    transform: translateY(-3px) scale(1.06);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.gravestone.is-appearing {
  animation: gravestone-pop-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Gravestone wobble as it moves to the captured area */
@keyframes gravestone-walk {
  0% {
    transform: translateX(0) rotate(0);
  }
  20% {
    transform: translateX(8px) rotate(5deg);
  }
  45% {
    transform: translateX(18px) rotate(-5deg);
  }
  70% {
    transform: translateX(28px) rotate(4deg);
  }
  100% {
    transform: translateX(36px) rotate(0);
  }
}

.gravestone.is-walking {
  animation: gravestone-walk 520ms ease-in-out both;
}

/* General interface transitions */
@keyframes panel-fade-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-enter {
  animation: panel-fade-in 220ms ease-out both;
}

@keyframes notification-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.notification.is-entering {
  animation: notification-enter 180ms ease-out both;
}

/* Elements created by animations.js (Web Animations API) */
.piece-moving,
.piece-capturing {
  display: grid;
  place-items: center;
  font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", serif;
  font-size: clamp(1.5rem, 6.2vw, 4.35rem);
  line-height: 1;
  filter: drop-shadow(0 5px 3px rgba(0, 0, 0, 0.35));
}

.chess-gravestone {
  display: inline-flex;
  min-width: 30px;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border: 1px solid rgba(238, 218, 184, 0.14);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--color-text-muted);
  font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", serif;
  font-size: 1.1rem;
  line-height: 1;
}

.gravestone-piece {
  font-size: 1.2rem;
}

.gravestone-label {
  display: none;
}

.gravestone-settled {
  opacity: 1;
  transform: none;
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  .chess-square.is-move-feedback,
  .chess-piece.is-arriving,
  .capture-fragment--left.is-splitting,
  .capture-fragment--right.is-splitting,
  .gravestone.is-appearing,
  .gravestone.is-walking,
  .panel-enter,
  .notification.is-entering {
    animation: none !important;
  }
}
