/* ==========================================================================
   Item 109 + 131 · Troubles de la marche et de l'équilibre — styles spécifiques
   Neurologie · multi-pathologies comparatives + sujet âgé HAS
   Composants spécifiques · 17 cards profils, tableau 3 ataxies coloré,
   mini-SVG marches pathologiques, schémas natifs (Romberg, HCA, algo HAS).
   ========================================================================== */

:root {
  --paper:    var(--bg-card);
  --paper-2:  #fffcf5;
  --rule:     #d7ccb4;
  --rule-2:   var(--accent-dash);
  --bg-2:     #ece5d6;
  --bg-3:     #e4dcc8;
  --ink-2:    #524a3e;
  --ink-3:    #8a8270;
  --ink-4:    #b2a98f;
  --danger:   var(--alert-red, #b8472c);
  --warn:     #8a5a12;
  --ok:       #4e6a2f;
  --info:     var(--accent-blue, #3a7a99);

  --fam-neuro:  var(--spe-neurologie, var(--spe-neuro, #3a7a99));
  --fam-geria:  var(--spe-geriatrie, #8a5a7a);
  --fam-warn:   var(--warn);
  --fam-info:   var(--info);
  --fam-ok:     var(--ok);
  --fam-urg:    var(--danger);
  --fam-tt:     #4e6a2f;
}

.content { max-width: 1400px; }

@keyframes pc-fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.content-panel.active { animation: pc-fadeIn .35s ease-out; }

.mono   { font-family: var(--font-mono); }
.danger { color: var(--danger); }
.warn   { color: var(--warn); }
.ok     { color: var(--ok); }
.muted  { color: var(--ink-3); }

/* Sec-title + rang-tag */
.sec-title       { display: flex; align-items: baseline; gap: 16px; margin: 36px 0 18px; flex-wrap: wrap; }
.sec-num         { font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em; color: var(--ink-3); text-transform: uppercase; }
.sec-title h2    { font-family: var(--font-serif); font-weight: 500; font-size: 30px; letter-spacing: -.01em; margin: 0; line-height: 1; }
.sec-title .rule { flex: 1; height: 1px; background: var(--rule); margin-bottom: 8px; min-width: 40px; }
.sec-title .hint { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); letter-spacing: .06em; }

.rang-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 2px;
  border: 1px solid var(--rule-2); color: var(--ink-2); background: var(--paper);
}
.rang-tag.rang-a { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 40%, var(--rule-2)); }
.rang-tag.rang-b { color: var(--ink-3); border-color: var(--rule-2); }
.rang-tag.rang-pivot { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 40%, var(--rule-2)); font-weight: 600; }

/* Familles de couleurs */
.fam-neuro   { --fam: var(--fam-neuro);   --fam-bg: #d5e3e7; }
.fam-geria   { --fam: var(--fam-geria);   --fam-bg: #ede1ed; }
.fam-warn    { --fam: var(--fam-warn);    --fam-bg: #f3e9cc; }
.fam-info    { --fam: var(--fam-info);    --fam-bg: #d5e3e7; }
.fam-ok      { --fam: var(--fam-ok);      --fam-bg: #dde2c8; }
.fam-urg     { --fam: var(--fam-urg);     --fam-bg: #fbeee3; }
.fam-tt      { --fam: var(--fam-tt);      --fam-bg: #dde2c8; }

/* Intro */
p.intro {
  font-size: 14px; line-height: 1.6; margin: 0 0 16px;
  padding: 14px 16px; background: var(--paper-2);
  border-left: 3px solid var(--fam-neuro); border-radius: 3px;
  color: var(--ink-2);
}

/* Vignette */
.vignette {
  background: var(--paper); border: 1px solid var(--rule);
  border-left: 3px solid var(--fam-neuro);
  border-radius: 3px; padding: 18px 22px; margin: 14px 0;
}
.vignette .vg-tag { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.vignette p { margin: 0; font-size: 14px; color: var(--ink); line-height: 1.6; }
.vignette .vg-trap { margin-top: 14px; padding: 12px 14px; background: var(--bg-2); border-left: 3px solid var(--fam-neuro); border-radius: 2px; font-size: 13px; color: var(--ink-2); line-height: 1.55; }

/* Keypoints */
.kp-ol { background: var(--paper); border: 1px solid var(--rule); border-radius: 3px; padding: 14px 18px 14px 38px; margin: 12px 0; }
.kp-ol li { margin: 8px 0; padding-left: 6px; line-height: 1.55; font-size: 13.5px; color: var(--ink-2); }
.kp-ol li::marker { color: var(--fam-neuro); font-weight: 600; }
.kp-ol li b { color: var(--ink); font-weight: 600; }

/* Définitions */
.def-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 14px 0; }
.def-card { background: var(--paper); border: 1px solid var(--rule); border-top: 3px solid var(--fam-neuro); border-radius: 3px; padding: 14px 16px; }
.def-card h3 { font-family: var(--font-serif); font-weight: 500; font-size: 18px; margin: 0 0 4px; letter-spacing: -.005em; color: var(--ink); }
.def-card .def-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); display: block; margin-bottom: 8px; }
.def-card p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.def-card p b { color: var(--ink); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 12px 0; }
table.matrix { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--rule); }
table.matrix th, table.matrix td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; font-size: 12.5px; }
table.matrix thead th { background: var(--bg-2); font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); font-weight: 500; border-bottom: 1px solid var(--rule-2); }
table.matrix tbody th { font-family: var(--font-serif); font-weight: 500; font-size: 14px; color: var(--ink); border-right: 1px solid var(--rule); width: 18%; }
table.matrix tbody tr:last-child th, table.matrix tbody tr:last-child td { border-bottom: none; }
table.matrix tbody tr:hover td { background: #fff; }
table.matrix.compact th, table.matrix.compact td { padding: 8px 10px; font-size: 12px; }
table.matrix ul { margin: 0; padding-left: 18px; line-height: 1.7; }
table.matrix ul li { margin: 4px 0; }

/* Tableau 3 ataxies — colonnes colorées + mise en relief discriminantes */
table.matrix.ataxies-table thead th:nth-child(2) { background: #dde2c8; color: var(--ok); }
table.matrix.ataxies-table thead th:nth-child(3) { background: #fbeee3; color: var(--danger); }
table.matrix.ataxies-table thead th:nth-child(4) { background: #d5e3e7; color: var(--info); }
table.matrix.ataxies-table tbody tr:nth-child(2) td { background: color-mix(in oklab, #f9e8c0 40%, transparent); font-weight: 500; }
table.matrix.ataxies-table tbody tr:nth-child(3) td { background: color-mix(in oklab, #f9e8c0 40%, transparent); font-weight: 500; }

/* Hbox */
.hbox {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 3px;
  padding: 12px 16px; margin: 12px 0;
  display: grid; grid-template-columns: 64px 1fr; gap: 4px 16px; align-items: baseline;
}
.hbox > .n { grid-column: 1; grid-row: 1 / -1; align-self: start; padding-top: 2px; font-family: var(--font-mono); font-size: 18px; color: var(--fam-neuro); font-weight: 500; }
.hbox > p, .hbox > ul { grid-column: 2; margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.hbox > ul { padding-left: 18px; }
.hbox > ul li { margin: 4px 0; }
.hbox > p b, .hbox > ul li b { color: var(--ink); font-weight: 600; }

/* Alert clinical */
.alert-clinical {
  background: #f3dccf; border: 1px solid var(--danger);
  border-radius: 4px; padding: 16px 20px;
  display: grid; grid-template-columns: 44px 1fr; gap: 16px; align-items: start;
  margin: 18px 0;
}
.alert-clinical .alert-icon { font-family: var(--font-serif); font-size: 32px; line-height: 1; color: var(--danger); font-style: italic; font-weight: 500; }
.alert-clinical h4 { font-family: var(--font-serif); font-weight: 500; font-size: 18px; letter-spacing: -.005em; color: var(--danger); margin: 0 0 8px; }
.alert-clinical ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.alert-clinical ul li { margin: 4px 0; }
.alert-clinical ul li b { color: var(--ink); font-weight: 600; }

/* Schémas SVG */
.schema-wrap { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 16px 18px; margin: 12px 0; }
.schema-wrap svg { width: 100%; height: auto; display: block; max-height: 380px; }
.schema-legend { font-size: 12px; color: var(--ink-3); line-height: 1.55; font-style: italic; margin: 10px 0 0; max-width: 1100px; }
.schema-legend b { color: var(--ink); font-weight: 600; }

/* Image cycle de marche */
.image-109-131 {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 4px; padding: 16px; margin: 14px 0;
  display: flex; flex-direction: column; gap: 12px;
}
.image-109-131 img { width: 100%; max-width: 760px; height: auto; object-fit: contain; border-radius: 3px; background: #fff; display: block; margin: 0 auto; }
.image-109-131 figcaption { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; font-style: italic; }
.image-109-131 figcaption b { color: var(--ink); font-weight: 600; }

/* Profils cards (marches déficitaires, petits pas, mvts anormaux, syndrome post-chute, PEC) */
.profils-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px; margin: 14px 0;
}
.profil-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 4px; border-top: 4px solid var(--fam, var(--ink));
  padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.profil-head { background: var(--fam-bg, var(--bg-2)); padding: 14px 16px; border-bottom: 1px solid color-mix(in oklab, var(--fam, var(--ink)) 30%, var(--rule)); }
.profil-head h4 { font-family: var(--font-serif); font-weight: 500; font-size: 17px; letter-spacing: -.005em; margin: 0 0 4px; color: var(--fam, var(--ink)); }
.profil-tag { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.profil-section { padding: 11px 16px; border-bottom: 1px dashed var(--rule); }
.profil-section:last-child { border-bottom: none; }
.profil-section h6 { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--fam, var(--ink-3)); margin: 0 0 6px; font-weight: 500; }
.profil-section p { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.profil-section p b { color: var(--ink); font-weight: 600; }
.profil-section ul { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.profil-section ul li { margin: 4px 0; }
.profil-section ul li b { color: var(--ink); font-weight: 600; }
.profil-section.profil-pieges { background: color-mix(in oklab, var(--fam-urg) 6%, var(--paper)); }
.profil-section.profil-pieges h6 { color: var(--fam-urg); }

.profil-mini-svg {
  display: flex; justify-content: center; align-items: center;
  padding: 8px 16px; background: var(--paper-2); border-bottom: 1px dashed var(--rule);
}
.profil-mini-svg svg { width: 96px; height: 120px; }

/* Mindmap */
.mmwrap {
  position: relative; width: 100%;
  border: 1px solid var(--rule); border-radius: 4px;
  background: linear-gradient(180deg, var(--paper-2) 0%, var(--paper) 100%);
  height: 840px; overflow: hidden;
}
.mmwrap .zctl { position: absolute; top: 14px; right: 14px; z-index: 10; display: flex; gap: 4px; }
.mmwrap .zctl button { width: 32px; height: 32px; background: var(--paper); border: 1px solid var(--rule); border-radius: 3px; font-family: var(--font-mono); font-size: 14px; color: var(--ink-2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.mmwrap .zctl button:hover { background: var(--bg-2); }
.mmwrap .zhint { position: absolute; bottom: 14px; left: 14px; z-index: 5; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; color: var(--ink-3); background: var(--paper); padding: 4px 10px; border-radius: 2px; border: 1px solid var(--rule); }
.mmwrap svg.canvas { width: 100%; height: 100%; cursor: grab; }
.mmwrap svg.canvas:active { cursor: grabbing; }
.mmwrap svg.canvas .root-circle { fill: var(--fam-neuro); }
.mmwrap svg.canvas .root-text { fill: var(--paper); font-family: var(--font-serif); font-weight: 500; }
.mmwrap svg.canvas .node-card { cursor: pointer; }
/* Piège mindmap atlas-edn : pas de translate au hover (écrase l'attribut SVG transform) */
.mmwrap svg.canvas .node-card:hover .node-bg {
  stroke-width: 2;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08));
}
.mmwrap svg.canvas .node-bg { fill: #fff; stroke: var(--rule-2); stroke-width: 1; }
.mmwrap svg.canvas .node-accent { fill: var(--fam, var(--ink)); }
.mmwrap svg.canvas .node-title { fill: var(--ink); font-family: var(--font-serif); font-weight: 500; font-size: 15px; }
.mmwrap svg.canvas .node-sub { fill: var(--ink-2); font-size: 11px; }
.mmwrap svg.canvas .node-chip { fill: #fff; stroke: var(--rule); stroke-width: 1; }
.mmwrap svg.canvas .node-chip-t { fill: var(--ink-2); font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.mmwrap svg.canvas path.link { fill: none; stroke: var(--rule-2); stroke-width: 1.2; stroke-dasharray: 3 4; }
.mmwrap svg.canvas path.link.main { stroke-width: 1.4; }
.mmwrap svg.canvas path.link.sat { stroke: var(--rule-2); stroke-width: 1; stroke-dasharray: 1 5; opacity: .55; }
.mmwrap svg.canvas .ring { fill: none; stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 5; }
.mmwrap svg.canvas .node-sat { cursor: pointer; }
.mmwrap svg.canvas .node-sat:hover .sat-bg { fill: var(--ink); }
.mmwrap svg.canvas .node-sat:hover .sat-title,
.mmwrap svg.canvas .node-sat:hover .sat-sub { fill: var(--paper); }
.mmwrap svg.canvas .sat-bg { fill: var(--bg-2); stroke: var(--ink); stroke-width: 1; }
.mmwrap svg.canvas .sat-title { fill: var(--ink); font-family: var(--font-serif); font-weight: 500; font-size: 12.5px; }
.mmwrap svg.canvas .sat-sub { fill: var(--ink-2); font-size: 9.5px; font-family: var(--font-mono); letter-spacing: .04em; }

/* Responsive */
@media (max-width: 900px) {
  .profils-grid { grid-template-columns: 1fr; }
  .def-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .mmwrap { height: 600px; }
  table.matrix tbody th { width: auto; }
}

/* MODE NUIT */
body.dark-mode {
  --paper:    #1f1c17;
  --paper-2:  #251f17;
  --rule:     #4a4232;
  --rule-2:   #6b5e45;
  --bg-2:     #2a241c;
  --bg-3:     #322a20;
  --ink-2:    #d7ccb4;
  --ink-3:    #a89c7d;
  --ink-4:    #786a52;
}
body.dark-mode .vignette { background: var(--paper); }
body.dark-mode .vignette p { color: var(--ink-2); }
body.dark-mode .vignette .vg-trap { background: var(--bg-2); color: var(--ink-3); }
body.dark-mode .def-card { background: var(--paper); }
body.dark-mode .def-card p { color: var(--ink-2); }
body.dark-mode .kp-ol { background: var(--paper); }
body.dark-mode .kp-ol li { color: var(--ink-2); }
body.dark-mode .hbox { background: var(--paper); }
body.dark-mode .hbox > p, body.dark-mode .hbox > ul { color: var(--ink-2); }
body.dark-mode table.matrix { background: var(--paper); }
body.dark-mode table.matrix tbody tr:hover td { background: var(--bg-2); }
body.dark-mode .alert-clinical { background: #3a1a14; border-color: #c9624c; }
body.dark-mode .alert-clinical h4 { color: #f0a896; }
body.dark-mode .alert-clinical ul { color: #f0d5c9; }
body.dark-mode .alert-clinical ul li b { color: #fff8e1; }
body.dark-mode .schema-wrap { background: var(--paper); }
body.dark-mode .profil-card { background: var(--paper); }
body.dark-mode .profil-section ul, body.dark-mode .profil-section p { color: var(--ink-2); }
body.dark-mode .profil-mini-svg { background: var(--paper-2); }
body.dark-mode .image-109-131 { background: var(--paper); }
body.dark-mode .image-109-131 img { background: #f4efe6; }
body.dark-mode .image-109-131 figcaption { color: var(--ink-2); }
body.dark-mode p.intro { background: var(--paper-2); color: var(--ink-2); }
body.dark-mode .mmwrap { background: linear-gradient(180deg, var(--paper-2), var(--paper)); }
body.dark-mode .mmwrap .zctl button { background: var(--paper); color: var(--ink-2); border-color: var(--rule); }
body.dark-mode .mmwrap .zhint { background: var(--paper); color: var(--ink-3); border-color: var(--rule); }
body.dark-mode .mmwrap svg.canvas .node-bg { fill: var(--paper); stroke: var(--rule-2); }
body.dark-mode .mmwrap svg.canvas .node-title { fill: var(--ink-2); }
body.dark-mode .mmwrap svg.canvas .node-sub { fill: var(--ink-3); }
body.dark-mode .mmwrap svg.canvas .node-chip { fill: var(--paper-2); stroke: var(--rule); }
body.dark-mode .mmwrap svg.canvas .node-chip-t { fill: var(--ink-3); }
body.dark-mode .mmwrap svg.canvas .sat-bg { fill: var(--bg-2); stroke: var(--ink-2); }
body.dark-mode .mmwrap svg.canvas .sat-title { fill: var(--ink-2); }
body.dark-mode .mmwrap svg.canvas .sat-sub { fill: var(--ink-3); }
body.dark-mode .mmwrap svg.canvas .root-circle { fill: var(--ink-2); }
body.dark-mode .mmwrap svg.canvas .root-text { fill: var(--paper); }

/* Decision-tree racine — fix piège 2 classes (rappel mémoire projet) */
.dt-svg .dt-node.dt-root rect { fill: var(--ink); }
.dt-svg .dt-node.dt-root text { fill: var(--paper-2, #faf6ec); }
body.dark-mode .dt-svg .dt-node.dt-root rect { fill: var(--ink-2) !important; }
body.dark-mode .dt-svg .dt-node.dt-root text { fill: var(--paper) !important; }
