/* Mouvement de l'interface : commun au site public et aux trois espaces connectés (entreprise, administrateur, payeur).
   Règles suivies partout :
   - on n'anime que transform et opacity (jamais largeur, hauteur ou position) : fluide même sur un petit téléphone ;
   - un retour au clic dure 60 à 200 ms, une entrée 250 à 400 ms, toujours en décélération, jamais en rebond ;
   - une animation dit quelque chose (où l'on va, ce qui a changé, ce qui charge), sinon elle n'existe pas ;
   - « réduire les animations » du système : les déplacements disparaissent, les fondus et les états de chargement restent. */

:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --ease-move: cubic-bezier(.4, 0, .2, 1);
}

/* ── D'une page à l'autre : le repère du menu glisse vers la nouvelle page, le logo suit s'il change de place ──
   Géré par le navigateur entre deux pages du site (sans script). Seuls ces deux éléments participent :
   le reste de la page est remplacé d'un coup et reste cliquable tout de suite, même si l'on enchaîne les clics.
   Là où ce n'est pas pris en charge, la page s'affiche simplement comme avant. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  :root { view-transition-name: none; }
  .side a.on { view-transition-name: ui-nav-on; }
  .site-head .brand, .topbar .brand, .docs-top .brand, .side .brand { view-transition-name: ui-brand; }
  ::view-transition { pointer-events: none; }
  ::view-transition-group(ui-nav-on), ::view-transition-group(ui-brand) { animation-duration: .24s; animation-timing-function: var(--ease-out); }
  ::view-transition-old(ui-nav-on), ::view-transition-new(ui-nav-on), ::view-transition-old(ui-brand), ::view-transition-new(ui-brand) { animation-duration: .16s; }
}

/* ── Arrivée du contenu : les blocs de la page se posent l'un après l'autre ──
   « backwards » seulement : une fois posée, la page ne garde aucune trace de l'animation
   (pas de contexte d'empilement qui gênerait un menu déroulant). */
@keyframes ui-rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes ui-fade { from { opacity: 0; } }
@keyframes ui-drop { from { opacity: 0; transform: translateY(-8px); } }
@keyframes ui-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: no-preference) {
  body.with-side main > *, body.no-side main > * { animation: ui-rise .38s var(--ease-out) backwards; }
  body.with-side main > :nth-child(2), body.no-side main > :nth-child(2) { animation-delay: 45ms; }
  body.with-side main > :nth-child(3), body.no-side main > :nth-child(3) { animation-delay: 90ms; }
  body.with-side main > :nth-child(4), body.no-side main > :nth-child(4) { animation-delay: 135ms; }
  body.with-side main > :nth-child(5), body.no-side main > :nth-child(5) { animation-delay: 180ms; }
  body.with-side main > :nth-child(n+6), body.no-side main > :nth-child(n+6) { animation-delay: 220ms; }

  /* Grilles de cartes : chaque carte suit la précédente. */
  .stats > *, .metrics > *, .addons > *, .guides-list > * { animation: ui-rise .4s var(--ease-out) backwards; }
  .stats > :nth-child(1), .metrics > :nth-child(1), .addons > :nth-child(1), .guides-list > :nth-child(1) { animation-delay: 60ms; }
  .stats > :nth-child(2), .metrics > :nth-child(2), .addons > :nth-child(2), .guides-list > :nth-child(2) { animation-delay: 105ms; }
  .stats > :nth-child(3), .metrics > :nth-child(3), .addons > :nth-child(3), .guides-list > :nth-child(3) { animation-delay: 150ms; }
  .stats > :nth-child(4), .metrics > :nth-child(4), .addons > :nth-child(4), .guides-list > :nth-child(4) { animation-delay: 195ms; }
  .stats > :nth-child(5), .metrics > :nth-child(5), .addons > :nth-child(5) { animation-delay: 240ms; }
  .stats > :nth-child(n+6), .metrics > :nth-child(n+6), .addons > :nth-child(n+6) { animation-delay: 285ms; }

  /* Tableaux : les premières lignes apparaissent en cascade, en fondu seulement. */
  tbody tr:nth-child(-n+12) { animation: ui-fade .28s ease-out backwards; }
  tbody tr:nth-child(1) { animation-delay: 80ms; } tbody tr:nth-child(2) { animation-delay: 100ms; }
  tbody tr:nth-child(3) { animation-delay: 120ms; } tbody tr:nth-child(4) { animation-delay: 140ms; }
  tbody tr:nth-child(5) { animation-delay: 160ms; } tbody tr:nth-child(6) { animation-delay: 180ms; }
  tbody tr:nth-child(7) { animation-delay: 200ms; } tbody tr:nth-child(8) { animation-delay: 220ms; }
  tbody tr:nth-child(9) { animation-delay: 240ms; } tbody tr:nth-child(10) { animation-delay: 260ms; }
  tbody tr:nth-child(11) { animation-delay: 280ms; } tbody tr:nth-child(12) { animation-delay: 300ms; }

  /* Un message (enregistré, erreur) descend du haut : on le remarque sans qu'il clignote. */
  .flash { animation: ui-drop .42s var(--ease-out) backwards; animation-delay: 120ms; }
}

/* ── Boutons : réponse immédiate sous le doigt ── */
.btn { transition: background-color .12s, border-color .12s, box-shadow .12s, color .12s, transform .16s var(--ease-out); }
.btn:active:not([disabled]) { transform: scale(.97); transition-duration: .06s; }
.linklike, .nav a, .side-foot a, td, .side-stat, .guides-list a { transition: background-color .14s, color .14s, border-color .14s; }

/* Envoi en cours : le libellé laisse place à un indicateur, le bouton garde sa taille (voir app.js). */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: ui-spin .7s linear infinite; }
.btn.ghost.is-loading::after, .btn.danger.is-loading::after { border-color: rgba(27, 33, 48, .18); border-top-color: var(--ink-2); }

/* ── Menu de gauche : l'icône avance d'un rien au survol ── */
.nav a .ico, .side-foot a .ico { transition: transform .2s var(--ease-out); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .nav a:hover .ico, .side-foot a:hover .ico { transform: translateX(2px); }
}

/* ── Cartes de chiffres : un halo discret suit le pointeur (déplacé par transform, voir app.js) ── */
.stat, .card.metric { position: relative; overflow: hidden; }
.stat > *, .card.metric > * { position: relative; }
.stat::before, .card.metric::before { content: ""; position: absolute; left: -170px; top: -170px; width: 340px; height: 340px; border-radius: 50%; pointer-events: none; opacity: 0; background: radial-gradient(closest-side, rgba(81, 70, 229, .11), rgba(81, 70, 229, 0)); transform: translate3d(var(--mx, 0px), var(--my, 0px), 0); transition: opacity .25s; }
.stat.main::before { background: radial-gradient(closest-side, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0)); }
@media (hover: hover) { .stat.lit::before, .card.metric.lit::before { opacity: 1; } }
/* Un chiffre qui vient de changer depuis votre dernier passage se signale une fois. */
.count-up { font-variant-numeric: tabular-nums; }

/* ── Panneaux qui s'ouvrent : menus, zones repliées ── */
.menu-panel { transform-origin: top right; transition: opacity .16s ease-out, transform .22s var(--ease-out); background: rgba(255, 255, 255, .88); -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .menu-panel { background: #fff; } }
@media (prefers-reduced-transparency: reduce) { .menu-panel { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; } }
body:not(.site) details[open] > :not(summary) { transition: opacity .2s ease-out, transform .26s var(--ease-out); }
@media (prefers-reduced-motion: no-preference) {
  @starting-style {
    details.menu[open] > .menu-panel { opacity: 0; transform: translateY(-6px) scale(.98); }
    body:not(.site) details[open] > :not(summary) { opacity: 0; transform: translateY(-5px); }
  }
}
details.edit > summary::before, details.menu > summary::after { transition: transform .2s var(--ease-out); }

/* ── Graphiques : tracé et barres animés par dashboard.js ; l'info-bulle suit sans à-coup ── */
.chart-tip { transition: left .12s var(--ease-move), opacity .12s; }
.chart svg [data-i] { transition: opacity .12s; }

/* ── Pages publiques : cartes des guides ── */
.guides-list a { position: relative; transition: transform .22s var(--ease-out), border-color .14s; }
.guides-list a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 14px 34px rgba(27, 33, 48, .10), 0 2px 6px rgba(27, 33, 48, .05); opacity: 0; transition: opacity .22s; pointer-events: none; }
@media (hover: hover) {
  .guides-list a:hover { box-shadow: none; }
  .guides-list a:hover::after { opacity: 1; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) { .guides-list a:hover { transform: translateY(-3px); } }

/* ── Animations réduites (réglage du système) : plus aucun déplacement, les fondus restent ── */
@media (prefers-reduced-motion: reduce) {
  .btn:active:not([disabled]) { transform: none; }
  .menu-panel, body:not(.site) details[open] > :not(summary) { transition: opacity .15s ease-out; }
  .stat::before, .card.metric::before { display: none; }
  .chart-tip { transition: opacity .12s; }
}
