/* ==========================================================================
   fond.css — maillage filaire interactif en arrière-plan de l'accueil
   (rubriques « Rachis — ce qui est traité » et « Pathologies cérébrales »).
   Associé à assets/js/fond.js.

   CONTRAT
   -----------------------------------------------------------------------
   <section class="… bg-section bg-section--right|--left">
     <canvas class="bg-canvas" data-bg="spine|brain"
             data-line="255,255,255" data-glow="143,179,212" aria-hidden="true">
     <div class="bg-scrim" aria-hidden="true"></div>
     <div class="wrap bg-content">
       <div class="bg-col"> … texte … </div>
       <p class="bg-caption"> … légende du repère … </p>
     </div>
   </section>

   - .bg-section    position:relative, overflow:hidden ; fond = rgb(var(--bg-rgb)).
                    --right : maillage à droite, texte à gauche (rachis)
                    --left  : maillage à gauche, texte à droite (encéphale)
   - .bg-canvas     calque 0, plein cadre, pointer-events:none (les événements
                    pointeur sont écoutés sur la section).
   - .bg-scrim      voile de lisibilité côté texte (calque 0, au-dessus du canvas).
   - .bg-content    calque 1, le contenu.   .bg-tip : étiquette de survol (JS).
   - Mobile         < 768px : moins de particules, voile renforcé,
                    touch-action: pan-y pinch-zoom (le défilement vertical
                    n'est jamais bloqué).
   - Mouvement réduit : voir fond.js (dessin fixe, aucune boucle).
   ========================================================================== */

/* --- Rubrique à fond interactif --------------------------------------- */
.bg-section {
  --bg-rgb: 13, 36, 56;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: rgb(var(--bg-rgb));
}
.brain-block.bg-section { --bg-rgb: 18, 48, 73; }

.bg-canvas {
  position: absolute; inset: 0; z-index: 0;
  display: block; width: 100%; height: 100%;
  pointer-events: none;
}

.bg-scrim {
  position: absolute; inset: 0; z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg,
      rgba(var(--bg-rgb), 1) 0,
      rgba(var(--bg-rgb), 0) 13%,
      rgba(var(--bg-rgb), 0) 87%,
      rgba(var(--bg-rgb), 1) 100%),
    var(--bg-scrim-side, none);
}
.bg-section--right {
  --bg-scrim-side: linear-gradient(90deg,
    rgba(var(--bg-rgb), .94) 0,
    rgba(var(--bg-rgb), .80) 32%,
    rgba(var(--bg-rgb), .30) 56%,
    rgba(var(--bg-rgb), 0) 72%);
}
.bg-section--left {
  --bg-scrim-side: linear-gradient(270deg,
    rgba(var(--bg-rgb), .94) 0,
    rgba(var(--bg-rgb), .80) 32%,
    rgba(var(--bg-rgb), .30) 56%,
    rgba(var(--bg-rgb), 0) 72%);
}

.bg-content { position: relative; z-index: 1; }
.bg-col { max-width: 640px; }
.bg-section--right .bg-col { margin-right: auto; }
.bg-section--left .bg-col { margin-left: auto; }

/* Légende du repère anatomique : sous le maillage. */
.bg-caption {
  margin: 0;
  max-width: 300px;
  font: 400 12px/1.6 var(--sans);
  color: var(--on-navy-soft);
  text-shadow: 0 0 10px rgb(var(--bg-rgb, 13, 36, 56)), 0 0 3px rgb(var(--bg-rgb, 13, 36, 56));
}
@media (min-width: 1080px) {
  .bg-section--right .bg-caption,
  .bg-section--left .bg-caption {
    position: absolute; bottom: 0;
  }
  .bg-section--right .bg-caption { right: var(--gutter); text-align: right; }
  .bg-section--left .bg-caption { left: var(--gutter); }
}

/* Étiquette de survol */
.bg-tip {
  position: absolute; left: 0; top: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 1px;
  padding: 7px 12px 8px;
  border: 1px solid rgba(143, 179, 212, .42);
  border-radius: 8px;
  background: rgba(13, 36, 56, .78);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .22);
  color: #fff;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .22s ease;
  will-change: transform, opacity;
}
.bg-tip.is-on { opacity: 1; }
.bg-tip__name { font: 600 11px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; }
.bg-tip__sub { font: 400 12px/1.4 var(--sans); color: var(--sky); }

/* Mode d'emploi discret (souris / tactile) */
.bg-howto {
  display: flex; align-items: center; gap: 10px;
  margin: 0;
  font: 500 11.5px/1.4 var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: rgba(143, 179, 212, .82);
}
.bg-howto::before {
  content: ""; flex: none;
  width: 7px; height: 7px; border-radius: 50%;
  background: #8fb3d4;
  box-shadow: 0 0 0 0 rgba(143, 179, 212, .5);
  animation: bg-ping 2.8s ease-out infinite;
}
.bg-howto__coarse { display: none; }
@media (pointer: coarse) {
  .bg-howto__fine { display: none; }
  .bg-howto__coarse { display: inline; }
}
@keyframes bg-ping {
  0% { box-shadow: 0 0 0 0 rgba(143, 179, 212, .5); }
  70%, 100% { box-shadow: 0 0 0 9px rgba(143, 179, 212, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .bg-howto::before { animation: none; }
}

/* --- Mobile ------------------------------------------------------------ */
@media (max-width: 767px) {
  /* Marges latérales resserrées, pour ces deux rubriques seulement. */
  .bg-section { --gutter: 16px; }

  .bg-section--right {
    --bg-scrim-side: linear-gradient(90deg,
      rgba(var(--bg-rgb), .74) 0,
      rgba(var(--bg-rgb), .50) 62%,
      rgba(var(--bg-rgb), .34) 100%);
  }
  .bg-section--left {
    --bg-scrim-side: linear-gradient(270deg,
      rgba(var(--bg-rgb), .74) 0,
      rgba(var(--bg-rgb), .50) 62%,
      rgba(var(--bg-rgb), .34) 100%);
  }
  .bg-col { max-width: none; }
  .bg-caption { margin: 22px 0 0; max-width: none; }
}

/* ==========================================================================
   Rubrique « Rachis — ce qui est traité »
   ========================================================================== */

.regions.bg-section {
  padding: 108px 0 100px;
  min-height: 800px;
  /* Le glisser horizontal fait pivoter la colonne ; le défilement vertical
     et le zoom à deux doigts restent au navigateur. */
  touch-action: pan-y pinch-zoom;
}
.regions.bg-section.is-hot { cursor: pointer; }

.regions .bg-col { gap: 30px; }
.regions .regions__heading h2 { font-size: 40px; }

/* L'ancien panneau à gauche disparaît : le détail prend toute la colonne. */
.regions.bg-section .regions__body { display: block; }
.regions.bg-section .regions__detail { gap: 6px; }
.regions.bg-section .regions__intro { margin: 0 0 12px; }
.regions.bg-section .patho-brief { padding: 16px 0 6px; }

.regions .bg-howto { margin-top: -12px; }

/* Puces : un voile léger pour qu'elles restent nettes sur le maillage. */
.regions.bg-section .chip { background: rgba(13, 36, 56, .35); }
.regions.bg-section .chip:hover { background: rgba(13, 36, 56, .55); }
.regions.bg-section .chip[aria-selected="true"] { background: #fff; }

@media (max-width: 1080px) {
  .regions.bg-section { min-height: 720px; padding: 88px 0 84px; }
  .regions .regions__heading h2 { font-size: 34px; }
}

@media (max-width: 767px) {
  .regions.bg-section { min-height: 0; padding: 44px 0 46px; }
  .regions .bg-col { gap: 18px; }
  .regions .regions__heading h2 { font-size: 26px; }
  .regions .regions__heading { padding-right: 18%; }
  .regions .bg-howto { margin-top: -4px; font-size: 10.5px; letter-spacing: .08em; }

  /* Accordéon : fond translucide pour la lisibilité, sans flou (le flou
     recalculé à chaque image coûterait cher sur téléphone). */
  .regions.bg-section .region-acc { background: rgba(13, 36, 56, .34); }
  .regions.bg-section .region-acc.is-open { background: rgba(13, 36, 56, .56); }
}

/* ==========================================================================
   Rubrique « Pathologies cérébrales »
   ========================================================================== */

.brain-block.bg-section {
  padding: 104px 0;
  touch-action: pan-y pinch-zoom;   /* glisser horizontal = rotation ; défilement vertical libre */
}

/* Légende sous le maillage (écran large). */
@media (min-width: 1080px) {
  .brain-block.bg-section .bg-caption { bottom: 40px; }
}

/* --- Liste interactive ------------------------------------------------- */
.brain-block.bg-section .domain-grid li.brain-zone-item {
  position: relative;
  padding: 13px 12px 13px 30px;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}
/* Repère : petit anneau qui s'allume avec la zone. */
.brain-block.bg-section .domain-grid li.brain-zone-item::before {
  content: "";
  position: absolute; left: 10px; top: 21px;
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid rgba(143, 179, 212, .55);
  transition: background-color .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.brain-block.bg-section .domain-grid li.brain-zone-item.is-lit {
  background: rgba(143, 179, 212, .09);
  border-top-color: rgba(143, 179, 212, .6);
  color: #fff;
}
.brain-block.bg-section .domain-grid li.brain-zone-item.is-lit::before {
  background: var(--sky);
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(143, 179, 212, .16), 0 0 14px rgba(143, 179, 212, .7);
}
@media (hover: hover) {
  .brain-block.bg-section .domain-grid li.brain-zone-item:hover { color: #fff; border-top-color: rgba(143, 179, 212, .6); }
}
.brain-block.bg-section .domain-grid li.brain-zone-item.is-pinned {
  background: rgba(143, 179, 212, .14);
  border-top-color: var(--sky);
}
.brain-block.bg-section .domain-grid li.brain-zone-item.is-pinned::before {
  animation: brain-dot 2.4s ease-in-out infinite;
}
.brain-block.bg-section .domain-grid li.brain-zone-item:focus { outline: none; }
.brain-block.bg-section .domain-grid li.brain-zone-item:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 2px;
}

@keyframes brain-dot {
  0%, 100% { box-shadow: 0 0 0 4px rgba(143, 179, 212, .16), 0 0 14px rgba(143, 179, 212, .7); }
  50%      { box-shadow: 0 0 0 7px rgba(143, 179, 212, .05), 0 0 22px rgba(143, 179, 212, .9); }
}

/* Aide sous la liste (créée par le script, style .bg-howto commun). */
.brain-block.bg-section .brain-hint { margin-top: -10px; }

/* --- Téléphone : le cerveau passe derrière le texte -------------------- */
@media (max-width: 767px) {
  .brain-block.bg-section { padding: 44px 0 48px; }
  .brain-block.bg-section .bg-content { padding-left: 16px; padding-right: 16px; }

  .brain-block.bg-section .domain-grid li.brain-zone-item {
    padding: 13px 10px 13px 28px;
    min-height: 44px;
  }
  .brain-block.bg-section .domain-grid li.brain-zone-item::before { left: 9px; top: 20px; }
  .brain-block.bg-section .brain-hint { margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .brain-block.bg-section .domain-grid li.brain-zone-item.is-pinned::before { animation: none; }
}
