/* ════════════════════════════════════════════════════════════════════════
   L'ANNEAU DE CREDITS — L'INDICATEUR STANDARD DE TOUT NETAIX
   Decision de Manu du 2026-11-03.

   « L'indicateur de credits standard de tout Netaix = un ANNEAU autour de
   l'avatar en bas du rail, qui se vide avec les credits restants. »

   UN SEUL FICHIER POUR LES TROIS SURFACES (l'Assistant `app.html`, la fenetre
   « Maitriser l'IA », le lanceur d'applications), et c'est tout le point de
   l'harmonisation : trois copies auraient diverge au premier ajustement, comme
   les trois rails de panneaux l'ont fait pendant trois mois.

   ── CE QUE L'ANNEAU DIT, ET A QUEL PRIX ──────────────────────────────────
   Trois etats, portes par `data-etat` sur `.nx-anneau` :
     * `normal`  — l'arc en accent, rien d'autre ;
     * `bas`     — moins de 20 % du plafond restant : arc OCRE + pastille ocre ;
     * `epuise`  — plus rien : le cercle entier passe en ROUGE + pastille rouge.
   PAS DE `data-etat` = PAS D'ANNEAU : l'avatar reste nu. C'est le cas d'un
   espace SANS PLAFOND (`credits_total` nul — compte proprietaire de la
   plateforme, ou allocation illimitee). Un anneau plein a 100 % y aurait
   annonce un solde qui n'existe pas.

   LA COULEUR N'EST JAMAIS SEULE (regle du depot) : la pastille double l'ocre
   et le rouge pour qui ne distingue pas les teintes, et l'infobulle comme
   l'`aria-label` du bouton disent l'etat EN MOTS avec le nombre restant. Le
   nombre exact, lui, vit dans le menu du compte.

   CONTRASTES — mesures dans le navigateur sur les jetons EFFECTIFS de
   `body.ux-shell` (et non sur ceux de `shared.css`, que `shell-2026.css`
   redefinit : l'accent n'y est pas #2E7BF6 mais #2A6FE6 en sombre et #1F4E79
   en clair). Arc contre le fond du rail :
     sombre (#121519) : accent #2A6FE6 3,94:1 · ocre #FFB020 10,01:1 · rouge #FF4D4F 5,60:1
     clair  (#FFFFFF) : accent #1F4E79 8,66:1 · ocre #B26A00  4,24:1 · rouge #D32F2F 4,98:1
   Tous au-dessus du 3:1 exige d'un element graphique porteur d'information.
   La PISTE (`.nx-anneau-fond`, `--border-strong`) est decorative : elle borne
   l'arc, elle ne porte rien — sauf en etat `epuise`, ou elle devient le rouge
   mesure ci-dessus, justement parce qu'il n'y a plus d'arc a montrer.
   ════════════════════════════════════════════════════════════════════════ */

.nx-anneau {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
  /* Le halo de la pastille imite le fond qui l'entoure : chaque page le pose
     a la valeur de SON rail (voir plus bas). */
  --anneau-halo: var(--frame);
}

/* L'anneau tourne de -90 deg : l'arc demarre a midi, comme une jauge qu'on lit
   dans le sens de l'horloge. `!important` sur la taille : dans l'Assistant,
   des regles de rail visent les `svg` descendants du bouton. */
.nx-anneau-cercle {
  position: absolute;
  inset: 0;
  width: 40px !important;
  height: 40px !important;
  transform: rotate(-90deg);
  pointer-events: none;
}
.nx-anneau-fond {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 2.5;
}
.nx-anneau-val {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dasharray .3s ease;
}
.nx-anneau[data-etat="bas"] .nx-anneau-val { stroke: var(--warning); }
.nx-anneau[data-etat="epuise"] .nx-anneau-fond { stroke: var(--danger); }

/* SANS PLAFOND, AUCUN CERCLE. Et l'avatar reprend sa taille pleine : sinon il
   paraitrait rapetissi sans qu'on sache pourquoi. */
.nx-anneau:not([data-etat]) .nx-anneau-cercle { display: none; }

.nx-anneau-pastille {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 2px var(--anneau-halo);
}
.nx-anneau[data-etat="epuise"] .nx-anneau-pastille { background: var(--danger); }

/* ── LA PASTILLE DE LA BARRE DU BAS (telephone) ──────────────────────────
   Sous 768 px il n'y a plus de rail, donc plus d'avatar ou poser l'anneau :
   une pastille sur l'entree qui MENE au compte suffit a dire « va voir ». Le
   nombre, lui, est derriere ce bouton — on ne le recopie pas dans une barre
   de 56 px de haut. L'hote doit porter `.nx-pastille-hote`. */
.nx-pastille-hote { position: relative; }
.nx-pastille-barre {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 2px var(--anneau-halo);
}
.nx-pastille-barre[data-etat="epuise"] { background: var(--danger); }

/* ════════════════════════════════════════════════════════════════════════
   L'ASSISTANT (`app.html` + `partials/sidebar.html`)
   L'anneau se pose sur l'AVATAR EXISTANT du bas du rail — on n'ajoute aucun
   bouton : celui des credits a ete retire du rail le 2026-08-25 et il n'y
   revient pas.
   L'avatar passe de 36 a 30 px DANS l'anneau, pour que le cercle respire
   comme sur la reference validee (anneau 40, avatar 28). Sans anneau, il
   garde ses 36 px.
   ════════════════════════════════════════════════════════════════════════ */
body.ux-shell .nx-anneau { --anneau-halo: var(--bg); }
body.light-mode.ux-shell .nx-anneau { --anneau-halo: var(--surface); }
body.ux-shell .nx-anneau[data-etat] .sidebar-avatar {
  width: 30px;
  height: 30px;
  border-width: 1px;
}
/* La barre du bas de l'Assistant a le fond `--bg` dans les deux themes
   (`app.css:6277`), et c'est ce fond que le halo de la pastille imite. */
.mobile-bottom-nav .nx-pastille-hote { --anneau-halo: var(--bg); }
/* ── LE NOMBRE EXACT, DANS LE MENU DU COMPTE ─────────────────────────────
   L'anneau dit l'ETAT, le menu dit le CHIFFRE. C'est ce bloc qui rend
   l'anneau verifiable sur un ecran tactile, ou il n'y a pas d'infobulle : sans
   lui, l'indicateur promettrait ce qu'aucun ecran ne montre. L'Assistant a
   deja le sien (`.ux-acct-credits`, dans `partials/sidebar.html`) ; celui-ci
   sert la coque des applications. */
.nx-credits {
  margin: 8px 10px 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.nx-credits-l1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.nx-credits-l1 span { font-size: 12px; color: var(--text-2); }
.nx-credits-l1 b {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.nx-credits-piste {
  display: block;
  margin-top: 8px;
  height: 5px;
  border-radius: 3px;
  background: var(--border-strong);
  overflow: hidden;
}
.nx-credits-piste i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width .3s ease;
}
.nx-credits-l3 { margin-top: 7px; font-size: 11.5px; line-height: 1.4; color: var(--text-2); }
.nx-credits[data-etat="bas"] .nx-credits-l1 b { color: var(--warning-ink); }
.nx-credits[data-etat="bas"] .nx-credits-piste i { background: var(--warning); }
.nx-credits[data-etat="epuise"] {
  background: var(--danger-dim);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.nx-credits[data-etat="epuise"] .nx-credits-l1 b { color: var(--danger-ink); }

/* ════════════════════════════════════════════════════════════════════════
   LA COQUE DES APPLICATIONS (`maitriser-ia.html`, `applications.html`)
   Le bouton du compte y porte une icone, pas une photo : l'anneau l'entoure
   de la meme facon. L'icone garde la taille du rail (`.mia-f-bouton svg`,
   21 px) — c'est pour elle que `.nx-anneau-cercle` porte `!important` sur sa
   taille, sinon cette regle-la rapetissait l'anneau a 21 px.
   Le rail et la barre du bas de cette coque ont le fond `--frame`, qui est
   deja la valeur par defaut du halo : rien a redeclarer.
   ════════════════════════════════════════════════════════════════════════ */

/* COQUE-RAIL-V1 — la photo ou l'initiale dans l'anneau, et le filet du bas du rail. */
.nx-anneau-photo, .nx-anneau-initiale {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  object-fit: cover; position: relative;
}
.nx-anneau-initiale { background: var(--surface-2); color: var(--text-1); font-size: 13px; font-weight: 600; }
.ux-rail-filet { display: block; width: 24px; height: 1px; margin: 6px auto; background: var(--border); }

/* COQUE-RAIL-V1 — ce qui attend dans une application : un chiffre sur sa ligne, et sur
   la grille du rail pour le total des autres applications. */
.nx-pastille-chiffre {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; margin-left: auto;
  background: var(--accent); color: var(--accent-fg, #fff);
  font-size: 12px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.nx-pastille-coin {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; font-size: 10px; margin: 0; pointer-events: none;
}
.sidebar-nav-item[data-selecteur-produit], .mia-f-bouton[data-selecteur-produit] { position: relative; }
.ux-selecteur-tout-voir {
  display: block; margin-top: 6px; padding: 10px 12px; border-top: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; font-weight: 500; text-decoration: none;
}
.ux-selecteur-tout-voir:hover { color: var(--text-1); }

/* NX-COMPTE — le menu du compte, le même dans toutes les applications. */
.nx-compte-v4 { width: 340px !important; min-width: 0 !important; padding: 10px !important; border-radius: 18px !important; }
.nx-compte { display: flex; flex-direction: column; gap: 4px; color: var(--text-1); font-size: 14.5px; text-align: left; }
.nx-compte-tete { display: flex; align-items: center; gap: 12px; padding: 6px 8px 10px; }
.nx-compte-ava { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.nx-compte-ava img { width: 100%; height: 100%; object-fit: cover; }
.nx-compte-qui { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.nx-compte-qui b { font-weight: 600; overflow-wrap: anywhere; }
.nx-compte-qui small { font-size: 13px; color: var(--text-3); overflow-wrap: anywhere; }
.nx-compte-cred { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.nx-compte-cred-l1 { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 10px; }
.nx-compte-cred-l1 span { font-size: 13px; color: var(--text-2); }
.nx-compte-cred-l1 b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.nx-compte-piste { display: block; height: 5px; border-radius: 3px; background: var(--surface-hover, var(--border)); overflow: hidden; }
.nx-compte-piste i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.nx-compte-cred[data-etat="bas"] .nx-compte-piste i { background: var(--warning); }
.nx-compte-cred[data-etat="bas"] .nx-compte-cred-l1 b { color: var(--warning-ink); }
.nx-compte-cred[data-etat="epuise"] .nx-compte-piste i { background: var(--danger); }
.nx-compte-cred[data-etat="epuise"] .nx-compte-cred-l1 b { color: var(--danger-ink); }
.nx-compte-conso { align-self: flex-start; min-height: 34px; padding: 0 12px; border: 1px solid var(--border-strong, var(--border)); border-radius: 9px; background: var(--surface); color: var(--text-1); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.nx-compte-conso:hover { background: var(--surface-hover); }
.nx-compte-filet { display: block; height: 1px; margin: 6px 4px; background: var(--border); }
.nx-compte-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; }
.nx-compte-theme-choix { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.nx-compte-theme-b { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.nx-compte-theme-b svg { width: 15px; height: 15px; flex: none; }
.nx-compte-theme-b:hover { color: var(--text-1); }
.nx-compte-theme-b[aria-pressed="true"] { background: var(--surface); color: var(--accent-ink, var(--accent)); box-shadow: inset 0 0 0 1px var(--border-strong, var(--border)); }
.nx-compte-ligne { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 8px; border: 0; border-radius: 10px; background: none; color: var(--text-1); font: inherit; text-align: left; cursor: pointer; }
.nx-compte-ligne svg { width: 18px; height: 18px; flex: none; color: var(--text-2); }
.nx-compte-ligne:hover { background: var(--surface-hover); }
.nx-compte button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (pointer: coarse) { .nx-compte-theme-b, .nx-compte-conso { min-height: 44px; } .nx-compte-ligne { min-height: 48px; } }
