/* ==========================================================================
   술 게임 오락실 — animations.css
   Screen transitions, game effects, and micro-interactions.
   ========================================================================== */

/* ----------- 1. Screen slide transitions -------------------------------- */
.screen {
  will-change: transform, opacity;
}

.screen.screen--enter-right {
  animation: slide-in-right var(--transition-slow) forwards;
}

.screen.screen--enter-left {
  animation: slide-in-left var(--transition-slow) forwards;
}

.screen.screen--exit-left {
  animation: slide-out-left var(--transition-slow) forwards;
}

.screen.screen--exit-right {
  animation: slide-out-right var(--transition-slow) forwards;
}

.screen.screen--fade-in {
  animation: fade-in 0.25s ease-out forwards;
}

.screen.screen--leaving {
  animation: fade-out 0.4s ease-in forwards;
  pointer-events: none;
}

@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slide-in-left {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes slide-out-left {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(-30%); opacity: 0; }
}

@keyframes slide-out-right {
  from { transform: translateX(0);   opacity: 1; }
  to   { transform: translateX(30%); opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to   { opacity: 0; visibility: hidden; }
}

/* ----------- 2. Card flip --------------------------------------------- */
.flip-card {
  perspective: 1000px;
  width: 100%;
}

.flip-card__inner {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-card.is-flipped .flip-card__inner {
  transform: rotateY(180deg);
}

.flip-card__front,
.flip-card__back {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-card);
}

.flip-card__back {
  transform: rotateY(180deg);
}

@keyframes card-flip {
  0%   { transform: rotateY(0); }
  100% { transform: rotateY(180deg); }
}

/* ----------- 3. Countdown pulse --------------------------------------- */
.countdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  font-weight: 900;
  color: var(--color-primary);
  text-shadow: 0 4px 24px rgba(255, 107, 107, 0.5);
  animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.8;
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* ----------- 4. Bounce (drink event, splash logo) --------------------- */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53);
  }
  50% {
    transform: translateY(-16px);
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  }
}

.bounce-once {
  animation: bounce-once 0.6s ease-out;
}

@keyframes bounce-once {
  0%   { transform: translateY(0)   scale(1); }
  30%  { transform: translateY(-20px) scale(1.1); }
  60%  { transform: translateY(0)   scale(0.95); }
  100% { transform: translateY(0)   scale(1); }
}

/* Counter bump (drink count increase) */
@keyframes count-bump {
  0%   { transform: scale(1); color: var(--color-accent); }
  40%  { transform: scale(1.4); color: var(--color-primary); }
  100% { transform: scale(1); color: var(--color-accent); }
}

/* Standalone .bump class — usable on any element (e.g. drink count, badges) */
.bump {
  animation: count-bump 0.4s ease;
}

/* ----------- 5. Shake (wrong answer / error) -------------------------- */
.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80%      { transform: translateX(8px); }
}

/* ----------- 6. Confetti (victory) ------------------------------------ */
.result-confetti .confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 18px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall 2.5s linear infinite;
}

.result-confetti .confetti-piece:nth-child(1) {
  left: 8%;
  background: var(--color-primary);
  animation-delay: 0s;
}
.result-confetti .confetti-piece:nth-child(2) {
  left: 22%;
  background: var(--color-accent);
  animation-delay: 0.25s;
}
.result-confetti .confetti-piece:nth-child(3) {
  left: 35%;
  background: var(--color-secondary);
  animation-delay: 0.5s;
}
.result-confetti .confetti-piece:nth-child(4) {
  left: 50%;
  background: var(--color-info);
  animation-delay: 0.1s;
}
.result-confetti .confetti-piece:nth-child(5) {
  left: 63%;
  background: var(--color-primary);
  animation-delay: 0.6s;
}
.result-confetti .confetti-piece:nth-child(6) {
  left: 76%;
  background: var(--color-accent);
  animation-delay: 0.35s;
}
.result-confetti .confetti-piece:nth-child(7) {
  left: 88%;
  background: var(--color-secondary);
  animation-delay: 0.8s;
}
.result-confetti .confetti-piece:nth-child(8) {
  left: 95%;
  background: var(--color-warn);
  animation-delay: 0.45s;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.4;
  }
}

/* ----------- 7. Drink animation overlay ------------------------------- */
.drink-animation-overlay {
  animation: fade-in 0.2s ease-out;
}

.drink-animation-overlay.is-leaving {
  animation: fade-out 0.3s ease-in forwards;
}

.drink-animation-text {
  animation: drink-pop 0.6s cubic-bezier(0.18, 1.27, 0.5, 1.5);
}

@keyframes drink-pop {
  0% {
    transform: scale(0) rotate(-15deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.15) rotate(2deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

/* ----------- 8. Toast slide-in ---------------------------------------- */
.toast {
  animation: toast-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.is-leaving {
  animation: toast-out 0.25s ease-in forwards;
}

@keyframes toast-in {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateY(0);   opacity: 1; }
  to   { transform: translateY(-8px); opacity: 0; }
}

/* ----------- 9. Modal pop-in ------------------------------------------ */
.modal-root {
  animation: fade-in 0.2s ease-out;
}

.modal-root.is-leaving {
  animation: fade-out 0.2s ease-in forwards;
}

.modal-card {
  animation: modal-pop 0.3s cubic-bezier(0.18, 1.0, 0.5, 1.2);
}

@keyframes modal-pop {
  0%   { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1);     opacity: 1; }
}

/* ----------- 10. Ready state pulse (lobby) ---------------------------- */
.player-item.is-ready {
  animation: ready-glow 2s ease-in-out infinite;
}

@keyframes ready-glow {
  0%, 100% {
    box-shadow: 0 0 0 rgba(78, 205, 196, 0);
  }
  50% {
    box-shadow: 0 0 12px rgba(78, 205, 196, 0.3);
  }
}

/* ----------- 11. Button press ripple --------------------------------- */
.btn--primary,
.btn--accent {
  position: relative;
  overflow: hidden;
}

.btn--primary::after,
.btn--accent::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 60%);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}

.btn--primary:active::after,
.btn--accent:active::after {
  opacity: 1;
  transform: scale(1.5);
  transition: 0s;
}

/* ----------- 12. Reduced motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .splash-loader,
  .countdown,
  .result-confetti .confetti-piece,
  .splash-logo {
    animation: none !important;
  }
}
