/* =================================================================
   EspaceVirtuel V2 — les briques d'ecran.
   Cahier des charges version 8, partie 5.
   Une seule feuille de style pour toute l'application.
   Ne jamais ajouter de reglage visuel dans l'application (5.6 point 4).
   ================================================================= */

/* ---------- 1. LES COULEURS (5.2) ---------- */
:root {
  /* La couleur de marque, provisoire, decidee le 13/09/2026 */
  --marque:          #2457F5;
  --marque-sombre:   #1B43C4;
  --marque-pale:     #E8EEFE;

  /* Les couleurs d'etat : chacune a TOUJOURS un mot a cote (principe 4) */
  --succes:          #12844B;
  --succes-pale:     #E3F5EC;
  --alerte:          #C92A2A;
  --alerte-pale:     #FDECEC;
  --attention:       #B35309;
  --attention-pale:  #FDF0E3;
  --pause:           #5A6B7D;
  --pause-pale:      #ECEFF3;

  /* Le fond et le texte : gris tres clair le jour */
  --fond:            #F4F5F7;
  --carte:           #FFFFFF;
  --bord:            #D8DCE3;
  --bord-fort:       #AEB6C2;
  --texte:           #11151C;
  --texte-doux:      #5A6472;
  --texte-eteint:    #8A93A1;
  --ombre:           0 1px 2px rgba(17,21,28,.06), 0 2px 8px rgba(17,21,28,.05);

  /* Les tailles de texte (5.2) — jamais en dessous de 14 px */
  --t-montant:  40px;
  --t-titre:    24px;
  --t-texte:    18px;
  --t-petit:    15px;
  --t-mini:     14px;

  --rayon:      12px;
  --rayon-petit: 8px;
  --touche-min: 48px;   /* la taille d'un pouce (principe 2) */
}

/* ---------- LE MODE SOMBRE (5.2 : de 20h a 3h) ----------
   Il s'active de trois facons :
   - automatiquement selon l'heure (briques.js pose data-theme="sombre")
   - selon le reglage du telephone ou de l'ordinateur
   - a la main, pour regarder les maquettes                          */
:root[data-theme="sombre"] {
  --marque:          #6C92FF;
  --marque-sombre:   #4B76F0;
  --marque-pale:     #1B2740;
  --succes:          #34C77B;
  --succes-pale:     #12271C;
  --alerte:          #FF6B6B;
  --alerte-pale:     #331617;
  --attention:       #F0A035;
  --attention-pale:  #2E2213;
  --pause:           #9AA7B6;
  --pause-pale:      #1E242C;
  --fond:            #0E1116;
  --carte:           #171C24;
  --bord:            #2A313C;
  --bord-fort:       #3E4756;
  --texte:           #F0F2F5;
  --texte-doux:      #A8B1BF;
  --texte-eteint:    #79828F;
  --ombre:           0 1px 2px rgba(0,0,0,.4), 0 2px 10px rgba(0,0,0,.3);
}

/* ---------- 2. LA BASE ---------- */
* { box-sizing: border-box; }

/* Un element marque "hidden" est TOUJOURS cache, meme si sa classe
   lui donne un display. Sans cette ligne, un message d'erreur
   s'affiche avant qu'il y ait la moindre erreur. */
[hidden] { display: none !important; }

body {
  margin: 0;
  /* Une seule police : celle du systeme (5.2) */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: var(--t-texte);
  line-height: 1.45;
  color: var(--texte);
  background: var(--fond);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Les chiffres alignes, pour les montants et les chronos (5.2) */
.ev-chiffres { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

h1 { font-size: var(--t-titre); margin: 0 0 8px; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: var(--t-texte); margin: 0 0 8px; font-weight: 700; }
p  { margin: 0 0 12px; }
.ev-doux   { color: var(--texte-doux); }
.ev-petit  { font-size: var(--t-petit); }
.ev-mini   { font-size: var(--t-mini); }

/* ---------- 3. LE CADRE D'ECRAN ----------
   Un ecran = une tache (principe 1). Pas de menu.                   */
.ev-ecran {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}
.ev-entete {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 10px;
  min-height: 56px;
}
/* Le logo, discret, en haut a gauche (5.2). Jamais de decoration "gaming". */
.ev-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-petit);
  font-weight: 700;
  color: var(--texte-doux);
  letter-spacing: .3px;
}
.ev-logo-pastille {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--marque);
  color: #fff;
  font-size: var(--t-mini);
  font-weight: 800;
  letter-spacing: -.5px;
  display: inline-grid;
  place-items: center;
}
.ev-corps  { flex: 1; padding-bottom: 16px; }
/* Un ecran qui ne pose QU'UNE question centre son contenu : pas de grand
   vide entre le titre et le bouton du bas. */
.ev-corps--centre { display: flex; flex-direction: column; justify-content: center; }
/* Le bouton principal est SEUL, en bas, pleine largeur (principe 2) */
.ev-pied {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--fond) 72%, transparent);
  padding: 12px 0 max(16px, env(safe-area-inset-bottom));
}

/* ---------- 4. BRIQUE : LE BOUTON (3 tailles, 4 etats) ---------- */
.ev-bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--touche-min);
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--rayon);
  font-family: inherit;
  font-size: var(--t-texte);
  font-weight: 600;
  color: #fff;
  background: var(--marque);
  cursor: pointer;
  user-select: none;
  transition: background .12s, transform .06s, opacity .12s;
}
/* Les 3 tailles, pas une de plus */
.ev-bouton--grand  { min-height: 64px; font-size: 22px; font-weight: 700; }
.ev-bouton--moyen  { min-height: var(--touche-min); }
.ev-bouton--petit  { min-height: var(--touche-min); width: auto; font-size: var(--t-petit); padding: 0 14px; }

/* Les 4 etats */
.ev-bouton:hover:not(:disabled)  { background: var(--marque-sombre); }         /* 1. survol */
.ev-bouton:active:not(:disabled) { transform: translateY(1px); }               /* 2. pression */
.ev-bouton:disabled,
.ev-bouton[aria-disabled="true"] {                                             /* 3. eteint */
  background: var(--bord);
  color: var(--texte-eteint);
  cursor: not-allowed;
}
.ev-bouton[data-encours="oui"] {                                               /* 4. en cours (5.5) */
  background: var(--marque-sombre);
  color: #fff;
  cursor: progress;
  pointer-events: none;
}
.ev-bouton[data-encours="oui"]::before {
  content: "";
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ev-tourne .7s linear infinite;
}
@keyframes ev-tourne { to { transform: rotate(360deg); } }

/* Les variantes de couleur */
.ev-bouton--vert   { background: var(--succes); }
.ev-bouton--vert:hover:not(:disabled) { filter: brightness(.92); }
.ev-bouton--rouge  { background: var(--alerte); }
.ev-bouton--rouge:hover:not(:disabled) { filter: brightness(.92); }
.ev-bouton--neutre {
  background: var(--carte);
  color: var(--texte);
  border-color: var(--bord-fort);
}
.ev-bouton--neutre:hover:not(:disabled) { background: var(--fond); }
.ev-bouton--fantome {
  background: transparent;
  color: var(--texte-doux);
  border-color: transparent;
  font-weight: 600;
}
.ev-bouton--fantome:hover:not(:disabled) { background: var(--marque-pale); color: var(--marque); }

/* ---------- 5. BRIQUE : LA CARTE DE POSTE (5.2) ---------- */
.ev-postes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}
.ev-poste {
  position: relative;
  text-align: left;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-left: 6px solid var(--bord-fort);
  border-radius: var(--rayon);
  padding: 12px 14px;
  min-height: 116px;
  box-shadow: var(--ombre);
  cursor: pointer;
  font-family: inherit;
  color: var(--texte);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ev-poste-nom     { font-size: var(--t-texte); font-weight: 700; }
.ev-poste-type    { font-size: var(--t-mini); color: var(--texte-doux); }
.ev-poste-bas     { margin-top: auto; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ev-poste-chrono  { font-size: 20px; font-weight: 700; }
.ev-poste-montant { font-size: 20px; font-weight: 700; }

/* Chaque etat a une COULEUR ET UN MOT (principe 4) */
.ev-poste[data-etat="libre"]      { border-left-color: var(--succes); }
.ev-poste[data-etat="occupe"]     { border-left-color: var(--marque); }
.ev-poste[data-etat="pause"]      { border-left-color: var(--attention); }
.ev-poste[data-etat="encaisser"]  { border-left-color: var(--alerte); animation: ev-respire 2.4s ease-in-out infinite; }
.ev-poste[data-etat="horsservice"]{
  border-left-color: var(--bord-fort);
  color: var(--texte-eteint);
  cursor: not-allowed;
  background-image: repeating-linear-gradient(45deg,
    transparent 0 9px, var(--pause-pale) 9px 18px);
}
/* "rouge qui clignote lentement" (5.2) — lent, jamais agressif */
@keyframes ev-respire {
  0%,100% { box-shadow: var(--ombre); }
  50%     { box-shadow: 0 0 0 3px var(--alerte-pale), var(--ombre); }
}
@media (prefers-reduced-motion: reduce) {
  .ev-poste[data-etat="encaisser"] { animation: none; box-shadow: 0 0 0 3px var(--alerte-pale); }
}

/* L'etiquette d'etat : le MOT, toujours present */
.ev-etat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-mini);
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  align-self: flex-start;
}
.ev-etat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ev-etat--libre      { color: var(--succes);    background: var(--succes-pale); }
.ev-etat--occupe     { color: var(--marque);    background: var(--marque-pale); }
.ev-etat--pause      { color: var(--attention); background: var(--attention-pale); }
.ev-etat--encaisser  { color: var(--alerte);    background: var(--alerte-pale); }
.ev-etat--horsservice{ color: var(--pause);     background: var(--pause-pale); }

/* ---------- 6. BRIQUE : LE GRAND MONTANT (principe 3) ---------- */
.ev-montant {
  font-size: var(--t-montant);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.ev-montant--geant  { font-size: 56px; }
.ev-montant--vert   { color: var(--succes); }
.ev-montant--rouge  { color: var(--alerte); }
.ev-montant-bloc {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 16px 18px;
  box-shadow: var(--ombre);
}
.ev-montant-titre { font-size: var(--t-mini); color: var(--texte-doux); font-weight: 700;
                    text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2px; }

/* ---------- 7. BRIQUE : LE CHRONO ---------- */
.ev-chrono {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
.ev-chrono--pause { color: var(--attention); }

/* ---------- 8. BRIQUE : LA BARRE D'ETAPES ("Etape 2 sur 5") ---------- */
.ev-etapes { margin: 4px 0 18px; }
.ev-etapes-texte {
  font-size: var(--t-mini);
  font-weight: 700;
  color: var(--texte-doux);
  margin-bottom: 6px;
  display: flex; justify-content: space-between; gap: 12px;
}
.ev-etapes-barre { display: flex; gap: 4px; }
.ev-etapes-barre span {
  flex: 1; height: 6px; border-radius: 3px; background: var(--bord);
}
.ev-etapes-barre span[data-faite="oui"] { background: var(--marque); }

/* ---------- 9. BRIQUE : LE CLAVIER DE BILLETS ET PIECES ----------
   Zero texte a lire pour encaisser (principe 5) : on tape sur des images. */
.ev-clavier { display: grid; gap: 10px; }
.ev-clavier-groupe { font-size: var(--t-mini); font-weight: 700; color: var(--texte-doux);
                     text-transform: uppercase; letter-spacing: .6px; margin: 6px 0 -2px; }
.ev-clavier-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }

.ev-coupure {
  position: relative;
  min-height: 72px;
  border: 1px solid var(--bord);
  border-radius: var(--rayon-petit);
  background: var(--carte);
  cursor: pointer;
  font-family: inherit;
  color: var(--texte);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  box-shadow: var(--ombre);
}
.ev-coupure:active { transform: translateY(1px); }
.ev-coupure-valeur { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ev-coupure-unite  { font-size: var(--t-mini); font-weight: 700; color: var(--texte-doux); letter-spacing: .5px; }
/* Un billet : un rectangle colore. Une piece : un rond. Reconnaissable sans lire. */
.ev-coupure--billet { border-top: 5px solid var(--ev-teinte, var(--marque)); }
.ev-coupure--piece  { border-radius: 999px; min-height: 80px; border-top: none;
                      box-shadow: inset 0 0 0 3px var(--ev-teinte, var(--bord-fort)), var(--ombre); }
/* Le compteur : combien de fois on a tape dessus */
.ev-coupure-compte {
  position: absolute;
  top: -7px; right: -7px;
  min-width: 26px; height: 26px;
  border-radius: 999px;
  background: var(--marque);
  color: #fff;
  font-size: var(--t-mini);
  font-weight: 800;
  display: none;
  align-items: center; justify-content: center;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}
.ev-coupure[data-compte]:not([data-compte="0"]) .ev-coupure-compte { display: flex; }
.ev-coupure[data-compte]:not([data-compte="0"]) { border-color: var(--marque); }

.ev-clavier-total {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 12px 14px; margin-top: 4px;
  background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon);
}

/* ---------- 10. BRIQUE : LA FICHE D'ALERTE ---------- */
.ev-alerte {
  display: flex;
  gap: 12px;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-left: 6px solid var(--alerte);
  border-radius: var(--rayon);
  padding: 14px;
  box-shadow: var(--ombre);
}
.ev-alerte--attention { border-left-color: var(--attention); }
.ev-alerte--info      { border-left-color: var(--marque); }
.ev-alerte--succes    { border-left-color: var(--succes); }
.ev-alerte-icone {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center; font-size: 18px; font-weight: 800;
  background: var(--alerte-pale); color: var(--alerte);
}
.ev-alerte--attention .ev-alerte-icone { background: var(--attention-pale); color: var(--attention); }
.ev-alerte--info      .ev-alerte-icone { background: var(--marque-pale);    color: var(--marque); }
.ev-alerte--succes    .ev-alerte-icone { background: var(--succes-pale);    color: var(--succes); }
.ev-alerte-titre { font-weight: 700; margin-bottom: 2px; }
.ev-alerte-quoifaire { font-size: var(--t-petit); color: var(--texte-doux); }
.ev-alerte-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- 11. BRIQUE : LA FENETRE DE CONFIRMATION ----------
   Une phrase, deux boutons (5.4 et 5.5).                            */
.ev-voile {
  position: fixed; inset: 0;
  background: rgba(9,12,17,.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}
.ev-voile[data-ouvert="oui"] { display: flex; }
@media (min-width: 560px) { .ev-voile { align-items: center; } }
.ev-fenetre {
  background: var(--carte);
  border-radius: 16px;
  padding: 22px 20px 18px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.ev-fenetre-phrase { font-size: 21px; font-weight: 700; margin-bottom: 18px; line-height: 1.35; }
.ev-fenetre-boutons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 12. BRIQUE : LE BANDEAU "CONNEXION PERDUE" (5.5) ---------- */
.ev-bandeau {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 80;
  background: var(--alerte);
  color: #fff;
  font-size: var(--t-petit);
  font-weight: 700;
  text-align: center;
  padding: 10px 16px;
  display: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.ev-bandeau[data-visible="oui"] { display: block; }
.ev-bandeau--attention { background: var(--attention); }

/* ---------- 13. BRIQUE : L'ENREGISTREUR AUDIO (2.15) ---------- */
.ev-audio {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 14px;
  box-shadow: var(--ombre);
}
.ev-audio-ligne { display: flex; align-items: center; gap: 12px; }
.ev-audio-micro {
  flex: 0 0 auto;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--alerte);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: grid; place-items: center;
}
.ev-audio-micro[data-enregistre="oui"] { animation: ev-pulse 1.4s ease-in-out infinite; }
@keyframes ev-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(201,42,42,.45); }
  50%     { box-shadow: 0 0 0 12px rgba(201,42,42,0); }
}
.ev-audio-duree { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ev-audio-onde { flex: 1; display: flex; align-items: center; gap: 3px; height: 30px; }
.ev-audio-onde i {
  flex: 1; background: var(--bord-fort); border-radius: 2px; height: 20%;
  transition: height .12s;
}

/* ---------- 14. PETITS ASSEMBLAGES REUTILISES ---------- */
.ev-carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 16px;
  box-shadow: var(--ombre);
}
.ev-champ { display: block; margin-bottom: 14px; }
.ev-champ-nom { display: block; font-size: var(--t-petit); font-weight: 700;
                color: var(--texte-doux); margin-bottom: 6px; }
.ev-champ input, .ev-champ textarea, .ev-champ select {
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: var(--t-texte);
  color: var(--texte);
  background: var(--carte);
  border: 1px solid var(--bord-fort);
  border-radius: var(--rayon-petit);
}
.ev-champ input:focus, .ev-champ textarea:focus {
  outline: 3px solid var(--marque-pale);
  border-color: var(--marque);
}
.ev-choix {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  min-height: 84px; padding: 14px 16px;
  background: var(--carte);
  border: 1px solid var(--bord-fort);
  border-radius: var(--rayon);
  font-family: inherit; font-size: var(--t-texte); color: var(--texte);
  cursor: pointer; box-shadow: var(--ombre); margin-bottom: 12px;
}
.ev-choix:hover  { border-color: var(--marque); background: var(--marque-pale); }
.ev-choix:disabled { opacity: .55; cursor: not-allowed; background: var(--fond); }
.ev-choix-icone {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px; font-weight: 800;
  background: var(--marque-pale); color: var(--marque);
}
.ev-choix-icone svg { width: 26px; height: 26px; stroke: currentColor;
  stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ev-choix-titre { font-weight: 700; }
.ev-choix-sous  { font-size: var(--t-petit); color: var(--texte-doux); }
.ev-choix-fleche { margin-left: auto; color: var(--texte-eteint); font-size: 22px; }

.ev-lignes { display: grid; gap: 1px; background: var(--bord); border: 1px solid var(--bord);
             border-radius: var(--rayon); overflow: hidden; }
.ev-ligne  { display: flex; justify-content: space-between; align-items: center;
             gap: 12px; padding: 13px 15px; background: var(--carte); }
.ev-ligne strong { font-variant-numeric: tabular-nums; }

.ev-pile  { display: grid; gap: 12px; }
.ev-pile--serree { gap: 8px; }
.ev-rangee { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 15. TELEPHONE : tout doit tenir en largeur ---------- */
@media (max-width: 420px) {
  :root { --t-montant: 36px; }
  .ev-montant--geant { font-size: 46px; }
  .ev-clavier-grille { grid-template-columns: repeat(3, 1fr); }
  .ev-postes { grid-template-columns: repeat(2, 1fr); }
}
