/* =====================================================================
   MOTION — dimuat setelah style.css
   Prinsip: gerak harus menjawab "apa yang berubah / ke mana harus lihat".
   Hanya transform & opacity (kecuali stroke SVG). Durasi 150–600ms.
   Semua dimatikan lewat prefers-reduced-motion atau tombol di Pengaturan.
   ===================================================================== */

/* ---------- keyframes ---------- */
@keyframes rise      { from { opacity: 0; transform: translateY(22px) scale(.985); } }
@keyframes rise-sm   { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-in   { from { opacity: 0; } }
@keyframes row-out   { to   { opacity: 0; transform: translateX(14px); } }
@keyframes bar-in    { from { transform: scaleY(0); } }
@keyframes meter-in  { from { transform: scaleX(0); } }
@keyframes ring-draw { from { stroke-dasharray: 0 100; } }
@keyframes spin      { to   { transform: rotate(360deg); } }
@keyframes float     { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes topo-drift { from { transform: rotate(0deg) scale(1); } to { transform: rotate(360deg) scale(1); } }
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes bell-ring {
  0%, 100% { transform: rotate(0); }
  10% { transform: rotate(16deg); } 20% { transform: rotate(-14deg); }
  30% { transform: rotate(10deg); } 40% { transform: rotate(-8deg); }
  50% { transform: rotate(4deg); }  60% { transform: rotate(0); }
}
@keyframes toast-in  { from { opacity: 0; transform: translateX(40px) scale(.92); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(40px) scale(.95); } }
@keyframes toast-bar { to   { transform: scaleX(0); } }
@keyframes dlg-in    { from { opacity: 0; transform: translateY(26px) scale(.93); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }    60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- masuk halaman (CSS murni, aman tanpa JS) ---------- */
.rise {
  animation: rise var(--t-slow) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.table tbody tr {
  animation: rise-sm .5s var(--ease-out) both;
  animation-delay: calc(min(var(--r, 0), 12) * 35ms + .25s);
}

/* ---------- reveal saat di-scroll (butuh JS; tanpa JS tetap tampil) ---------- */
.js .reveal:not(.in) { opacity: 0; transform: translateY(26px); }
.js .reveal {
  transition: opacity .7s var(--ease-out), transform .8s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 70ms);
}

/* ---------- transisi antar halaman (Chromium; browser lain = pindah biasa) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .sidebar { view-transition-name: sidebar; }
  .global-topbar { view-transition-name: topbar; }
  ::view-transition-group(sidebar), ::view-transition-group(topbar) { animation-duration: 0s; }
  ::view-transition-old(root) { animation: vt-out 160ms ease-in both; }
  ::view-transition-new(root) { animation: vt-in 420ms var(--ease-out) 60ms both; }
}
@keyframes vt-out { to   { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in  { from { opacity: 0; transform: translateY(14px); } }

/* ---------- efek pada hero dashboard ---------- */
.hero .eyebrow i { animation: float 4s ease-in-out infinite; }
.hero-wave { animation: wave-slide 14s linear infinite; }
@keyframes wave-slide { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- login: pindah ke login.css ---------- */

/* ---------- hormati preferensi pengguna ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; transition-delay: 0s !important;
  }
  .js .reveal:not(.in) { opacity: 1; transform: none; }
  .sidebar::before, .hero-topo, .hero-wave { animation: none !important; }
}
/* tombol "Kurangi animasi" di Pengaturan menambahkan atribut ini */
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; transition-delay: 0s !important;
}
:root[data-motion="off"] .js .reveal:not(.in), :root[data-motion="off"].js .reveal:not(.in) { opacity: 1; transform: none; }
:root[data-motion="off"] .sidebar::before, :root[data-motion="off"] .hero-topo, :root[data-motion="off"] .hero-wave { animation: none !important; }
