/* Gazouillette – Phylogénie v0.5.7.
 * Réglages en CSS classique uniquement : couleurs, largeur, padding,
 * polices, écarts et rayons sont définis par les classes ci-dessous.
 * Pour les cases : width: max-content = largeur selon le texte,
 * width: Npx = largeur fixe, max-width = limite de largeur.
 * Voir exemple-personnalisation.css et README.md.
 */
.gz-phylo {
  margin: 1.5rem 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #263c36;
  background: transparent; /* fond extérieur éventuel */
}
#arbre { scroll-margin-top: 96px; }
.gz-phylo * { box-sizing: border-box; }

/* MÉTRIQUES DE DISPOSITION : ce sont des classes appliquées à des éléments
 * de mesure invisibles. Le JS lit les propriétés habituelles de CSS.
 * column-gap/row-gap = espacement horizontal/vertical minimal des sous-arbres.
 * padding = marges internes du dessin, min-width/height = plancher du SVG.
 */
.gz-phylo-layout-metrics {
  column-gap: 76px;
  /* Réserve davantage de hauteur entre sous-arbres pour séparer les dates
   * des noms libres lorsque leurs branches sont très rapprochées. */
  row-gap: 42px;
  padding: 30px 36px
           30px 24px;
  min-width: 500px;
  min-height: 160px;
}
.gz-phylo-text-metrics {
  row-gap: 2px;
  line-height: 1.3;
  padding-right: 18px; /* place pour +/− */
}
.gz-phylo-branch-metrics {
  max-width: 210px;
  padding: 3px 6px;
  margin-bottom: 7px;
  margin-right: 13px;
}
.gz-phylo-divergence-metrics {
  padding: 2px 5px;
  margin-top: 12px;
}

/* Mesures de chaque case, lues depuis les classes par le JavaScript :
 * width: max-content = ajuste le cadre au contenu (dans min/max-width).
 * width: XXXpx = conserve une largeur fixe.
 * Les dimensions incluent le padding (box-sizing: border-box).
 */
.gz-phylo-node { border-radius: 8px; }
.gz-phylo-node-groupe {
  width: 118px;
  min-width: 90px;
  max-width: 300px;
  min-height: 44px;
  padding: 11px 16px
           11px 16px;
}
.gz-phylo-node-ordre {
  width: 218px; /* mettre max-content pour activer l'ajustement automatique */
  min-width: 115px;
  max-width: 340px;
  min-height: 44px;
  padding: 11px 21px
           11px 21px;
}
.gz-phylo-node-famille {
  width: max-content; /* les familles sont automatiquement ajustées */
  min-width: 90px;
  max-width: 240px;
  min-height: 44px;
  padding: 11px 21px
           11px 21px;
}
.gz-phylo-node-especes {
  /* Une ligne saisie reste entière si elle tient dans max-width.
   * Chaque retour chariot manuel est conservé par le moteur de dessin.
   */
  width: max-content;
  min-width: 70px;
  max-width: 340px;
  min-height: 44px;
  padding: 11px 12px
           11px 12px;
}

/* Fond général, boutons d'action et boutons de zoom. */
.gz-phylo-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 7px; margin: 0 0 9px;
}
.gz-phylo-toolbar button {
  display: inline-flex; align-items: center; justify-content: center;
  appearance: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1.3;
  border: 1px solid #a9b9b0; border-radius: 6px;
  padding: 7px 11px;
  background: #f9fbf9;
  color: #304d3f;
}
.gz-phylo-toolbar button:hover { background: #e8f1eb; border-color: #658475; }
/* Sélecteur de vue (facultatif) : deux boutons exclusifs.
 * Un réglage visuel distinct est possible sans toucher aux autres boutons.
 */
.gz-phylo-view-switch {
  display: inline-flex; flex-wrap: wrap; gap: 0;
  margin-right: 10px;
  border-radius: 6px;
}
.gz-phylo-view-switch button { border-radius: 0; }
.gz-phylo-view-switch button:first-child { border-radius: 6px 0 0 6px; }
.gz-phylo-view-switch button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.gz-phylo-view-switch button[aria-pressed="true"] {
  background: #d3e9d8;
  border-color: #739c80;
  color: #1d5138;
  font-weight: 700;
  z-index: 1;
}
.gz-phylo-view-switch button[aria-pressed="true"]:hover {
  background: #c6e1ce;
}
.gz-phylo-view-switch button:disabled { opacity: 0.5; cursor: not-allowed; }

/* RECHERCHE : interface séparée pour ne pas modifier les boutons de zoom.
 * Les styles des résultats et des chemins sont définis plus bas.
 */
.gz-phylo-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 9px; }
.gz-phylo-search label { font-size: 13px; font-weight: 600; margin: 0; align-self: center; line-height: 1.4; }
.gz-phylo-search-controls { min-width: 0; display: flex; flex: 1 1 330px; align-items: center; gap: 8px; flex-wrap: wrap; }
.gz-phylo-search-input {
  box-sizing: border-box; margin: 0; flex: 1 1 240px; min-width: 120px; max-width: 500px;
  padding: 7px 10px; border: 1px solid #a9b9b0; border-radius: 6px;
  font-family: inherit; font-size: 14px; line-height: 1.4;
  color: #263c36; background: #fff;
}
/* Éviter deux croix d'effacement (celle du navigateur et celle du plugin). */
.gz-phylo-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.gz-phylo-search-clear {
  border: 1px solid #a9b9b0; border-radius: 6px; background: #f9fbf9;
  color: #304d3f; font: 600 18px/1 system-ui,sans-serif;
  padding: 7px 11px; cursor: pointer;
}
.gz-phylo-search-clear:hover { background: #e8f1eb; }
.gz-phylo-search-clear[hidden] { display: none !important; }
.gz-phylo-search-count { color: #557267; font-size: 13px; }
.gz-phylo-status { color: #557267; font-size: 13px; margin: 0 0 10px; }
.gz-phylo-status.is-error, .gz-phylo-error { color: #b2322a; }
.gz-phylo-viewport {
  display: block; width: 100%; height: auto;
  min-height: 0; max-height: none;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
  border: 1px solid #c9d8d0;
  border-radius: 9px;
  background: #fbfdfb; /* fond général de l'arbre */
  cursor: grab;
  scrollbar-color: #aabeb3 #f5f8f6;
}
.gz-phylo-viewport.is-panning { cursor: grabbing; user-select: none; }
/* Aperçu latéral : le cadre occupe toute la colonne et centre le dessin.
 * Son viewBox est ajusté en JS sur l'emprise réelle des branches et cases :
 * les marges du grand arbre ne réduisent plus l'aperçu visible.
 */
.gz-phylo-sidebar-preview { width: 100%; max-width: 100%; min-width: 0; margin: 1rem 0; }
.gz-phylo-sidebar-preview-link {
  display: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: hidden;
  border: 1px solid #c9d8d0;
  border-radius: 9px;
  background: #fbfdfb;
  color: inherit;
  text-decoration: none;
}
.gz-phylo-preview-svg {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  flex: 0 1 100%;
  margin-inline: auto;
  overflow: hidden;
}
/* Légende intégrée à l'en-tête du viewport, sans recouvrir les cases.
 * Elle défile verticalement avec la page, mais reste contre le bord droit
 * du viewport lors du défilement horizontal du cladogramme.
 */
.gz-phylo-legend {
  position: sticky; left: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 5px 15px; width: 100%; padding: 10px 14px 3px;
  color: #476054; background: transparent;
  font: 500 12px/1.3 system-ui, sans-serif;
  pointer-events: none;
}
.gz-phylo-legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.gz-phylo-legend-item svg { display: block; width: 24px; height: 16px; flex: 0 0 auto; }
.gz-phylo-legend-item .gz-phylo-legend-dashed { width: 40px; }
.gz-phylo-legend-item rect { stroke-width: 1.2; }
.gz-phylo-svg { display: block; max-width: none !important; max-height: none !important; overflow: visible; }
.gz-phylo-css-probe, .gz-phylo-text-probe {
  position: absolute !important; top: 0; left: 0;
  height: 0; visibility: hidden; pointer-events: none; overflow: hidden;
}
.gz-phylo-text-probe { width: 0; }

/* Liens, embranchements, noms de branches et datations. */
.gz-phylo-link {
  fill: none;
  stroke: #91a79b;
  stroke-width: 1.8px;
  stroke-linecap: round; stroke-linejoin: round;
}
/* Position incertaine : les 3 segments du chemin parent -> enfant sont
 * concernés. Les parties communes sont pointillées dès qu'un trajet
 * incertain les emprunte. Le CSS de recherche conserve ces tirets.
 */
.gz-phylo-link-uncertain { stroke-dasharray: 6px 4px; }
.gz-phylo-junction {
  fill: #597e6d;
  r: 3.5px;
}
.gz-phylo-junction-toggle {
  fill: #fff; stroke: #597e6d; stroke-width: 1.4;
  r: 9px;
}
.gz-phylo-simple-sign { pointer-events: none; font: 700 14px system-ui, sans-serif; fill: #37604d; }
.gz-phylo-branch-label-back {
  fill: #fbfdfb;
  fill-opacity: .98; pointer-events: none;
}
.gz-phylo-divergence-back {
  fill: #fbfdfb;
  fill-opacity: .98; pointer-events: none;
}
.gz-phylo-branch-label {
  pointer-events: none;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  fill: #466353;
}
.gz-phylo-divergence-label {
  pointer-events: none;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  fill: #466353;
}
.gz-phylo-simple.gz-phylo-interactive { cursor: pointer; }
.gz-phylo-simple.gz-phylo-interactive:hover .gz-phylo-junction-toggle { stroke: #277657; stroke-width: 2.5; }

/* Couleurs des cases : fond + bordure de leur rectangle, texte de chaque type.
 * Pour les ordres, le nom scientifique se règle indépendamment si nécessaire.
 */
.gz-phylo-node rect { stroke-width: 1.2; }
.gz-phylo-node-groupe rect {
  fill: #d3e9d8;
  stroke: #739c80;
}
.gz-phylo-node-ordre rect {
  fill: #e6eff9;
  stroke: #8aacc9;
}
.gz-phylo-node-famille rect {
  fill: #e8f3ea;
  stroke: #8bb49a;
}
.gz-phylo-node-especes rect {
  fill: #fff7e9;
  stroke: #d7bd8e;
}
.gz-phylo-node text { pointer-events: none; font-family: system-ui, sans-serif; }
.gz-phylo-label-main { font-size: 14px; font-weight: 600; fill: #284136; }
.gz-phylo-node-groupe .gz-phylo-label-main { font-size: 14px; }
.gz-phylo-node-ordre .gz-phylo-label-main {
  font-size: 14px;
  fill: #294b67;
}
.gz-phylo-node-famille .gz-phylo-label-main { font-size: 14px; }
/* Nom scientifique facultatif des groupes et des ordres. */
.gz-phylo-node-groupe .gz-phylo-label-scientific {
  font-size: 12px;
  font-style: italic;
  font-weight: 400;
  fill: #527665;
}
.gz-phylo-node-ordre .gz-phylo-label-scientific {
  font-size: 12px;
  font-style: italic;
  fill: #5d7488;
}
.gz-phylo-node-especes .gz-phylo-label-species {
  font-size: 13px;
  font-weight: 400;
  fill: #53452e;
}
.gz-phylo-tag-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.gz-phylo-tag-link--galerie { color: #657d55; }
.gz-phylo-article-case-link { cursor: pointer; text-decoration: none; }
.gz-phylo-tag-toggle { cursor: pointer; }
.gz-phylo-tag-link__icon {
  fill: currentColor;
  font-family: system-ui, sans-serif;
  font-size: 16px;
  pointer-events: none;
}
.gz-phylo-node-especes .gz-phylo-tag-link__hitarea {
  fill: transparent;
  stroke: none;
  stroke-width: 0;
  pointer-events: all;
}
.gz-phylo-gallery-preview {
  position: fixed;
  z-index: 100000;
  display: grid;
  max-width: calc(100vw - 16px);
  padding: 6px;
  border: 1px solid #c9d8d0;
  border-radius: 7px;
  background: #fbfdfb;
  box-shadow: 0 4px 14px rgba(25, 45, 35, .2);
  pointer-events: none;
}
.gz-phylo-gallery-preview[hidden] { display: none; }
.gz-phylo-gallery-preview .gz-galeries-visuel {
  display: block;
  position: static;
  width: max-content;
  max-width: 220px;
  aspect-ratio: auto;
  overflow: visible;
}
.gz-phylo-gallery-preview .gz-galeries-visuel img {
  position: static;
  inset: auto;
  display: block;
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 170px;
  object-fit: contain;
  transition: none;
}
.gz-phylo-toggle-sign { fill: #47755b; font-size: 19px; font-weight: 700; }
.gz-phylo-interactive { cursor: pointer; }
.gz-phylo-node-especes .gz-phylo-tag-toggle__hitarea {
  fill: transparent;
  stroke: none;
  stroke-width: 0;
  pointer-events: all;
}
@media (max-width: 700px) {
  .gz-phylo-toolbar button { font-size: 12px; padding: 6px 8px; }
}

/* RECHERCHE : toutes les couleurs et épaisseurs restent modifiables depuis
 * le CSS du thème. Les classes sont appliquées dynamiquement dans le SVG.
 * La couleur des chemins sélectionnés est appliquée directement aux traits,
 * sans seconde ligne pleine sous les tirets. Les éléments non concernés
 * gardent leur apparence normale.
 */
.gz-phylo-search-path {
  fill: none;
  stroke: #e59b22;
  stroke-width: 3.8px;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.gz-phylo-node.gz-phylo-search-match > rect {
  fill: #fff1b8;
  fill-opacity: 1;
  stroke: #dc8f17;
  stroke-width: 2.5px;
}
.gz-phylo-node-especes.gz-phylo-search-match > rect,
.gz-phylo-node-especes.gz-phylo-search-match > .gz-phylo-article-case-link > rect {
  fill: #fff1b8 !important;
  fill-opacity: 1 !important;
  stroke: #dc8f17 !important;
  stroke-width: 2.5px !important;
}
.gz-phylo-node.gz-phylo-search-match text {
  fill: #704716;
}
.gz-phylo-simple.gz-phylo-search-match .gz-phylo-junction,
.gz-phylo-simple.gz-phylo-search-match .gz-phylo-junction-toggle {
  fill: #fff1b8;
  stroke: #dc8f17;
  stroke-width: 2.7px;
}
.gz-phylo-simple.gz-phylo-search-match .gz-phylo-branch-label,
.gz-phylo-simple.gz-phylo-search-match .gz-phylo-divergence-label {
  fill: #b16a00;
  font-weight: 750;
}

/* Aucun entourage de focus dans l'interface publique de l'arbre.
 * La spécificité couvre aussi les anciennes règles de focus du champ de
 * recherche dans le thème. Les bordures normales et les survols sont gardés.
 */
.gz-phylo.gz-phylo :is(button, input, a, [tabindex]):is(:focus, :focus-visible) {
  outline: none !important;
  box-shadow: none !important;
}
.gz-phylo .gz-phylo-toolbar button:is(:focus, :focus-visible) {
  border-width: 1px !important;
}
