/* =========================================================================
   consensus-ben-or.css — /projets/consensus-ben-or. Complète demo.css.
   Le réseau est un SVG dont les couleurs viennent de ces variables
   (classes posées par le script), dans les deux thèmes.
   ========================================================================= */

.demo-benor {
    --bo-zero: #0E9C9C;
    --bo-zero-fond: rgba(14, 156, 156, 0.16);
    --bo-un: #9333EA;
    --bo-un-fond: rgba(147, 51, 234, 0.14);
    --bo-inconnu: #8A83A8;
    --bo-inconnu-fond: rgba(138, 131, 168, 0.14);
    --bo-panne: #6E6690;
    --bo-panne-fond: rgba(42, 33, 69, 0.10);
    --bo-lien: rgba(90, 70, 160, 0.09);
}
/* Pas plus clair en sombre : ces deux teintes codent une valeur, elles
   restent dans la bande de clarté validée pour des marques de données. */
html.dark-mode .demo-benor {
    --bo-zero: #17A597;
    --bo-zero-fond: rgba(23, 165, 151, 0.20);
    --bo-un: #C74BE6;
    --bo-un-fond: rgba(199, 75, 230, 0.20);
    --bo-inconnu: #9C8AC2;
    --bo-inconnu-fond: rgba(156, 138, 194, 0.14);
    --bo-panne: #6E6490;
    --bo-panne-fond: rgba(5, 1, 16, 0.55);
    --bo-lien: rgba(168, 133, 255, 0.10);
}

/* --- Scénarios -------------------------------------------------------------- */
.bo-scenarios { display: grid; gap: 14px; margin-bottom: 1rem; }
.bo-groupe { display: grid; gap: 8px; }
.bo-groupe__titre {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.bo-scenario {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-color);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.bo-scenario:hover { background: var(--submenu-hover); }
.bo-scenario[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-color); }
.bo-scenario:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }

/* --- Simulateur ------------------------------------------------------------- */
.bo-simulateur {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    grid-template-areas: "reseau commande" "journal commande";
    gap: 22px 30px;
    align-items: start;
}
.bo-reseau { grid-area: reseau; margin: 0; display: grid; gap: 10px; }
.bo-reseau svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.bo-commande { grid-area: commande; display: grid; gap: 14px; align-content: start; }
.bo-journal { grid-area: journal; display: grid; gap: 8px; }

.bo-legende { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 0.82rem; color: var(--text-secondary); }
.bo-puce { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: -8px; vertical-align: -1px; border: 2px solid; }
.bo-puce--zero { background: var(--bo-zero-fond); border-color: var(--bo-zero); }
.bo-puce--un { background: var(--bo-un-fond); border-color: var(--bo-un); }
.bo-puce--inconnu { background: var(--bo-inconnu-fond); border-color: var(--bo-inconnu); }
.bo-puce--panne { background: var(--bo-panne-fond); border-color: var(--bo-panne); border-style: dashed; }

/* Éléments du SVG */
.bo-lien { stroke: var(--bo-lien); stroke-width: 1; }
.bo-centre { fill: var(--text-secondary); font-size: 15px; font-weight: 700; text-anchor: middle; dominant-baseline: central; letter-spacing: 0.04em; }
.bo-noeud { cursor: pointer; outline: none; }
.bo-noeud__disque { fill: var(--bo-inconnu-fond); stroke: var(--bo-inconnu); stroke-width: 2.5; transition: fill 0.2s ease, stroke 0.2s ease; }
.bo-noeud__anneau { fill: none; stroke: transparent; stroke-width: 3; }
.bo-noeud__valeur { fill: var(--text-color); font-size: 19px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }
.bo-noeud__tour { fill: var(--text-secondary); font-size: 10px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.bo-noeud__nom { fill: var(--text-secondary); font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.bo-noeud__croix { stroke: var(--bo-panne); stroke-width: 3; stroke-linecap: round; visibility: hidden; }
.bo-noeud.est-zero .bo-noeud__disque { fill: var(--bo-zero-fond); stroke: var(--bo-zero); }
.bo-noeud.est-un .bo-noeud__disque { fill: var(--bo-un-fond); stroke: var(--bo-un); }
.bo-noeud.est-decide .bo-noeud__anneau { stroke: currentColor; }
.bo-noeud.est-zero.est-decide { color: var(--bo-zero); }
.bo-noeud.est-un.est-decide { color: var(--bo-un); }
.bo-noeud.est-panne .bo-noeud__disque { fill: var(--bo-panne-fond); stroke: var(--bo-panne); stroke-dasharray: 5 4; }
.bo-noeud.est-panne .bo-noeud__croix { visibility: visible; }
.bo-noeud:hover .bo-noeud__disque { stroke-width: 3.5; }
.bo-noeud:focus-visible .bo-noeud__anneau { stroke: var(--accent-color); stroke-dasharray: 3 3; }

.bo-msg { stroke-width: 2; }
.bo-msg.est-R.est-v0 { fill: var(--bo-zero); stroke: var(--bo-zero); }
.bo-msg.est-R.est-v1 { fill: var(--bo-un); stroke: var(--bo-un); }
.bo-msg.est-P { fill: var(--bg-elevated); }
.bo-msg.est-P.est-v0 { stroke: var(--bo-zero); }
.bo-msg.est-P.est-v1 { stroke: var(--bo-un); }
.bo-msg.est-P.est-vq { stroke: var(--bo-inconnu); }

/* Réglages */
.bo-reglage { display: grid; gap: 6px; }
.bo-reglage label { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; }
.bo-reglage output { font-variant-numeric: tabular-nums; color: var(--accent-color); }
.bo-reglage input[type="range"] { width: 100%; accent-color: var(--accent-color); }
.bo-seuils { font-size: 0.84rem; color: var(--text-secondary); line-height: 1.55; }
.bo-vitesse { max-width: 220px; }
.bo-compteurs { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.bo-statut { font-size: 0.9rem; color: var(--text-color); min-height: 2.8em; line-height: 1.5; }

/* Journal */
.bo-journal h3,
.bo-stats h3 { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); }
.bo-liste-journal {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    max-height: 330px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
}
.bo-liste-journal li {
    padding: 8px 11px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    font-size: 0.82rem;
    line-height: 1.5;
}
.bo-liste-journal strong { display: block; font-size: 0.78rem; color: var(--text-secondary); }
.bo-liste-journal p { color: var(--text-color); }
.bo-liste-journal li.est-decision { border-color: var(--accent-color); }
.bo-liste-journal li.est-piece { border-style: dashed; }
/* Valeur reçue : chiffre à l'encre sur une pastille teintée (le texte ne
   porte jamais la couleur de la donnée). */
.bo-v {
    display: inline-block;
    min-width: 1.5em;
    padding: 0 3px;
    border-radius: 5px;
    text-align: center;
    font-family: var(--font-mono);
    font-weight: 700;
    background: var(--bo-inconnu-fond);
}
.bo-v--0 { background: var(--bo-zero-fond); box-shadow: inset 0 -2px 0 var(--bo-zero); }
.bo-v--1 { background: var(--bo-un-fond); box-shadow: inset 0 -2px 0 var(--bo-un); }

/* --- Mille exécutions ------------------------------------------------------- */
.bo-stats { margin-top: 1rem; display: grid; gap: 12px; }
.bo-stats__tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.bo-stats__tete h3 { margin-bottom: 4px; }
.bo-stats__resume { font-size: 0.92rem; line-height: 1.6; color: var(--text-color); }
.bo-histo { display: grid; gap: 8px; }
.bo-histo__barres {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 2px;
    height: 170px;
    border-bottom: 1px solid var(--border-color);
}
/* Colonne : compte (seulement sur la plus haute), barre, calées en bas. */
.bo-histo__barre {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    outline: none;
}
.bo-histo__remplissage {
    width: min(24px, 100%);
    height: calc(var(--part, 0) * 136px);
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    background: var(--bo-zero);
    transition: filter 0.15s ease;
}
.bo-histo__barre:hover .bo-histo__remplissage,
.bo-histo__barre:focus-visible .bo-histo__remplissage { filter: brightness(1.25); }
.bo-histo__barre:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-color); border-radius: 6px; }
.bo-histo__compte { font-size: 0.72rem; font-weight: 700; color: var(--text-color); }
/* Info-bulle : le détail de la barre au survol et au clavier. */
.bo-histo__barre::after {
    content: attr(data-info);
    position: absolute;
    bottom: calc(100% - 20px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 180px;
    padding: 6px 9px;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--text-color);
    white-space: normal;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    z-index: 2;
}
.bo-histo__barre:hover::after,
.bo-histo__barre:focus-visible::after { opacity: 1; }
.bo-histo__etiquettes { display: flex; justify-content: space-around; gap: 2px; }
.bo-histo__etiquettes span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bo-histo__axe { font-size: 0.8rem; color: var(--text-secondary); text-align: center; }
.bo-tableau summary { cursor: pointer; font-size: 0.84rem; font-weight: 600; color: var(--text-secondary); width: fit-content; }
.bo-tableau summary:hover { color: var(--text-color); }
.bo-tableau table { margin-top: 8px; border-collapse: collapse; font-size: 0.84rem; }
.bo-tableau th, .bo-tableau td { padding: 5px 12px; border-bottom: 1px solid var(--border-color); text-align: right; font-variant-numeric: tabular-nums; }
.bo-tableau th { color: var(--text-secondary); font-weight: 600; }

/* --- Pseudo-code ------------------------------------------------------------ */
.bo-phases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.bo-code {
    margin: 0 0 0.9rem;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.65;
    overflow-x: auto;
    white-space: pre;
}
.bo-texte { font-size: 0.93rem; color: var(--text-secondary); line-height: 1.65; }
.bo-texte strong { color: var(--text-color); }

@media (max-width: 860px) {
    .bo-simulateur { grid-template-columns: 1fr; grid-template-areas: "reseau" "commande" "journal"; }
    .bo-phases { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .bo-noeud__nom { font-size: 15px; }
    .bo-noeud__tour { font-size: 12px; }
    .bo-centre { font-size: 18px; }
    .bo-liste-journal { max-height: 260px; }
}
@media (prefers-reduced-motion: reduce) {
    .bo-noeud__disque { transition: none; }
}
