/* ============================================================================
   TicTask — Kit de démonstration · feuille partagée
   ----------------------------------------------------------------------------
   Toutes les démos publiées sous app.tictask.fr/demo/ partagent ce fichier.
   Il porte la charte des APPLICATIONS (kit/tokens.css), pas celle du site
   vitrine : une démo doit ressembler à un logiciel qu'on utilise huit heures
   par jour, pas à une page de vente.

   Deux couches :
     1. le CADRE de démonstration — barre du haut, rail d'étapes, narrateur,
        bouton rejouer. Commun à toutes les démos, jamais surchargé par elles ;
     2. les COMPOSANTS métier — blocs, boutons, états, tableaux, champs. Repris
        du vocabulaire de l'application réelle (mêmes noms de classes), pour que
        le rendu soit crédible et que le code se relise d'une démo à l'autre.

   Le mouvement n'utilise que transform et opacity. Tout est coupé en bloc par
   prefers-reduced-motion en fin de fichier.
   ========================================================================== */

/* ------------------------------------------------------------------ Base -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* `hidden` est un attribut, pas une suggestion. Sans cette ligne, le moindre
   `display: flex` ou `display: grid` posé sur un élément le rend visible malgré
   l'attribut — et l'on se retrouve avec des bandeaux vides à l'écran. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  font-family: var(--texte);
  font-size: var(--t-md);
  line-height: var(--interligne);
  color: var(--encre);
  background: var(--brume);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--titre);
  line-height: var(--interligne-serre);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--t-2xl); font-weight: 700; }
h2 { font-size: var(--t-xl); font-weight: 700; }
h3 { font-size: var(--t-lg); font-weight: 600; }

a { color: var(--bleu); text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; border-radius: var(--r-xs); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================================
   1 · LE CADRE DE DÉMONSTRATION
   ========================================================================== */

.demo {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* -- Barre du haut --------------------------------------------------------- */
.demo__barre {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-3);
  background: var(--bleu-nuit);
  color: var(--texte-nuit);
  position: sticky;
  top: 0;
  z-index: 30;
}

.demo__retour {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--texte-nuit-doux);
  font-size: var(--t-sm); font-weight: 500;
  padding: 5px 9px; border-radius: var(--r-sm);
  transition: background var(--vite) linear, color var(--vite) linear;
}
.demo__retour:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.demo__identite { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.demo__nom { font-family: var(--titre); font-size: var(--t-lg); font-weight: 700; color: #fff; }
.demo__metier {
  font-size: var(--t-xs); color: var(--texte-nuit-doux);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.demo__outils { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Étiquette permanente : on ne laisse jamais croire qu'il s'agit de vraies
   données ni d'un vrai envoi. */
.demo__mention {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--texte-nuit-doux);
  border: 1px solid var(--ligne-nuit);
  padding: 4px 9px; border-radius: var(--r-pill);
  white-space: nowrap;
}

.demo__bouton {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  font-size: var(--t-sm); font-weight: 600;
  color: var(--texte-nuit);
  border: 1px solid var(--ligne-nuit);
  border-radius: var(--r-md);
  transition: background var(--vite) linear, border-color var(--vite) linear;
}
.demo__bouton:hover { background: rgba(255, 255, 255, .10); border-color: var(--texte-nuit-doux); color: #fff; }
.demo__bouton[aria-pressed="true"] { background: var(--bleu); border-color: var(--bleu); color: #fff; }

/* -- Scène ----------------------------------------------------------------- */
.demo__scene {
  flex: 1 0 auto;
  padding: var(--sp-3);
  padding-bottom: 150px;          /* place pour le narrateur, qui flotte */
  max-width: var(--contenu-max);
  width: 100%;
  margin-inline: auto;
}

/* -- Narrateur ------------------------------------------------------------- */
/* Il flotte en bas : sur un écran d'ordinateur il ne mange pas la scène, et sur
   téléphone il reste à portée de pouce. */
.demo__narrateur {
  position: fixed;
  left: 50%;
  bottom: var(--sp-2);
  transform: translateX(-50%);
  z-index: 40;
  width: min(760px, calc(100% - var(--sp-3)));
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 13px var(--sp-2) 13px var(--sp-3);
  background: var(--blanc);
  border-radius: var(--r-xl);
  box-shadow: var(--ombre-l);
}

.demo__rail { display: flex; gap: 5px; flex: 0 0 auto; }
.demo__cran {
  width: 22px; height: 4px;
  border-radius: var(--r-pill);
  background: var(--ligne);
  transition: background var(--moyen) linear, width var(--moyen) var(--sortie);
}
.demo__cran.est-fait { background: var(--bleu-vif); }
.demo__cran.est-courant { background: var(--bleu); width: 34px; }

.demo__propos { flex: 1 1 auto; min-width: 0; }
.demo__etape {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--acier);
}
.demo__consigne { font-size: var(--t-lg); font-weight: 500; line-height: 1.35; }
.demo__consigne strong { font-weight: 700; color: var(--bleu-fonce); }

.demo__suite { flex: 0 0 auto; }

/* Le bouton d'avancement est toujours actif, et il respire pour appeler le
   clic. Un bouton grisé qui dit « À vous » sans dire où cliquer perd le
   visiteur en dix secondes. */
.demo__avancer {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 17px;
  font-size: var(--t-md); font-weight: 600;
  border-radius: var(--r-md);
  background: var(--brume); color: var(--acier);
  transition: background var(--vite) linear, color var(--vite) linear;
  cursor: default;
}
.demo__avancer.est-pret {
  background: var(--bleu); color: var(--blanc);
  cursor: pointer;
  animation: kit-invite 2.6s var(--sortie) infinite;
}
.demo__avancer.est-pret:hover { background: var(--bleu-fonce); animation: none; box-shadow: var(--ombre-bleu); }
.demo__avancer[disabled] { animation: none; opacity: .7; cursor: progress; }

@keyframes kit-invite {
  0%, 100% { box-shadow: 0 0 0 0 rgba(44, 102, 224, .45); }
  60%      { box-shadow: 0 0 0 11px rgba(44, 102, 224, 0); }
}

/* -- Projecteur ------------------------------------------------------------ */
/* Désigne l'endroit où le visiteur doit agir. Posé par le moteur à partir du
   champ `vise` de l'acte, retiré dès que le geste est fait. */
.kit-vise {
  position: relative;
  z-index: 5;
  border-radius: var(--r-lg);
  animation: kit-vise 2s var(--sortie) infinite;
}
@keyframes kit-vise {
  0%, 100% { box-shadow: 0 0 0 3px rgba(44, 102, 224, .70), 0 0 0 9px rgba(44, 102, 224, .12); }
  55%      { box-shadow: 0 0 0 3px rgba(44, 102, 224, 1),   0 0 0 18px rgba(44, 102, 224, 0); }
}

/* Fin de parcours */
.demo__fin { display: flex; align-items: center; gap: 10px; }

/* ============================================================================
   2 · COMPOSANTS MÉTIER — vocabulaire de l'application réelle
   ========================================================================== */

.bloc {
  background: var(--blanc);
  border-radius: var(--r-lg);
  box-shadow: var(--ombre-m);
  overflow: hidden;
}
.bloc__entete {
  display: flex; align-items: baseline; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2) 13px;
}
.bloc__entete h2 { flex: 1 1 auto; min-width: 0; font-size: var(--t-lg); font-weight: 600; }
.bloc__lien { flex: 0 0 auto; font-size: var(--t-sm); font-weight: 500; color: var(--ardoise); }
.bloc__corps { padding: 0 var(--sp-2) var(--sp-2); }

.grille { display: grid; gap: var(--sp-2); }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  font-family: var(--texte); font-size: var(--t-md); font-weight: 500;
  border-radius: var(--r-md); border: 1px solid transparent;
  color: var(--encre); white-space: nowrap;
  transition: background var(--vite) linear, border-color var(--vite) linear,
              box-shadow var(--moyen) var(--sortie), transform var(--vite) linear;
}
.bouton:active { transform: translateY(1px); }
.bouton--primaire { background: var(--bleu); color: var(--blanc); font-weight: 600; box-shadow: var(--ombre-bleu); }
.bouton--primaire:hover { background: var(--bleu-fonce); box-shadow: var(--ombre-l); }
.bouton--secondaire { border-color: var(--ligne); background: var(--blanc); box-shadow: var(--ombre-s); }
.bouton--secondaire:hover { background: var(--voile); border-color: var(--acier); }
.bouton--discret { color: var(--ardoise); padding: 7px 9px; }
.bouton--discret:hover { background: var(--brume); }
.bouton[disabled] { opacity: .45; cursor: not-allowed; }

.etat {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  font-size: var(--t-xs); font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-pill);
  white-space: nowrap;
}
.etat--neutre    { background: var(--brume);          color: var(--ardoise); }
.etat--info      { background: var(--bleu-ciel);      color: var(--bleu-fonce); }
.etat--valide    { background: var(--valide-fond);    color: var(--valide); }
.etat--attention { background: var(--attention-fond); color: var(--attention); }
.etat--alerte    { background: var(--alerte-fond);    color: var(--alerte); }

.champ {
  display: block; width: 100%;
  padding: 9px 11px;
  background: var(--blanc);
  border: 1px solid var(--ligne);
  border-radius: var(--r-sm);
  font-size: var(--t-md);
  transition: border-color var(--vite) linear, box-shadow var(--vite) linear;
}
.champ:focus { outline: none; border-color: var(--bleu); box-shadow: var(--ombre-focus); }
.champ::placeholder { color: var(--acier); }

.etiquette {
  display: block;
  font-size: var(--t-xs); font-weight: 600;
  color: var(--ardoise);
  margin-bottom: 5px;
}

.tableau { width: 100%; border-collapse: collapse; font-size: var(--t-md); }
.tableau th {
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--acier);
  padding: 0 12px 9px;
  white-space: nowrap;
}
.tableau td { padding: 11px 12px; vertical-align: middle; border-top: 1px solid var(--ligne); }
.tableau .chiffre { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

.bandeau {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: var(--t-md); font-weight: 500;
}
.bandeau--info      { background: var(--bleu-ciel);      color: var(--bleu-fonce); }
.bandeau--valide    { background: var(--valide-fond);    color: var(--valide); }
.bandeau--attention { background: var(--attention-fond); color: var(--attention); }
.bandeau--alerte    { background: var(--alerte-fond);    color: var(--alerte); }

/* ============================================================================
   3 · UTILITAIRES D'ANIMATION partagés par les démos
   ========================================================================== */

/* Une ligne qui vient d'apparaître */
@keyframes kit-entre {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: none; }
}
.kit-entre { animation: kit-entre .4s var(--sortie) both; }

/* Une ligne qui s'en va vers la gauche (un message rangé, une facture retirée) */
@keyframes kit-part {
  to { opacity: 0; transform: translate3d(-26px, 0, 0); }
}
.kit-part { animation: kit-part .45s var(--sortie) both; }

/* Un élément qu'on veut faire remarquer sans le déplacer */
@keyframes kit-signale {
  0%, 100% { box-shadow: 0 0 0 0 rgba(44, 102, 224, 0); }
  35%      { box-shadow: 0 0 0 4px rgba(44, 102, 224, .30); }
}
.kit-signale { animation: kit-signale 1.1s var(--sortie) 2; }

/* Pastille qui bat : quelque chose tourne en fond */
@keyframes kit-pouls {
  0%   { transform: scale(1);   opacity: .5; }
  70%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}
.kit-pouls { position: relative; }
.kit-pouls::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: currentColor;
  animation: kit-pouls 2.4s var(--sortie) infinite;
}

/* ============================================================================
   4 · RESPONSIVE
   ========================================================================== */
@media (max-width: 720px) {
  /* La barre haute ne tient pas sur une ligne : lien de retour, mention et deux
     boutons dépassaient de 42 px sur un téléphone de 390. On l'enroule plutôt
     que de sacrifier la mention « Démonstration », qui est un garde-fou. */
  .demo__barre { flex-wrap: wrap; row-gap: 8px; padding: 9px var(--sp-2); }
  .demo__identite { order: 3; flex-basis: 100%; }
  .demo__outils { flex-wrap: wrap; justify-content: flex-end; }
  .demo__nom { font-size: var(--t-md); }
  .demo__bouton { padding: 6px 10px; }

  .demo__scene { padding: var(--sp-2); padding-bottom: 175px; }
  .demo__metier { display: none; }
  .demo__narrateur { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .demo__propos { order: 2; flex-basis: 100%; }
  .demo__rail { order: 1; }
  .demo__suite { order: 3; margin-left: auto; }
  .demo__consigne { font-size: var(--t-md); }
}

/* ============================================================================
   5 · MOUVEMENT RÉDUIT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .kit-entre, .kit-part, .kit-signale, .kit-pouls::after,
  .demo__avancer.est-pret { animation: none; }
  /* Le projecteur ne bat plus, mais il DOIT rester visible : c'est lui qui dit
     où cliquer. On le fige sur son état haut. */
  .kit-vise { animation: none; box-shadow: 0 0 0 3px var(--bleu), 0 0 0 9px rgba(44, 102, 224, .12); }
  .demo__avancer.est-pret { box-shadow: var(--ombre-bleu); }
  .kit-part { opacity: 0; }
  * { transition-duration: 1ms !important; }
}

/* Curseur d'écriture, posé par Kit.ecrire(). Vit dans le kit depuis que
   l'écriture progressive y a été remontée. */
.curseur {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--bleu);
  vertical-align: -2px;
  animation: kit-curseur .9s steps(2) infinite;
}
@keyframes kit-curseur { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
