/* Neaakor - interface web. Charte C-NEAA : navy, cyan, violet, rose, glassmorphism, Inter. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('inter-latin-wght.woff2') format('woff2-variations'), url('inter-latin-wght.woff2') format('woff2');
}

:root {
  --navy: #0a0f1e;
  --navy-2: #0f1629;
  --cyan: #06b6d4;
  --violet: #8b5cf6;
  --rose: #ec4899;
  --texte: #e6eaf4;
  --discret: #8b96ad;
  --pale: #808ba4;   /* contraste >= 4,5:1 sur les cartes (etait #5f6b85 : 3,2:1) */
  --verre: rgba(255, 255, 255, 0.04);
  --verre-fort: rgba(255, 255, 255, 0.07);
  --bord: rgba(255, 255, 255, 0.09);
  --bord-fort: rgba(255, 255, 255, 0.16);
  --erreur: #f87171;
  --rayon: 14px;
  --flou: blur(18px) saturate(140%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--texte);
  background: var(--navy);
  -webkit-font-smoothing: antialiased;
}

.fond {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(6, 182, 212, 0.14), transparent 40%),
    radial-gradient(circle at 90% 14%, rgba(139, 92, 246, 0.14), transparent 44%),
    radial-gradient(circle at 55% 105%, rgba(236, 72, 153, 0.09), transparent 46%);
}

.carte {
  position: relative; z-index: 1;
  background: var(--verre);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  backdrop-filter: var(--flou);
  -webkit-backdrop-filter: var(--flou);
}

.logo {
  font-size: 20px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--cyan), var(--violet) 60%, var(--rose));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
h1.logo { font-size: 28px; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--discret); }
.discret { color: var(--discret); }
.erreur { color: var(--erreur); min-height: 1.5em; font-size: 13px; }

/* --- Formulaires et boutons --- */
label { display: block; font-size: 12px; font-weight: 500; color: var(--discret); margin: 14px 0 6px; }
input {
  width: 100%; padding: 11px 13px;
  font: inherit; color: var(--texte);
  background: rgba(10, 15, 30, 0.6);
  border: 1px solid var(--bord); border-radius: 10px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.18); }
button { font: inherit; cursor: pointer; border: none; }
button:disabled { opacity: 0.5; cursor: default; }
body[aria-busy="true"] { cursor: progress; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.principal {
  width: 100%; margin-top: 22px; padding: 12px;
  font-weight: 600; color: #fff;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-radius: 10px; transition: filter 0.15s;
}
.principal:hover:not(:disabled) { filter: brightness(1.1); }
.lien { background: none; color: var(--cyan); padding: 4px 6px; font-size: 13px; font-weight: 500; border-radius: 6px; }
.lien:hover { color: #67e8f9; }

/* --- Ecrans centres (demarrage, connexion) --- */
.centre { position: relative; z-index: 1; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.connexion { width: 100%; max-width: 380px; padding: 32px 28px 24px; }
.connexion .discret { margin-top: 6px; }

/* --- Application : barre, laterale, scene, panneau --- */
.app {
  position: relative; z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  grid-template-rows: auto 1fr;
  grid-template-areas: "barre barre barre" "laterale scene panneau";
  gap: 12px; padding: 12px;
}
.barre {
  grid-area: barre;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 6px;
}
.barre .logo { flex: none; }

/* --- Recherche (en-tete) --- */
.recherche { position: relative; flex: 1; max-width: 520px; }
.recherche input { padding: 9px 13px; font-size: 13px; background: rgba(10, 15, 30, 0.55); }
.resultats {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(70vh, 560px); overflow-y: auto; padding: 6px;
  background: rgba(13, 19, 36, 0.96); border: 1px solid var(--bord-fort); border-radius: 12px;
  backdrop-filter: var(--flou); -webkit-backdrop-filter: var(--flou);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
#resultats-etat { padding: 8px 10px; font-size: 13px; }
#resultats-etat.erreur { color: var(--erreur); }
.liste-resultats { list-style: none; }
.liste-resultats button {
  width: 100%; display: flex; flex-direction: column; gap: 3px; padding: 9px 10px;
  text-align: left; color: var(--texte); background: none; border-radius: 9px;
}
.liste-resultats button:hover, .liste-resultats button:focus-visible { background: var(--verre-fort); }
.liste-resultats .tete { display: flex; align-items: center; gap: 8px; min-width: 0; }
.liste-resultats .titre { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste-resultats .score { font-size: 11px; color: var(--cyan); font-variant-numeric: tabular-nums; }
.liste-resultats .extrait {
  font-size: 12px; color: var(--discret); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.liste-resultats .meta { font-size: 11px; color: var(--pale); }

.compte { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.compte strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.laterale { grid-area: laterale; padding: 16px 10px 10px; min-height: 0; display: flex; flex-direction: column; }
.laterale .defile { flex: 1; min-height: 0; overflow-y: auto; }
.titre-section { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; }
.pastille {
  font-size: 11px; font-weight: 600; color: var(--texte);
  background: var(--verre-fort); border: 1px solid var(--bord);
  padding: 2px 8px; border-radius: 20px;
}
.pastille:empty { display: none; }
.projets { list-style: none; }
.projets .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projets .compte-projet { font-size: 12px; color: var(--discret); font-variant-numeric: tabular-nums; }
#projets-etat { padding: 8px; font-size: 13px; }
#projets-etat:empty { display: none; }

.scene { grid-area: scene; overflow: hidden; min-height: 0; display: flex; flex-direction: column; }
.outils { padding: 10px 14px; border-bottom: 1px solid var(--bord); }
.groupe { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-height: 30px; font-size: 13px; }
.seuil { margin: 0; font-size: 12px; }
input[type="range"] { width: 140px; padding: 0; accent-color: var(--cyan); background: none; border: none; box-shadow: none; }
input[type="range"]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }
#seuil-valeur { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 2.6em; }
#nb-liens { font-size: 12px; font-variant-numeric: tabular-nums; }
.evidence { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--bord-fort); border-radius: 20px; background: var(--verre-fort); }
.zoom { margin-left: auto; display: inline-flex; gap: 4px; }
.bouton-outil {
  min-width: 30px; height: 30px; padding: 0 10px;
  color: var(--texte); background: var(--verre-fort);
  border: 1px solid var(--bord); border-radius: 8px; font-size: 13px; font-weight: 600;
}
.bouton-outil:hover { border-color: var(--cyan); }
.titre-liste { font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--texte); }
.puce { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }

.cadre { position: relative; flex: 1; min-height: 0; }
.zone-graphe { position: absolute; inset: 0; }
.vide { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }

/* Infobulle et legende (creees par graphe.js, textContent) */
.infobulle {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  max-width: 320px; padding: 8px 11px;
  background: rgba(10, 15, 30, 0.92); border: 1px solid var(--bord-fort); border-radius: 9px;
  backdrop-filter: var(--flou); -webkit-backdrop-filter: var(--flou);
  display: flex; flex-direction: column; gap: 2px; font-size: 12px;
}
.infobulle strong { font-weight: 600; font-size: 13px; }
.infobulle span { color: var(--discret); }
.legende {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  display: flex; flex-direction: column; max-height: calc(100% - 24px); max-width: 230px; padding: 4px;
  background: rgba(10, 15, 30, 0.7); border: 1px solid var(--bord); border-radius: 10px;
  backdrop-filter: var(--flou); -webkit-backdrop-filter: var(--flou);
}
.legende ul { list-style: none; overflow-y: auto; max-height: 40vh; order: -1; margin-bottom: 2px; }
.legende .legende-bascule { color: var(--discret); font-weight: 500; justify-content: flex-start; }
.legende .legende-bascule:hover { color: var(--texte); }
.legende button {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  background: none; color: var(--texte); font-size: 12px; text-align: left; border-radius: 6px;
}
.legende button:hover { background: var(--verre-fort); }
.legende button.actif { background: var(--verre-fort); font-weight: 600; }
.legende button.attenue { opacity: 0.45; }
.legende .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legende .nb { color: var(--discret); font-variant-numeric: tabular-nums; }

/* En vue liste, le graphe et ses surcouches sont masques */
.mode-liste .legende, .mode-liste .infobulle { display: none; }

/* Liste des souvenirs d'un projet */
.vue-liste { position: absolute; inset: 0; overflow-y: auto; padding: 8px; }
.vue-liste > .discret { padding: 16px; }
.souvenirs { list-style: none; }
.souvenirs button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline;
  padding: 10px 12px; text-align: left; color: var(--texte); background: none; border-radius: 9px;
}
.souvenirs button:hover, .souvenirs button.actif { background: var(--verre-fort); }
.souvenirs .titre { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.souvenirs .date { font-size: 12px; color: var(--discret); font-variant-numeric: tabular-nums; white-space: nowrap; }
.souvenirs .type { grid-column: 1 / -1; font-size: 12px; color: var(--pale); }
.souvenirs li + li { border-top: 1px solid rgba(255, 255, 255, 0.04); }

/* Projets de la colonne de gauche : boutons */
.projets .projet, .entree-corbeille {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 9px; background: none; color: var(--texte); text-align: left;
}
.projets .projet:hover, .entree-corbeille:hover { background: var(--verre-fort); }
.projets .projet.actif, .entree-corbeille.actif { background: var(--verre-fort); box-shadow: inset 2px 0 0 var(--cyan); }
.entree-corbeille .nom { flex: 1; }
.entree-corbeille .compte-projet { font-size: 12px; color: var(--discret); font-variant-numeric: tabular-nums; }
.ligne-projet { position: relative; }
/* "Renommer" (et "Supprimer" pour un projet vide) apparaissent au survol ou au clavier, par-dessus le compteur */
.ligne-projet .actions-projet {
  position: absolute; right: 4px; top: 4px; display: flex; gap: 2px; opacity: 0;
  background: rgba(15, 22, 41, 0.96); border-radius: 6px;
}
.ligne-projet .actions-projet .lien { padding: 4px 8px; font-size: 12px; }
.ligne-projet .supprimer-projet { color: #fda4af; }
.ligne-projet .supprimer-projet:hover { color: var(--rose); }
.ligne-projet:hover .actions-projet, .ligne-projet .actions-projet:focus-within, .ligne-projet.ouverte .actions-projet { opacity: 1; }
/* Ecran tactile (pas de survol) : "Renommer" sur le projet choisi seulement, le compteur reste lisible */
@media (hover: none) { .ligne-projet:has(.projet.actif) .actions-projet { opacity: 1; } }
.edition-projet { margin: 2px 4px 8px; }
.suppression-projet { margin-top: 10px; font-size: 12px; }
.suppression-projet .discret { font-size: 12px; margin: 0; }
.confirmer-suppression p { font-size: 12px; margin-bottom: 0; }
.suppression-liste { padding: 0 16px 16px; max-width: 460px; }
.suppression-liste .suppression-projet { font-size: 13px; }
.suppression-liste .confirmer-suppression p { font-size: 13px; }
.suppression-liste .erreur:empty { display: none; }
.ajout { align-self: flex-start; margin: -4px 4px 6px; }
.separateur { flex: none; height: 1px; margin: 8px 8px; background: var(--bord); }
.laterale .confirmation { margin: 6px 4px; }
.laterale label { margin-top: 8px; }
.laterale input { padding: 8px 10px; font-size: 13px; }

/* Formulaires et confirmations dans la page (etape 8) */
.boutons { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.confirmation {
  margin-top: 12px; padding: 12px; font-size: 13px;
  background: rgba(10, 15, 30, 0.55); border: 1px solid var(--bord-fort); border-radius: 10px;
}
.confirmation label { margin-top: 0; }
.confirmation .erreur:empty { display: none; }
.aide { font-size: 12px; }
textarea, select {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 13px; color: var(--texte);
  background: rgba(10, 15, 30, 0.6); border: 1px solid var(--bord); border-radius: 10px; outline: none;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
select { width: auto; flex: 1; min-width: 0; padding: 6px 10px; }
select option { background: var(--navy-2); color: var(--texte); }
textarea:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.18); }
.bouton-outil.danger { color: #fda4af; border-color: rgba(236, 72, 153, 0.35); }
.bouton-outil.danger:hover:not(:disabled) { border-color: var(--rose); color: #fff; background: rgba(236, 72, 153, 0.18); }
.danger-lien { color: #fda4af; padding-left: 0; }
.danger-lien:hover { color: var(--rose); }
.edition { margin-top: 14px; }
.edition .deplacer { margin-top: 14px; }
.edition .deplacer label { margin: 0; }
.edition .deplacer .boutons { margin-top: 6px; flex-wrap: nowrap; }
#edition-etat:empty { display: none; }
#btn-restaurer-panneau { margin-top: 4px; }

/* Vue Corbeille */
.corbeille { list-style: none; }
.corbeille li { padding: 10px 12px; }
.corbeille li + li { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.corbeille .ouvrir {
  display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 0;
  background: none; color: var(--texte); text-align: left; font-weight: 500;
}
.corbeille .ouvrir:hover .titre { text-decoration: underline; }
.corbeille .titre { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.corbeille .meta { margin-top: 2px; font-size: 12px; color: var(--pale); }
.corbeille .reste { color: #fbbf24; }
.corbeille .boutons { margin-top: 8px; }
.corbeille .confirmation { max-width: 460px; }
#vue-corbeille > .aide { padding: 6px 12px 4px; }
#corbeille-etat { padding: 12px; }
#corbeille-etat.erreur { color: var(--erreur); }

/* Panneau de lecture d'un souvenir */
.panneau-entete { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 10px; }
.panneau-entete .lien { margin-left: auto; }
.panneau h3 { font-size: 16px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; overflow-wrap: anywhere; }
.panneau p { font-size: 13px; margin-top: 6px; }
#panneau-etat:empty { display: none; }
#panneau-etat.erreur { color: var(--erreur); }
.dates { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 10px 0; font-size: 12px; }
.dates dt { color: var(--pale); }
.dates dd { color: var(--discret); font-variant-numeric: tabular-nums; }
.avertissement { color: #fbbf24; }
.texte-souvenir {
  margin-top: 12px; padding: 12px 14px; font-size: 13.5px; line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: rgba(10, 15, 30, 0.45); border: 1px solid var(--bord); border-radius: 10px;
}
.texte-souvenir.ancien { margin-top: 4px; font-size: 12.5px; color: var(--discret); }
.historique { margin-top: 14px; }
.historique summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--cyan); padding: 4px 0; }
.historique ol { list-style: none; }
.historique li { margin-top: 10px; }
.historique .version { font-size: 12px; color: var(--pale); }
.lies { margin-top: 16px; }
.lies h4 { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--discret); margin-bottom: 4px; }
.lies ul { list-style: none; }
.lies button {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 6px;
  text-align: left; font-size: 13px; color: var(--texte); background: none; border-radius: 8px;
}
.lies button:hover { background: var(--verre-fort); }
.lies .titre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lies .score { font-size: 11px; color: var(--discret); font-variant-numeric: tabular-nums; }

.panneau { grid-area: panneau; width: 380px; padding: 18px; overflow-y: auto; min-height: 0; }

/* --- Notifications --- */
.notifications { position: fixed; z-index: 10; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100% - 32px)); }
.notification {
  padding: 11px 14px; font-size: 13px;
  background: rgba(15, 22, 41, 0.92);
  border: 1px solid var(--bord-fort); border-left: 3px solid var(--cyan);
  border-radius: 10px;
  backdrop-filter: var(--flou); -webkit-backdrop-filter: var(--flou);
}
.notification.erreur-notif { border-left-color: var(--rose); }

/* --- Ecrans moyens (tablette) : le panneau devient un tiroir par-dessus la scene, au lieu de
   l'ecraser (a 768 px, la scene tombait a 80 px de large). --- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 240px 1fr; grid-template-areas: "barre barre" "laterale scene"; }
  .panneau {
    grid-area: auto; position: fixed; z-index: 30; top: 12px; right: 12px; bottom: 12px;
    width: min(420px, calc(100vw - 24px));
    background: rgba(13, 19, 36, 0.97);
    box-shadow: -18px 0 50px rgba(0, 0, 0, 0.5);
  }
  .compte .discret { display: none; }
}

/* --- Petits ecrans : la laterale passe au-dessus, le panneau couvre l'ecran --- */
@media (max-width: 760px) {
  .app {
    height: auto; min-height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(360px, 1fr);
    grid-template-areas: "barre" "laterale" "scene";
  }
  .barre { flex-wrap: wrap; }
  .recherche { order: 3; flex-basis: 100%; max-width: none; }
  .laterale { max-height: 340px; }
  .panneau { inset: 0; width: auto; border-radius: 0; border: none; }
  body:has(#panneau:not([hidden])) { overflow: hidden; }   /* la page dessous ne defile pas */
  .zoom { margin-left: 0; }
  .legende { max-height: 30%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
