/* LE DEUXIEME CERVEAU -- « second brain » (Lionel, 30/09/2026).
   « un truc limite à côté du nom d'Alpha [...] quand j'appuie dessus, la
   grosse carte du second brain s'ouvre, comme au-dessus d'Alpha ».
   Même famille que la plaque d'Alpha : nuit bleue, or, verre dépoli. */

:root {
  --cerveau-or: rgba(225, 185, 110, 0.92);
  --cerveau-or-doux: rgba(225, 185, 110, 0.35);
  --cerveau-fond: rgba(7, 9, 20, 0.95);
  --cerveau-texte: rgba(220, 228, 250, 0.92);
  --cerveau-gris: rgba(200, 214, 245, 0.55);
}

/* ---------- Le petit signe, collé à droite de la plaque « Alpha » ---------- */
#cerveau-signe {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 4;
  height: 46px;
  width: 30px;
  padding: 0;
  border: 1px solid var(--cerveau-or-doux);
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: rgba(10, 10, 14, 0.92);
  color: var(--cerveau-or);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  transition: opacity 0.2s, background 0.2s;
}
#cerveau-signe:hover,
#cerveau-signe[aria-expanded="true"] { opacity: 1; background: rgba(28, 22, 12, 0.95); }
#cerveau-signe svg { width: 16px; height: 16px; }

/* ---------- La grande carte ---------- */
#cerveau-panneau {
  position: fixed;
  inset: 84px 4vw 4vh 4vw;
  z-index: 9;
  display: none;
  flex-direction: column;
  background: var(--cerveau-fond);
  border: 1px solid var(--cerveau-or-doux);
  border-radius: 14px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.6), inset 0 0 80px rgba(80, 90, 160, 0.08);
  backdrop-filter: blur(14px);
  overflow: hidden;
  color: var(--cerveau-texte);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
#cerveau-panneau.ouvert { display: flex; animation: cerveau-naitre 0.28s ease-out; }
@keyframes cerveau-naitre { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

.cerveau-tete {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(225, 185, 110, 0.14);
}
.cerveau-titre {
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.06em;
  color: var(--cerveau-or);
}
.cerveau-compte { font-size: 12px; color: var(--cerveau-gris); }
.cerveau-chercher {
  margin-left: auto;
  width: min(280px, 40vw);
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(200, 214, 245, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--cerveau-texte);
  font-size: 13px;
  outline: none;
}
.cerveau-chercher:focus { border-color: var(--cerveau-or-doux); }
.cerveau-fermer {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(200, 214, 245, 0.2);
  background: transparent;
  color: var(--cerveau-texte);
  font-size: 15px;
  cursor: pointer;
}
.cerveau-fermer:hover { border-color: var(--cerveau-or-doux); color: var(--cerveau-or); }

.cerveau-corps { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.cerveau-toile { flex: 1 1 auto; position: relative; min-width: 0; }
.cerveau-toile canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.cerveau-toile canvas.saisi { cursor: grabbing; }

.cerveau-vide {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 30px; text-align: center;
  font-style: italic; color: var(--cerveau-gris); font-size: 14px; line-height: 1.6;
}
/* l'attribut hidden doit gagner sur le display:flex du dessus, sinon ce voile
   invisible avale tous les clics de la carte (trouvé au banc du navigateur) */
.cerveau-vide[hidden] { display: none; }
.cerveau-vide { white-space: pre-line; }

.cerveau-legende {
  position: absolute; left: 14px; bottom: 12px;
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  max-width: 70%;
  font-size: 11px; color: var(--cerveau-gris);
  pointer-events: none;
}
.cerveau-legende span { display: inline-flex; align-items: center; gap: 5px; }
.cerveau-legende i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- La note ouverte, à droite ---------- */
.cerveau-note {
  flex: 0 0 360px;
  max-width: 42%;
  border-left: 1px solid rgba(225, 185, 110, 0.14);
  background: rgba(10, 12, 26, 0.9);
  overflow-y: auto;
  padding: 16px 18px 22px;
  display: none;
}
.cerveau-note.ouverte { display: block; }
.cerveau-note h3 {
  margin: 4px 0 8px;
  font-family: Georgia, "Palatino Linotype", serif;
  font-weight: normal;
  font-size: 18px;
  line-height: 1.3;
  color: var(--cerveau-or);
}
.cerveau-note .quand { font-size: 11.5px; color: var(--cerveau-gris); margin-bottom: 10px; }
.cerveau-note .texte { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.cerveau-note .source { margin-top: 12px; font-size: 11.5px; color: var(--cerveau-gris); }
.cerveau-note .badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase;
  border: 1px solid currentColor;
}
.cerveau-note .liens { margin-top: 14px; display: flex; flex-direction: column; gap: 5px; }
.cerveau-note .liens button {
  text-align: left; background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(200, 214, 245, 0.12); border-radius: 8px;
  color: var(--cerveau-texte); padding: 6px 9px; font-size: 12.5px; cursor: pointer;
}
.cerveau-note .liens button:hover { border-color: var(--cerveau-or-doux); }
.cerveau-note details { margin-top: 14px; font-size: 12px; color: var(--cerveau-gris); }
.cerveau-note details div { white-space: pre-wrap; margin-top: 6px; line-height: 1.5; }
.cerveau-note-fermer {
  float: right; background: none; border: none; color: var(--cerveau-gris);
  font-size: 15px; cursor: pointer;
}

/* ---------- Téléphone : plein écran, la note en bas ---------- */
@media (max-width: 640px) {
  html #cerveau-signe { top: 12px; height: 38px; width: 28px; }
  html #cerveau-panneau { inset: 0; border-radius: 0; border: none; }
  html .cerveau-tete { flex-wrap: wrap; padding: 58px 12px 10px; gap: 8px 12px; }
  html .cerveau-chercher { width: 100%; margin-left: 0; order: 5; font-size: 16px; }
  html .cerveau-fermer { margin-left: auto; width: 40px; height: 40px; }
  html .cerveau-corps { flex-direction: column; }
  html .cerveau-note {
    flex: 0 0 auto; max-width: none; max-height: 48vh;
    border-left: none; border-top: 1px solid rgba(225, 185, 110, 0.2);
  }
  html .cerveau-legende { max-width: 92%; bottom: 8px; }
}
