/* ============================================
   ZGRAJA RADZI — Animations & Keyframes
   ============================================ */

/* --- Screen Transitions --- */

.screen-enter {
  animation: slideInRight 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.screen-exit {
  animation: slideOutLeft 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

/* --- Reverse transition (going back) --- */

.screen-enter-reverse {
  animation: slideInLeft 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.screen-exit-reverse {
  animation: slideOutRight 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}

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

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(30%);
    opacity: 0;
  }
}

/* --- Character-Specific Animations --- */

/* Zagaj: nose sniffing (subtle vertical oscillation) */
@keyframes zagaj-sniff {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-3px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-2px); }
}

.character-zagaj .character-avatar {
  animation: zagaj-sniff 2s ease-in-out infinite;
}

/* Bajzel: constant bouncing */
@keyframes bajzel-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.character-bajzel .character-avatar {
  animation: bajzel-bounce 0.8s ease-in-out infinite;
}

/* Lean: spinning entrance */
@keyframes lean-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.character-lean .character-avatar {
  animation: lean-spin 0.6s ease-out;
}

/* Data: triple blink on entrance */
@keyframes data-blink {
  0%, 20%, 40%, 60%, 80%, 100% { opacity: 1; }
  10%, 30%, 50% { opacity: 0.3; }
}

.character-data .character-avatar {
  animation: data-blink 1.5s ease-in-out;
}

/* Kaizen: golden ring pulse on click */
@keyframes kaizen-click {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 164, 74, 0.6);
  }
  100% {
    box-shadow: 0 0 0 20px rgba(212, 164, 74, 0);
  }
}

.character-kaizen .character-avatar {
  animation: kaizen-click 1s ease-out;
}

/* Stoik: slow breathing glow */
@keyframes stoik-breathe {
  0%, 100% {
    box-shadow: 0 0 10px rgba(74, 85, 104, 0.2);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 30px rgba(74, 85, 104, 0.4);
    transform: scale(1.03);
  }
}

.character-stoik .character-avatar,
.stoik-avatar-large {
  animation: stoik-breathe 4s ease-in-out infinite;
}

/* Edek: lazy yawn entrance */
@keyframes edek-yawn {
  0% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

.character-edek .character-avatar {
  animation: edek-yawn 1s ease-out;
}

/* --- Progress Bar Avatar --- */

@keyframes gentle-bounce {
  0%, 100% { transform: scale(1.25) translateY(0); }
  50% { transform: scale(1.25) translateY(-4px); }
}

.progress-avatar.active {
  animation: gentle-bounce 1.5s ease-in-out infinite;
}

/* --- Card Interactions --- */

@keyframes card-select {
  0% { transform: scale(1); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.option-card.just-selected {
  animation: card-select 200ms ease-out;
}

/* --- Discovery Card Flip --- */

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

.discovery-card-inner.flipping {
  animation: card-flip-in 600ms ease-out forwards;
}

/* --- Staggered Row Entrance (Data report) --- */

@keyframes stagger-in {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.data-row {
  opacity: 0;
  animation: stagger-in 400ms ease-out forwards;
}

.data-row:nth-child(1) { animation-delay: 0ms; }
.data-row:nth-child(2) { animation-delay: 200ms; }
.data-row:nth-child(3) { animation-delay: 400ms; }
.data-row:nth-child(4) { animation-delay: 600ms; }

/* --- Breathing Exercise --- */

@keyframes breathe-in {
  from {
    transform: scale(0.6);
    opacity: 0.4;
  }
  to {
    transform: scale(1);
    opacity: 0.8;
  }
}

@keyframes breathe-out {
  from {
    transform: scale(1);
    opacity: 0.8;
  }
  to {
    transform: scale(0.6);
    opacity: 0.4;
  }
}

.breathing-circle.inhale {
  animation: breathe-in 4s ease-in-out forwards;
}

.breathing-circle.exhale {
  animation: breathe-out 4s ease-in-out forwards;
}

/* --- Stoik Word Reveal --- */

.stoik-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.stoik-word.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Fade In (general purpose) --- */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out forwards;
}

.fade-in-delay-1 { animation-delay: 0.2s; opacity: 0; }
.fade-in-delay-2 { animation-delay: 0.4s; opacity: 0; }
.fade-in-delay-3 { animation-delay: 0.6s; opacity: 0; }
.fade-in-delay-4 { animation-delay: 0.8s; opacity: 0; }

/* --- Lean Result Entrance --- */

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lean-result {
  opacity: 0;
  animation: slideUp 500ms ease-out forwards;
}

.lean-result:nth-child(2) {
  animation-delay: 800ms;
}

.lean-note {
  opacity: 0;
  animation: fadeInUp 600ms ease-out forwards;
  animation-delay: 1600ms;
}

/* --- Modal --- */

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal {
  animation: modalIn 300ms ease-out;
}

.modal-overlay {
  animation: fadeIn 200ms ease-out;
}

/* --- Collection Card Shimmer --- */

@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

.collection-card.completed:hover {
  background: linear-gradient(90deg, var(--white) 0%, var(--gold-light) 50%, var(--white) 100%);
  background-size: 400px 100%;
  animation: shimmer 2s ease-in-out infinite;
}

/* --- Badge Pulse (for "szalone!" badge) --- */

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

.badge-absurd {
  animation: badge-pulse 1.5s ease-in-out infinite;
}

/* --- Golden Glow (selected Kaizen rule) --- */

@keyframes golden-glow {
  0%, 100% {
    box-shadow: 0 0 8px rgba(200, 164, 92, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(200, 164, 92, 0.6);
  }
}

.rule-card.selected {
  animation: golden-glow 2s ease-in-out infinite;
}

/* --- Deck Card Entrance --- */

.deck-card {
  opacity: 0;
  animation: fadeInUp 300ms ease-out forwards;
}

.deck-card:nth-child(1) { animation-delay: 0ms; }
.deck-card:nth-child(2) { animation-delay: 50ms; }
.deck-card:nth-child(3) { animation-delay: 100ms; }
.deck-card:nth-child(4) { animation-delay: 150ms; }
.deck-card:nth-child(5) { animation-delay: 200ms; }
.deck-card:nth-child(6) { animation-delay: 250ms; }
.deck-card:nth-child(7) { animation-delay: 300ms; }
.deck-card:nth-child(8) { animation-delay: 350ms; }
.deck-card:nth-child(9) { animation-delay: 400ms; }
.deck-card:nth-child(10) { animation-delay: 450ms; }
.deck-card:nth-child(11) { animation-delay: 500ms; }
.deck-card:nth-child(12) { animation-delay: 550ms; }
.deck-card:nth-child(13) { animation-delay: 600ms; }
.deck-card:nth-child(14) { animation-delay: 650ms; }
.deck-card:nth-child(15) { animation-delay: 700ms; }
.deck-card:nth-child(16) { animation-delay: 750ms; }
.deck-card:nth-child(17) { animation-delay: 800ms; }
.deck-card:nth-child(18) { animation-delay: 850ms; }
.deck-card:nth-child(19) { animation-delay: 900ms; }
.deck-card:nth-child(20) { animation-delay: 950ms; }

/* --- Success Checkmark --- */

@keyframes checkmark-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.checkmark {
  animation: checkmark-pop 300ms ease-out;
}

/* --- Collection Added Message --- */

@keyframes slide-up-fade {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.collection-added {
  animation: slide-up-fade 500ms ease-out forwards;
  animation-delay: 1000ms;
  opacity: 0;
}

/* --- 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;
  }

  .screen-enter,
  .screen-exit,
  .screen-enter-reverse,
  .screen-exit-reverse {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .stoik-word {
    opacity: 1 !important;
    transform: none !important;
  }

  .breathing-circle {
    animation: none !important;
  }
}
