/* Composants de l'appli. Aucune couleur ni taille brute ici : tout vient de tokens.css. */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--papier);
  color: var(--encre);
  font: 400 var(--t-m)/1.45 var(--f-texte);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  /* La barre d'onglets est fixe : on réserve sa place pour que le dernier enfant
     de la liste ne passe jamais dessous. */
  padding-bottom: calc(var(--barre-bas) + env(safe-area-inset-bottom) + var(--e-4));
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ——— En-tête ——— */
.entete {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: var(--e-3);
  padding: calc(env(safe-area-inset-top) + var(--e-3)) var(--e-4) var(--e-3);
  background: color-mix(in srgb, var(--papier) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--trait);
}
.entete-titre { font: 600 var(--t-l)/1.1 var(--f-titre); letter-spacing: -0.01em; }
.entete-titre small {
  display: block; margin-top: 2px;
  font: 400 var(--t-xs)/1.2 var(--f-texte); color: var(--encre-3); letter-spacing: 0;
}
.bouton-icone {
  width: var(--cible); height: var(--cible); flex: none;
  display: grid; place-items: center; border-radius: var(--r-rond); color: var(--encre-2);
}
.bouton-icone:active { background: var(--papier-2); }
/* Quatre icônes dans l'en-tête (thème, cloche, arbre, autres jeux) : un peu plus serrées pour
   laisser le titre respirer sur 375 px, en gardant une cible au pouce de 42 px. */
.entete .bouton-icone { width: 42px; height: 42px; }

.page { padding: var(--e-4); max-width: 560px; margin: 0 auto; }

/* ——— Fil d'ascendance ———
   La lignée jusqu'à Henry, sur une ligne qui défile : on sait toujours où l'on est. */
.fil {
  display: flex; gap: var(--e-1); align-items: center;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--e-4)) var(--e-4); padding: 0 var(--e-4);
}
.fil::-webkit-scrollbar { display: none; }
.fil a {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 var(--e-3);
  border-radius: var(--r-rond); background: var(--papier-2);
  font-size: var(--t-s); color: var(--encre-2); white-space: nowrap;
}
.fil a::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--branche, var(--accent));
}
.fil a[aria-current="page"] { background: var(--branche); color: var(--sur-branche); font-weight: 600; }
.fil a[aria-current="page"]::before { background: var(--sur-branche); }
.fil .sep { flex: none; color: var(--encre-3); font-size: var(--t-xs); }

/* ——— Titres de section ——— */
.section { margin-top: var(--e-5); }
.section-titre {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--e-2);
  font: 600 var(--t-xs)/1 var(--f-texte); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--encre-3);
}

/* ——— Carte héros : la personne affichée ———
   C'est déjà la silhouette de la future carte à jouer : bande de branche en haut,
   portrait, nom, et les « statistiques » en bas. */
.carte {
  position: relative; overflow: hidden;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--r-l);
  box-shadow: var(--ombre-2);
}
.carte-bande {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--e-2) var(--e-4);
  background: var(--branche); color: var(--sur-branche);
  font: 600 var(--t-xs)/1.2 var(--f-texte); letter-spacing: 0.06em; text-transform: uppercase;
}
.carte-corps { padding: var(--e-5) var(--e-4) var(--e-4); text-align: center; }
.carte-nom { margin-top: var(--e-3); font: 600 var(--t-xxl)/1.1 var(--f-titre); letter-spacing: -0.015em; }
.carte-nom .patronyme { display: block; font-size: var(--t-l); font-weight: 500; color: var(--encre-2); margin-top: 4px; }
.carte-prenoms { margin-top: var(--e-2); color: var(--encre-2); font-size: var(--t-s); }
.carte-dates {
  display: flex; justify-content: center; flex-wrap: wrap; gap: var(--e-2) var(--e-4);
  margin-top: var(--e-3); font-size: var(--t-s); color: var(--encre-2);
}
.carte-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--trait);
}
.carte-stats div { padding: var(--e-3) var(--e-1); text-align: center; }
.carte-stats div + div { border-left: 1px solid var(--trait); }
.carte-stats b { display: block; font: 600 var(--t-l)/1.1 var(--f-titre); }
.carte-stats span { font-size: var(--t-xs); color: var(--encre-3); }

/* ——— Portrait ———
   En attendant les photos : les initiales, cerclées de la couleur de branche. */
.portrait {
  width: 88px; height: 88px; margin: 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--papier-2); color: var(--branche);
  box-shadow: 0 0 0 3px var(--carte), 0 0 0 5px var(--branche);
  font: 600 30px/1 var(--f-titre);
}
.portrait.petit { width: 40px; height: 40px; font-size: 15px; box-shadow: 0 0 0 2px var(--branche); margin: 0; flex: none; }

/* ——— Ligne-personne : l'élément de liste universel ——— */
.liste { display: flex; flex-direction: column; gap: var(--e-2); }
.ligne {
  display: flex; align-items: center; gap: var(--e-3);
  min-height: 64px; padding: var(--e-2) var(--e-3);
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r-m);
  box-shadow: var(--ombre-1);
  transition: transform var(--duree) var(--courbe);
}
.ligne:active { transform: scale(0.985); }
.ligne-texte { flex: 1; min-width: 0; }
.ligne-nom { font: 600 var(--t-m)/1.25 var(--f-titre); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-info { font-size: var(--t-xs); color: var(--encre-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-fin { flex: none; display: flex; align-items: center; gap: var(--e-2); color: var(--encre-3); }
.pastille {
  min-width: 26px; height: 22px; padding: 0 7px; border-radius: var(--r-rond);
  display: inline-grid; place-items: center;
  background: var(--papier-2); color: var(--encre-2); font-size: var(--t-xs); font-weight: 600;
}

/* ——— Mini-carte : parents, fratrie ——— */
.defile {
  display: flex; gap: var(--e-2); overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--e-4)); padding: 2px var(--e-4) var(--e-2);
  scroll-snap-type: x proximity;
}
.defile::-webkit-scrollbar { display: none; }
.mini {
  flex: none; width: 116px; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; gap: var(--e-2);
  padding: var(--e-3) var(--e-2);
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r-m);
  border-top: 3px solid var(--branche);
  text-align: center;
}
.mini-nom { font: 600 var(--t-s)/1.2 var(--f-titre); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* ——— La fiche en morceau d'arbre ———
   Parents en haut, la personne au centre avec son conjoint, les enfants en dessous sur un
   rail : des traits relient les générations, comme sur un arbre dessiné (Eugène trouvait
   l'empilement de listes peu intuitif). */
.aide-arbre { margin: calc(-1 * var(--e-2)) 0 var(--e-3); font-size: var(--t-xs); color: var(--encre-3); text-align: center; }
.gen-titre {
  margin: 0 0 var(--e-2); text-align: center;
  font: 600 var(--t-xs)/1 var(--f-texte); letter-spacing: .08em; text-transform: uppercase; color: var(--encre-3);
}
.parents { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--e-1); }
.parents.un { grid-template-columns: minmax(0, 60%); justify-content: center; }
.parents .mini { width: auto; flex-direction: row; text-align: left; padding: var(--e-2); min-width: 0; }
.parents .mini-nom { font-size: var(--t-s); }
.lien-couple { font: 600 var(--t-l)/1 var(--f-titre); color: var(--accent); text-align: center; }
.trait-v { width: 2px; height: 22px; margin: 0 auto; background: var(--accent); opacity: .35; border-radius: 1px; }
.couple { display: flex; flex-direction: column; align-items: stretch; gap: var(--e-1); margin-top: var(--e-2); }
.couple .lien-couple { display: block; margin: 2px 0; }
/* Les enfants pendent d'un rail vertical, chacun relié par un petit trait. */
.rail { position: relative; display: flex; flex-direction: column; gap: var(--e-2); padding-left: 22px; }
.rail::before { content: ""; position: absolute; left: 9px; top: -6px; bottom: 32px; width: 2px; background: var(--accent); opacity: .35; border-radius: 1px; }
.rail > .ligne { position: relative; }
.rail > .ligne::before { content: ""; position: absolute; left: -13px; top: 50%; width: 13px; height: 2px; background: var(--accent); opacity: .35; }

.vide { padding: var(--e-4); text-align: center; color: var(--encre-3); font-size: var(--t-s);
  border: 1px dashed var(--trait); border-radius: var(--r-m); }

/* ——— Arbre dépliable ——— */
.arbre { display: flex; flex-direction: column; }
.noeud {
  display: flex; align-items: center; min-height: var(--cible);
  border-bottom: 1px solid var(--trait);
  /* Retrait plafonné : six générations doivent tenir dans 375 px sans que les noms
     de la sixième soient réduits à trois lettres. */
  padding-left: min(calc(var(--prof) * 14px), 84px);
}
.noeud-deplier {
  width: 40px; height: var(--cible); flex: none; display: grid; place-items: center; color: var(--encre-3);
}
.noeud-deplier svg { transition: transform var(--duree) var(--courbe); }
.noeud[aria-expanded="true"] .noeud-deplier svg { transform: rotate(90deg); }
.noeud-lien { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--e-2); min-height: var(--cible); padding-right: var(--e-2); }
.noeud-lien::before { content: ""; width: 4px; align-self: stretch; margin: 10px 0; border-radius: 2px; background: var(--branche); flex: none; }
.noeud-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noeud-nom small { color: var(--encre-3); }
.noeud.courant { background: var(--accent-doux); }

/* ——— Recherche ——— */
.champ {
  width: 100%; height: 52px; padding: 0 var(--e-4) 0 44px;
  border: 1px solid var(--trait); border-radius: var(--r-m);
  background: var(--carte) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%239a8b7a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cpath d='m14 14 4 4'/%3E%3C/svg%3E") no-repeat 14px center;
  color: var(--encre); font: 400 var(--t-m) var(--f-texte);
  outline: none;
}
.champ:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.branches { display: flex; gap: var(--e-2); flex-wrap: wrap; margin-top: var(--e-3); }
.puce {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--e-3);
  border-radius: var(--r-rond); background: var(--papier-2); font-size: var(--t-s); color: var(--encre-2);
}
.puce::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--branche); }
.puce[aria-pressed="true"] { background: var(--branche); color: var(--sur-branche); }
.puce[aria-pressed="true"]::before { background: var(--sur-branche); }

/* ——— Barre d'onglets ——— */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--barre-bas) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--carte) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--trait);
}
.onglets a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--encre-3);
}
.onglets a[aria-current="page"] { color: var(--accent); }

.apparait { animation: apparait var(--duree) var(--courbe); }
@keyframes apparait { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .apparait { animation: none; } .ligne, .noeud-deplier svg { transition: none; } }
