/* ==========================================================================
   Schémas pipelines — constellations géométriques + flux animé
   ========================================================================== */

.pp-schema {
    --pp-accent: var(--bleu-1);
    --pp-line: color-mix(in srgb, var(--bleu-1) 22%, transparent);
    --pp-text: var(--noir);
    --pp-text-soft: var(--gris-texte);
    margin: 0;
    position: relative;
}

.pp-schema--ocr { --pp-accent: var(--orange-1); }
.pp-schema--audio { --pp-accent: var(--vert-1); }

/* Pièces : uniquement tokens palette */
.pp-schema[data-pp-pieces="1"] {
    --pp-piece-ink: var(--orange-1);
}

.pp-schema--audio[data-pp-pieces="1"] {
    --pp-accent: var(--vert-1);
    --pp-piece-ink: var(--vert-1);
}

.pp-schema--ocr[data-pp-pieces="1"] {
    --pp-accent: var(--orange-1);
    --pp-piece-ink: var(--orange-1);
}

/* Étapes en pièces stipplées : labels legacy masqués (chip centre = visible) */
.pp-schema[data-pp-pieces="1"] .pp-schema__title,
.pp-schema[data-pp-pieces="1"] .pp-schema__node-label,
.pp-schema[data-pp-pieces="1"] .pp-schema__node-sub,
.pp-schema[data-pp-pieces="1"] .pp-schema__metric-label,
.pp-schema[data-pp-pieces="1"] .pp-schema__metric-track,
.pp-schema[data-pp-pieces="1"] .pp-schema__metric-fill,
.pp-schema[data-pp-pieces="1"] .pp-schema__key,
.pp-schema[data-pp-pieces="1"] .pp-schema__caption {
    display: none !important;
}

/* Mini-amas de points + libellé dessous */
.pp-schema__chip-layer {
    pointer-events: none;
}

.pp-schema__node-chip-g {
    pointer-events: none;
}

.pp-schema__node-chip {
    font-family: 'Space Grotesk', 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.03em;
    fill: #ffffff;
    stroke: none;
    pointer-events: none;
    user-select: none;
}

.pp-schema--hub:not(.is-lightbox) .pp-schema__node-chip {
    font-size: 9px;
    letter-spacing: 0.02em;
}

.pp-schema.is-lightbox .pp-schema__node-chip {
    font-size: 10.5px;
}

html:not(.dark) .pp-schema__node-chip {
    fill: var(--noir);
}

.pp-schema[data-pp-pieces="1"] .pp-schema__cloud--piece .pp-schema__cloud-dot {
    fill: var(--pp-piece-ink);
}

.pp-schema[data-pp-pieces="1"] .pp-schema__node-plate {
    display: none !important;
}

.pp-schema[data-pp-pieces="1"] .pp-schema__edge {
    stroke: color-mix(in srgb, var(--pp-accent) 28%, var(--noir));
    stroke-width: 0.9;
    opacity: 0.5;
    transition: none;
}

/* Trajectoires figées : aucun highlight / changement d’état */
.pp-schema[data-pp-pieces="1"] .pp-schema__edge.is-lit {
    stroke: color-mix(in srgb, var(--pp-accent) 28%, var(--noir));
    opacity: 0.5;
}

/* Étapes pièces : couleur pleine, aucun effet (pas de dim / pulse / halo) */
.pp-schema[data-pp-pieces="1"] .pp-schema__node {
    color: var(--pp-piece-ink);
}

.pp-schema[data-pp-pieces="1"] .pp-schema__node.is-active,
.pp-schema[data-pp-pieces="1"] .pp-schema__node:hover {
    color: var(--pp-piece-ink);
}

.pp-schema[data-pp-pieces="1"] .pp-schema__node-halo {
    display: none !important;
}

/* Masque la trajectoire sous la pièce (fond surface palette) */
.pp-schema__node-plate {
    fill: var(--blanc);
    stroke: none;
    pointer-events: none;
}

.pp-schema__cloud--piece .pp-schema__cloud-dot {
    fill: var(--pp-piece-ink);
    opacity: 1;
    transition: none;
}

.pp-schema__cloud--piece .pp-schema__cloud-wire {
    display: none !important;
}

.pp-schema.is-cloud-live .pp-schema__node:not(.is-active) .pp-schema__cloud--piece .pp-schema__cloud-dot,
.pp-schema.is-cloud-live .pp-schema__node.is-active .pp-schema__cloud--piece .pp-schema__cloud-dot {
    opacity: 1;
}

/* Fade morph : points seulement, le plate reste opaque */
.pp-schema[data-pp-pieces="1"] .pp-schema__cloud--piece {
    opacity: 1;
}

.pp-schema[data-pp-pieces="1"] .pp-schema__cloud--piece .pp-schema__cloud-dots {
    opacity: var(--pp-piece-vis, 1);
}

.pp-schema__cloud--piece {
    --pp-piece-vis: 1;
}

.pp-schema__stage {
    background: transparent;
    border: none;
    padding: 0;
    position: relative;
    overflow: visible;
}

/* Lecture d’étape — sous le SVG, jamais par-dessus le graphe */
.pp-schema__tip {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0.85rem 0 0;
    padding: 0.7rem 0 0;
    border: none;
    border-top: 1px solid color-mix(in srgb, var(--pp-accent) 42%, var(--bleu-2-bordure));
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--pp-text);
    pointer-events: none;
    opacity: 0;
    transform: translateY(0.25rem);
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
    line-height: 1.45;
    min-height: 2.85rem;
}

.pp-schema__tip.is-on {
    opacity: 1;
    transform: translateY(0);
}

.pp-schema__tip-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem 0.75rem;
}

.pp-schema__tip-kicker {
    display: inline-block;
    margin: 0;
    padding: 0.18rem 0.5rem;
    border: 1px solid color-mix(in srgb, var(--pp-accent) 55%, transparent);
    background: color-mix(in srgb, var(--pp-accent) 12%, transparent);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--pp-accent);
    writing-mode: horizontal-tb;
    transform: none;
    white-space: nowrap;
    line-height: 1.2;
}

.pp-schema__tip-label {
    display: block;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--noir);
    letter-spacing: 0.005em;
    line-height: 1.25;
}

.pp-schema__tip-desc {
    display: block;
    margin: 0;
    max-width: 40rem;
    font-size: var(--fs-body-sm, 0.875rem);
    font-weight: 400;
    color: var(--gris-texte);
    line-height: 1.5;
}

.pp-schema--audio .pp-schema__tip {
    border-top-color: color-mix(in srgb, var(--vert-1) 48%, var(--bleu-2-bordure));
}

.pp-schema--ocr .pp-schema__tip {
    border-top-color: color-mix(in srgb, var(--orange-1) 48%, var(--bleu-2-bordure));
}

/* Mode pièces : pas de loupe — info sous le schéma uniquement */
.pp-schema[data-pp-pieces="1"] .pp-schema__lens {
    display: none !important;
}

.pp-schema[data-pp-pieces="1"] .pp-schema__tip {
    display: flex;
    opacity: 0.55;
    transform: none;
    min-height: 3.2rem;
}

.pp-schema[data-pp-pieces="1"] .pp-schema__tip.is-on {
    opacity: 1;
}

.pp-schema[data-pp-pieces="1"] .pp-schema__tip:not(.is-on) .pp-schema__tip-kicker,
.pp-schema[data-pp-pieces="1"] .pp-schema__tip:not(.is-on) .pp-schema__tip-label {
    display: none;
}

.pp-schema[data-pp-pieces="1"] .pp-schema__tip:not(.is-on) .pp-schema__tip-desc {
    font-size: var(--fs-small, 0.78rem);
    font-style: italic;
}

.pp-schema[data-pp-pieces="1"] .pp-schema__node.is-step-focus .pp-schema__cloud--piece {
    opacity: 1;
}

.pp-schema[data-pp-pieces="1"].is-step-reading .pp-schema__node:not(.is-step-focus) .pp-schema__cloud--piece {
    opacity: 0.4;
}

.pp-schema[data-pp-pieces="1"].is-step-reading .pp-schema__node:not(.is-step-focus) .pp-schema__node-chip {
    opacity: 0.45;
}

.pp-schema__lens {
    pointer-events: none;
}

.pp-schema__lens-edge {
    fill: none;
    stroke: color-mix(in srgb, var(--pp-accent) 50%, transparent);
    stroke-width: 1.35;
    opacity: 0.9;
}

/* Cache le 1× sous la loupe (remplace le mask qui figeait le <use>) */
.pp-schema__lens-cover {
    fill: var(--blanc);
    stroke: none;
    pointer-events: none;
}

.pp-schema.is-lens-zoom .pp-schema__svg,
.pp-schema.is-lens-zoom .pp-schema__stage {
    overflow: visible;
}

/* ——— Composition (modes Rapidité / Coût / Qualité) ——— */
.pp-schema.is-compose {
    --pp-compose-tint: var(--pp-accent);
}

/* Audio : teintes proches de --vert-1 */
.pp-schema--audio[data-pp-compose-mode="rapidite"] {
    --pp-accent: color-mix(in srgb, var(--vert-1) 78%, #c8ffb4);
    --pp-piece-ink: color-mix(in srgb, var(--vert-1) 78%, #c8ffb4);
    --pp-compose-tint: color-mix(in srgb, var(--vert-1) 78%, #c8ffb4);
}

.pp-schema--audio[data-pp-compose-mode="qualite"] {
    --pp-accent: var(--vert-1);
    --pp-piece-ink: var(--vert-1);
    --pp-compose-tint: var(--vert-1);
}

.pp-schema--audio[data-pp-compose-mode="cout"] {
    --pp-accent: color-mix(in srgb, var(--vert-1) 82%, #d3ebe0);
    --pp-piece-ink: color-mix(in srgb, var(--vert-1) 82%, #d3ebe0);
    --pp-compose-tint: color-mix(in srgb, var(--vert-1) 82%, #d3ebe0);
}

/* OCR : teintes proches de --orange-1 */
.pp-schema--ocr[data-pp-compose-mode="rapidite"] {
    --pp-accent: color-mix(in srgb, var(--orange-1) 78%, #ffd8c4);
    --pp-piece-ink: color-mix(in srgb, var(--orange-1) 78%, #ffd8c4);
    --pp-compose-tint: color-mix(in srgb, var(--orange-1) 78%, #ffd8c4);
}

.pp-schema--ocr[data-pp-compose-mode="smart"],
.pp-schema--ocr[data-pp-compose-mode="cout"] {
    --pp-accent: var(--orange-1);
    --pp-piece-ink: var(--orange-1);
    --pp-compose-tint: var(--orange-1);
}

.pp-schema--ocr[data-pp-compose-mode="qualite"] {
    --pp-accent: color-mix(in srgb, var(--orange-1) 82%, #f5c4a8);
    --pp-piece-ink: color-mix(in srgb, var(--orange-1) 82%, #f5c4a8);
    --pp-compose-tint: color-mix(in srgb, var(--orange-1) 82%, #f5c4a8);
}

.pp-schema.is-compose .pp-schema__node.is-compose-off {
    opacity: 0.16;
    filter: grayscale(0.35);
    pointer-events: none;
}

.pp-schema.is-compose .pp-schema__node.is-compose-on {
    opacity: 1;
    filter: none;
}

/* Chips hors chemin : quasi invisibles (couche séparée des nœuds) */
.pp-schema.is-compose .pp-schema__chip-layer > g.is-compose-off {
    opacity: 0.14;
}

.pp-schema.is-compose .pp-schema__chip-layer > g.is-compose-on {
    opacity: 1;
}

.pp-schema.is-compose .pp-schema__edge-tag.is-compose-off {
    opacity: 0.12;
}

.pp-schema.is-compose .pp-schema__edge-tag.is-compose-on {
    opacity: 1;
}

.pp-schema.is-compose .pp-schema__edge.is-compose-off {
    /* Opacité 1 + teinte déjà atténuée : les traits superposés ne s’additionnent plus */
    opacity: 1;
    stroke: color-mix(in srgb, var(--pp-piece-ink, var(--pp-accent)) 18%, var(--blanc));
    pointer-events: none;
}

.pp-schema.is-compose .pp-schema__edge.is-compose-on {
    opacity: 1;
    stroke: color-mix(in srgb, var(--pp-piece-ink, var(--pp-accent)) 72%, var(--noir));
}

/* Raccourci Parakeet→Valider : masqué hors modes Rapidité/Coût */
.pp-schema__edge--shortcut {
    display: none;
}

.pp-schema.is-compose .pp-schema__edge--shortcut.is-compose-off {
    display: none;
}

.pp-schema.is-compose .pp-schema__edge--shortcut.is-compose-on {
    display: inline;
    stroke-dasharray: 5 4;
    opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
    .pp-schema__tip {
        transition: none;
    }
}

.pp-schema__svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.pp-schema__svg text {
    font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
}

.pp-schema__title {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    fill: var(--pp-text-soft);
}

.pp-schema__node-label {
    font-size: 10px;
    font-weight: 600;
    fill: var(--pp-text);
    transition: fill 0.2s ease, opacity 0.2s ease;
}

.pp-schema__node-sub {
    font-size: 8px;
    fill: var(--pp-text-soft);
}

/* Libellé dans la coupure du trait (Excalidraw) */
.pp-schema__edge-tag {
    font-family: 'Space Grotesk', 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 8.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    fill: var(--pp-accent);
    stroke: none;
    pointer-events: none;
    user-select: none;
}

.pp-schema--hub:not(.is-lightbox) .pp-schema__edge-label-layer {
    display: none;
}

html.dark .pp-schema__edge-tag {
    fill: #ffffff;
}

/* Fils — traits fins et sobres, la donnée seule porte la couleur */
.pp-schema__edge {
    fill: none;
    stroke: var(--pp-line);
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.6;
    transition: stroke 0.4s ease, opacity 0.4s ease;
}

.pp-schema__edge.is-lit {
    stroke: color-mix(in srgb, var(--pp-accent) 45%, transparent);
    opacity: 1;
}

/* Gouttes métaballes : la donnée se lie au nœud puis s'en détache */
.pp-schema__goo {
    pointer-events: none;
}

.pp-schema__trail {
    pointer-events: none;
}

.pp-schema__trail-dot {
    fill: var(--pp-accent);
    opacity: 0.8;
    shape-rendering: optimizeSpeed;
}

.pp-schema__goo-blob,
.pp-schema__goo-core,
.pp-schema__goo-sym,
.pp-schema__lens-blob {
    fill: var(--pp-accent);
    shape-rendering: optimizeSpeed;
}

/* Proxies loupe : gouttes sans filtre (évite double feGaussian) */
.pp-schema__lens-fx {
    pointer-events: none;
}

.pp-schema__goo-blob {
    visibility: hidden;
}

.pp-schema__goo-blob.is-placed {
    visibility: visible;
}

.pp-schema__goo-core {
    transition: none;
}

/* Le cercle gabarit des templates n'est plus utilisé */
.pp-schema__packet {
    display: none;
}

.pp-schema__hit {
    fill: transparent;
    stroke: none;
    cursor: pointer;
}

/* Constellations vivantes — nuages de points animés */
.pp-schema__node {
    color: var(--noir);
}

.pp-schema__node--ghost {
    pointer-events: none;
    color: var(--pp-accent);
    opacity: 0.55;
}

.pp-schema.is-flowing .pp-schema__node--ghost {
    opacity: 0.7;
}

.pp-schema__cloud {
    pointer-events: none;
}

.pp-schema__cloud-dot {
    fill: currentColor;
    opacity: 0.88;
    transition: opacity 0.2s ease;
}

.pp-schema.is-cloud-live .pp-schema__node:not(.is-active) .pp-schema__cloud-dot {
    opacity: 0.55;
}

.pp-schema.is-cloud-live .pp-schema__node.is-active .pp-schema__cloud-dot {
    opacity: 1;
}

.pp-schema__cloud-wire {
    fill: none;
    stroke: currentColor;
    stroke-width: 0.65;
    stroke-linecap: round;
    opacity: 0.22;
}

.pp-schema__node-halo {
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
    opacity: 0;
}

.pp-schema__node.is-active,
.pp-schema__node:hover {
    color: var(--pp-accent);
}

.pp-schema__node.is-active .pp-schema__cloud-dot,
.pp-schema__node:hover .pp-schema__cloud-dot {
    opacity: 1;
}

.pp-schema__node.is-active .pp-schema__cloud-wire,
.pp-schema__node:hover .pp-schema__cloud-wire {
    opacity: 0.48;
}

.pp-schema__node.is-active .pp-schema__node-label,
.pp-schema__node:hover .pp-schema__node-label {
    fill: var(--pp-accent);
}

/* Legacy symbols (fallback si JS désactivé) */
.pp-schema__node use {
    color: inherit;
}

.pp-schema__const-wire {
    fill: none;
    stroke: currentColor;
    stroke-width: 0.7;
    opacity: 0.28;
}

.pp-schema__dot {
    fill: currentColor;
    opacity: 0.9;
}

.pp-schema__dot--core {
    opacity: 1;
}

/* Hub compact : labels / clé / métriques masqués (visibles en lightbox) */
.pp-schema--hub:not(.is-lightbox) .pp-schema__node-label,
.pp-schema--hub:not(.is-lightbox) .pp-schema__node-sub,
.pp-schema--hub:not(.is-lightbox) .pp-schema__title,
.pp-schema--hub:not(.is-lightbox) .pp-schema__edge-tag,
.pp-schema--hub:not(.is-lightbox) .pp-schema__metric-label,
.pp-schema--hub:not(.is-lightbox) .pp-schema__metric-track,
.pp-schema--hub:not(.is-lightbox) .pp-schema__metric-fill,
.pp-schema--hub:not(.is-lightbox) .pp-schema__key,
.pp-schema--hub:not(.is-lightbox) .pp-schema__caption,
.pp-schema--hub:not(.is-lightbox) .pp-schema__toolbar,
.pp-schema--hub:not(.is-lightbox) .pp-schema__tip {
    display: none !important;
}

/* Lightbox : le bandeau tip SVG est remplacé par le panneau info du hub */
.pp-schema.is-lightbox .pp-schema__tip {
    display: none !important;
}

/* Hub : pas de pastille sous les pièces — juste le SVG sur le fond de la carte */
.pp-schema--hub:not(.is-lightbox) .pp-schema__node-plate {
    display: none !important;
}

/* Clé visuelle */
.pp-schema__key {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 14px;
}

.pp-schema__key-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-small);
    color: var(--gris-texte);
    line-height: 1.35;
}

.pp-schema__key-item strong {
    color: var(--noir);
    font-weight: 700;
}

.pp-schema__key-ico {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    color: var(--pp-accent);
    overflow: visible;
}

/* Pastilles de légende (forme = rôle) — teinte = accent pipeline */
.pp-schema__key-swatch {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    position: relative;
    background:
        radial-gradient(circle at 50% 50%, var(--pp-accent) 1.4px, transparent 1.6px),
        radial-gradient(circle at 30% 35%, var(--pp-accent) 1.1px, transparent 1.3px),
        radial-gradient(circle at 70% 35%, var(--pp-accent) 1.1px, transparent 1.3px),
        radial-gradient(circle at 30% 70%, var(--pp-accent) 1.1px, transparent 1.3px),
        radial-gradient(circle at 70% 70%, var(--pp-accent) 1.1px, transparent 1.3px);
}

.pp-schema__key-swatch--in {
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pp-accent) 35%, transparent);
}

.pp-schema__key-swatch--logic {
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
    box-shadow: none;
}

.pp-schema__key-swatch--model {
    background:
        radial-gradient(circle at 25% 30%, var(--pp-accent) 1.3px, transparent 1.5px),
        radial-gradient(circle at 25% 70%, var(--pp-accent) 1.3px, transparent 1.5px),
        radial-gradient(circle at 55% 20%, var(--pp-accent) 1.3px, transparent 1.5px),
        radial-gradient(circle at 55% 50%, var(--pp-accent) 1.3px, transparent 1.5px),
        radial-gradient(circle at 55% 80%, var(--pp-accent) 1.3px, transparent 1.5px),
        radial-gradient(circle at 85% 35%, var(--pp-accent) 1.3px, transparent 1.5px),
        radial-gradient(circle at 85% 65%, var(--pp-accent) 1.3px, transparent 1.5px);
}

.pp-schema__key-swatch--out {
    border-radius: 50%;
    background: var(--pp-accent);
    opacity: 0.85;
}

.pp-schema__metric-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.14em;
    fill: var(--pp-text-soft);
}

.pp-schema__metric-track { fill: var(--bleu-2-bordure); }
.pp-schema__metric-fill { fill: var(--pp-accent); }

/* Caption / légende */
.pp-schema__caption {
    margin-top: 10px;
    min-height: 1.4em;
    font-size: var(--fs-small);
    color: var(--gris-texte);
    line-height: 1.45;
}

/* Si tip + caption coexistent (schémas non-pièces), tip reste sous le SVG */
.pp-schema:not([data-pp-pieces="1"]) .pp-schema__tip {
    margin-top: 0.55rem;
}

.pp-schema:not([data-pp-pieces="1"]) .pp-schema__tip:not(.is-on) {
    min-height: 0;
    margin: 0;
    padding: 0;
    border-top-width: 0;
    overflow: hidden;
}

.pp-schema__caption-live strong {
    color: var(--noir);
    font-weight: 700;
}

.pp-schema__toolbar {
    display: none;
}

.pp-schema__auto-btn {
    display: none;
}

.pp-schema__legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1px;
    background: var(--blanc);
}

.pp-schema__legend-item {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    background: var(--blanc);
    box-shadow: 0 0 0 1px var(--bleu-2-bordure);
    cursor: pointer;
}

.pp-schema__legend-item strong {
    font-size: var(--fs-body-sm);
    font-weight: 700;
    color: var(--noir);
}

.pp-schema__legend-item span {
    font-size: var(--fs-small);
    color: var(--gris-texte);
    line-height: 1.45;
}

.pp-schema__legend-item.is-active { background: var(--bleu-2); }

@media (prefers-reduced-motion: reduce) {
    .pp-schema__goo-blob,
    .pp-schema__trail-dot { display: none; }
}
