/* ==========================================================================
   SCHÉMAS DE PROCESSUS — bibliothèque de composants réutilisables
   Palette attendue en variables CSS sur le document hôte :
   --primary, --primary-light, --secondary, --secondary-light,
   --secondary-dark, --text-dark, --text-light, --white
   Si absentes, des valeurs de repli (COPILOF) sont utilisées ci-dessous.
   ========================================================================== */

:root {
    --ps-primary: var(--primary, #14304C);
    --ps-primary-light: var(--primary-light, #1F4A70);
    --ps-secondary: var(--secondary, #28AEC5);
    --ps-secondary-light: var(--secondary-light, #5CC9DB);
    --ps-secondary-dark: var(--secondary-dark, #1D8598);
    --ps-text: var(--text-dark, #32373C);
    --ps-text-light: var(--text-light, #6D6D6D);
    --ps-white: var(--white, #FFFFFF);
}

/* --------------------------------------------------------------------------
   1) STEPPER HORIZONTAL — processus linéaire courant (3 à 6 étapes)
   Usage : parcours de certification, méthodologie d'accompagnement.
   <div class="ps-stepper">
     <div class="ps-step">
       <div class="ps-step-marker">1</div>
       <h3 class="ps-step-title">…</h3>
       <p class="ps-step-text">…</p>
     </div>
     …
   </div>
   -------------------------------------------------------------------------- */

.ps-stepper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0;
    position: relative;
    /* Correctif 17/09/2026 — debordement horizontal de la page entre ~761px
       et ~1100px. Le trait de liaison .ps-step::after porte volontairement un
       `right` negatif pour rejoindre l'etape suivante. Des que `auto-fit`
       replie la grille sur plusieurs rangees, l'etape en fin de rangee
       projette ce trait hors du conteneur : la page defilait alors
       horizontalement (scrollWidth 844 pour un viewport de 768). Seul
       :last-child etait neutralise, ce qui ne couvre pas les fins de rangee.
       On borne le trait au composant. */
    overflow: hidden;
}

.ps-step {
    position: relative;
    padding: 0 1.25rem 0 0;
    text-align: left;
}

.ps-step::after {
    content: '';
    position: absolute;
    top: 20px;
    left: calc(50% + 20px);
    right: calc(-50% + 20px);
    height: 2px;
    background: linear-gradient(90deg, var(--ps-secondary), rgba(40, 174, 197, 0.25));
}

.ps-step:last-child::after { display: none; }

.ps-step-marker {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--ps-primary);
    color: var(--ps-white);
    font-weight: 800;
    font-size: 1.05rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.ps-step:nth-child(1) .ps-step-marker { background: var(--ps-secondary-light); color: var(--ps-primary-dark, #0C2135); }
.ps-step:nth-child(2) .ps-step-marker { background: var(--ps-secondary); }
.ps-step:nth-child(3) .ps-step-marker { background: var(--ps-secondary-dark); }
.ps-step:nth-child(4) .ps-step-marker { background: var(--ps-primary); }
.ps-step:nth-child(5) .ps-step-marker { background: var(--ps-primary-light); }

.ps-step-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ps-primary);
    margin: 0 0 0.4rem;
}

.ps-step-text {
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--ps-text-light);
    margin: 0;
}

@media (max-width: 760px) {
    .ps-stepper { grid-template-columns: 1fr; gap: 1.75rem; }
    .ps-step::after { display: none; }
}

/* --------------------------------------------------------------------------
   2) TIMELINE VERTICALE — processus détaillé, avec beaucoup de texte par étape
   Usage : explication longue d'une procédure (ex. dépôt de dossier NDA).
   <ol class="ps-timeline">
     <li class="ps-timeline-item">
       <div class="ps-timeline-marker">1</div>
       <div class="ps-timeline-body">
         <h3 class="ps-step-title">…</h3>
         <p class="ps-step-text">…</p>
       </div>
     </li>
     …
   </ol>
   -------------------------------------------------------------------------- */

.ps-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.ps-timeline-item {
    display: flex;
    gap: 1.5rem;
    position: relative;
    padding-bottom: 2.25rem;
}

.ps-timeline-item:last-child { padding-bottom: 0; }

.ps-timeline-item::before {
    content: '';
    position: absolute;
    top: 42px;
    left: 20px;
    bottom: -2px;
    width: 2px;
    background: rgba(20, 48, 76, 0.12);
}

.ps-timeline-item:last-child::before { display: none; }

.ps-timeline-marker {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--ps-white);
    border: 2px solid var(--ps-secondary);
    color: var(--ps-secondary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    position: relative;
    z-index: 1;
}

.ps-timeline-item.is-done .ps-timeline-marker {
    background: var(--ps-secondary);
    border-color: var(--ps-secondary);
    color: var(--ps-white);
}

.ps-timeline-body { flex: 1; padding-top: 0.35rem; }

/* --------------------------------------------------------------------------
   3) CYCLE — processus récurrent qui boucle (ex. surveillance Qualiopi
   tous les ans, amélioration continue). 4 étapes disposées en boucle avec
   flèche de retour vers le point de départ.
   <div class="ps-cycle">
     <div class="ps-cycle-step"><div class="ps-step-marker">1</div>…</div>
     … (4 étapes)
     <div class="ps-cycle-arrow" aria-hidden="true"></div>
   </div>
   -------------------------------------------------------------------------- */

.ps-cycle {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem 1.5rem 2.5rem;
    border: 2px dashed rgba(40, 174, 197, 0.35);
    border-radius: 20px;
}

/* Correctif 17/09/2026 — debordement horizontal sous 380px.
   `minmax(300px, 1fr)` impose une colonne de 300px alors que le conteneur
   ne fait que 272px a 320px de viewport : la page defilait horizontalement
   (scrollWidth 350 au lieu de 320). Constate en production sur
   /guide-rnq-v10-qualiopi/ et /qualiopi-2026/, puis sur les deux pages
   d'accompagnement surveillance/renouvellement. On repasse en colonne
   unique avant d'atteindre ce seuil. */
@media (max-width: 380px) {
    .ps-cycle {
        grid-template-columns: 1fr;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

.ps-cycle-step { text-align: left; }

.ps-cycle-note {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(40, 174, 197, 0.35);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ps-secondary-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ps-cycle-note svg { width: 16px; height: 16px; }

/* --------------------------------------------------------------------------
   4) ENTONNOIR — filtrage / éligibilité progressive
   Usage : éligibilité CPF, sélection de candidats VAE, qualification de leads.
   <div class="ps-funnel">
     <div class="ps-funnel-row" style="--w:100%"><span>…</span></div>
     <div class="ps-funnel-row" style="--w:75%"><span>…</span></div>
     …
   </div>
   -------------------------------------------------------------------------- */

.ps-funnel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.ps-funnel-row {
    width: var(--w, 100%);
    max-width: 640px;
    background: linear-gradient(90deg, var(--ps-primary), var(--ps-secondary));
    color: var(--ps-white);
    text-align: center;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.92rem;
    transition: transform 0.2s ease;
}

.ps-funnel-row:hover { transform: scale(1.02); }

.ps-funnel-row span { display: block; }

.ps-funnel-row small {
    display: block;
    font-weight: 500;
    font-size: 0.78rem;
    opacity: 0.85;
    margin-top: 0.2rem;
}

/* --------------------------------------------------------------------------
   5) MERMAID — conteneur pour diagrammes en texte (flowchart, séquence,
   gantt). Voir assets/js/mermaid-theme.js pour la config aux couleurs
   de la marque.
   -------------------------------------------------------------------------- */

.ps-mermaid {
    background: var(--ps-white);
    border: 1px solid rgba(20, 48, 76, 0.08);
    border-radius: 16px;
    padding: 1.5rem;
    overflow-x: auto;
    box-shadow: 0 6px 20px rgba(20, 48, 76, 0.06);
}
