/* =============================================================================
   bacteriologie.net — schémas mécanistiques (assets/schema.js)
   Chargé uniquement sur les fiches qui contiennent un <figure class="mech-lab">.
   Couleurs : variables de site.css (thème clair / sombre automatique).
   ============================================================================= */

/* ---------- version sans JavaScript (et lue par les moteurs) ---------- */
.mech-lab {
  margin: 1.75rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.mech-lab figcaption { margin: 0 0 0.75rem; color: var(--text-muted); font-size: 0.95rem; }
.mech-lab figcaption strong { display: block; color: var(--text); font-size: 1.02rem; }
.mech-scenario-title { margin: 1rem 0 0.4rem; font-weight: 600; }
.mech-steps { margin: 0; padding-left: 1.4rem; }
.mech-steps > li { margin: 0 0 0.7rem; }
.mech-step-title { display: block; }
.mech-lane {
  display: block;
  margin-top: 0.4rem;
  padding-left: 0.65rem;
  border-left: 3px solid var(--border);
}
.mech-lane[data-lane="pos"] { border-left-color: var(--gram-pos); }
.mech-lane[data-lane="neg"] { border-left-color: var(--gram-neg); }
.mech-lane[data-lane="pos"] b { color: var(--gram-pos); }
.mech-lane[data-lane="neg"] b { color: var(--gram-neg); }
.mech-source { margin: 0.75rem 0 0; font-size: 0.85rem; color: var(--text-muted); }

/* ---------- version interactive ---------- */
.mech-lab.is-enhanced .mech-scenario { display: none; }
.mech-ui { display: grid; gap: 0.85rem; }

.mech-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; }
.mech-switch { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.mech-switch-btn[aria-pressed="true"], .mech-quiz-toggle[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--bg);
  font-weight: 600;
}
.mech-quiz-toggle { font-size: 0.9rem; }

/* chaîne de nœuds : cause → effet */
.mech-nodes {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.mech-node-item { flex: 1 1 0; min-width: 4.5rem; position: relative; display: flex; justify-content: center; }
.mech-node-item + .mech-node-item::before { /* trait de liaison entre deux nœuds */
  content: "";
  position: absolute;
  top: 1.05rem;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.mech-node-item.is-done + .mech-node-item::before,
.mech-node-item.is-active::before { background: var(--brand); }
.mech-node {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
}
.mech-node-num {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.mech-node-label { max-width: 7rem; line-height: 1.2; }
.mech-node-item.is-done .mech-node-num { border-color: var(--brand); color: var(--brand); }
.mech-node-item.is-active .mech-node-num { border-color: var(--brand); background: var(--brand); color: var(--surface); }
.mech-node-item.is-active .mech-node { color: var(--text); font-weight: 600; }
.mech-node-item[data-tone="success"].is-active .mech-node-num { background: var(--res-s); border-color: var(--res-s); }
.mech-node-item[data-tone="danger"].is-active .mech-node-num { background: var(--res-r); border-color: var(--res-r); }
.mech-node-item[data-tone="success"].is-done .mech-node-num { border-color: var(--res-s); color: var(--res-s); }
.mech-node-item[data-tone="danger"].is-done .mech-node-num { border-color: var(--res-r); color: var(--res-r); }
.mech-node:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: var(--radius); }

.mech-progress { width: 100%; height: 0.35rem; accent-color: var(--brand); }

/* carte de l'étape active */
.mech-card {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  background: var(--bg);
}
.mech-card[data-tone="success"] { border-left-color: var(--res-s); }
.mech-card[data-tone="danger"] { border-left-color: var(--res-r); }
.mech-count { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.mech-card-title { margin: 0.2rem 0 0.5rem; font-size: 1.08rem; font-weight: 700; }
.mech-card-body { line-height: 1.6; }
.mech-card-body .mech-lane { margin-top: 0.6rem; }
.mech-prompt { margin: 0 0 0.6rem; color: var(--text-muted); font-style: italic; }

.mech-nav { display: flex; justify-content: space-between; gap: 0.5rem; }
.mech-nav .btn[disabled] { opacity: 0.45; cursor: default; }

/* écrans larges : les deux colonnes Gram + / Gram − côte à côte */
@media (min-width: 40rem) {
  .mech-card-body:has(.mech-lane) { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1rem; }
  .mech-card-body:has(.mech-lane) > .mech-card-text { grid-column: 1 / -1; }
}
/* téléphone : nœuds compacts, la carte porte le texte */
@media (max-width: 39.99rem) {
  .mech-lab { padding: 0.85rem; }
  .mech-node-label { display: none; }
  .mech-node-item { min-width: 2.6rem; }
  .mech-bar { flex-direction: column; align-items: stretch; }
  .mech-switch { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .mech-node-num { transition: none; }
}
@media print {
  .mech-ui { display: none; }
  .mech-lab.is-enhanced .mech-scenario { display: block; }
}
