/**
 * Passage d'un dossier a l'autre (js/dossier-transition.js) - Whisp It
 * Entre deux dossiers : la feuille sort de la chemise (regles html.vt-dossier-sheet, en bas du fichier).
 * Vers ou depuis la liste des dossiers : l'ancienne page et la nouvelle glissent ensemble, cote a cote.
 * Aucun fondu. Chaque page reste coupee au bord de son cadre, pour ne pas passer par-dessus la liste
 * sur ordinateur. Rien d'autre ne bouge ni ne s'efface.
 */

/* Les barres de l'application restent dans la page pendant le mouvement (sinon dessinees par-dessus le rapport) */
html.vt-dossier .top-navbar,
html.vt-dossier .bottom-nav-bar {
  view-transition-name: none !important;
}

/* Pas de double animation : l'entree de secours est coupee pendant le defilement */
html.vt-dossier .dossiers-root .dossier-report,
html.vt-dossier .dossiers-root .dossiers-home {
  animation: none !important;
}

/* Pendant le defilement, les touches passent a la page (sinon un appui rapide sur une chemise etait perdu) */
html.vt-dossier::view-transition {
  pointer-events: none;
}

/* Ancienne et nouvelle page : chacune reste a sa place verticale, seule leur position horizontale bouge */
html.vt-dossier::view-transition-group(dossier-out),
html.vt-dossier::view-transition-group(dossier-in) {
  animation: none;
}

html.vt-dossier::view-transition-old(dossier-out),
html.vt-dossier::view-transition-new(dossier-in) {
  mix-blend-mode: normal;
  height: auto;
  animation-duration: 0.42s;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
  animation-fill-mode: both;
}

/* La page qui part passe au-dessus de la barre et de la rangee : elle les decouvre en s'en allant
 * (cas du bouton "Dossier suivant" en bas de page, ou l'ancienne page occupe tout l'ecran) */
html.vt-dossier::view-transition-group(dossier-out) {
  z-index: 1;
}

/* Avancer : tout part vers la gauche */
html.vt-dossier-forward::view-transition-old(dossier-out) { animation-name: dossier-push-out-left; }
html.vt-dossier-forward::view-transition-new(dossier-in) { animation-name: dossier-push-in-right; }

/* Reculer : tout part vers la droite */
html.vt-dossier-back::view-transition-old(dossier-out) { animation-name: dossier-push-out-right; }
html.vt-dossier-back::view-transition-new(dossier-in) { animation-name: dossier-push-in-left; }

/* La decoupe suit le deplacement : chaque page disparait exactement au bord de son cadre */
@keyframes dossier-push-out-left {
  from { transform: translateX(0); clip-path: inset(0 0 0 0); }
  to { transform: translateX(-100%); clip-path: inset(0 0 0 100%); }
}

@keyframes dossier-push-in-right {
  from { transform: translateX(100%); clip-path: inset(0 100% 0 0); }
  to { transform: translateX(0); clip-path: inset(0 0 0 0); }
}

@keyframes dossier-push-out-right {
  from { transform: translateX(0); clip-path: inset(0 0 0 0); }
  to { transform: translateX(100%); clip-path: inset(0 100% 0 0); }
}

@keyframes dossier-push-in-left {
  from { transform: translateX(-100%); clip-path: inset(0 0 0 100%); }
  to { transform: translateX(0); clip-path: inset(0 0 0 0); }
}

/* Un seul mouvement : le reste de l'ecran (en-tete du rapport, fond) passe d'un coup a son nouvel etat, sans fondu.
 * L'ancienne image de la page reste affichee dessous, immobile : rien ne peut se vider le temps du mouvement. */
html.vt-dossier::view-transition-old(root),
html.vt-dossier::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* Barre et rangee de chemises : posees a leur place d'un coup, sans fondu ni deplacement.
 * La rangee affichee est la vraie (image en direct) : la chemise ouverte y sort du rang toute seule. */
html.vt-dossier::view-transition-group(dossier-top),
html.vt-dossier::view-transition-group(dossier-shelf) {
  animation: none;
}

html.vt-dossier::view-transition-old(dossier-top),
html.vt-dossier::view-transition-old(dossier-shelf) {
  display: none;
}

html.vt-dossier::view-transition-new(dossier-top),
html.vt-dossier::view-transition-new(dossier-shelf) {
  animation: none;
  mix-blend-mode: normal;
}

/* Le temps de reprendre l'aspect de l'ancienne rangee, les chemises ne s'animent pas */
.dossier-shelf-still,
.dossier-shelf-still * {
  transition: none !important;
}

/* ---------- Entre deux dossiers : la feuille sort de la chemise (choix 1 de la demo du 15/11) ----------
 * L'ancienne page ne bouge pas ; la nouvelle descend de sous la rangee de chemises et la recouvre.
 * Les reperes --dossier-* sont poses par js/dossier-transition.js. */

/* Ancienne page : immobile, dessous, coupee au ras de la rangee */
html.vt-dossier-sheet::view-transition-group(dossier-out) {
  z-index: 0;
  clip-path: inset(var(--dossier-out-top, 0px) 0 0 0);
}

html.vt-dossier-sheet::view-transition-old(dossier-out) {
  animation: none;
}

/* Nouvelle page : dessus, sur un fond plein pour cacher l'ancienne, coupee au ras de la rangee */
html.vt-dossier-sheet::view-transition-group(dossier-in) {
  z-index: 1;
  clip-path: inset(var(--dossier-in-top, 0px) 0 0 0);
}

html.vt-dossier-sheet::view-transition-new(dossier-in) {
  background: var(--dossier-page-bg, #ffffff);
  animation-name: dossier-sheet-in;
  animation-duration: 0.46s;
}

html.vt-dossier-sheet::view-transition-group(dossier-top),
html.vt-dossier-sheet::view-transition-group(dossier-shelf) {
  z-index: 2;
}

/* La feuille descend de 56 px pendant que son bord bas parcourt l'ecran */
@keyframes dossier-sheet-in {
  from {
    transform: translateY(-56px);
    clip-path: inset(0 0 calc(100% - var(--dossier-in-top, 0px) - 56px) 0);
  }
  to {
    transform: translateY(0);
    clip-path: inset(0 0 calc(100% - var(--dossier-in-top, 0px) - var(--dossier-view-h, 100vh) - 40px) 0);
  }
}

/* Le bouton flottant "+" est pose sur la page : sans cela, le fond plein de la feuille le cachait
 * pendant le mouvement (il disparaissait puis revenait). Il reste au-dessus, immobile, dans tous les cas. */
html.vt-dossier .speed-dial-wrapper {
  view-transition-name: dossier-fab;
}

html.vt-dossier::view-transition-group(dossier-fab) {
  z-index: 3;
  animation: none;
}

html.vt-dossier::view-transition-old(dossier-fab) {
  display: none;
}

html.vt-dossier::view-transition-new(dossier-fab) {
  animation: none;
  mix-blend-mode: normal;
}
