/* =========================================================
   Animations NewPlex
   ========================================================= */
:root {
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- Entrée de page ---------- */
.page-enter > * { animation: rise .45s var(--ease-out) both; }
.page-enter > *:nth-child(2) { animation-delay: .05s; }
.page-enter > *:nth-child(3) { animation-delay: .1s; }
.page-enter > *:nth-child(n+4) { animation-delay: .15s; }
.page-enter > .shelf:nth-child(2) { animation-delay: .08s; }
.page-enter > .shelf:nth-child(3) { animation-delay: .16s; }
.page-enter > .shelf:nth-child(n+4) { animation-delay: .24s; }

/* ---------- Cartes en cascade ---------- */
.page-enter .grid .card,
.page-enter .scroller .card,
.page-enter .episode {
  animation: pop-in .5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 28ms + .08s);
}

/* ---------- Survol des affiches ---------- */
.poster, .thumb { transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out); }
.card:hover .poster { transform: translateY(-5px) scale(1.03); }
.card:hover .thumb { transform: translateY(-3px) scale(1.02); }
.card:active .poster, .card:active .thumb { transform: scale(.98); transition-duration: .1s; }
.poster img, .thumb img { transition: transform .6s var(--ease-out), opacity .4s ease; }
.card:hover .poster img, .card:hover .thumb img, .episode:hover .thumb img { transform: scale(1.06); }
.hover-play { transition: opacity .2s; }
.hover-play .ic { transform: scale(.6); transition: transform .3s var(--ease-spring); }
.card:hover .hover-play .ic, .episode:hover .hover-play .ic { transform: scale(1); }
.card .t { transition: color .2s; }
.card:hover .t { color: var(--accent); }

/* ---------- Images : fondu au chargement, shimmer en attendant ---------- */
.fade-img { opacity: 0; }
.fade-img.loaded { opacity: 1; }
.fade-img.dim.loaded { opacity: .4; }
.poster:has(.fade-img:not(.loaded)), .thumb:has(.fade-img:not(.loaded)) {
  background: linear-gradient(100deg, var(--bg-3) 30%, var(--bg-4) 50%, var(--bg-3) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}

/* Barres de progression qui se remplissent */
.page-enter .bar i { animation: grow-x .9s var(--ease-out) both; animation-delay: .35s; transform-origin: left; }

/* ---------- Fiche détaillée ---------- */
.page-enter .detail { animation: none; }
.page-enter .detail .backdrop { animation: backdrop-in 1.2s var(--ease-out) both; }
.page-enter .detail .inner > .poster { animation: poster-in .6s var(--ease-out) both; }
.page-enter .detail .inner > div:not(.poster):not(.seasons) > * { animation: rise .5s var(--ease-out) both; }
.page-enter .detail .inner > div:not(.poster):not(.seasons) > *:nth-child(2) { animation-delay: .06s; }
.page-enter .detail .inner > div:not(.poster):not(.seasons) > *:nth-child(3) { animation-delay: .12s; }
.page-enter .detail .inner > div:not(.poster):not(.seasons) > *:nth-child(4) { animation-delay: .18s; }
.page-enter .detail .inner > div:not(.poster):not(.seasons) > *:nth-child(n+5) { animation-delay: .24s; }
.page-enter .detail .seasons { animation: rise .5s var(--ease-out) .2s both; }
.season-tabs button { transition: color .2s, border-color .25s var(--ease-out); }
.episode { transition: background .2s, transform .25s var(--ease-out); }
.episode:hover { transform: translateX(4px); }

/* ---------- Barre latérale ---------- */
.nav-item { transition: background .2s, color .2s, box-shadow .25s var(--ease-out); }
.nav-item .ic { transition: transform .3s var(--ease-spring), color .2s; }
.nav-item:hover .ic { transform: scale(1.12); }
.nav-item.active .ic { color: var(--accent); }
.nav-add:hover .ic { transform: rotate(90deg) scale(1.1); }
.brand img { transition: transform .5s var(--ease-spring); }
.brand:hover img { transform: rotate(-12deg) scale(1.08); }

/* Engrenage de gestion d'une bibliothèque */
.nav-lib { position: relative; }
/* Le nombre d'éléments occupe la place de l'engrenage ; au survol il laisse place à Scanner + Gérer */
.nav-lib .nav-item { padding-right: 44px; }
.nav-lib .nav-item > span:not(.count):not(.spinner) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Nombre centré sur l'emplacement de l'engrenage (28px à 6px du bord) */
.nav-lib .nav-item .count, .nav-lib .nav-item .spinner { position: absolute; right: 6px; top: 50%; width: 28px; margin-top: -9px; text-align: center; line-height: 18px; transition: opacity .15s; }
.nav-lib .nav-item .spinner { width: 14px; height: 14px; margin-top: -7px; right: 13px; }
.nav-lib.can-edit:hover .nav-item, .nav-lib.can-edit:focus-within .nav-item { padding-right: 70px; }
.nav-lib.can-edit:hover .nav-item .count, .nav-lib.can-edit:focus-within .nav-item .count,
.nav-lib.can-edit:hover .nav-item .spinner, .nav-lib.can-edit:focus-within .nav-item .spinner { opacity: 0; }
.nav-actions { position: absolute; right: 6px; top: 50%; margin-top: -14px; display: flex; gap: 2px; pointer-events: none; }
.nav-act {
  width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none;
  color: var(--text-3); cursor: pointer; opacity: 0; transform: scale(.7); will-change: transform, opacity; backface-visibility: hidden;
  transition: opacity .15s, transform .25s var(--ease-spring), color .2s, background .2s;
}
.nav-act .ic { width: 17px; height: 17px; transition: transform .5s var(--ease-out); }
.nav-lib:hover .nav-act, .nav-lib:focus-within .nav-act { opacity: 1; transform: scale(1); pointer-events: auto; }
.nav-lib:hover .nav-refresh { transition-delay: .03s; }
.nav-act:hover { background: var(--bg-4); color: var(--accent); }
.nav-gear:hover .ic { transform: rotate(120deg); }
.nav-refresh:hover .ic { transform: rotate(180deg); }
.nav-act:disabled { cursor: default; opacity: .35 !important; }
.nav-act:disabled:hover { background: none; color: var(--text-3); }
.nav-act:disabled .ic { transform: none !important; }
@media (hover: none) {
  .nav-act { opacity: 1; transform: none; pointer-events: auto; }
  .nav-lib.can-edit .nav-item { padding-right: 70px; }
  .nav-lib.can-edit .nav-item .count { display: none; }
}

/* ---------- Boutons et champs ---------- */
.btn { transition: background .2s, border-color .2s, color .2s, transform .12s, box-shadow .2s; }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn.primary:hover { box-shadow: 0 4px 18px rgba(229, 160, 13, .35); }
.btn .ic { transition: transform .3s var(--ease-spring); }
.btn:hover .ic { transform: scale(1.1); }
.seg button { transition: background .2s, color .2s; }
.input { transition: border-color .2s, box-shadow .2s; }
.input:focus, .search input:focus { box-shadow: 0 0 0 3px rgba(229, 160, 13, .18); }
.search input { transition: border-color .2s, box-shadow .2s; }
.type-pick button { transition: border-color .2s, background .2s, color .2s, transform .2s var(--ease-spring); }
.type-pick button:hover:not(:disabled) { transform: translateY(-2px); }
.type-pick button.on .ic { animation: bounce .45s var(--ease-spring); }

/* ---------- Fenêtres modales ---------- */
.modal-bg { animation: fade .2s ease both; }
.modal-bg .modal { animation: modal-in .32s var(--ease-out) both; }
.modal-bg.closing { animation: fade-out .18s ease both; }
.modal-bg.closing .modal { animation: modal-out .18s ease both; }
.browser .dir, .match, .list-row { transition: background .15s, transform .2s var(--ease-out); }
.browser .dir:hover { transform: translateX(3px); }
.browser > *, .match-list > * { animation: rise .3s var(--ease-out) both; }
.folder-chip { animation: pop-in .3s var(--ease-out) both; }

/* ---------- Menu utilisateur et notifications ---------- */
.dropdown { animation: drop-in .2s var(--ease-out) both; transform-origin: top right; }
.toast { animation: toast-in .35s var(--ease-spring) both; }
.toast.leaving { animation: toast-out .25s ease both; }

/* ---------- Lecteur ---------- */
.player { animation: fade .3s ease both; }
.player .popup { animation: popup-in .22s var(--ease-out) both; transform-origin: bottom right; }
.player .upnext { animation: slide-left .4s var(--ease-out) both; }
.player .resume { animation: modal-in-centered .35s var(--ease-out) both; }
.player .pbtn { transition: background .2s, transform .15s; }
.player .pbtn:active { transform: scale(.9); }
.player .pbtn .ic { transition: transform .25s var(--ease-spring); }
.player .pbtn:hover .ic { transform: scale(1.12); }
.empty > .ic { animation: float 3s ease-in-out infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes poster-in { from { opacity: 0; transform: translateY(20px) scale(.94) rotate(-1deg); } }
@keyframes backdrop-in { from { opacity: 0; transform: scale(1.08); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.96); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes modal-in-centered { from { opacity: 0; transform: translate(-50%, -46%) scale(.95); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-6px) scale(.96); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }
@keyframes popup-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes slide-left { from { opacity: 0; transform: translateX(30px); } }
@keyframes bounce { 40% { transform: scale(1.25); } }
@keyframes float { 50% { transform: translateY(-6px); } }

/* Respecte le réglage Windows « Afficher les animations » */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0s !important; transition-duration: .01ms !important;
  }
}
