/* AllFresh - animations.css
   Mikro-animasi bersama. Aman dipasang di halaman mana pun:
   semua class berawalan "afa-", tidak mengubah style yang sudah ada. */

:root {
  --afa-ease: cubic-bezier(.2, .8, .2, 1);
  --afa-green: 22, 132, 71;
}

/* 1. Halaman muncul halus (opacity saja, tidak mengganggu layout) */
body { animation: afa-page .3s ease backwards; }
@keyframes afa-page { from { opacity: 0; } }

/* 2. Efek tekan: tombol mengecil sedikit saat ditekan
      (pakai :where supaya transition/transform bawaan halaman tetap menang) */
:where(button:not(:disabled), .afa-press) {
  transition: transform .12s var(--afa-ease);
}
:where(button:not(:disabled), .afa-press):active {
  transform: scale(.96);
}

/* 3. Kartu / elemen muncul berurutan (pakai class afa-stagger di wadahnya) */
.afa-stagger > *, .afa-rise {
  animation: afa-rise .45s var(--afa-ease) backwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}
@keyframes afa-rise {
  from { opacity: 0; transform: translateY(14px); }
}

/* 4. Item baru masuk di daftar + kilat hijau tipis */
.afa-enter { animation: afa-enter .38s var(--afa-ease) backwards, afa-flash 1.2s ease-out; }
@keyframes afa-enter {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
}
@keyframes afa-flash {
  from { background-color: rgba(var(--afa-green), .18); }
}

/* 5. Item dihapus: menyusut lalu hilang */
.afa-leave {
  animation: afa-leave .25s ease-in forwards;
  overflow: hidden;
  pointer-events: none;
}
@keyframes afa-leave {
  to { opacity: 0; transform: translateX(24px) scale(.96); max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
}

/* 6. Tombol sukses: centang membesar sebentar */
.afa-success {
  background: #168447 !important;
  color: #fff !important;
  animation: afa-pop .4s var(--afa-ease);
}
@keyframes afa-pop {
  0% { transform: scale(.92); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* 6b. Pop kecil untuk ikon centang (tanpa ubah warna) */
.afa-tick { animation: afa-pop .4s var(--afa-ease); }

/* 7. Getar kecil untuk error / validasi gagal */
.afa-shake { animation: afa-shake .35s ease; }
@keyframes afa-shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* 8. Skeleton loading (kotak abu berdenyut) */
.afa-skel {
  display: block;
  border-radius: 12px;
  color: transparent !important;
  background: linear-gradient(90deg, #e4e8e5 25%, #f1f4f2 40%, #e4e8e5 60%);
  background-size: 300% 100%;
  animation: afa-shimmer 1.3s linear infinite;
  margin-bottom: 10px;
}
@keyframes afa-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
/* Mode gelap: app memakai html[data-tema="gelap"] (diatur af_tema).
   Halaman tanpa atribut itu (mis. Animasi_Test) mengikuti sistem. */
html[data-tema="gelap"] .afa-skel {
  background: linear-gradient(90deg, #2a302c 25%, #353c37 40%, #2a302c 60%);
  background-size: 300% 100%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema]) .afa-skel {
    background: linear-gradient(90deg, #2a302c 25%, #353c37 40%, #2a302c 60%);
    background-size: 300% 100%;
  }
}

/* Hormati pengaturan "kurangi gerakan" di HP */
@media (prefers-reduced-motion: reduce) {
  body, .afa-stagger > *, .afa-rise, .afa-enter, .afa-leave, .afa-success, .afa-tick, .afa-shake, .afa-skel {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
  }
  :where(button:not(:disabled), .afa-press) { transition: none !important; }
}
