/* =====================================================================
   animasi.css — Hybrid Windows Motion System
   Vista (Aero Glass: transparansi, blur, kilau kaca)
 + Windows 8 (Metro: slide, zoom, tilt 3D, stagger)
 + Windows 11 (Fluent: gerak halus, decelerate, depth berlapis)
   Dimuat SETELAH style.css di semua halaman KECUALI Detail File.
   Ubah token di :root untuk menyetel kecepatan / karakter gerak.
   ===================================================================== */

:root {
  /* durasi */
  --w-in: 300ms;          /* buka / masuk  */
  --w-out: 170ms;         /* tutup / keluar (lebih cepat = terasa responsif) */
  --w-page: 380ms;
  /* kurva */
  --w-ease-out: cubic-bezier(.16, 1, .3, 1);      /* Fluent decelerate */
  --w-ease-metro: cubic-bezier(.1, .9, .2, 1);    /* Metro exponential-out */
  --w-ease-in: cubic-bezier(.7, 0, .84, 0);       /* keluar cepat */
  --w-ease-spring: cubic-bezier(.34, 1.45, .64, 1);
  /* efek 3D popup: miring dari atas (rotateX) + naik + mengecil */
  --w-pop-from: perspective(720px) rotateX(-9deg) translateY(-10px) scale(.95);
  /* kaca Aero */
  --w-glass-bg: rgba(255, 255, 255, .80);
  --w-glass-sheen: linear-gradient(135deg, rgba(255,255,255,.70) 0%, rgba(255,255,255,.14) 36%, rgba(255,255,255,0) 60%, rgba(255,255,255,.38) 100%);
  --w-glass-blur: blur(26px) saturate(1.7);
  --w-glass-edge: inset 0 1px 0 rgba(255,255,255,.95), inset 0 0 0 1px rgba(255,255,255,.40);
  --w-depth: 0 22px 54px -14px rgba(0,30,80,.38), 0 6px 16px -4px rgba(0,30,80,.14), 0 1px 3px rgba(0,0,0,.08);
}

/* ============ 1. VISUAL — Aero Glass + kedalaman 3D ============ */
html body :is(.modal-box, .qa-menu, .file-menu, .sort-menu, .ck-panel,
              .search-panel, .ms-pop, .up-dialog, .akses-type-menu, .foto-menu) {
  background-color: var(--w-glass-bg) !important;
  background-image: var(--w-glass-sheen) !important;
  -webkit-backdrop-filter: var(--w-glass-blur) !important;
          backdrop-filter: var(--w-glass-blur) !important;
  border: 1px solid rgba(255,255,255,.72) !important;
  box-shadow: var(--w-glass-edge), var(--w-depth) !important;
}
html body .modal-box { background-color: rgba(255,255,255,.86) !important; }
/* menu profil: latar penuh (tidak transparan) agar konten di belakangnya tidak tembus */
html body .profile-menu {
  background-color: #fff !important;
  background-image: none !important;
  -webkit-backdrop-filter: none !important;
          backdrop-filter: none !important;
  border: 1px solid rgba(0,0,0,.07) !important;
  box-shadow: var(--w-depth) !important;
}

/* ============ 2. POP-UP & QUICK VIEW — buka/tutup beranimasi ============ */
html body :is(.profile-menu, .qa-menu, .file-menu, .sort-menu, .ck-panel, .search-panel,
              .ms-pop, .up-dialog, .akses-type-menu, .akses-suggest) {
  transition:
    opacity var(--w-out) var(--w-ease-in),
    transform var(--w-out) var(--w-ease-in),
    visibility 0s linear var(--w-out) !important;
  will-change: opacity, transform;
}
html body :is(.profile-menu, .sort-menu) { transform-origin: top right !important; }
html body :is(.qa-menu, .search-panel)   { transform-origin: top center !important; }
html body :is(.ck-panel, .ms-pop)        { transform-origin: top left !important; }
html body .ms-pop.ms-up                  { transform-origin: bottom left !important; }
html body .up-dialog                     { transform-origin: bottom right !important; }

/* --- tertutup (berbasis kelas) --- */
html body :is(.profile-menu, .qa-menu, .sort-menu, .ck-panel, .search-panel) {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: var(--w-pop-from) !important;
  pointer-events: none !important;
}
html body .up-dialog {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: perspective(800px) rotateX(10deg) translateY(26px) scale(.94) !important;
  pointer-events: none !important;
}
/* --- tertutup (berbasis atribut hidden) — tetap dirender agar transisi tutup berjalan --- */
html body :is(.file-menu, .ms-pop, .akses-type-menu, .akses-suggest)[hidden] {
  display: block !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: var(--w-pop-from) !important;
  pointer-events: none !important;
}
html body .file-menu[hidden] { display: flex !important; }

/* --- terbuka --- */
html body :is(.profile-menu.open, .qa-menu.qa-open, .sort-dd.open .sort-menu,
              .ck-dd.open .ck-panel, .search-panel.open, .up-dialog.up-show,
              .file-menu:not([hidden]), .ms-pop:not([hidden]),
              .akses-type-menu:not([hidden]), .akses-suggest:not([hidden])) {
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
  pointer-events: auto !important;
  animation: none !important;
  transition:
    opacity var(--w-in) var(--w-ease-out),
    transform var(--w-in) var(--w-ease-out),
    visibility 0s !important;
}
html body .file-menu:not([hidden]) { display: flex !important; }

/* foto profil: tampil/hilang pakai display → animasi masuk saja */
html body .foto-menu.open { animation: winPopIn var(--w-in) var(--w-ease-out) both; transform-origin: bottom left; }

/* isi menu muncul berurutan (stagger gaya Metro) */
html body .profile-menu.open > .profile-item,
html body .qa-menu.qa-open .qa-item,
html body .sort-dd.open .sort-menu > *,
html body .ck-dd.open .ck-panel .ck-btn,
html body .file-menu:not([hidden]) .file-menu-item,
html body .ms-menu:not([hidden]) > button,
html body .ms-menu:not([hidden]) .ms-menu-grp > button,
html body .akses-type-menu:not([hidden]) .akses-type-opt,
html body .foto-menu.open > * {
  animation: winItemIn var(--w-in) var(--w-ease-out) backwards !important;
  animation-delay: calc(var(--i, 0) * 28ms + 30ms) !important;
}
html body .profile-menu.open > .profile-item:nth-child(2),
html body .qa-menu.qa-open .qa-item:nth-child(2),
html body .sort-dd.open .sort-menu > *:nth-child(2),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(2),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(2),
html body .ms-menu:not([hidden]) > button:nth-child(2),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(2),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(2),
html body .foto-menu.open > *:nth-child(2) { --i:1; }
html body .profile-menu.open > .profile-item:nth-child(3),
html body .qa-menu.qa-open .qa-item:nth-child(3),
html body .sort-dd.open .sort-menu > *:nth-child(3),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(3),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(3),
html body .ms-menu:not([hidden]) > button:nth-child(3),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(3),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(3),
html body .foto-menu.open > *:nth-child(3) { --i:2; }
html body .profile-menu.open > .profile-item:nth-child(4),
html body .qa-menu.qa-open .qa-item:nth-child(4),
html body .sort-dd.open .sort-menu > *:nth-child(4),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(4),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(4),
html body .ms-menu:not([hidden]) > button:nth-child(4),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(4),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(4),
html body .foto-menu.open > *:nth-child(4) { --i:3; }
html body .profile-menu.open > .profile-item:nth-child(5),
html body .qa-menu.qa-open .qa-item:nth-child(5),
html body .sort-dd.open .sort-menu > *:nth-child(5),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(5),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(5),
html body .ms-menu:not([hidden]) > button:nth-child(5),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(5),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(5),
html body .foto-menu.open > *:nth-child(5) { --i:4; }
html body .profile-menu.open > .profile-item:nth-child(6),
html body .qa-menu.qa-open .qa-item:nth-child(6),
html body .sort-dd.open .sort-menu > *:nth-child(6),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(6),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(6),
html body .ms-menu:not([hidden]) > button:nth-child(6),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(6),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(6),
html body .foto-menu.open > *:nth-child(6) { --i:5; }
html body .profile-menu.open > .profile-item:nth-child(7),
html body .qa-menu.qa-open .qa-item:nth-child(7),
html body .sort-dd.open .sort-menu > *:nth-child(7),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(7),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(7),
html body .ms-menu:not([hidden]) > button:nth-child(7),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(7),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(7),
html body .foto-menu.open > *:nth-child(7) { --i:6; }
html body .profile-menu.open > .profile-item:nth-child(8),
html body .qa-menu.qa-open .qa-item:nth-child(8),
html body .sort-dd.open .sort-menu > *:nth-child(8),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(8),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(8),
html body .ms-menu:not([hidden]) > button:nth-child(8),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(8),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(8),
html body .foto-menu.open > *:nth-child(8) { --i:7; }
html body .profile-menu.open > .profile-item:nth-child(n+9),
html body .qa-menu.qa-open .qa-item:nth-child(n+9),
html body .sort-dd.open .sort-menu > *:nth-child(n+9),
html body .ck-dd.open .ck-panel .ck-btn:nth-child(n+9),
html body .file-menu:not([hidden]) .file-menu-item:nth-child(n+9),
html body .ms-menu:not([hidden]) > button:nth-child(n+9),
html body .ms-menu:not([hidden]) .ms-menu-grp > button:nth-child(n+9),
html body .akses-type-menu:not([hidden]) .akses-type-opt:nth-child(n+9),
html body .foto-menu.open > *:nth-child(n+9) { --i:8; }

/* ============ 3. MODAL — zoom 3D + kaca + blur latar ============ */
html body .modal {
  display: flex !important;
  perspective: 1200px;
  opacity: 1;
  visibility: visible;
  animation: none !important;
  background: rgba(0, 20, 40, .36);
  -webkit-backdrop-filter: blur(10px) saturate(1.25);
          backdrop-filter: blur(10px) saturate(1.25);
  transition:
    opacity var(--w-in) var(--w-ease-out),
    background-color var(--w-in) var(--w-ease-out),
    backdrop-filter var(--w-in) var(--w-ease-out),
    -webkit-backdrop-filter var(--w-in) var(--w-ease-out),
    visibility 0s;
}
html body .modal[hidden] {
  display: flex !important;           /* tetap dirender supaya animasi tutup terlihat */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: rgba(0, 20, 40, 0);
  -webkit-backdrop-filter: blur(0) saturate(1);
          backdrop-filter: blur(0) saturate(1);
  transition:
    opacity var(--w-out) var(--w-ease-in),
    background-color var(--w-out) var(--w-ease-in),
    backdrop-filter var(--w-out) var(--w-ease-in),
    -webkit-backdrop-filter var(--w-out) var(--w-ease-in),
    visibility 0s linear var(--w-out);
}
html body .modal .modal-box {
  animation: none !important;
  transform: none;
  filter: none;
  opacity: 1;
  transition:
    transform var(--w-in) var(--w-ease-spring),
    opacity var(--w-in) var(--w-ease-out),
    filter var(--w-in) var(--w-ease-out);
}
/* buka = maximize (miring 3D + zoom dari bawah)  |  tutup = minimize (mengecil ke bawah) */
html body .modal[hidden] .modal-box {
  opacity: 0;
  filter: blur(5px);
  transform: rotateX(11deg) translateY(30px) scale(.9);
  transition:
    transform var(--w-out) var(--w-ease-in),
    opacity var(--w-out) var(--w-ease-in),
    filter var(--w-out) var(--w-ease-in);
}

/* ============ 4. TRANSISI HALAMAN — slide + zoom (minimize / maximize) ============ */
html.win-enter .content,
html.win-enter .login-card { animation: winPageIn var(--w-page) var(--w-ease-out) backwards; }
html.win-enter-back .content { animation-name: winPageInBack; }
html.win-leave .content,
html.win-leave .login-card { animation: winPageOut 200ms var(--w-ease-in) forwards; pointer-events: none; }
html.win-leave-back .content { animation-name: winPageOutBack; }

/* ============ 5. INTERAKSI MODERN — hover, klik, tab, panel ============ */
/* konten halaman naik berurutan */
html body .fade-in { animation: winRise .46s var(--w-ease-out) backwards; }

/* kartu: angkat saat hover (kedalaman) + tilt 3D saat ditekan (ubin Windows 8) */
html body :is(.ms-stat, .stat-row > *, .file-card) {
  transition: transform .28s var(--w-ease-out), box-shadow .28s var(--w-ease-out), background-color .2s ease;
}
html body .ms-stat:hover { transform: translateY(-3px); box-shadow: 0 16px 30px -14px rgba(0,40,100,.30); }
html body :is(.ms-stat, .file-card, .btn-new):active {
  transform: perspective(700px) rotateX(var(--ty, 0deg)) rotateY(var(--tx, 0deg)) scale(.975) !important;
  transition-duration: .08s;
}

/* tombol & item menu: umpan balik klik */
html body :is(.btn-primary, .btn-cancel, .ms-pg, .ck-btn, .sort-btn, .chip, .up-btn, .btn-new, .pf-tab) {
  transition: background-color .2s var(--w-ease-metro), color .2s var(--w-ease-metro), border-color .2s var(--w-ease-metro),
              box-shadow .25s var(--w-ease-metro), transform .15s var(--w-ease-metro);
}
html body :is(.btn-primary, .btn-cancel, .ms-pg, .ck-btn, .sort-btn, .chip, .up-btn):active:not(:disabled) { transform: scale(.96); }
html body :is(.profile-item, .qa-item, .file-menu-item, .sort-opt, .ms-menu button, .akses-type-opt):active { transform: scale(.98); }
html body :is(.profile-item, .qa-item, .file-menu-item, .sort-opt, .ms-menu button, .akses-type-opt) {
  transition: background-color .18s var(--w-ease-metro), color .18s var(--w-ease-metro), transform .12s var(--w-ease-metro) !important;
}
html body .nav-item { transition: background-color .2s var(--w-ease-metro), color .2s var(--w-ease-metro), transform .25s var(--w-ease-out); }
html body .nav-item:hover { transform: translateX(3px); }
html body .nav-item:active { transform: translateX(1px) scale(.98); }

/* tab: warna/garis bergeser halus, panel masuk dari kanan */
html body .pf-tab { transition: color .25s var(--w-ease-out), border-color .25s var(--w-ease-out); }
html body :is(#tab-pribadi, #tab-keamanan) { animation: winTabIn .36s var(--w-ease-out) backwards; }
html body .ms-seg button {
  transition: background-color .25s var(--w-ease-out), color .25s var(--w-ease-out), box-shadow .25s var(--w-ease-out), transform .15s var(--w-ease-out);
}
html body .ms-seg button:active { transform: scale(.95); }

/* baris tabel / daftar aktivitas: masuk berurutan tiap kali panel berganti halaman */
html body .ms-table tbody td { transition: background-color .2s ease; }
html body .ms-table tbody tr,
html body .ms-akt-list > .ms-akt {
  animation: winItemIn var(--w-in) var(--w-ease-out) backwards !important;
  animation-delay: calc(var(--i, 0) * 36ms + 0ms) !important;
}
html body .ms-table tbody tr:nth-child(2),
html body .ms-akt-list > .ms-akt:nth-child(2) { --i:1; }
html body .ms-table tbody tr:nth-child(3),
html body .ms-akt-list > .ms-akt:nth-child(3) { --i:2; }
html body .ms-table tbody tr:nth-child(4),
html body .ms-akt-list > .ms-akt:nth-child(4) { --i:3; }
html body .ms-table tbody tr:nth-child(5),
html body .ms-akt-list > .ms-akt:nth-child(5) { --i:4; }
html body .ms-table tbody tr:nth-child(6),
html body .ms-akt-list > .ms-akt:nth-child(6) { --i:5; }
html body .ms-table tbody tr:nth-child(7),
html body .ms-akt-list > .ms-akt:nth-child(7) { --i:6; }
html body .ms-table tbody tr:nth-child(8),
html body .ms-akt-list > .ms-akt:nth-child(8) { --i:7; }
html body .ms-table tbody tr:nth-child(n+9),
html body .ms-akt-list > .ms-akt:nth-child(n+9) { --i:8; }

/* ============ KEYFRAMES ============ */
@keyframes winItemIn   { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes winRise     { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes winPopIn    { from { opacity: 0; transform: var(--w-pop-from); } to { opacity: 1; transform: none; } }
@keyframes winTabIn    { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes winPageIn     { from { opacity: 0; transform: translateX(38px) scale(.965); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes winPageInBack { from { opacity: 0; transform: translateX(-38px) scale(.965); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes winPageOut     { to { opacity: 0; transform: translateX(-30px) scale(.96); filter: blur(3px); } }
@keyframes winPageOutBack { to { opacity: 0; transform: translateX(30px) scale(.96); filter: blur(3px); } }

/* ============ Aksesibilitas: hormati "kurangi gerakan" ============ */
@media (prefers-reduced-motion: reduce) {
  html body *, html body *::before, html body *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}
