/* ashable — arbre.css : la navigation « arbre » (idée d’Ash 23/09 20h27, cadrage Fable 20h45).
   Un seul bouton central, le tronc. Un appui : 5 racines sur l’anneau 1 (Projet, Tournage, Montage, Livraison, Réglages).
   Toucher une racine : elle glisse au centre, ses enfants s’ouvrent sur l’anneau 2 (≈ 1,55 × l’anneau 1), le voile s’épaissit.
   Deux niveaux, jamais trois. La racine au centre ramène à l’anneau 1 ; « Ouvrir … » sous elle mène à sa page globale.
   Remplace le bloc .cadran d’app.css (qu’il ne touche pas). Ne dépend que de tokens.css et de la classe .glass d’app.css.
   Aucune couleur en dur : tout vient des variables de tokens.css. Positions par data-i, jamais par :nth-child
   (un élément inséré décalerait tout). Géométrie vérifiée à 320, 375, 393 et 430 px de large (outils/verifie-arbre.py). */

.arbre{
  --ar-tronc:calc(52px + env(safe-area-inset-bottom));  /* centre du tronc, compté depuis le bas */
  --ar-o:calc(var(--ar-tronc) + 16px);                  /* centre des anneaux : 16 px au-dessus du tronc (le rayon du cadran actuel, repris tel quel) */
  --ar-taille:56px;                                      /* diamètre d’une pastille */
  --ar-r1:min(130px,35vw);                               /* anneau 1 : les 5 racines (le rayon du cadran actuel) */
  --ar-r2:min(201px,54vw);                               /* anneau 2 : les enfants, ≈ 1,55 × l’anneau 1 */
  --ar-montee:calc(66px + var(--ar-taille)/2);           /* hauteur de la racine choisie au-dessus du centre : le tronc, la porte, puis elle */
  --ar-voile-1:color-mix(in srgb,var(--bg) 55%,transparent);   /* niveau 1 : la page se retire */
  --ar-voile-2:color-mix(in srgb,var(--bg) 86%,transparent);   /* niveau 2 : plus opaque (l’opacité monte, jamais le flou) */
  --ar-trait:color-mix(in srgb,var(--ink-3) 55%,transparent); /* les branches dessinées */
  position:fixed;left:0;right:0;bottom:0;height:0;z-index:50
}

/* ---- voile : clair en Épure, sombre en Épure nuit (il suit le thème) ---- */
.arbre .voile{position:fixed;inset:0;background-color:var(--ar-voile-1);-webkit-backdrop-filter:blur(8px) saturate(120%);backdrop-filter:blur(8px) saturate(120%);opacity:0;visibility:hidden;touch-action:none;
  transition:opacity var(--t) var(--ease),background-color var(--t) var(--ease),visibility 0s linear var(--t)}
.arbre.ouvert .voile{opacity:1;visibility:visible;transition:opacity var(--t) var(--ease),background-color var(--t) var(--ease),visibility 0s}
/* ce qui s’efface ne capte plus le toucher dès le premier instant (le fondu dure 0,35 s, le doigt n’attend pas) */
.arbre .voile,.arbre .racine,.arbre .enfant,.arbre .porte,.arbre .projet-courant{pointer-events:none}
.arbre.ouvert .voile,.arbre.ouvert .projet-courant,.arbre.ouvert:not(.profond) .racine,.arbre.profond .deployee>.racine,.arbre.profond .deployee>.enfant,.arbre.profond .deployee>.porte{pointer-events:auto}
.arbre.profond .voile{background-color:var(--ar-voile-2)}
/* sans flou (navigateur qui ne le connaît pas, ou « réduire la transparence ») : un voile presque plein, sinon le texte de la page
   se mêle aux libellés */
@supports not ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){.arbre{--ar-voile-1:color-mix(in srgb,var(--bg) 90%,transparent);--ar-voile-2:color-mix(in srgb,var(--bg) 96%,transparent)}}
@media (prefers-reduced-transparency:reduce){.arbre{--ar-voile-1:color-mix(in srgb,var(--bg) 92%,transparent);--ar-voile-2:var(--bg)}}

/* ---- sonde : un élément invisible dont le navigateur calcule les cotes (min(), vw, env() résolus) ; arbre.js y lit la géométrie
   pour dessiner les branches : bottom = centre du tronc, height = écart tronc → centre des anneaux, padding-left = r1, width = r2, padding-top = montée ---- */
.arbre .sonde{position:absolute;left:0;bottom:var(--ar-tronc);width:var(--ar-r2);height:calc(var(--ar-o) - var(--ar-tronc));padding:var(--ar-montee) 0 0 var(--ar-r1);box-sizing:content-box;visibility:hidden;pointer-events:none}

/* ---- branches dessinées (arbre.js trace les courbes ; sans lui, rien ne s’affiche) ---- */
.arbre .liens{position:fixed;left:0;top:0;width:100%;height:100%;pointer-events:none;overflow:visible}
.arbre .liens path{fill:none;stroke:var(--ar-trait);stroke-width:1.25;stroke-linecap:round;stroke-dasharray:var(--ar-long,400);stroke-dashoffset:var(--ar-long,400);opacity:0;
  transition:stroke-dashoffset .22s var(--ease),opacity .18s var(--ease)}
.arbre .liens path.on{stroke:color-mix(in srgb,var(--accent) 60%,transparent);stroke-width:1.5}
.arbre.ouvert:not(.profond) .liens .l1 path,.arbre.profond .liens .l2.actif path{stroke-dashoffset:0;opacity:1;transition:stroke-dashoffset .36s var(--ease) .04s,opacity .2s var(--ease) .04s}

/* ---- le tronc : le seul bouton visible quand l’arbre est fermé ---- */
.arbre .tronc{position:absolute;z-index:2;left:50%;bottom:calc(var(--ar-tronc) - 32px);width:64px;height:64px;margin-left:-32px;border-radius:50%;color:var(--ink);
  box-shadow:var(--shadow-float),inset 0 1px 0 var(--glass-hi);-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;touch-action:none;-webkit-tap-highlight-color:transparent;
  transition:transform var(--t-fast) var(--ease)}
.arbre .tronc:active{transform:scale(.95)}
.arbre .tronc svg{position:absolute;left:50%;top:50%;width:24px;height:24px;margin:-12px 0 0 -12px;transition:opacity .2s var(--ease),transform var(--t) var(--ease)}
.arbre .tronc .sv-close{opacity:0;transform:rotate(-90deg) scale(.6)}
.arbre:not(.pret) .tronc .sv-sec{opacity:0}
.arbre.ouvert .tronc .sv-sec{opacity:0;transform:rotate(90deg) scale(.6)}
.arbre.ouvert .tronc .sv-close{opacity:1;transform:none}

/* ---- le projet en cours : une ligne de verre au-dessus de l’anneau ouvert ; elle mène à tous les projets ---- */
.arbre .projet-courant{position:absolute;z-index:1;left:50%;bottom:calc(var(--ar-o) + var(--ar-r1) + var(--ar-taille)/2 + 30px);max-width:calc(100% - 32px);min-height:34px;padding:0 10px 0 12px;border-radius:var(--r-pill);
  display:inline-flex;align-items:center;gap:7px;font-size:13px;font-weight:600;letter-spacing:-.015em;color:var(--ink);white-space:nowrap;-webkit-tap-highlight-color:transparent;
  transform:translate(-50%,10px);opacity:0;visibility:hidden;transition:transform var(--t) var(--ease),opacity .2s var(--ease),visibility 0s linear var(--t)}
.arbre .projet-courant::after{content:"";position:absolute;left:0;right:0;top:-5px;bottom:-5px}
.arbre .projet-courant span{overflow:hidden;text-overflow:ellipsis}
.arbre .projet-courant svg{width:15px;height:15px;flex:0 0 15px;color:var(--ink-2)}
.arbre .projet-courant .chev{width:13px;height:13px;flex-basis:13px;color:var(--ink-3)}
.arbre.ouvert .projet-courant{transform:translate(-50%,0);opacity:1;visibility:visible;transition:transform var(--t) var(--ease),opacity .25s var(--ease) .05s,visibility 0s}
.arbre.profond .projet-courant{transform:translate(-50%,calc(var(--ar-r1) - var(--ar-r2)))}

/* ---- pastilles : racines et enfants (même dessin, deux anneaux) ---- */
.arbre .racine,.arbre .enfant{position:absolute;left:calc(50% - var(--ar-taille)/2);bottom:calc(var(--ar-o) - var(--ar-taille)/2);width:var(--ar-taille);height:var(--ar-taille);border-radius:50%;
  display:grid;place-items:center;color:var(--ink);box-shadow:var(--shadow-float),inset 0 1px 0 var(--glass-hi);-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;
  --ar-x:0px;--ar-y:0px;--ar-s:.5;transform:translate(var(--ar-x),var(--ar-y)) scale(var(--ar-s));opacity:0;visibility:hidden}
.arbre .racine svg,.arbre .enfant svg{width:22px;height:22px}
/* pastilles, porte et ligne du projet n’existent que sur le voile, qui floute déjà la page : pas de second flou (les vieux téléphones
   souffrent du flou empilé ; le tronc garde le sien, il vit aussi sur la page nue) */
.arbre .racine,.arbre .enfant,.arbre .porte,.arbre .projet-courant{-webkit-backdrop-filter:none;backdrop-filter:none}
.arbre .racine b,.arbre .enfant b{position:absolute;left:50%;bottom:calc(100% + 5px);transform:translateX(var(--ar-lx,-50%));width:max-content;max-width:110px;white-space:nowrap;text-align:center;
  font-size:11.5px;font-weight:600;line-height:1.15;letter-spacing:-.01em;color:var(--ink);text-shadow:0 0 8px var(--bg),0 0 2px var(--bg);pointer-events:none;transition:opacity .2s var(--ease)}
.arbre .racine:focus-visible,.arbre .enfant:focus-visible,.arbre .porte:focus-visible,.arbre .projet-courant:focus-visible,.arbre .tronc:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
/* la page où l’on est : la racine et l’enfant prennent le dégradé (sans filet de bordure : background-origin) */
.arbre .racine.on,.arbre .enfant.on{background:var(--grad);background-origin:border-box;border-color:transparent;color:var(--on-accent)}
.arbre .racine.on::before,.arbre .enfant.on::before{display:none}

/* racines : fermé → au centre, petites ; ouvert → sur l’anneau 1, en éventail (22 ms d’écart) */
.arbre .racine{transition:transform var(--t) var(--ease),opacity .22s var(--ease),visibility 0s linear var(--t)}
.arbre.ouvert .racine{--ar-x:calc(var(--ar-ux) * var(--ar-r1));--ar-y:calc(var(--ar-uy) * var(--ar-r1));--ar-s:1;opacity:1;visibility:visible;
  transition:transform var(--t) var(--ease) calc(var(--ar-k) * 22ms),opacity .22s var(--ease) calc(var(--ar-k) * 22ms),visibility 0s}
/* niveau 2 : les autres racines reculent et s’effacent ; celle qu’on a touchée monte au centre */
.arbre.profond .racine{--ar-s:.6;opacity:0;visibility:hidden;transition:transform var(--t) var(--ease),opacity .2s var(--ease),visibility 0s linear var(--t)}
.arbre.profond .deployee>.racine{--ar-x:0px;--ar-y:calc(-1 * var(--ar-montee));--ar-s:1.06;opacity:1;visibility:visible;transition:transform var(--t) var(--ease),opacity .2s var(--ease),visibility 0s}
.arbre.profond .deployee>.racine b{opacity:0}

/* enfants : cachés dans la racine au centre ; niveau 2 → sur l’anneau 2, un peu plus petits (la profondeur) */
.arbre .enfant{--ar-y:calc(-1 * var(--ar-montee));--ar-s:.35;transition:transform .26s var(--ease),opacity .18s var(--ease),visibility 0s linear .26s}
.arbre.profond .deployee>.enfant{--ar-x:calc(var(--ar-vx) * var(--ar-r2));--ar-y:calc(var(--ar-vy) * var(--ar-r2));--ar-s:.94;opacity:1;visibility:visible;
  transition:transform .34s var(--ease) calc(40ms + var(--ar-k) * 18ms),opacity .22s var(--ease) calc(40ms + var(--ar-k) * 18ms),visibility 0s}

/* la porte : « Ouvrir Projet », sous la racine au centre = la page globale sans passer par les branches (le « double » d’Ash) */
.arbre .porte{position:absolute;left:50%;bottom:calc(var(--ar-o) + 24px);min-height:34px;padding:0 10px 0 14px;border-radius:var(--r-pill);display:inline-flex;align-items:center;gap:4px;
  font-size:13px;font-weight:600;letter-spacing:-.015em;color:var(--accent);white-space:nowrap;box-shadow:var(--shadow-card),inset 0 1px 0 var(--glass-hi);-webkit-tap-highlight-color:transparent;
  transform:translate(-50%,8px) scale(.96);opacity:0;visibility:hidden;transition:transform .26s var(--ease),opacity .18s var(--ease),visibility 0s linear .26s}
.arbre .porte::after{content:"";position:absolute;left:0;right:0;top:-5px;bottom:-5px}
.arbre .porte svg{width:13px;height:13px;flex:0 0 13px}
.arbre.profond .deployee>.porte{transform:translate(-50%,0);opacity:1;visibility:visible;transition:transform .3s var(--ease) .1s,opacity .22s var(--ease) .1s,visibility 0s}

/* survol pendant le glisser (maintenir le tronc, glisser, relâcher) */
.arbre.ouvert .racine.survol,.arbre.profond .deployee>.racine.survol{--ar-s:1.14;box-shadow:0 0 0 3px var(--tint-a),var(--shadow-float)}
.arbre.profond .deployee>.enfant.survol{--ar-s:1.08;box-shadow:0 0 0 3px var(--tint-a),var(--shadow-float)}
.arbre .porte.survol,.arbre .projet-courant.survol{box-shadow:0 0 0 3px var(--tint-a),var(--shadow-card)}
@media (hover:hover){.arbre.ouvert .racine:hover{--ar-s:1.05}.arbre.profond .deployee>.enfant:hover{--ar-s:1}.arbre.profond .deployee>.racine:hover{--ar-s:1.1}}

/* ---- anneau 1 : cinq racines de -160° à -20° (vecteurs unitaires : x = cos, y = sin, y vers le haut négatif) ---- */
.arbre .branche[data-i="0"]{--ar-ux:-.9397;--ar-uy:-.342;--ar-k:0}
.arbre .branche[data-i="1"]{--ar-ux:-.5736;--ar-uy:-.8192;--ar-k:1}
.arbre .branche[data-i="2"]{--ar-ux:0;--ar-uy:-1;--ar-k:2}
.arbre .branche[data-i="3"]{--ar-ux:.5736;--ar-uy:-.8192;--ar-k:3}
.arbre .branche[data-i="4"]{--ar-ux:.9397;--ar-uy:-.342;--ar-k:4}
/* les deux racines du bas : libellé tiré vers l’extérieur, sinon il mord sur la voisine du dessus */
.arbre .branche[data-i="0"]>.racine b{--ar-lx:calc(-100% + 14px)}
.arbre .branche[data-i="4"]>.racine b{--ar-lx:-14px}

/* ---- anneau 2 : 2 à 5 enfants, en éventail resserré (--ar-ax = |x|, sert à borner la largeur du libellé) ---- */
.arbre .branche[data-n="5"]>.enfant[data-i="0"]{--ar-vx:-.7431;--ar-vy:-.6691;--ar-ax:.7431;--ar-k:0}
.arbre .branche[data-n="5"]>.enfant[data-i="1"]{--ar-vx:-.4067;--ar-vy:-.9135;--ar-ax:.4067;--ar-k:1}
.arbre .branche[data-n="5"]>.enfant[data-i="2"]{--ar-vx:0;--ar-vy:-1;--ar-ax:0;--ar-k:2}
.arbre .branche[data-n="5"]>.enfant[data-i="3"]{--ar-vx:.4067;--ar-vy:-.9135;--ar-ax:.4067;--ar-k:3}
.arbre .branche[data-n="5"]>.enfant[data-i="4"]{--ar-vx:.7431;--ar-vy:-.6691;--ar-ax:.7431;--ar-k:4}
.arbre .branche[data-n="4"]>.enfant[data-i="0"]{--ar-vx:-.7071;--ar-vy:-.7071;--ar-ax:.7071;--ar-k:0}
.arbre .branche[data-n="4"]>.enfant[data-i="1"]{--ar-vx:-.2588;--ar-vy:-.9659;--ar-ax:.2588;--ar-k:1}
.arbre .branche[data-n="4"]>.enfant[data-i="2"]{--ar-vx:.2588;--ar-vy:-.9659;--ar-ax:.2588;--ar-k:2}
.arbre .branche[data-n="4"]>.enfant[data-i="3"]{--ar-vx:.7071;--ar-vy:-.7071;--ar-ax:.7071;--ar-k:3}
.arbre .branche[data-n="3"]>.enfant[data-i="0"]{--ar-vx:-.5878;--ar-vy:-.809;--ar-ax:.5878;--ar-k:0}
.arbre .branche[data-n="3"]>.enfant[data-i="1"]{--ar-vx:0;--ar-vy:-1;--ar-ax:0;--ar-k:1}
.arbre .branche[data-n="3"]>.enfant[data-i="2"]{--ar-vx:.5878;--ar-vy:-.809;--ar-ax:.5878;--ar-k:2}
.arbre .branche[data-n="2"]>.enfant[data-i="0"]{--ar-vx:-.3746;--ar-vy:-.9272;--ar-ax:.3746;--ar-k:0}
.arbre .branche[data-n="2"]>.enfant[data-i="1"]{--ar-vx:.3746;--ar-vy:-.9272;--ar-ax:.3746;--ar-k:1}
/* les enfants des extrémités : libellé rentré de 8 px vers le centre (il y a de la place de ce côté), ce qui lui rend 16 px de largeur */
.arbre .branche[data-n="5"]>.enfant[data-i="0"],.arbre .branche[data-n="4"]>.enfant[data-i="0"]{--ar-dl:8px;--ar-lx:calc(-50% + 8px)}
.arbre .branche[data-n="5"]>.enfant[data-i="4"],.arbre .branche[data-n="4"]>.enfant[data-i="3"]{--ar-dl:8px;--ar-lx:calc(-50% - 8px)}
/* un libellé d’enfant ne sort jamais de l’écran : sa largeur est bornée par la place qui reste jusqu’au bord, 8 px de marge
   (au-delà il passe sur deux lignes : « Nouvelle scène » à 320 px) */
.arbre .enfant b{white-space:normal;max-width:min(110px,calc(2 * (50vw - var(--ar-ax) * var(--ar-r2) - 8px + var(--ar-dl,0px))))}

/* ---- variante « dock » (pages de chat) : fermé, le tronc se range à droite de la barre de saisie ; ouvert, il revient au centre ---- */
.arbre.dock .tronc{left:calc(100% - 56px);bottom:calc(15px + env(safe-area-inset-bottom));width:44px;height:44px;margin-left:0;
  transition:left var(--t) var(--ease),bottom var(--t) var(--ease),width var(--t) var(--ease),height var(--t) var(--ease),margin var(--t) var(--ease),transform var(--t-fast) var(--ease)}
.arbre.dock .tronc svg{width:20px;height:20px;margin:-10px 0 0 -10px}
.arbre.dock.ouvert .tronc{left:50%;bottom:calc(var(--ar-tronc) - 32px);width:64px;height:64px;margin-left:-32px}
.arbre.dock.ouvert .tronc svg{width:24px;height:24px;margin:-12px 0 0 -12px}

/* ---- petits écrans : pastilles de 50 px (toujours ≥ 44 px au toucher) ---- */
@media (max-width:360px){
  .arbre{--ar-taille:50px}
  .arbre .racine svg,.arbre .enfant svg{width:20px;height:20px}
  .arbre .racine b,.arbre .enfant b{font-size:10.5px}
}

/* ---- mouvement réduit : tout change d’un coup, sans glissement ni tracé ---- */
@media (prefers-reduced-motion:reduce){
  .arbre *,.arbre .liens path{transition:none!important;animation:none!important}
}

/* --- indice de retour (Ash 23/09 22h41) : badge « ‹ » sur la racine au centre, et une astuce la première fois --- */
.arbre .racine .retour{display:none;position:absolute;left:-7px;top:-7px;width:24px;height:24px;border-radius:50%;background:var(--surface);color:var(--ink);box-shadow:var(--shadow-card);place-items:center;border:1px solid var(--hair)}
.arbre .racine .retour svg{width:12px;height:12px}
.arbre.profond .deployee>.racine .retour{display:grid}
.arbre .astuce{position:fixed;left:50%;top:calc(78px + env(safe-area-inset-top));transform:translate(-50%,-6px);padding:9px 14px;border-radius:999px;font-size:13px;font-weight:600;color:var(--ink);z-index:62;opacity:0;pointer-events:none;transition:opacity .35s var(--ease),transform .35s var(--ease);white-space:nowrap}
.arbre .astuce.montre{opacity:1;transform:translate(-50%,0)}
