/* Documentation — « Comment ça marche ».

   Même matière que la page vitrine (landing.css est chargée avant) : bandes
   vert nuit, papier chaud, Fraunces pour les titres. Ce fichier n'ajoute que
   ce qui est propre à la documentation : la scène du schéma, tenue dans la
   hauteur de la fenêtre, ses info-bulles, son volet latéral, son récit ; puis
   les sections qui la prolongent.

   Le schéma est un SVG en ligne : ses couleurs et ses animations sont ici,
   pas dans le balisage, pour que le mode « moins d'animations » du système
   puisse tout éteindre d'un seul bloc. */

:root {
  --barre-h: 3.8rem;            /* mesurée au chargement par le script */
  --volet-l: 27rem;
  --lueur: rgba(217, 142, 61, .55);
}

.page-documentation { background: var(--pin-nuit); }

/* ================= barre : un titre de page au milieu ================= */

.barre-titre {
  font-family: var(--serif); font-weight: 600; font-size: 1.05rem;
  color: rgba(243, 241, 232, .8); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ================= la scène ================= */

.scene {
  position: relative;
  display: flex; align-items: stretch;
  height: calc(100vh - var(--barre-h));
  height: calc(100dvh - var(--barre-h));
  min-height: 34rem;
  background: var(--pin-nuit); color: var(--papier);
  overflow: hidden;
}
.scene-planche {
  position: relative; flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; justify-content: center;
}
/* une seule cellule de grille aux dimensions définies : c'est ce qui permet
   au SVG de remplir la hauteur (un pourcentage ne se résout pas contre une
   ligne « auto ») ; le viewBox se centre dedans par « meet » */
.scene-cadre {
  width: 100%; height: 100%; padding: .5rem 1rem;
  display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  place-items: center;
}
.schema {
  width: 100%; height: 100%;
  font-family: var(--corps);
  overflow: visible;
}

/* ---------- cadres Famille / Établissement ---------- */

.zone {
  fill: rgba(243, 241, 232, .035);
  stroke: rgba(243, 241, 232, .26); stroke-width: 1.5;
  transition: stroke .25s ease, fill .25s ease;
}
.cadre-zone:hover .zone, .cadre-zone:focus-visible .zone { stroke: rgba(243, 241, 232, .6); fill: rgba(243, 241, 232, .06); }
.cadre-zone.actif .zone { stroke: var(--abricot); }
.zone-titre {
  font-family: var(--mono); font-size: 17px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; fill: var(--abricot);
}
.zone-sous { font-size: 18px; fill: rgba(243, 241, 232, .62); }

/* ---------- appareils et personnes ---------- */

.noeud { cursor: pointer; outline: none; }
.noeud:focus-visible .halo { stroke: var(--abricot); stroke-opacity: 1; }

.halo {
  fill: none; stroke: var(--abricot); stroke-width: 2.5; stroke-opacity: 0;
  transition: stroke-opacity .25s ease;
}
.noeud:hover .halo { stroke-opacity: .55; }
.noeud.actif .halo { stroke-opacity: 1; animation: pulsation 1.4s ease-in-out infinite; }
.noeud.estompe { opacity: .38; transition: opacity .3s ease; }
.noeud { transition: opacity .3s ease; }

.monture {
  fill: rgba(243, 241, 232, .14);
  stroke: rgba(243, 241, 232, .4); stroke-width: 1.2;
}
.monture-tv { fill: #0B1815; stroke: rgba(243, 241, 232, .5); }
.socle { fill: rgba(243, 241, 232, .3); }
.appareil image { transition: filter .3s ease; }
.appareil.actif image { filter: brightness(1.08); }

.avatar, .carte-personne circle:not(.point) { fill: #DDE7E0; }
.initiale {
  font-family: var(--corps); font-weight: 700; font-size: 30px; fill: var(--pin-nuit);
}
.carte-personne rect { fill: rgba(243, 241, 232, .09); stroke: rgba(243, 241, 232, .28); stroke-width: 1.2; }
.nom { font-size: 22px; font-weight: 700; fill: var(--papier); }
.role { font-size: 17px; fill: rgba(243, 241, 232, .66); }
.point { fill: rgba(243, 241, 232, .35); }
.point-ok { fill: #7FC98F; }
.silhouette { fill: none; stroke: var(--pin-nuit); stroke-width: 2.4; stroke-linecap: round; }
.badge rect { fill: var(--abricot); }
.badge circle { fill: none; stroke: var(--pin-nuit); stroke-width: 2; }
.badge path { stroke: var(--pin-nuit); stroke-width: 2; stroke-linecap: round; }

.legende { font-size: 17px; fill: rgba(243, 241, 232, .66); }
.legende-forte { font-family: var(--serif); font-size: 24px; font-weight: 600; fill: var(--papier); }

/* ---------- liens ---------- */

.lien { cursor: pointer; outline: none; transition: opacity .3s ease; }
.lien.estompe { opacity: .28; }
.lien-zone { fill: none; stroke: transparent; stroke-width: 34; pointer-events: stroke; }
.lien-trait {
  fill: none; stroke: rgba(243, 241, 232, .5); stroke-width: 2.5;
  transition: stroke .25s ease, stroke-width .25s ease;
}
.pointe { fill: rgba(243, 241, 232, .7); }
.lien:hover .lien-trait, .lien:focus-visible .lien-trait, .lien.actif .lien-trait {
  stroke: var(--abricot); stroke-width: 3.5;
}
.lien-flux {
  fill: none; stroke: var(--abricot); stroke-width: 2.5;
  stroke-dasharray: 8 18; stroke-linecap: round;
  opacity: .55;
  animation: defilement 1.6s linear infinite;
}
.lien.actif .lien-flux { opacity: 1; animation-duration: .7s; }
.lien-texte { font-size: 17px; fill: rgba(243, 241, 232, .74); pointer-events: none; }
.lien-texte-milieu { text-anchor: middle; }
.lien:hover .lien-texte, .lien.actif .lien-texte { fill: var(--papier); }

/* paquets qui circulent le long des liens (créés par le script) */
.paquet { fill: var(--abricot); }
.paquet-lueur { fill: var(--abricot); opacity: .28; }
.paquet-eclat { fill: #FFF3E0; }

@keyframes defilement { to { stroke-dashoffset: -26; } }
@keyframes pulsation {
  0%, 100% { stroke-opacity: 1; stroke-width: 2.5; }
  50% { stroke-opacity: .35; stroke-width: 5; }
}

/* ---------- menu des scénarios ---------- */

.scenarios {
  position: absolute; z-index: 5; top: 1rem; left: 1rem;
  width: 17rem; max-width: calc(100% - 2rem);
  background: rgba(16, 37, 31, .92); backdrop-filter: blur(6px);
  border: 1px solid rgba(243, 241, 232, .22); border-radius: 14px;
  padding: .55rem .6rem .7rem;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .35);
}
.scenarios-titre {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: 0; color: inherit; cursor: pointer;
  padding: .25rem .35rem; font: inherit;
}
.scenarios-chevron {
  width: .55rem; height: .55rem; border-right: 2px solid var(--abricot); border-bottom: 2px solid var(--abricot);
  transform: rotate(45deg); transition: transform .2s ease; margin-right: .3rem;
}
/* replié en pastille pour ne rien cacher du schéma ; la liste se déplie au
   survol (souris) ou au clic (doigt, clavier) */
.scenarios-liste, .scenarios-aide { display: none; }
.scenarios.ouvert .scenarios-liste, .scenarios.ouvert .scenarios-aide { display: grid; }
.scenarios.ouvert .scenarios-aide { display: block; }
.scenarios.ouvert .scenarios-chevron { transform: rotate(-135deg); margin-top: .3rem; }
@media (hover: hover) {
  .scenarios:hover .scenarios-liste { display: grid; }
  .scenarios:hover .scenarios-aide { display: block; }
  .scenarios:hover .scenarios-chevron { transform: rotate(-135deg); margin-top: .3rem; }
}
.scenarios-liste { list-style: none; margin: .35rem 0 0; padding: 0; gap: .25rem; }
.scenario {
  width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: .6rem;
  background: rgba(243, 241, 232, .06); border: 1px solid transparent;
  color: var(--papier); border-radius: 9px; padding: .5rem .6rem;
  font: inherit; font-size: .9rem; line-height: 1.3;
  transition: background-color .15s ease, border-color .15s ease;
}
.scenario:hover { background: rgba(243, 241, 232, .12); }
.scenario.en-cours { border-color: var(--abricot); background: rgba(217, 142, 61, .16); }
.scenario-picto {
  flex: 0 0 auto; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--abricot); color: var(--pin-nuit); font-weight: 700; font-size: .8rem;
}
.scenario.en-cours .scenario-picto { animation: clignote 1s steps(2, start) infinite; }
.scenarios-aide { margin-top: .6rem; font-size: .8rem; color: rgba(243, 241, 232, .55); line-height: 1.4; padding: 0 .35rem; }

@keyframes clignote { to { visibility: hidden; } }

/* ---------- récit ---------- */

.recit {
  position: absolute; z-index: 5; left: 50%; bottom: 1rem; transform: translateX(-50%);
  width: min(46rem, calc(100% - 2rem));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .3rem 1rem;
  background: rgba(16, 37, 31, .94); backdrop-filter: blur(6px);
  border: 1px solid rgba(243, 241, 232, .22); border-radius: 14px;
  padding: .7rem 1rem .8rem;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .35);
}
.recit[hidden] { display: none; }
.recit-barre {
  grid-column: 1 / -1; height: 4px; border-radius: 2px;
  background: rgba(243, 241, 232, .14); overflow: hidden;
}
.recit-progression {
  display: block; height: 100%; width: 0; background: var(--abricot);
  border-radius: 2px;
}
.recit-progression.en-cours { transition: width var(--duree, 3s) linear; width: 100%; }
.recit-etape { font-size: 1rem; line-height: 1.45; display: flex; gap: .7rem; align-items: baseline; }
.recit-rang { font-family: var(--mono); font-size: .78rem; font-weight: 600; color: var(--abricot); flex: 0 0 auto; }
.recit-stop {
  font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer;
  background: none; color: var(--papier); border: 1.5px solid rgba(243, 241, 232, .4);
  border-radius: 999px; padding: .3rem .8rem;
}
.recit-stop:hover { border-color: var(--papier); }

/* ---------- info-bulle ---------- */

.bulle {
  position: fixed; z-index: 60; pointer-events: none;
  max-width: 19rem;
  background: var(--craie); color: var(--encre);
  border-radius: 10px; padding: .6rem .8rem;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
  font-size: .88rem; line-height: 1.4;
  opacity: 0; transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease;
}
.bulle.visible { opacity: 1; transform: none; }
.bulle[hidden] { display: none; }
.bulle-titre { font-family: var(--serif); font-weight: 600; font-size: 1rem; margin-bottom: .2rem; }
.bulle-texte { color: var(--encre-douce); }

/* ---------- volet latéral ---------- */

.volet {
  position: relative; flex: 0 0 auto;
  width: var(--volet-l); max-width: 100%;
  background: var(--papier); color: var(--encre);
  border-left: 1px solid rgba(16, 37, 31, .2);
  box-shadow: -14px 0 32px rgba(0, 0, 0, .3);
  overflow-y: auto; overscroll-behavior: contain;
  animation: glisse-volet .28s cubic-bezier(.2, .7, .3, 1);
}
.volet[hidden] { display: none; }
.volet-fermer {
  position: sticky; top: .6rem; float: right; margin: .6rem .7rem 0 0; z-index: 2;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: 1px solid var(--trait); background: var(--craie); color: var(--encre);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.volet-fermer:hover { background: #fff; }
.volet-contenu { padding: 1.4rem 1.5rem 2rem; }
.volet-contenu .surtitre { margin-bottom: .4rem; }
.volet-contenu h2 { font-size: 1.7rem; margin-bottom: .6rem; letter-spacing: -.02em; }
.volet-contenu .resume { color: var(--encre-douce); margin-bottom: 1rem; }
.volet-contenu h3 {
  font-family: var(--corps); font-size: .8rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--pin);
  margin: 1.3rem 0 .5rem;
}
.volet-contenu ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .4rem; }
.volet-contenu li { font-size: .93rem; line-height: 1.45; }
.volet-contenu li::marker { color: var(--abricot); }
.volet-flux { list-style: none; padding: 0; }
.volet-flux li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .55rem; align-items: baseline; }
.volet-flux .sens {
  font-family: var(--mono); font-size: .72rem; font-weight: 600; color: var(--abricot);
  white-space: nowrap;
}
.volet-jamais {
  margin-top: .5rem; padding: .7rem .9rem; border-radius: 10px;
  background: var(--abricot-pale); border-left: 3px solid var(--abricot);
  font-size: .9rem; line-height: 1.45;
}
.volet-jamais strong { display: block; font-family: var(--serif); font-size: 1rem; margin-bottom: .2rem; }
.volet-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.volet-actions .bouton { font-size: .85rem; padding: .45rem .95rem; }
.volet-actions .bouton-ligne { color: var(--pin-nuit); border-color: rgba(22, 33, 28, .3); }
.volet-actions .bouton-ligne:hover { border-color: var(--pin-nuit); background: rgba(22, 33, 28, .05); }
.volet-images { display: grid; gap: 1rem; margin-top: .4rem; }
.volet-images .cadre { padding: .45rem; border-radius: 12px; }
.volet-images .cadre .ecran { border-radius: 7px; }
.volet-images .cadre-telephone { max-width: 12rem; margin-inline: auto; border-radius: 22px; }
.volet-images .cadre-telephone .ecran { border-radius: 16px; }
.volet-images .cadre-borne { max-width: 13rem; margin-inline: auto; }
.volet-images figcaption { color: var(--encre-douce); }
.volet-images .paire { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.volet-liens { display: flex; flex-wrap: wrap; gap: .4rem; }
.volet-liens button {
  font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer;
  background: var(--craie); color: var(--pin-nuit);
  border: 1px solid var(--trait); border-radius: 999px; padding: .3rem .75rem;
}
.volet-liens button:hover { border-color: var(--pin); }

@keyframes glisse-volet { from { transform: translateX(2rem); opacity: 0; } }

/* ================= quatre surfaces ================= */

.page-documentation main > .section, .page-documentation .final { background: var(--papier); }
.page-documentation main > .section { max-width: none; padding-inline: 0; }
.page-documentation main > .section > * {
  max-width: var(--colonne); margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}
.surfaces { padding-top: var(--marche); }
.surfaces .titre-section { margin-bottom: 1rem; }
.intro { color: var(--encre-douce); font-size: 1.12rem; max-width: 42rem; margin-bottom: 2.5rem; }
.grille-surfaces {
  display: grid; gap: 1.4rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}
.surface { display: grid; gap: .5rem; align-content: start; }
.surface .cadre { margin-bottom: .7rem; }
.surface .cadre-borne { max-width: 11rem; }
.surface .cadre-telephone { max-width: 9rem; }
/* la borne et le téléphone sont hauts : les cadres larges s'alignent sur leur pied */
.surface .cadre-tv, .surface .cadre-bureau { margin-top: auto; }
.surface h3 { font-size: 1.35rem; }
.surface-qui { font-family: var(--mono); font-size: .74rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--abricot); }
.surface ul { margin: .3rem 0 0; padding-left: 1.05rem; display: grid; gap: .35rem; color: var(--encre-douce); font-size: .93rem; line-height: 1.45; }
.surface li::marker { color: var(--abricot); }

/* ================= sous le capot ================= */

.technique { background: var(--pin); color: var(--papier); }
.technique-dedans {
  max-width: var(--colonne); margin: 0 auto;
  padding: var(--marche) clamp(1.25rem, 4vw, 2.5rem);
}
.technique h2 { font-size: clamp(1.9rem, 3.6vw, 2.7rem); margin: .9rem 0 1.1rem; }
.technique-intro { color: rgba(243, 241, 232, .84); max-width: 44rem; margin-bottom: 2.2rem; }
.technique-cadre { overflow-x: auto; }
.schema-technique { width: 100%; min-width: 56rem; height: auto; font-family: var(--corps); overflow: visible; }
.t-groupe-titre { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; fill: var(--abricot); }
.t-noeud rect { fill: rgba(16, 37, 31, .55); stroke: rgba(243, 241, 232, .3); stroke-width: 1.5; transition: stroke .2s ease; }
.t-noeud:hover > rect, .t-noeud:focus-visible > rect { stroke: var(--abricot); }
.t-serveur > rect { fill: var(--pin-nuit); }
.t-cloud > rect { fill: rgba(16, 37, 31, .35); stroke-dasharray: 6 6; }
.t-nom { font-size: 22px; font-weight: 700; fill: var(--papier); }
.t-nom-grand { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.t-detail { font-size: 16px; fill: rgba(243, 241, 232, .68); }
.t-brique rect { fill: rgba(243, 241, 232, .08); stroke: none; }
.t-brique text { font-size: 16px; fill: rgba(243, 241, 232, .88); }
.t-lien .lien-trait { stroke: rgba(243, 241, 232, .55); }
.t-lien .lien-texte { font-size: 15px; }

/* ================= ce qui ne circule jamais ================= */

.jamais { padding-bottom: var(--marche); }

/* ================= final ================= */

.page-documentation .final { max-width: none; }
.final-note { margin: 1.8rem auto 0; max-width: 40rem; color: var(--encre-douce); font-size: .9rem; line-height: 1.5; }

/* ================= fenêtres étroites ================= */

@media (max-width: 78rem) {
  .grille-surfaces { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 1.6rem; }
  .surface .cadre-tv, .surface .cadre-bureau { margin-top: 0; }
}

@media (max-width: 60rem) {
  /* la scène cesse de tenir dans la fenêtre : le schéma garde une largeur
     lisible et défile dans son propre cadre, le volet passe en tiroir bas */
  .scene { height: auto; min-height: 0; display: block; }
  .scene-planche { display: block; }
  /* calé à gauche, pas centré : ce qui déborde d'un contenu centré n'est
     pas atteignable au défilement (le schéma partait à -260 px) */
  .scene-cadre {
    display: flex; justify-content: flex-start; align-items: flex-start;
    overflow-x: auto; padding: 4.6rem 1rem 1rem;
  }
  .schema { flex: 0 0 56rem; width: 56rem; height: auto; }
  .scenarios { width: calc(100% - 2rem); }
  .scenarios.ouvert { max-height: 60vh; overflow-y: auto; }
  .recit { position: sticky; bottom: .8rem; margin: 0 auto 1rem; transform: none; left: 0; width: min(46rem, calc(100% - 2rem)); }
  .volet {
    position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
    width: 100%; max-height: 72vh;
    border-left: 0; border-top: 1px solid rgba(16, 37, 31, .2);
    border-radius: 16px 16px 0 0;
    animation: glisse-tiroir .28s cubic-bezier(.2, .7, .3, 1);
  }
  .technique-cadre { margin-inline: calc(-1 * clamp(1.25rem, 4vw, 2.5rem)); padding-inline: clamp(1.25rem, 4vw, 2.5rem); }
}
@keyframes glisse-tiroir { from { transform: translateY(2rem); opacity: 0; } }

@media (max-width: 40rem) {
  .barre-titre { display: none; }
  .grille-surfaces { grid-template-columns: minmax(0, 1fr); }
  .surface .cadre-borne, .surface .cadre-telephone { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  .lien-flux { animation: none; }
  .noeud.actif .halo, .scenario.en-cours .scenario-picto { animation: none; }
  .volet, .bulle { animation: none; transition: none; }
  .recit-progression.en-cours { transition: none; }
}
