/* graphiques.css : moteur de graphiques natif de G-CORE Mining Operations.
   S'appuie sur les jetons de app.css (--bg-*, --ink*, --line*, --focus, --ok, --warn, --bad, --info,
   --font, --fs-*). Palette de 16 couleurs --graph-1 à --graph-16, déclinée pour les deux thèmes :
   tons lumineux sur fond graphite (sombre), tons profonds sur fond blanc (clair), contraste
   d'au moins 3:1 avec le fond du tracé. Chaque couleur a aussi une forme et un motif (graphiques.js). */

/* ==================================================================== 1. Jetons */
:root, :root[data-theme="dark"] {
  --graph-1: #4C9BEF; --graph-2: #2EB67D; --graph-3: #E2B33D; --graph-4: #F2756A;
  --graph-5: #A68CF2; --graph-6: #36BFD0; --graph-7: #E57AB5; --graph-8: #F0923E;
  --graph-9: #A9CEF7; --graph-10: #93DDB6; --graph-11: #F0D58F; --graph-12: #F8B4AC;
  --graph-13: #CFC1F8; --graph-14: #9BE1EA; --graph-15: #F3B9D8; --graph-16: #B9C2CD;
  --graph-motif: rgb(12 14 16 / .45);   /* hachures posées sur une couleur de série */
  --graph-sur: #101214;                  /* texte posé sur une couleur de série */
}
:root[data-theme="light"] {
  --graph-1: #1F6FD1; --graph-2: #138A5A; --graph-3: #9A6F00; --graph-4: #C9392D;
  --graph-5: #7553D6; --graph-6: #0D7F8F; --graph-7: #B83A80; --graph-8: #B85A0C;
  --graph-9: #0D3F7A; --graph-10: #0B5C3A; --graph-11: #6E5200; --graph-12: #8F2A21;
  --graph-13: #45308C; --graph-14: #0B5662; --graph-15: #7D2257; --graph-16: #4B5663;
  --graph-motif: rgb(255 255 255 / .55);
  --graph-sur: #FFFFFF;
}
:root {
  /* Échelle typographique des graphiques (tableaux de bord standard, 02/11/2026) : reprise par les trois familles. */
  --gg-fs-petit: 10px; --gg-fs-base: 11px; --gg-fs-fort: 13px; --gg-fs-valeur-m: 18px; --gg-fs-valeur-l: 26px;
  --graph-fond: var(--grid-bg);
  --graph-grille: color-mix(in srgb, var(--ink) 10%, transparent);
  --graph-axe: color-mix(in srgb, var(--ink) 32%, transparent);
  --graph-curseur: color-mix(in srgb, var(--ink) 8%, transparent);
}
.g-c1 { --c: var(--graph-1); }   .g-c2 { --c: var(--graph-2); }   .g-c3 { --c: var(--graph-3); }   .g-c4 { --c: var(--graph-4); }
.g-c5 { --c: var(--graph-5); }   .g-c6 { --c: var(--graph-6); }   .g-c7 { --c: var(--graph-7); }   .g-c8 { --c: var(--graph-8); }
.g-c9 { --c: var(--graph-9); }   .g-c10 { --c: var(--graph-10); } .g-c11 { --c: var(--graph-11); } .g-c12 { --c: var(--graph-12); }
.g-c13 { --c: var(--graph-13); } .g-c14 { --c: var(--graph-14); } .g-c15 { --c: var(--graph-15); } .g-c16 { --c: var(--graph-16); }

/* ==================================================================== 2. Cadre */
.gg {
  position: relative; box-sizing: border-box; margin: 0; width: 100%; height: 100%; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 8px;
  font-family: var(--font); color: var(--ink); background: var(--graph-fond);
}
.gg.gg-ratio { height: auto; }
.gg *, .gg *::before, .gg *::after { box-sizing: border-box; }
.gg-tete { display: flex; align-items: flex-start; gap: 8px; min-width: 0; flex: none; }
/* Titres à leur largeur : la bulle (i) des notes, premier élément des actions, vient juste après le titre ; les boutons
   restent calés à droite. */
.gg-titres { flex: 0 1 auto; min-width: 0; }
.gg-titre { font-size: var(--fs-l); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.gg-sous-titre { font-size: var(--fs-s); color: var(--ink-2); line-height: 1.3; overflow-wrap: anywhere; }
.gg-titre:empty, .gg-sous-titre:empty { display: none; }
.gg-actions { display: flex; justify-content: flex-end; gap: 4px; flex: 1 0 auto; }
/* Bulle (i) des notes du graphique (bulles.js, demande du PDG du 04/11/2026) : notes, séries non tracées et leurs raisons
   lues d'un clic au lieu d'un texte sous le tracé ; centrée sur la hauteur des boutons. */
.gg-info { display: inline-flex; align-items: center; min-height: 22px; margin-right: auto; }
.gg-info[hidden] { display: none; }
.gg-info > .bl { margin-left: 0; }
.gg-bouton {
  font: inherit; font-size: var(--fs-xs); line-height: 1; color: var(--ink-2); background: transparent;
  border: 1px solid var(--line); border-radius: var(--r2); padding: 4px 7px; min-height: 22px; cursor: pointer;
}
.gg-bouton:hover { color: var(--ink); border-color: var(--line-fort); }
.gg-bouton[aria-pressed="true"] { color: var(--ink); background: var(--bg-3); }
.gg-bouton:focus-visible, .gg-leg-item:focus-visible, .gg-leg-tout:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.gg-corps { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.gg-trace { position: relative; flex: 1 1 auto; min-height: 150px; min-width: 0; }
.gg-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: hidden; outline: none; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.gg-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

/* Densité compacte (options.densite, cellule de moins de 260 x 360 px) : textes de 10 px, légende sur une ligne,
   sous-titre dans la bulle (i) des notes, tracé minimal de 110 px. */
.gg.gg-compacte { gap: 3px; padding: 4px 6px 4px; }
.gg-compacte .gg-sous-titre { display: none; }
.gg-compacte .gg-trace { min-height: 110px; }
.gg-compacte .gg-corps { gap: 3px; }
.gg-compacte .gg-legende { max-height: 22px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.gg-compacte .gg-leg-item { min-height: 20px; padding: 1px 6px 1px 3px; font-size: var(--gg-fs-petit); }
/* Une ligne : les éléments se resserrent (libellés coupés, complets en infobulle) avant tout défilement horizontal. */
.gg-compacte:not([data-legende="droite"]) .gg-leg-item { flex: 0 1 auto; min-width: 44px; }
.gg-compacte[data-legende="droite"] .gg-legende { flex-wrap: nowrap; overflow-x: hidden; overflow-y: auto; max-height: none; width: clamp(110px, 26%, 180px); }
.gg-compacte .gg-bouton { min-height: 18px; padding: 2px 6px; }
.gg-compacte .gg-info { min-height: 18px; }
/* Barres horizontales dans une cellule : le tracé défile dans sa zone quand les catégories demandent plus de place. */
.gg-trace.gg-defile { overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
.gg-trace.gg-defile > .gg-svg { position: relative; inset: auto; height: auto; }

/* ==================================================================== 3. Légende */
.gg-legende { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; max-height: 58px; overflow-y: auto; scrollbar-width: thin; min-width: 0; }
.gg[data-legende="bas"] .gg-legende { order: 2; }
.gg[data-legende="droite"] .gg-corps { flex-direction: row; }
.gg[data-legende="droite"] .gg-legende { order: 2; flex-direction: column; flex-wrap: nowrap; align-items: stretch; width: clamp(130px, 22%, 220px); max-height: none; align-self: stretch; }
.gg-leg-item {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 24px; padding: 2px 8px 2px 5px;
  font: inherit; font-size: var(--fs-s); color: var(--ink); background: transparent;
  border: 1px solid transparent; border-radius: 999px; cursor: pointer; text-align: left;
}
.gg-leg-item:hover { background: var(--graph-curseur); }
.gg-leg-item.gg-masque { color: var(--ink-2); opacity: .55; }
.gg-leg-item.gg-masque .gg-leg-lib { text-decoration: line-through; }
.gg-leg-item.gg-masque .gg-pastille { filter: grayscale(1); }
.gg-leg-lib { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gg-leg-detail { flex: none; font-size: var(--fs-xs); color: var(--ink-2); }
.gg-leg-tout { font: inherit; font-size: var(--fs-xs); color: var(--ink-2); background: transparent; border: 1px dashed var(--line-fort); border-radius: 999px; padding: 2px 8px; min-height: 22px; cursor: pointer; }
.gg-pastille { flex: none; display: block; overflow: visible; }

/* ==================================================================== 4. Marques SVG */
.gg text { font-family: var(--font); font-size: var(--gg-fs-base); fill: var(--ink-2); }
.gg text.gg-petit { font-size: var(--gg-fs-petit); }
/* « n.d. » écrit dans le tracé (familles séries et statistiques) : une seule règle. */
.gg text.gs-nd-txt { font-size: var(--gg-fs-petit); font-style: italic; fill: var(--ink-2); }
.gg.gg-compacte text { font-size: var(--gg-fs-petit); }
.gg-grad { font-variant-numeric: tabular-nums; }
.gg text.gg-unite { font-size: var(--gg-fs-petit); font-weight: 600; fill: var(--ink-2); }
.gg-grille { stroke: var(--graph-grille); stroke-width: 1; shape-rendering: crispEdges; }
.gg-zero, .gg-axe { stroke: var(--graph-axe); stroke-width: 1; shape-rendering: crispEdges; }
.gg-barre { fill: var(--c); }
.gg-sep .gg-barre { stroke: var(--graph-fond); stroke-width: .75; }
.gg-motif-calque { pointer-events: none; }
.gg-motif-trait { stroke: var(--graph-motif); stroke-width: 1.1; fill: none; }
.gg-motif-point { fill: var(--graph-motif); }
.gg-ligne { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.gg-ligne-aire { stroke-width: 1.6; }
.gg-pointilles { stroke-dasharray: 6 4; }
.gg-aire { stroke: none; }
.gg-aire-pleine { fill: var(--c); fill-opacity: .74; stroke: none; }
/* Style « référence » (plan, budget, prévision, 3MRP, période précédente) : barres atténuées et contour de la couleur,
   aire claire du plan d'un combiné ; la pastille de légende et celle de l'infobulle suivent. */
.gg-barre-ref .gg-barre, .gg-barre.gg-barre-ref { fill-opacity: .35; stroke: var(--c); stroke-width: 1.25; }
.gg-aire-ref { fill: var(--c); fill-opacity: .16; stroke: none; }
.gg-stop-haut { stop-color: var(--c); stop-opacity: .42; }
.gg-stop-bas { stop-color: var(--c); stop-opacity: .03; }
.gg-marqueur { fill: var(--c); stroke: var(--graph-fond); stroke-width: 1.2; }
.gg-marqueur.gg-creux { fill: var(--graph-fond); stroke: var(--c); stroke-width: 1.6; }
.gg-tendance { fill: none; stroke: var(--c); stroke-width: 1.6; stroke-dasharray: 1.5 4; stroke-linecap: round; }
.gg-prev-bande { fill: var(--c); fill-opacity: .14; stroke: none; }
.gg-prev-ligne { fill: none; stroke: var(--c); stroke-width: 2; stroke-dasharray: 6 4; stroke-linecap: round; }
.gg-seuil { stroke: var(--warn); stroke-width: 1.25; stroke-dasharray: 5 3; }
.gg text.gg-seuil-txt { font-size: var(--gg-fs-petit); font-weight: 600; fill: var(--warn); paint-order: stroke; stroke: var(--graph-fond); stroke-width: 3px; stroke-linejoin: round; }
.gg-seuil.gg-ton-ok { stroke: var(--ok); }   .gg text.gg-seuil-txt.gg-ton-ok { fill: var(--ok); }
.gg-seuil.gg-ton-bad { stroke: var(--bad); } .gg text.gg-seuil-txt.gg-ton-bad { fill: var(--bad); }
.gg-seuil.gg-ton-info { stroke: var(--info); } .gg text.gg-seuil-txt.gg-ton-info { fill: var(--info); }
.gg-bande { fill: var(--graph-curseur); }
.gg text.gg-bande-txt { font-size: var(--gg-fs-petit); font-style: italic; fill: var(--ink-2); }
.gg-annot-guide { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.gg-annot-ligne { stroke: var(--ink-2); stroke-width: 1; }
.gg-annot-point { fill: var(--ink); stroke: var(--graph-fond); stroke-width: 1.5; }
.gg-annot-fond { fill: var(--bg-3); stroke: var(--line-fort); stroke-width: 1; }
.gg text.gg-annot-txt { font-size: var(--gg-fs-petit); font-weight: 600; fill: var(--ink); }
.gg text.gg-etiq { font-size: var(--gg-fs-petit); fill: var(--ink); font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--graph-fond); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.gg text.gg-etiq-dedans { fill: var(--graph-sur); stroke: none; }
.gg text.gg-etiq-total { font-weight: 600; }
.gg text.gg-etiq-fin { font-weight: 600; }
.gg text.gg-vide { font-size: var(--gg-fs-fort); fill: var(--ink-2); }
.gg-pm-cadre { fill: none; stroke: var(--graph-grille); stroke-width: 1; }
.gg text.gg-pm-titre { font-size: var(--gg-fs-petit); font-weight: 600; fill: var(--ink); }

/* Interaction */
.gg-curseur-bande { fill: var(--graph-curseur); }
.gg-curseur-ligne { stroke: var(--graph-axe); stroke-width: 1; stroke-dasharray: 3 3; }
.gg-point-actif { stroke: var(--graph-fond); stroke-width: 2; }
.gg-anneau-focus { fill: none; stroke: var(--focus); stroke-width: 2; }
.gg-anneau-survol { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.gg-selection { fill: color-mix(in srgb, var(--focus) 18%, transparent); stroke: var(--focus); stroke-width: 1; }
.gg-interactif { cursor: pointer; }
.gg-survol { filter: brightness(1.18); }
.gg-serie { transition: opacity var(--duree) ease; }
.gg-trace.gg-avant .gg-serie:not(.gg-actif) { opacity: .14; }
.gg-trace.gg-avant .gg-serie.gg-actif .gg-ligne { stroke-width: 2.6; }
@media (prefers-reduced-motion: no-preference) {
  .gg-entree .gg-c-donnees, .gg-entree .gg-c-etiquettes { animation: gg-apparition 420ms cubic-bezier(.2, .7, .2, 1) both; }
}
@keyframes gg-apparition { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==================================================================== 5. Infobulle */
.gg-infobulle {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; opacity: 0; visibility: hidden;
  transition: opacity 90ms ease; max-width: min(400px, calc(100% - 8px)); max-height: calc(100% - 8px); overflow: hidden;
  padding: 7px 9px; font-size: var(--fs-s); color: var(--ink);
  background: color-mix(in srgb, var(--bg-1) 94%, transparent); border: 1px solid var(--line-fort);
  border-radius: 6px; box-shadow: var(--ombre); backdrop-filter: blur(6px);
}
.gg-infobulle.gg-visible { opacity: 1; visibility: visible; }
.gg-ib-titre { font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gg-ib-lignes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px 14px; }
.gg-ib-lignes.gg-ib-2col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.gg-ib-ligne { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; column-gap: 6px; line-height: 1.45; min-width: 0; }
.gg-ib-vide { display: block; width: 18px; }
.gg-ib-lib { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.gg-ib-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.gg-ib-detail { grid-column: 2 / 4; font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.3; }
.gg-ib-total { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 2px; }
.gg-ib-secondaire .gg-ib-val { font-weight: 400; color: var(--ink-2); }
.gg-ib-nd .gg-ib-val { font-weight: 400; font-style: italic; color: var(--ink-2); }
.gg-ib-pied { margin-top: 4px; font-size: var(--fs-xs); color: var(--ink-2); }

/* ==================================================================== 6. Données accessibles */
.gg-cache, .gg-donnees:not(.gg-donnees-visible) {
  position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.gg-donnees.gg-donnees-visible {
  position: absolute; inset: 0; z-index: 6; overflow: auto; background: var(--graph-fond);
  border: 1px solid var(--line); border-radius: 4px; scrollbar-width: thin;
}
.gg-tableau { border-collapse: collapse; width: 100%; font-size: var(--fs-s); font-variant-numeric: tabular-nums; }
.gg-tableau caption { text-align: left; padding: 6px 8px; font-weight: 600; color: var(--ink); }
.gg-tableau th, .gg-tableau td { padding: 3px 8px; border-bottom: 1px solid var(--graph-grille); text-align: right; white-space: nowrap; }
.gg-tableau thead th { position: sticky; top: 0; background: var(--bg-2); color: var(--ink); font-weight: 600; }
.gg-tableau tbody th { text-align: left; font-weight: 400; color: var(--ink-2); }

/* ==================================================================== 7. Contraste forcé */
@media (forced-colors: active) {
  .gg-barre, .gg-aire-pleine, .gg-marqueur { fill: CanvasText; }
  .gg-ligne, .gg-tendance, .gg-prev-ligne, .gg-seuil { stroke: CanvasText; }
  .gg-motif-trait { stroke: Canvas; } .gg-motif-point { fill: Canvas; }
}
