/* =====================================================================
   unites.css — Page « Stats des unités »
   Reprend les variables et composants de style.css (cartes, boutons
   segmentés, interrupteurs, couleurs de ressources). Une seule teinte pour
   les barres et le nuage : l'identité d'une unité passe par son nom écrit.
   La matrice est divergente : bleu (gagne) ↔ rouge (perd), gris au milieu,
   avec le signe + / − écrit dans chaque case.
   ===================================================================== */

:root {
  --matrice-gagne: #3987e5;
  --matrice-perd: #e66767;
  --matrice-neutre: #383835;
  --barre: var(--laiton-clair);
  --barre-fond: rgba(200, 164, 90, 0.12);
  --grille: rgba(200, 164, 90, 0.12);
  --argent: #c9c6bd;
  --bronze: #c98a52;
}

/* ---------------------------------------------------------------------
   Mise en page
   --------------------------------------------------------------------- */
.page-unites { padding: 28px 16px 60px; }

.entete-unites { position: relative; margin-bottom: 22px; }
.retour-coach { position: absolute; left: 0; top: 0; text-decoration: none; }
.unites-source { margin-top: 8px; font-size: 14px; color: var(--texte-pale); }

.unites {
  width: min(1320px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.aide { font-size: 15px; color: var(--texte-doux); margin-bottom: 8px; }
.pale { color: var(--texte-pale); }
.vide { color: var(--texte-pale); font-style: italic; padding: 8px 0; }
.erreur-donnees { width: min(760px, 100%); margin: 0 auto 18px; color: #f0a59a; }
small { font-size: 0.8em; }

/* ---------------------------------------------------------------------
   Réglages
   --------------------------------------------------------------------- */
.reglages-grille {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px 22px;
  align-items: start;
}
.reglage { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.reglage-large { grid-column: 1 / -1; }
.reglage .segmente { align-self: flex-start; max-width: 100%; }
.reglage .etiquette-champ small { text-transform: none; letter-spacing: 0; font-family: var(--police-texte); font-size: 14px; }

.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--bord);
  border-radius: 4px;
  background: rgba(255, 240, 210, 0.03);
  color: var(--texte-doux);
  font-family: var(--police-titre);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  cursor: pointer;
}
.puce small {
  font-family: var(--police-texte);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--texte-pale);
}
.puce:hover:not(:disabled) { border-color: var(--laiton-clair); color: var(--texte); }
.puce-active { background: rgba(200, 164, 90, 0.24); border-color: var(--laiton-clair); color: var(--or-vif); }
.puce-active small { color: var(--texte-doux); }
.puce:disabled { cursor: default; opacity: 0.55; }
.puce-petite { min-height: 32px; padding: 4px 12px; justify-content: center; }

.forge {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 8px 22px;
}
.forge-ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.forge-nom { color: var(--texte-doux); }
.btn-segment:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-segment:disabled:hover { background: transparent; color: var(--texte-doux); }

.technos { margin-top: 14px; border-top: 1px solid var(--bord); padding-top: 10px; }
.technos summary {
  cursor: pointer;
  font-family: var(--police-titre);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--laiton-clair);
  padding: 6px 0;
}
.technos[open] summary { margin-bottom: 6px; }
.technos-liste {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 6px 26px;
}
.techno-groupe-titre {
  font-family: var(--police-titre);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--texte-pale);
  margin: 10px 0 4px;
}
.techno {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "case nom cout" "case effet effet";
  gap: 0 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(168, 135, 79, 0.12);
  cursor: pointer;
}
.techno input { grid-area: case; margin-top: 4px; accent-color: var(--laiton-clair); width: 16px; height: 16px; }
.techno-nom { grid-area: nom; }
.techno-age { font-size: 13px; color: var(--texte-pale); margin-left: 4px; }
.techno-effet { grid-area: effet; font-size: 14px; color: var(--texte-doux); }
.techno-cout { grid-area: cout; font-size: 14px; white-space: nowrap; }
.techno-indispo, .techno-non-modelisee { opacity: 0.5; cursor: default; }

/* ---------------------------------------------------------------------
   Armée adverse (barre au-dessus des classements)
   --------------------------------------------------------------------- */
.armee-grille {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 14px 28px;
  align-items: start;
}
.armee-seul { margin-top: 6px; }
.armee .puce { max-width: 100%; }
.armee-curseurs { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.curseur { display: flex; align-items: center; gap: 10px; min-width: 0; }
.curseur input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 28px;
  margin: 0;
  accent-color: var(--laiton-clair);
  cursor: pointer;
}
.curseur-borne { font-size: 15px; color: var(--texte-doux); white-space: nowrap; }
.curseur-inactif input[type="range"] { opacity: 0.5; }
.curseur-inactif input[type="range"]:hover { opacity: 0.8; }
.curseur-pas { min-width: 32px; padding: 0 8px; font-size: 16px; }
.curseur-valeur {
  min-width: 2ch;
  font-family: var(--police-chiffres);
  font-size: 18px;
  font-weight: 700;
  color: var(--or-vif);
  text-align: right;
  font-variant-numeric: lining-nums tabular-nums;
}

.armee-reponse {
  margin-top: 14px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid var(--laiton);
  font-size: 17px;
  color: var(--texte-doux);
}
.armee-reponse strong { color: var(--or-vif); font-weight: 600; }

/* ---------------------------------------------------------------------
   Podiums
   --------------------------------------------------------------------- */
.podiums-entete { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--bord); margin-bottom: 12px; }
.podiums-entete .etiquette { border-bottom: 0; margin-bottom: 0; }
.podiums-face { color: var(--texte-doux); font-size: 16px; }

.contres {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 18px;
}
.contre { border-left: 2px solid var(--bord-fort); padding-left: 12px; }
.contre-titre { font-family: var(--police-titre); font-size: 15px; letter-spacing: 0.06em; color: var(--laiton-clair); margin-bottom: 4px; }
.contre-liste { list-style: none; margin: 0; padding: 0; }
.contre-bouton {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--texte);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.contre-bouton:hover { border-color: var(--bord); background: rgba(200, 164, 90, 0.08); }
.contre-valeur { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.contre-eviter { margin-top: 4px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--texte-pale); font-family: var(--police-titre); }
.contre-pire .contre-bouton { color: var(--texte-pale); }

/* Contres : sous-titres de la section et des cartes, cartes de groupe. */
.contres-sous-titre {
  font-family: var(--police-titre);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--texte-doux);
  margin: 4px 0 6px;
}
.contres + .contres-sous-titre { margin-top: 20px; }
.contre-sous { margin: 8px 0 2px; font-family: var(--police-titre); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--texte-doux); }
.contre-titre + .contre-sous { margin-top: 0; }
.contres-groupes { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.contre-groupe-noms { font-size: 14px; color: var(--texte-pale); }
/* Largeurs en px : l'en-tête (12 px) et les lignes (15 px) restent alignés. */
.contre-bouton-groupe, .contre-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) 48px 80px; gap: 8px; }
.contre-colonnes { padding: 0 7px; letter-spacing: 0.06em; white-space: nowrap; }
.contre-colonnes span + span, .contre-bouton-groupe .contre-valeur { text-align: right; }
.contre-victoire { text-align: right; color: var(--texte-doux); font-variant-numeric: tabular-nums; white-space: nowrap; }

.podiums {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 8px;
}
.podium { display: flex; flex-direction: column; }
.podium-titre {
  font-family: var(--police-titre);
  font-size: 18px;
  letter-spacing: 0.05em;
  color: var(--texte);
}
.podium-unite { color: var(--texte-pale); font-size: 15px; margin: 2px 0 10px; }
.podium-liste { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.podium-aide { margin-top: auto; font-size: 14px; color: var(--texte-pale); }

.podium-bouton {
  width: 100%;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  grid-template-areas: "rang nom valeur" ". barre barre";
  align-items: center;
  gap: 1px 8px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--texte);
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.podium-bouton:hover { background: rgba(200, 164, 90, 0.08); border-color: var(--bord); }
.podium-choisi .podium-bouton { border-color: var(--bord-fort); background: rgba(200, 164, 90, 0.1); }
.podium-rang {
  grid-area: rang;
  font-family: var(--police-chiffres);
  font-size: 13px;
  font-weight: 700;
  color: var(--texte-pale);
  text-align: center;
}
.podium-nom { grid-area: nom; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-valeur { grid-area: valeur; font-variant-numeric: lining-nums tabular-nums; font-weight: 600; }
.podium-barre { grid-area: barre; height: 6px; border-radius: 3px; background: var(--barre-fond); overflow: hidden; }
.podium-barre span { display: block; height: 100%; border-radius: 0 3px 3px 0; background: var(--barre); }

/* « Le moins cher pour gagner » : toute la largeur, liste sur deux colonnes. */
.podium-large { grid-column: 1 / -1; }
.podium-large .podium-liste { display: block; column-count: 2; column-gap: 28px; }
.podium-large .podium-ligne { break-inside: avoid; margin-bottom: 2px; }
.podium-effectif { color: var(--laiton-clair); font-variant-numeric: lining-nums tabular-nums; }

.podium-rang-1 .podium-rang, .podium-rang-2 .podium-rang, .podium-rang-3 .podium-rang {
  border-radius: 50%;
  width: 22px; height: 22px; line-height: 20px;
  color: #1d140c;
}
.podium-rang-1 .podium-rang { background: var(--or-vif); }
.podium-rang-2 .podium-rang { background: var(--argent); }
.podium-rang-3 .podium-rang { background: var(--bronze); }
.podium-rang-1 .podium-nom { font-weight: 600; color: var(--or-vif); }
.podium-rang-1 .podium-barre span { background: var(--or-vif); }

.marque-requis { color: var(--laiton); font-size: 0.75em; cursor: help; }
.marque-zone { color: var(--texte-pale); cursor: help; white-space: nowrap; }

/* ---------------------------------------------------------------------
   Nuage « Frappe / Tient »
   --------------------------------------------------------------------- */
.nuage { width: 100%; }
.nuage-svg { display: block; width: 100%; height: auto; max-height: 560px; }
.nuage-grille { stroke: var(--grille); stroke-width: 1; }
.nuage-axe { stroke: var(--bord-fort); stroke-width: 1; }
.nuage-axe-texte { fill: var(--texte-pale); font-family: var(--police-texte); font-size: 12px; font-variant-numeric: tabular-nums; }
.nuage-titre-axe { fill: var(--texte-doux); font-family: var(--police-titre); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.nuage-iso { fill: none; stroke: var(--laiton); stroke-opacity: 0.35; stroke-width: 1; stroke-dasharray: 3 4; }
.nuage-point { fill: var(--laiton-clair); stroke: var(--carte); stroke-width: 2; }
.nuage-point-choisi { fill: var(--or-vif); }
.nuage-etiquette { fill: var(--texte); font-family: var(--police-texte); font-size: 12px; pointer-events: none; }
.nuage-cible { fill: transparent; cursor: pointer; }
.nuage-cible:hover + .nuage-cible, .nuage-cible:hover { fill: rgba(230, 199, 122, 0.12); }

.infobulle {
  position: fixed;
  z-index: 20;
  max-width: 320px;
  padding: 8px 11px;
  border: 1px solid var(--bord-fort);
  border-radius: 4px;
  background: rgba(23, 17, 12, 0.96);
  color: var(--texte);
  font-size: 15px;
  white-space: pre-line;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* Fiche d'unité au survol, comme l'infobulle du jeu (MOTEUR_UNITES.ficheHtml). */
.infobulle:has(.fiche-unite) { max-width: 340px; white-space: normal; padding: 9px 12px 10px; }
.fiche-unite { font-size: 14px; line-height: 1.3; min-width: 250px; }
.fiche-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.fiche-nom { font-family: var(--police-titre); font-size: 15px; color: var(--or-vif); }
.fiche-age { color: var(--texte-pale); font-size: 12px; white-space: nowrap; }
.fiche-sous { margin: 1px 0 0; color: var(--texte-doux); font-size: 13px; }
.fiche-tags { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 3px; }
.fiche-tags span {
  padding: 0 6px;
  border: 1px solid var(--bord);
  border-radius: 3px;
  color: var(--texte-doux);
  font-size: 12px;
}
.fiche-etat { margin: 5px 0 0; color: var(--texte); font-weight: 600; }
.fiche-bloc {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 12px;
  margin: 6px 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--bord);
}
.fiche-bloc dt { color: var(--texte-pale); }
.fiche-bloc dd { margin: 0; font-variant-numeric: tabular-nums; }
.fiche-bloc small { color: var(--texte-pale); }
.ecart { font-size: 12px; font-weight: 600; }
.ecart-mieux { color: var(--hausse); }
.ecart-moins { color: var(--baisse); }
.fiche-sources, .fiche-description, .fiche-pied {
  margin: 6px 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--bord);
  color: var(--texte-doux);
  font-size: 13px;
}
.fiche-sources-titre { margin: 0 0 2px; color: var(--texte-pale); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.fiche-sources ul { margin: 0; padding: 0; list-style: none; }
.fiche-sources li { padding-left: 0.8em; text-indent: -0.8em; }
.fiche-source { color: var(--texte); }
.fiche-plus { color: var(--hausse); }
.fiche-moins { color: var(--baisse); }
.fiche-pied { color: var(--texte-pale); }

/* ---------------------------------------------------------------------
   Tableaux (stats, matrice, fiche)
   --------------------------------------------------------------------- */
.tableau-defile { overflow-x: auto; }

.table-unites, .table-matrice, .table-fiche {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  font-variant-numeric: lining-nums tabular-nums;
}
.table-unites th, .table-unites td,
.table-matrice th, .table-matrice td,
.table-fiche th, .table-fiche td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(168, 135, 79, 0.14);
  vertical-align: middle;
}
.table-unites thead th, .table-matrice thead th, .table-fiche thead th {
  font-family: var(--police-titre);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--laiton-clair);
  border-bottom: 1px solid var(--bord-fort);
  white-space: nowrap;
}
.col-texte { text-align: left; }
.col-nombre { text-align: right; white-space: nowrap; }
.table-unites tbody th { font-weight: 500; white-space: nowrap; }
.table-unites tbody tr:hover, .table-matrice tbody tr:hover { background: rgba(200, 164, 90, 0.05); }

.tri {
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}
.tri:hover { color: var(--or-vif); }
.col-mesure { background: rgba(200, 164, 90, 0.04); }

.lien-unite {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--texte);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.lien-unite:hover { color: var(--or-vif); text-decoration: underline; text-underline-offset: 3px; }

.cellule-barre {
  display: inline-block;
  min-width: 72px;
  padding: 1px 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(200, 164, 90, 0.32) var(--largeur), transparent var(--largeur));
}

/* Matrice des duels */
.table-matrice th:not(.col-texte), .table-matrice td { text-align: center; }
.table-matrice tbody th { font-weight: 500; white-space: nowrap; }
.table-matrice td { padding: 3px; }
.case-duel {
  display: block;
  width: 100%;
  min-width: 70px;
  padding: 7px 4px;
  border: 2px solid transparent;
  border-radius: 4px;
  color: var(--texte);
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.case-duel:hover { border-color: var(--or-vif); }
.case-ouverte { border-color: var(--or-vif); box-shadow: 0 0 0 1px var(--or-vif); }
.case-globale { cursor: default; }
.case-globale:hover { border-color: transparent; }
.col-global { border-left: 1px solid var(--bord-fort); }

.duel-detail { margin-top: 14px; border-left: 2px solid var(--laiton); padding: 4px 0 4px 16px; }
.duel-detail p, .fiche-duel p { margin-bottom: 6px; }
.duel-titre { font-family: var(--police-titre); font-size: 17px; letter-spacing: 0.04em; margin-bottom: 8px; }
.duel-coup small, .duel-detail small, .fiche-duel small { color: var(--texte-pale); }
.duel-qui { display: inline-block; min-width: 190px; color: var(--laiton-clair); }
.duel-detail .etiquette-champ, .fiche-duel .etiquette-champ { margin-right: 8px; }

/* Fiche comparée */
.fiche-choix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px 22px;
  margin-bottom: 12px;
}
.table-fiche tbody th {
  text-align: left;
  font-weight: 500;
  color: var(--texte-doux);
  white-space: nowrap;
  width: 1%;
}
.table-fiche td { width: 45%; vertical-align: top; }
.table-fiche thead th { text-align: left; font-size: 13px; }
.fiche-duel { margin-top: 14px; border-left: 2px solid var(--laiton); padding: 4px 0 4px 16px; }

/* Règles */
.regles ul { margin: 0; padding-left: 20px; color: var(--texte-doux); }
.regles li { margin-bottom: 6px; }
.regles strong { color: var(--texte); }

/* ---------------------------------------------------------------------
   Petits écrans
   --------------------------------------------------------------------- */
@media (max-width: 720px) {
  .page-unites { padding-top: 64px; }
  .retour-coach { top: -48px; }
  .podiums, .technos-liste, .armee-grille { grid-template-columns: 1fr; }
  .podium-large .podium-liste { column-count: 1; }
  .duel-qui { display: block; min-width: 0; }
  .reglage .segmente { max-width: 100%; }
}
