/*
 * Confort d'usage commun aux outils (commun/ux/, recopié par scripts/sync-ux.sh : ne pas modifier
 * les copies). Couleurs par variables de l'outil quand elles existent ; un outil peut fixer
 * --mgr-ux-accent (maillots : vert du club). Rien n'est animé en mouvement réduit.
 */
:root {
  --mgr-ux-accent: var(--accent, #006666);
  --mgr-ux-fond: var(--bg, #ffffff);
  --mgr-ux-texte: var(--ink, #171a1a);
  --mgr-ux-discret: var(--muted, #626968);
  --mgr-ux-filet: var(--line, #e6e8e7);
  --mgr-ux-filet-fort: var(--line-strong, #d4d8d6);
  --mgr-ux-doux: var(--soft, #f6f7f6);
  --mgr-ux-courbe: cubic-bezier(0.23, 1, 0.32, 1);
}

/* --- Typographie : titres équilibrés, chiffres à largeur fixe ----------------------------- */
:where(h1, h2, h3, h4, h5, h6) { text-wrap: balance; }
:where(p, li, dd, figcaption) { text-wrap: pretty; }
:where(.nombre, .nombre-g, .prix, .credits, .montant, .chiffre, .compte, time, td.num, [data-chiffre], .stat dd, .ligne__date) { font-variant-numeric: tabular-nums; }

/* --- Transitions entre les pages (navigateurs qui les connaissent) ------------------------ */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 160ms var(--mgr-ux-courbe) both mgr-ux-sortie; }
::view-transition-new(root) { animation: 220ms var(--mgr-ux-courbe) both mgr-ux-entree; }
@keyframes mgr-ux-sortie { to { opacity: 0; } }
@keyframes mgr-ux-entree { from { opacity: 0; } }
/* la barre, l'en-tête et les onglets du bas ne bougent pas */
:where(aside.barre) { view-transition-name: mgr-barre; }
:where(header.haut, header.entete) { view-transition-name: mgr-entete; }
:where(nav.onglets-bas) { view-transition-name: mgr-onglets; }
::view-transition-group(mgr-barre), ::view-transition-group(mgr-entete), ::view-transition-group(mgr-onglets) { animation: none; }
::view-transition-old(mgr-barre), ::view-transition-old(mgr-entete), ::view-transition-old(mgr-onglets) { display: none; }
::view-transition-new(mgr-barre), ::view-transition-new(mgr-entete), ::view-transition-new(mgr-onglets) { animation: none; }

/* --- Attente : le contenu respire (opacité seule) ------------------------------------------ */
html.mgr-attente :where(main, #main, #contenu) { animation: mgr-ux-respire 1.2s ease-in-out infinite alternate; }
@keyframes mgr-ux-respire { from { opacity: 1; } to { opacity: .55; } }

/* --- Visite guidée --------------------------------------------------------------------------- */
.mgr-visite { position: fixed; inset: 0; z-index: 1000; }
.mgr-visite__zone {
  position: fixed; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(23, 26, 26, .6), 0 0 0 2px #ffffff inset;
  transition: top 260ms var(--mgr-ux-courbe), left 260ms var(--mgr-ux-courbe), width 260ms var(--mgr-ux-courbe), height 260ms var(--mgr-ux-courbe);
}
.mgr-visite__bulle {
  position: fixed; box-sizing: border-box; background: var(--mgr-ux-fond); color: var(--mgr-ux-texte);
  border: 1px solid var(--mgr-ux-filet); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(23, 26, 26, .06), 0 12px 32px rgba(23, 26, 26, .16);
  display: flex; flex-direction: column; gap: 8px; font-family: inherit;
  animation: mgr-ux-fondu 200ms var(--mgr-ux-courbe);
}
.mgr-visite__etape { margin: 0; font-size: 12px; color: var(--mgr-ux-discret); font-variant-numeric: tabular-nums; }
.mgr-visite__titre { margin: 0; font-size: 18px; font-weight: 600; font-stretch: 112%; letter-spacing: -.01em; line-height: 1.25; }
.mgr-visite__texte { margin: 0; font-size: 14px; line-height: 1.5; }
.mgr-visite__actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.mgr-visite__vide { flex: 1; }
.mgr-visite__passer { background: none; border: 0; padding: 8px 0; white-space: nowrap; font: inherit; font-size: 14px; color: var(--mgr-ux-discret); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.mgr-visite__bouton {
  min-height: 40px; padding: 0 14px; border-radius: 6px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  background: var(--mgr-ux-fond); color: var(--mgr-ux-texte); border: 1px solid var(--mgr-ux-filet-fort);
}
.mgr-visite__bouton--principal { background: var(--mgr-ux-accent); border-color: var(--mgr-ux-accent); color: #ffffff; }
.mgr-visite__bouton:active { transform: scale(.97); }
.mgr-visite button:focus-visible { outline: 2px solid var(--mgr-ux-accent); outline-offset: 2px; }
@keyframes mgr-ux-fondu { from { opacity: 0; transform: translateY(4px); } }

/* --- Palette « Aller à… » ---------------------------------------------------------------- */
.mgr-palette {
  width: min(640px, calc(100vw - 32px)); max-height: min(70dvh, 560px); margin: 10dvh auto auto; padding: 0;
  border: 1px solid var(--mgr-ux-filet); border-radius: 12px; background: var(--mgr-ux-fond); color: var(--mgr-ux-texte);
  box-shadow: 0 1px 2px rgba(23, 26, 26, .06), 0 16px 40px rgba(23, 26, 26, .18); overflow: hidden; font-family: inherit;
}
.mgr-palette[open] { display: flex; flex-direction: column; animation: mgr-ux-fondu 200ms var(--mgr-ux-courbe); }
.mgr-palette::backdrop { background: rgba(23, 26, 26, .56); }
.mgr-palette__champ { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--mgr-ux-filet); }
.mgr-palette__champ input { flex: 1; min-width: 0; min-height: 44px; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; font-size: 17px; padding: 0; }
.mgr-palette__champ input::-webkit-search-cancel-button { display: none; }
.mgr-palette__fermer { min-height: 36px; padding: 0 12px; border: 1px solid var(--mgr-ux-filet-fort); border-radius: 6px; background: var(--mgr-ux-fond); color: var(--mgr-ux-texte); font: inherit; font-size: 14px; cursor: pointer; }
.mgr-palette__liste { list-style: none; margin: 0; padding: 4px 8px 8px; overflow-y: auto; overscroll-behavior: contain; }
.mgr-palette__liste ul { list-style: none; margin: 0; padding: 0; }
.mgr-palette__titre { margin: 12px 8px 4px; font-size: 13px; color: var(--mgr-ux-discret); }
.mgr-palette__option { display: flex; align-items: baseline; gap: 12px; min-height: 44px; padding: 10px 8px; border-radius: 8px; cursor: pointer; box-sizing: border-box; }
.mgr-palette__option[aria-selected="true"] { background: var(--mgr-ux-doux); }
.mgr-palette__nom { font-weight: 500; }
.mgr-palette__aide-ligne { font-size: 14px; color: var(--mgr-ux-discret); }
.mgr-palette__etat:empty { display: none; }
.mgr-palette__etat { margin: 8px 16px; color: var(--mgr-ux-discret); font-size: 14px; }
.mgr-palette__aide { margin: 0; padding: 10px 16px; border-top: 1px solid var(--mgr-ux-filet); font-size: 13px; color: var(--mgr-ux-discret); }
@media (max-width: 600px) {
  .mgr-palette { margin-top: max(12px, env(safe-area-inset-top)); max-height: calc(100dvh - 24px); }
  .mgr-palette__aide { display: none; }
}
/* Boutons « Visite guidée » et « Aller à… » : montrés par le script seulement. */
[data-visite-lancer][hidden], [data-palette-ouvrir][hidden] { display: none !important; }
[data-palette-ouvrir] kbd { font: inherit; font-size: 12px; color: var(--mgr-ux-discret); border: 1px solid var(--mgr-ux-filet-fort); border-radius: 4px; padding: 0 4px; margin-left: 4px; white-space: nowrap; }
/* L'astuce « Ctrl K » ne sert qu'à la souris et au clavier. */
@media (pointer: coarse) { .mgr-souris-seule { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  .mgr-visite__zone { transition: none; }
  .mgr-visite__bulle, .mgr-palette[open] { animation: none; }
  html.mgr-attente :where(main, #main, #contenu) { animation: none; opacity: .7; }
  @view-transition { navigation: none; }
}
