/* Composants. Chacun est montré dans tous ses états sur /guide/ (en développement).
 *
 * Les couleurs, tailles et espacements viennent des variables de socle.css.
 * Un état ne tient jamais à la couleur seule : il a aussi un mot, un signe ou un trait.
 * Rien n'est arrondi, sauf les pastilles de signe.
 */

/* --- Mise en page : trois outils --- */

/* Empile ses enfants avec un écart régulier. */
.pile {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--e-4);
  align-content: start;
}

.pile > * {
  margin-block: 0;
}

/* Aligne ses enfants sur une ligne, qui se replie si la place manque. */
.rangee {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--e-3);
}

.rangee > * {
  margin-block: 0;
}

/* Colonnes égales, aussi nombreuses que la largeur le permet. */
.grille {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: var(--e-4);
  align-items: start;
}

/* --- Panneau : la vitre sombre qui porte tout contenu ---
 *
 * <section class="panneau">
 *   <h2 class="panneau__tete">Titre</h2>
 *   <div class="panneau__corps">…</div>     (ou une liste, un tableau, sans marge)
 * </section>
 *
 * Variantes : --positif et --negatif colorent la tête (traits), --etroit et --moyen
 * bornent la largeur (formulaires). */

.panneau {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--c-bord);
  border-top-color: var(--c-arete);
  background: var(--c-panneau);
}

.panneau__tete {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--e-1) var(--e-3);
  min-height: var(--tete);
  margin: 0;
  padding: var(--e-1) var(--e-3);
  border-bottom: 1px solid var(--c-bord);
  background: var(--c-tete);
  font-family: var(--police-titre);
  font-size: var(--t-tete);
  font-weight: 700;
  font-stretch: 75%;
  letter-spacing: 0.02em;
  line-height: 1;
}

/* Un titre dans une tête qui porte aussi autre chose (un badge, un identifiant). */
.panneau__tete > :is(h1, h2, h3) {
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
}

/* La tête d'un panneau qui est toute la page : son titre est le <h1>. */
.panneau__tete--page {
  min-height: 3.25rem;
  padding-inline: var(--e-4);
  font-size: var(--t-h2);
  font-weight: 800;
}

.panneau__corps {
  margin: 0;
  padding: var(--e-4);
}

.panneau__corps > :last-child {
  margin-bottom: 0;
}

.panneau--positif > .panneau__tete {
  color: var(--c-mousse);
}

.panneau--negatif > .panneau__tete {
  color: var(--c-rouille);
}

.panneau--etroit {
  width: 100%;
  max-width: 27rem;
}

.panneau--moyen {
  width: 100%;
  max-width: 44rem;
}

/* --- Bouton ---
 * <button class="bouton"> ou <a class="bouton">. Variantes : --primaire (une par écran),
 * --discret, --danger. Inactif : attribut disabled, ou aria-disabled="true" pour qu'il
 * reste atteignable au clavier. */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--e-2);
  min-height: var(--cible);
  padding: var(--e-1) var(--e-5);
  border: 1px solid var(--bouton-bord, var(--c-bord-controle));
  border-radius: 0;
  background: var(--bouton-fond, var(--c-relief));
  color: var(--bouton-texte, var(--c-cendre));
  font-family: var(--police-titre);
  font-size: 1.25rem;
  font-weight: 700;
  font-stretch: 75%;
  letter-spacing: 0.03em;
  line-height: 1.05;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.bouton:hover {
  background: var(--bouton-survol, var(--c-survol));
  color: var(--bouton-texte, var(--c-cendre));
}

.bouton--primaire {
  --bouton-fond: var(--c-braise);
  --bouton-bord: var(--c-braise-vive);
  --bouton-texte: var(--c-sur-braise);
  --bouton-survol: var(--c-braise-vive);
}

.bouton--discret {
  --bouton-fond: transparent;
  --bouton-bord: transparent;
  padding-inline: var(--e-3);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.bouton--danger {
  --bouton-bord: var(--c-rouille);
  --bouton-texte: var(--c-rouille);
  --bouton-survol: var(--c-rouille-fond);
}

/* Dans une ligne de tableau : aussi haut, moins large. */
.bouton--petit {
  padding-inline: var(--e-3);
  font-size: 1.0625rem;
  white-space: nowrap;
}

.bouton:disabled,
.bouton[aria-disabled="true"] {
  --bouton-fond: transparent;
  --bouton-bord: var(--c-bord-controle);
  --bouton-texte: var(--c-eteint);
  --bouton-survol: transparent;
  border-style: dashed;
  cursor: not-allowed;
}

/* --- Champ ---
 * <div class="champ"> contient un <label>, le contrôle natif, puis au besoin
 * <p class="champ__erreur">. Ajouter --erreur au bloc quand la saisie est refusée. Un champ ne prend pas toute la largeur : un nom tient
 * dans --champ-moyen, un nombre (inputmode="numeric") dans --champ-court. */

.champ {
  --champ-bord: var(--c-bord-controle);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--e-1);
  align-content: start;
}

.champ > label {
  font-size: var(--t-dense);
  font-weight: 600;
}

/* :where() garde cette règle au poids d'une classe et d'un élément : les suivantes, qui
 * règlent la largeur d'un type de champ, passent après elle. */
.champ :is(input:where(:not([type="checkbox"], [type="radio"], [type="range"])), select, textarea) {
  width: 100%;
  max-width: var(--champ-moyen);
  min-height: var(--cible);
  padding: var(--e-2) var(--e-3);
  border: 1px solid var(--champ-bord);
  border-radius: 0;
  background: var(--c-creux);
  box-shadow: var(--champ-renfort, none);
}

.champ :is(input[inputmode="numeric"], input[type="number"]) {
  max-width: var(--champ-court);
  font-variant-numeric: tabular-nums;
}

.champ select {
  width: auto;
  min-width: min(100%, 11rem);
}

.champ textarea {
  max-width: var(--mesure);
  min-height: 8rem;
  line-height: 1.55;
  resize: vertical;
}

.champ input[type="file"] {
  max-width: 100%;
  padding: var(--e-1);
  font-size: var(--t-dense);
}

/* Le bouton d'un champ de fichier : un petit bouton du site, pas celui du système. */
input[type="file"]::file-selector-button {
  min-height: 2.125rem;
  margin: 0 var(--e-3) 0 0;
  padding: 0 var(--e-3);
  border: 1px solid var(--c-bord-controle);
  border-radius: 0;
  background: var(--c-relief);
  color: var(--c-cendre);
  font-family: var(--police-titre);
  font-size: 1.0625rem;
  font-weight: 700;
  font-stretch: 75%;
  letter-spacing: 0.03em;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: var(--c-survol);
}

/* Dans un panneau borné, un champ en prend la largeur : il s'aligne sur les messages. */
.panneau--etroit .champ :is(input, textarea),
.panneau--moyen .champ textarea {
  max-width: none;
}

.champ :is(input, select, textarea):hover:not(:disabled) {
  border-color: var(--c-cendre);
}

.champ :is(input, select, textarea):disabled {
  border-style: dashed;
  color: var(--c-eteint);
  cursor: not-allowed;
}

.champ :is(input, textarea)::placeholder {
  color: var(--c-brume);
  opacity: 1;
}

.champ--erreur {
  --champ-bord: var(--c-rouille);
  --champ-renfort: inset 0 0 0 1px var(--c-rouille);
}

.champ__erreur {
  display: flex;
  align-items: baseline;
  gap: var(--e-2);
  max-width: var(--mesure);
  margin: 0;
  color: var(--c-rouille);
  font-size: var(--t-petit);
  font-weight: 600;
}

/* Case à cocher ou bouton radio natifs, partout où ils se voient. */
input:is([type="checkbox"], [type="radio"]) {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--c-braise);
}

/* Une case seule avec son libellé. */
.case {
  display: grid;
  gap: var(--e-1);
  align-content: start;
}

.case > label {
  display: flex;
  gap: var(--e-2);
  align-items: center;
  min-height: var(--cible);
  font-size: var(--t-dense);
  font-weight: 600;
  cursor: pointer;
}

/* --- Pastille de signe ---
 * Le rond qui précède une erreur de champ, un message ou un budget dépassé :
 * « ! », « i » ou une coche. */

.champ__erreur::before,
.alerte::before,
.compteur-points__depassement::before {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  border-radius: 50%;
  background: var(--pastille, var(--c-rouille));
  color: var(--c-sur-braise);
  font-family: var(--police-texte);
  font-size: 0.875em;
  font-weight: 700;
  line-height: 1;
  content: "!";
  content: "!" / "";
}

/* --- Badge : l'état d'une fiche, comme une étiquette cousue ---
 * <span class="badge badge--brouillon">Brouillon</span> ; aussi --soumise, --validee,
 * --refusee. Le mot est obligatoire, le signe et la couleur l'accompagnent. */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 1.75rem;
  padding: 0 0.6em;
  border: 1px solid currentColor;
  color: var(--c-cendre);
  font-family: var(--police-titre);
  font-size: 1.0625rem;
  font-weight: 600;
  font-stretch: 75%;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge::before {
  content: "";
  flex: none;
  width: 0.6em;
  height: 0.6em;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.badge--brouillon,
.badge--desactive {
  border-style: dashed;
}

.badge--desactive {
  color: var(--c-brume);
  text-decoration: line-through;
}

.badge--soumise {
  color: var(--c-braise-vive);
}

.badge--soumise::before {
  background: linear-gradient(to right, currentColor 50%, transparent 50%);
}

.badge--validee {
  background: var(--c-mousse-fond);
  color: var(--c-mousse);
}

.badge--validee::before {
  width: 0.36em;
  margin-inline: 0.12em;
  border-width: 0 2px 2px 0;
  border-radius: 0;
  transform: translateY(-0.1em) rotate(45deg);
}

.badge--refusee {
  background: var(--c-rouille-fond);
  color: var(--c-rouille);
}

.badge--refusee::before {
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(45deg, transparent 42%, currentColor 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, currentColor 42% 58%, transparent 58%);
}

/* --- Alerte : un message ---
 * <div class="alerte alerte--erreur" role="alert"><p>…</p></div> ; aussi --info, --succes.
 * Elle a son propre fond plein : elle se pose aussi bien sur la scène que dans un panneau. */

.alerte {
  --pastille: var(--c-braise-vive);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--e-3);
  align-items: baseline;
  max-width: 56rem;
  padding: var(--e-3) var(--e-4);
  border: 1px solid var(--c-bord);
  border-left: 3px solid var(--pastille);
  background:
    linear-gradient(var(--alerte-fond, var(--c-braise-fond-leger)), var(--alerte-fond, var(--c-braise-fond-leger))),
    var(--c-nuit-pleine);
  font-size: var(--t-dense);
}

.alerte > * {
  grid-column: 2;
  margin-block: 0;
}

.alerte > * + * {
  margin-top: var(--e-2);
}

.alerte--info::before {
  content: "i";
  content: "i" / "";
}

.alerte--erreur {
  --pastille: var(--c-rouille);
  --alerte-fond: var(--c-rouille-fond);
}

.alerte--succes {
  --pastille: var(--c-mousse);
  --alerte-fond: var(--c-mousse-fond);
}

.alerte--succes::before {
  content: "✓";
  content: "✓" / "";
}

/* --- Onglets ---
 * <div class="onglets" role="tablist"> avec des <button class="onglets__onglet" role="tab"
 * aria-selected="true|false">, puis un <div class="onglets__panneau" role="tabpanel"> par
 * onglet. Pour naviguer entre des pages, mettre des liens et aria-current="page". */

.onglets {
  display: flex;
  border-bottom: 1px solid var(--c-bord);
  background: var(--c-panneau);
}

.onglets__onglet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--cible);
  padding: var(--e-1) var(--e-4);
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--c-brume);
  font-family: var(--police-titre);
  font-size: var(--t-tete);
  font-weight: 600;
  font-stretch: 75%;
  letter-spacing: 0.02em;
  line-height: 1.05;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.onglets__onglet:hover {
  background: var(--c-survol);
  color: var(--c-cendre);
}

.onglets__onglet:focus-visible {
  outline-offset: -2px;
}

.onglets__onglet:is([aria-selected="true"], [aria-current="page"]) {
  background: linear-gradient(to top, var(--c-braise-fond), transparent);
  box-shadow: inset 0 -3px 0 var(--c-braise);
  color: var(--c-cendre);
  font-weight: 700;
}

.onglets__panneau {
  padding-top: var(--e-4);
}

/* Couleurs forcées (contraste élevé de Windows) : fonds et ombres disparaissent, un
 * vrai bord marque l'onglet choisi. */
@media (forced-colors: active) {
  .onglets__onglet {
    border-bottom: 3px solid transparent;
  }

  .onglets__onglet:is([aria-selected="true"], [aria-current="page"]) {
    border-bottom-color: Highlight;
  }
}

@media (max-width: 40rem) {
  .onglets__onglet {
    flex: 1 1 auto;
    padding-inline: var(--e-2);
  }
}

/* --- Tableau ---
 * <div class="tableau-cadre" tabindex="0" role="region" aria-label="…"> autour de
 * <table class="tableau"> : le cadre est le panneau, et sur un écran étroit c'est lui
 * qui défile. La légende (<caption>) sert de tête au panneau. */

.tableau-cadre {
  position: relative;   /* un texte masqué d'une cellule reste dans le cadre */
  overflow-x: auto;
  border: 1px solid var(--c-bord);
  border-top-color: var(--c-arete);
  background: var(--c-panneau);
}

.tableau-cadre:focus-visible {
  outline-offset: -2px;
}

/* Un cadre qui défile de côté le montre : une ombre du côté où il reste à voir. Elle
 * suit le défilement (animation-timeline), sans script ; un navigateur qui ne connaît
 * pas cela n'affiche pas d'ombre. Un cadre qui ne défile pas n'en a pas non plus. */
@supports (animation-timeline: scroll()) {
  .tableau-cadre,
  .regles__onglets {
    animation: ombre-de-defilement linear both;
    animation-timeline: scroll(self inline);
  }
}

@keyframes ombre-de-defilement {
  0% {
    box-shadow:
      inset 0 0 0 0 transparent,
      inset -1.75rem 0 1.25rem -1.25rem var(--c-braise-halo);
  }

  8%, 92% {
    box-shadow:
      inset 1.75rem 0 1.25rem -1.25rem var(--c-braise-halo),
      inset -1.75rem 0 1.25rem -1.25rem var(--c-braise-halo);
  }

  100% {
    box-shadow:
      inset 1.75rem 0 1.25rem -1.25rem var(--c-braise-halo),
      inset 0 0 0 0 transparent;
  }
}

/* Dans un panneau, le tableau n'a pas besoin d'un second cadre. */
.panneau > .tableau-cadre,
.panneau__corps > .tableau-cadre {
  border: 0;
  background: none;
}

.panneau__corps > .tableau-cadre {
  margin-inline: calc(-1 * var(--e-4));
}

.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-dense);
  font-variant-numeric: tabular-nums;
}

.tableau caption {
  padding: var(--e-2) var(--e-3);
  background: var(--c-tete);
  font-family: var(--police-titre);
  font-size: var(--t-tete);
  font-weight: 700;
  font-stretch: 75%;
  letter-spacing: 0.02em;
  line-height: 1;
  text-align: left;
}

.tableau :is(th, td) {
  padding: var(--e-2) var(--e-3);
  border-bottom: 1px solid var(--c-filet);
  text-align: left;
  vertical-align: baseline;
}

.tableau thead th {
  border-block: 1px solid var(--c-bord);
  background: var(--c-tete);
  color: var(--c-brume);
  font-size: var(--t-petit);
  font-weight: 600;
  white-space: nowrap;
}

.tableau tbody th {
  font-weight: 600;
}

/* Le lien d'une ligne (ouvrir la fiche, le trait) ou d'un nombre : toute la cellule se clique. */
.tableau tbody :is(th, td) > a:only-child {
  display: block;
  margin: calc(-1 * var(--e-2)) calc(-1 * var(--e-3));
  padding: var(--e-2) var(--e-3);
}

.tableau tbody tr:hover {
  background: var(--c-survol);
}

.tableau tbody:last-child tr:last-child > * {
  border-bottom: 0;
}

.tableau .tableau__nombre {
  text-align: right;
}

/* --serre : les cellules tiennent sur une ligne, sauf celles marquées __large. */
.tableau--serre :is(th, td) {
  white-space: nowrap;
}

.tableau--serre .tableau__large {
  min-width: 10rem;
  white-space: normal;
}

/* --- Ligne de choix : un métier ou un trait ---
 *
 * <div class="ligne-choix ligne-choix--positif">
 *   <label class="ligne-choix__choix">
 *     <input class="ligne-choix__case" type="radio|checkbox" …>
 *     <svg class="picto ligne-choix__picto">…</svg>                 (métiers)
 *     <span class="ligne-choix__texte">
 *       <span class="ligne-choix__nom">Nom</span>
 *       <span class="ligne-choix__effets">Force +5</span>           (facultatif)
 *     </span>
 *     <span class="ligne-choix__cout">6</span>
 *   </label>
 *   <p class="ligne-choix__raison" id="…">Incompatible avec …</p>  (si indisponible)
 *   <details class="ligne-choix__detail">                          (si description)
 *     <summary class="ligne-choix__ouvrir"><span class="visuellement-masque">…</span></summary>
 *     <p class="ligne-choix__description">…</p>
 *   </details>
 * </div>
 *
 * --positif colore la ligne en mousse, --negatif en rouille (traits).
 * Indisponible : ajouter --indisponible au bloc, et sur la case aria-disabled="true" et
 * aria-describedby vers la raison. Jamais disabled : la case doit rester atteignable.
 * Un coût qui rend des points porte ligne-choix__cout--gain et s'écrit « +5 ». */

.ligne-choix {
  --ligne-encre: var(--c-cendre);
  position: relative;
  border-bottom: 1px solid var(--c-filet);
  color: var(--ligne-encre);
  font-size: var(--t-dense);
}

.ligne-choix--positif {
  --ligne-encre: var(--c-mousse);
}

.ligne-choix--negatif {
  --ligne-encre: var(--c-rouille);
}

.ligne-choix__choix {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: var(--cible);
  padding: var(--e-1) var(--e-3);
  font-weight: 500;
  line-height: 1.15;
  cursor: pointer;
}

/* À droite, la place du bouton de description, pour que les coûts restent alignés. */
.ligne-choix:has(.ligne-choix__detail) > .ligne-choix__choix {
  padding-right: var(--cible);
}

.ligne-choix__choix:hover {
  background: var(--c-survol);
}

.ligne-choix__choix:has(:focus-visible) {
  outline: 2px solid var(--c-braise-vive);
  outline-offset: -2px;
}

.ligne-choix__case {
  cursor: inherit;
}

.ligne-choix__picto {
  color: var(--c-brume);
}

.ligne-choix__texte {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 0.625rem;
  min-width: 0;
}

.ligne-choix__nom {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ligne-choix__effets {
  color: var(--c-brume);
  font-size: var(--t-mini);
  font-weight: 400;
}

/* Sur un écran étroit, les effets vont toujours sous le nom : une liste régulière. */
@media (max-width: 40rem) {
  .ligne-choix__effets {
    flex-basis: 100%;
  }
}

.ligne-choix__cout {
  flex: none;
  min-width: 1.75rem;
  font-family: var(--police-titre);
  font-size: 1.25rem;
  font-weight: 700;
  font-stretch: 75%;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  line-height: 1;
  text-align: right;
}

.ligne-choix:not(.ligne-choix--negatif) .ligne-choix__cout--gain {
  color: var(--c-mousse);
}

/* Choisie : la braise. Fond en dégradé, trait dans la marge, nom en gras. */
.ligne-choix:has(.ligne-choix__case:checked) {
  background: linear-gradient(90deg, var(--c-braise-fond), var(--c-braise-fond-leger));
  box-shadow: inset 3px 0 0 var(--c-braise);
  color: var(--c-cendre);
}

.ligne-choix:has(.ligne-choix__case:checked) .ligne-choix__choix {
  font-weight: 600;
}

.ligne-choix:has(.ligne-choix__case:checked) :is(.ligne-choix__picto, .ligne-choix__cout) {
  color: var(--c-braise-vive);
}

/* Couleurs forcées : la ligne choisie garde un trait dans la marge. */
@media (forced-colors: active) {
  .ligne-choix {
    border-left: 3px solid transparent;
  }

  .ligne-choix:has(.ligne-choix__case:checked) {
    border-left-color: Highlight;
  }
}

/* Indisponible : hachures, nom barré, et la raison en toutes lettres. */
.ligne-choix--indisponible {
  background: repeating-linear-gradient(
    135deg,
    var(--c-hachure) 0 6px,
    transparent 6px 12px
  );
}

.ligne-choix--indisponible .ligne-choix__choix {
  padding-bottom: 0;
  cursor: not-allowed;
}

.ligne-choix--indisponible .ligne-choix__choix:hover {
  background: none;
}

.ligne-choix--indisponible .ligne-choix__nom {
  color: var(--c-eteint);
  text-decoration: line-through;
  text-decoration-color: var(--c-rouille);
}

.ligne-choix--indisponible :is(.ligne-choix__effets, .ligne-choix__cout, .ligne-choix__picto) {
  color: var(--c-eteint);
}

.ligne-choix__raison,
.ligne-choix__description {
  margin: 0;
  padding: 0 var(--e-3) var(--e-2);
  color: var(--c-cendre);
  font-size: var(--t-mini);
  line-height: 1.3;
}

.ligne-choix__ouvrir {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: var(--cible);
  height: var(--cible);
  color: var(--c-brume);
  list-style: none;
  cursor: pointer;
}

.ligne-choix__ouvrir:hover {
  color: var(--c-cendre);
}

.ligne-choix__ouvrir:focus-visible {
  outline-offset: -2px;
}

.ligne-choix__ouvrir::-webkit-details-marker {
  display: none;
}

.ligne-choix__ouvrir::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-25%) rotate(45deg);
}

.ligne-choix__detail[open] > .ligne-choix__ouvrir::before {
  transform: translateY(20%) rotate(-135deg);
}

.ligne-choix__description {
  max-width: var(--mesure);
  font-size: var(--t-petit);
  line-height: 1.45;
}

/* --- Compteur de points : le nombre que le feu éclaire ---
 *
 * <div class="compteur-points">
 *   <span class="compteur-points__libelle">Points à dépenser</span>
 *   <strong class="compteur-points__valeur">108</strong>
 *   <span class="compteur-points__suite">
 *     <span class="compteur-points__budget">sur 150</span>
 *     <span class="compteur-points__depassement">12 de trop</span>  (si dépassé)
 *   </span>
 * </div>
 *
 * Budget dépassé : ajouter --depasse au bloc. La valeur s'écrit alors « −12 », en rouille. */

.compteur-points {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--e-1) 0.875rem;
  margin: 0;
  white-space: nowrap;
}

.compteur-points__libelle,
.compteur-points__budget {
  font-family: var(--police-titre);
  font-size: 1.4375rem;
  font-weight: 600;
  font-stretch: 75%;
  letter-spacing: 0.025em;
  line-height: 1;
}

.compteur-points__valeur {
  color: var(--c-braise-vive);
  font-family: var(--police-titre);
  font-size: var(--t-chiffre);
  font-weight: 800;
  font-stretch: 75%;
  font-variant-numeric: tabular-nums;
  line-height: 0.88;
  filter: drop-shadow(0 0 1rem var(--c-braise-halo)) drop-shadow(0 2px 0 var(--c-ombre));
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .compteur-points:not(.compteur-points--depasse) .compteur-points__valeur {
    background: linear-gradient(0deg, var(--c-braise-claire) 10%, var(--c-braise-vive) 50%, var(--c-braise) 94%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

.compteur-points__suite {
  display: grid;
  gap: var(--e-1);
  justify-items: start;
}

/* Le texte du dépassement porte la pastille « ! » : la couleur ne dit rien seule. */
.compteur-points__depassement {
  display: flex;
  align-items: baseline;
  gap: var(--e-2);
  color: var(--c-rouille);
  font-size: var(--t-petit);
  font-weight: 600;
}

.compteur-points--depasse .compteur-points__valeur {
  color: var(--c-rouille);
  filter: drop-shadow(0 2px 0 var(--c-ombre));
}

/* --- Jauge de stat ---
 *
 * <div class="jauge-stat" style="--reparti: 40; --final: 50">
 *   <span class="jauge-stat__nom">Perception</span>
 *   <span class="jauge-stat__detail">40 <b class="stat-bonus">+10</b></span>   (si métier et traits changent la valeur)
 *   <span class="jauge-stat__valeur">50</span>
 *   <span class="jauge-stat__piste" aria-hidden="true"></span>
 * </div>
 *
 * --reparti et --final sont des nombres sans unité, sur une échelle de 0 à --echelle
 * (100 par défaut). La piste, graduée de dix en dix, montre de gauche à droite : la
 * valeur répartie en plein, puis ce que métier et traits ajoutent (hachures de mousse)
 * ou retirent (hachures de rouille). Le dessin n'est qu'un appui : les nombres disent tout.
 * Ce qu'ils retirent s'écrit <b class="stat-bonus stat-bonus--perte">−5</b>.
 *
 * Variante --compacte : nom abrégé et valeur sur une ligne, piste fine dessous. */

.jauge-stat {
  --echelle: 100;
  --pas: calc(100% / var(--echelle));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  column-gap: var(--e-2);
  align-items: baseline;
}

.jauge-stat__nom {
  font-size: var(--t-dense);
  font-weight: 600;
}

.jauge-stat__detail {
  grid-column: 2;
  color: var(--c-brume);
  font-size: var(--t-petit);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Ce que métier et traits ajoutent à une stat, ou lui retirent : le signe le dit, la
 * couleur l'accompagne. */
.stat-bonus {
  color: var(--c-mousse);
  font-weight: 600;
}

.stat-bonus--perte {
  color: var(--c-rouille);
}

.jauge-stat__valeur {
  grid-column: 3;
  min-width: 1.75rem;
  font-family: var(--police-titre);
  font-size: 1.5625rem;
  font-weight: 800;
  font-stretch: 75%;
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
  text-align: right;
}

.jauge-stat__piste {
  grid-column: 1 / -1;
  position: relative;
  height: 0.625rem;
  margin-top: var(--e-1);
  /* En plein : ce qui reste de la valeur répartie. */
  background: linear-gradient(
    to right,
    var(--c-cendre) calc(min(var(--reparti), var(--final)) * var(--pas)),
    var(--c-survol) 0
  );
  /* Les graduations, de dix en dix : des fentes qui laissent voir le panneau. */
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 calc(10% - 1px), transparent calc(10% - 1px) 10%);
  mask-image: repeating-linear-gradient(90deg, #000 0 calc(10% - 1px), transparent calc(10% - 1px) 10%);
}

.jauge-stat__piste::before,
.jauge-stat__piste::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
}

/* Retiré : des hachures de rouille, de la valeur finale à la valeur répartie. */
.jauge-stat__piste::before {
  left: calc(var(--final) * var(--pas));
  width: calc(max(0, var(--reparti) - var(--final)) * var(--pas));
  background: repeating-linear-gradient(
    135deg,
    var(--c-rouille) 0 3px,
    var(--c-rouille-sombre) 3px 6px
  );
}

/* Ajouté : des hachures de mousse, à la suite de la valeur répartie. */
.jauge-stat__piste::after {
  left: calc(var(--reparti) * var(--pas));
  width: calc(max(0, var(--final) - var(--reparti)) * var(--pas));
  background: repeating-linear-gradient(
    135deg,
    var(--c-mousse) 0 3px,
    var(--c-mousse-sombre) 3px 6px
  );
}

.jauge-stat--compacte {
  grid-template-columns: auto auto;
  justify-content: center;
  column-gap: var(--e-1);
}

.jauge-stat--compacte .jauge-stat__nom {
  color: var(--c-brume);
  font-size: var(--t-mini);
  font-weight: 500;
  text-decoration: none;
}

.jauge-stat--compacte .jauge-stat__valeur {
  grid-column: auto;
  min-width: 0;
  font-size: 1.125rem;
}

.jauge-stat--compacte .jauge-stat__piste {
  height: 0.25rem;
  margin-top: 0.125rem;
  -webkit-mask-image: none;
  mask-image: none;
}

/* --- Note du MJ : son commentaire, en marge de la fiche --- */

.note-mj {
  max-width: var(--mesure);
  margin: 0;
  padding: var(--e-2) var(--e-3);
  border-left: 3px solid var(--c-braise);
  background: var(--c-braise-fond-leger);
}

/* Seule dans un panneau, la note en prend la largeur. */
.panneau__corps > .note-mj:only-child {
  max-width: none;
}

.note-mj__titre {
  color: var(--c-brume);
  font-size: var(--t-petit);
  font-weight: 600;
}

.note-mj__texte {
  margin: var(--e-1) 0 0;
  font-size: var(--t-dense);
}

.note-mj__texte > :last-child {
  margin-bottom: 0;
}

/* --- Liste de ce qui ne va pas : une phrase par ligne --- */

.anomalies {
  margin: 0;
  padding-left: var(--e-5);
}

.anomalies > li + li {
  margin-top: var(--e-1);
}
