/* Formation loom_v2 — feuille de style commune.
   Le fil rouge de la formation est dessiné littéralement : un fil garance qui
   traverse la navigation et relie les versions de l'agent. Le reste reste sobre. */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans+Condensed:wght@500;600;700&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap");

:root {
  --papier: #f6f7f9;
  --surface: #ffffff;
  --encre: #1a2233;
  --encre-douce: #4d576a;
  --filet: #d9dde5;
  --garance: #c21f3a;          /* le fil rouge */
  --garance-pale: #f7e3e7;
  --indigo: #2b4c8c;           /* liens, variante vrai modèle */
  --indigo-pale: #e8edf7;
  --sauge: #2f7a5b;            /* ce que vous devez voir */
  --sauge-pale: #e6f2ec;
  --ocre: #8a5d00;             /* pièges */
  --ocre-pale: #fbf2d9;
  --code-fond: #172036;
  --code-texte: #e3e8f2;
  --code-sourdine: #8e9bb6;

  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --titre: "IBM Plex Sans Condensed", "Arial Narrow", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --mesure: 72ch;
  --nav: 17.5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #121829;
    --surface: #182036;
    --encre: #e4e8f0;
    --encre-douce: #a3adc2;
    --filet: #2d3753;
    --garance: #ec5a72;
    --garance-pale: #3a1d29;
    --indigo: #8fb0ef;
    --indigo-pale: #1e2a48;
    --sauge: #6cc49c;
    --sauge-pale: #16302a;
    --ocre: #e2b44d;
    --ocre-pale: #33290f;
    --code-fond: #0d1322;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papier: #121829; --surface: #182036; --encre: #e4e8f0; --encre-douce: #a3adc2;
  --filet: #2d3753; --garance: #ec5a72; --garance-pale: #3a1d29; --indigo: #8fb0ef;
  --indigo-pale: #1e2a48; --sauge: #6cc49c; --sauge-pale: #16302a; --ocre: #e2b44d;
  --ocre-pale: #33290f; --code-fond: #0d1322; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 106.25%; -webkit-text-size-adjust: 100%; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--sans);
  line-height: 1.62;
  font-feature-settings: "kern", "liga";
}

a { color: var(--indigo); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--garance); outline-offset: 2px; border-radius: 2px; }

.saut { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.saut:focus { left: 1rem; }

/* ---------- Ossature : navigation (le fil) + contenu ---------- */

.ossature {
  display: grid;
  grid-template-columns: var(--nav) minmax(0, 1fr);
  min-height: 100vh;
}

.fil {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  padding: 1.6rem 1.2rem 2rem 1.4rem;
  border-right: 1px solid var(--filet);
  background: var(--surface);
  font-size: .86rem;
}
.fil-titre {
  display: block; text-decoration: none; color: var(--encre);
  font-family: var(--titre); font-weight: 700; font-size: 1.25rem; line-height: 1.15;
  margin-bottom: .2rem;
}
.fil-sous { color: var(--encre-douce); margin: 0 0 1.4rem; font-size: .8rem; }

/* La liste est écrite deux fois : toujours visible sur grand écran, repliable sur petit. */
.fil-replie { display: none; }
.fil-replie > summary { cursor: pointer; font-weight: 600; padding: .4rem 0; }

.fil-groupe { margin: 1.1rem 0 .3rem; color: var(--encre-douce); font-weight: 600; font-size: .8rem; }

/* La liste des étapes est une vraie séquence : le fil la traverse, chaque module est un nœud. */
.fil ol { list-style: none; margin: 0; padding: 0; position: relative; }
.fil ol.trame::before {
  content: ""; position: absolute; left: .42rem; top: .55rem; bottom: .55rem;
  width: 2px; background: var(--garance); border-radius: 2px;
}
.fil li { position: relative; padding: .22rem 0 .22rem 1.55rem; }
.fil ol.trame li::before {
  content: ""; position: absolute; left: .17rem; top: .62rem;
  width: .55rem; height: .55rem; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--garance);
}
.fil ol.trame li.ici::before { background: var(--garance); box-shadow: 0 0 0 3px var(--garance-pale); }
.fil li a, .fil li span.a-venir { display: block; text-decoration: none; color: var(--encre); line-height: 1.3; }
.fil li a:hover { color: var(--garance); }
.fil li.ici > a { font-weight: 600; color: var(--garance); }
.fil li .num { color: var(--encre-douce); font-variant-numeric: tabular-nums; margin-right: .25rem; }
.fil li span.a-venir { color: var(--encre-douce); }
.fil li span.a-venir em { font-style: normal; font-size: .75rem; }
.fil ol.annexes li { padding-left: 0; }

/* ---------- Contenu ---------- */

main { padding: 2.6rem clamp(1rem, 4vw, 3.5rem) 4rem; min-width: 0; }
.page { max-width: var(--mesure); margin: 0 auto 0 0; }

h1, h2, h3, h4 { font-family: var(--titre); line-height: 1.15; color: var(--encre); text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 4.6vw, 3rem); font-weight: 700; margin: 0 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.75rem; font-weight: 600; margin: 3rem 0 .9rem; padding-top: .4rem; border-top: 1px solid var(--filet); }
h3 { font-size: 1.3rem; font-weight: 600; margin: 2.2rem 0 .6rem; }
h4 { font-size: 1.02rem; font-weight: 600; margin: 1.5rem 0 .4rem; font-family: var(--sans); }
p, ul, ol { margin: 0 0 1rem; }
li { margin-bottom: .3rem; }
.chapeau { font-size: 1.16rem; color: var(--encre-douce); margin-bottom: 1.6rem; max-width: 62ch; }
strong { font-weight: 600; }

/* Code */
code, kbd, pre { font-family: var(--mono); font-size: .86em; }
:not(pre) > code {
  background: var(--indigo-pale); color: var(--encre);
  padding: .08em .32em; border-radius: 3px; overflow-wrap: anywhere;
}
pre {
  background: var(--code-fond); color: var(--code-texte);
  padding: 1rem 1.15rem; border-radius: 6px; overflow-x: auto;
  line-height: 1.5; margin: 0 0 1.2rem; font-size: .82rem; tab-size: 2;
}
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
figure.code { margin: 0 0 1.2rem; }
figure.code figcaption {
  font-family: var(--mono); font-size: .76rem; color: var(--encre-douce);
  margin-bottom: .3rem;
}
figure.code pre { margin: 0; }
pre .c { color: var(--code-sourdine); }          /* commentaire */
pre .p { color: #f2a7b4; user-select: none; }    /* invite $ */
pre .s { color: #a8d8b9; }                      /* sortie mise en avant */

/* Tableaux */
.tableau { overflow-x: auto; margin: 0 0 1.3rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; vertical-align: top; padding: .5rem .7rem; border-bottom: 1px solid var(--filet); }
th { font-weight: 600; color: var(--encre-douce); font-size: .82rem; }
td code { white-space: nowrap; }

/* Codes de fonctions (A1, D13…) : renvoient à la matrice de couverture. */
.fn {
  display: inline-block; font-family: var(--mono); font-size: .74rem; font-weight: 500;
  padding: .02rem .38rem; margin: 0 .15rem .15rem 0; border-radius: 3px;
  border: 1px solid var(--garance); color: var(--garance); text-decoration: none; line-height: 1.5;
}
a.fn:hover { background: var(--garance); color: var(--surface); }

/* Encadrés : chacun a un sens précis, pas de décoration. */
.encadre { border-left: 4px solid; padding: .8rem 1rem .4rem; margin: 0 0 1.3rem; border-radius: 0 6px 6px 0; }
.encadre > :first-child { margin-top: 0; }
.encadre-titre { font-weight: 600; margin: 0 0 .35rem; }
.voir   { border-color: var(--sauge);  background: var(--sauge-pale); }
.piege  { border-color: var(--ocre);   background: var(--ocre-pale); }
.reel   { border-color: var(--indigo); background: var(--indigo-pale); }
.note   { border-color: var(--filet);  background: var(--surface); }
.voir .encadre-titre { color: var(--sauge); }
.piege .encadre-titre { color: var(--ocre); }
.reel .encadre-titre { color: var(--indigo); }

/* Fiche de l'agent en tête de module : où en est le fil rouge. */
.fiche-agent {
  display: grid; grid-template-columns: auto 1fr; gap: .2rem 1.1rem;
  background: var(--surface); border: 1px solid var(--filet);
  border-left: 4px solid var(--garance); border-radius: 0 8px 8px 0;
  padding: 1rem 1.2rem; margin: 0 0 2rem; font-size: .93rem;
}
.fiche-agent dt { color: var(--encre-douce); }
.fiche-agent dd { margin: 0; }
.fiche-agent .version { font-family: var(--titre); font-weight: 700; font-size: 1.15rem; color: var(--garance); }

/* Exercice : la structure Pourquoi / Objectif / Mise en place / Exécution / À retenir. */
.exo { margin-top: 2.8rem; }
.exo > h3 { margin-top: 0; display: flex; gap: .7rem; align-items: baseline; flex-wrap: wrap; }
.exo > h3 .exo-num { font-variant-numeric: tabular-nums; color: var(--garance); }
.exo .fns { margin: -.2rem 0 .9rem; }
.exo h4 { color: var(--encre-douce); font-size: .9rem; margin-top: 1.2rem; }

/* Navigation bas de page */
.suite {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 3.5rem; padding-top: 1.2rem; border-top: 1px solid var(--filet); font-size: .95rem;
}
.suite a { text-decoration: none; display: block; max-width: 48%; }
.suite small { display: block; color: var(--encre-douce); }
.suite .apres { text-align: right; margin-left: auto; }

.pied { margin-top: 2.5rem; color: var(--encre-douce); font-size: .8rem; }

/* ---------- Accueil : le métier à tisser des versions ---------- */

.une { margin: 0 0 2.5rem; max-width: none; }
.une h1 { font-size: clamp(2.4rem, 6vw, 4rem); max-width: 16ch; }
.une .chapeau { max-width: 58ch; }

.metier { margin: 2.2rem 0 0; }
/* Chaque étape porte son bout de fil : la frise se replie sur plusieurs rangs sans casser le fil. */
.metier ol {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(8.4rem, 1fr)); row-gap: 1.6rem;
}
.metier li { position: relative; padding: 2.2rem .7rem 0 0; margin: 0; font-size: .82rem; line-height: 1.3; }
.metier li::after {
  content: ""; position: absolute; left: 0; right: 0; top: 1.05rem;
  height: 3px; background: var(--garance);
}
.metier li:last-child::after { right: auto; width: 1rem; }
.metier li::before {
  content: ""; position: absolute; left: .1rem; top: .68rem; z-index: 1;
  width: .82rem; height: .82rem; border-radius: 50%;
  background: var(--papier); border: 3px solid var(--garance);
}
.metier li.palier::before { background: var(--garance); }
.metier li .niv { position: absolute; top: -.2rem; left: 1.35rem; font-size: .72rem; color: var(--encre-douce); white-space: nowrap; }
.metier li b { display: block; font-family: var(--titre); font-size: 1.05rem; color: var(--garance); margin-bottom: .15rem; }
.metier li a { color: var(--encre); }

.principes { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.4rem; margin: 0 0 1.5rem; }
.principes div { border-top: 3px solid var(--encre); padding-top: .6rem; }
.principes h3 { margin: 0 0 .35rem; font-size: 1.1rem; }
.principes p { margin: 0; font-size: .93rem; color: var(--encre-douce); }

.sommaire-niveau { margin: 1.8rem 0 .4rem; font-family: var(--titre); font-weight: 600; font-size: 1.15rem; }
.sommaire-niveau small { font-family: var(--sans); font-weight: 400; color: var(--encre-douce); font-size: .85rem; margin-left: .4rem; }
ol.sommaire { list-style: none; padding: 0; margin: 0 0 1rem; border-top: 1px solid var(--filet); }
ol.sommaire li {
  display: grid; grid-template-columns: 2.2rem minmax(0, 1fr) auto; gap: .3rem .8rem;
  padding: .7rem 0; border-bottom: 1px solid var(--filet); margin: 0;
}
ol.sommaire .n { font-family: var(--titre); font-weight: 700; color: var(--garance); font-size: 1.15rem; }
ol.sommaire .t a { font-weight: 600; text-decoration: none; color: var(--encre); }
ol.sommaire .t a:hover { color: var(--garance); }
ol.sommaire .t p { margin: .15rem 0 .3rem; font-size: .9rem; color: var(--encre-douce); }
ol.sommaire .v { font-family: var(--mono); font-size: .8rem; color: var(--encre-douce); white-space: nowrap; }
ol.sommaire .req { font-size: .78rem; color: var(--ocre); }

/* ---------- Écrans étroits : la navigation se replie ---------- */

@media (max-width: 960px) {
  .ossature { display: block; }
  .fil { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--filet); padding: 1rem; }
  .fil-ouvert { display: none; }
  .fil-replie { display: block; }
  .fil-sous { margin-bottom: .4rem; }
  main { padding: 1.6rem 1rem 3rem; }
  .suite a { max-width: 100%; }
}

@media (max-width: 560px) {
  html { font-size: 100%; }
  ol.sommaire li { grid-template-columns: 1.8rem minmax(0, 1fr); }
  ol.sommaire .v { grid-column: 2; }
  .fiche-agent { grid-template-columns: 1fr; }
  .fiche-agent dt { margin-top: .4rem; }
  pre { font-size: .76rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  .fil, .suite { display: none; }
  .ossature { display: block; }
  pre { white-space: pre-wrap; }
}

/* Lignes ajoutées dans un fichier complet (marquées « ++ » dans la source). */
pre .aj {
  display: block; margin: 0 -1.15rem; padding: 0 1.15rem 0 calc(1.15rem - 3px);
  background: rgba(108, 196, 156, .16); border-left: 3px solid #6cc49c;
}
.legende-aj { font-size: .82rem; color: var(--encre-douce); margin: -.6rem 0 1.2rem; }
.legende-aj span { display: inline-block; width: .8rem; height: .8rem; vertical-align: -.1rem; background: rgba(108,196,156,.35); border-left: 3px solid #6cc49c; margin-right: .3rem; }

/* Explication ligne à ligne d'un fichier. */
table.lignes td:first-child { white-space: nowrap; width: 1%; }
table.lignes td:first-child code { background: none; padding: 0; font-weight: 500; }

.termes { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 0 0 1.4rem; }
.termes dt { font-weight: 600; }
.termes dd { margin: 0; }
@media (max-width: 560px) { .termes { grid-template-columns: 1fr; } .termes dd { margin-bottom: .5rem; } }

/* Point de départ d'un module : les fichiers complets, repliés par défaut. */
details.depart {
  background: var(--surface); border: 1px solid var(--filet); border-radius: 8px;
  padding: .7rem 1rem; margin: -1rem 0 2rem;
}
details.depart > summary { cursor: pointer; font-weight: 600; color: var(--encre-douce); }
details.depart[open] > summary { margin-bottom: .8rem; }
details.depart figure.code:last-child { margin-bottom: .2rem; }

/* Matrice des fonctions */
table.matrice td:first-child { white-space: nowrap; width: 1%; }
table.matrice td:nth-child(2) { width: 42%; }
table.matrice tr:target { background: var(--garance-pale); }

/* Annexe « Pièges et dépannage » : les messages de loom sont longs, ils doivent passer à la ligne. */
table.pieges td code { white-space: normal; overflow-wrap: anywhere; }
table.pieges td:first-child { width: 34%; }
table.pieges td:last-child { width: 1%; white-space: nowrap; font-size: .85rem; }
@media (max-width: 640px) {
  table.pieges thead { display: none; }
  table.pieges tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--filet); }
  table.pieges td { display: block; width: auto !important; border: 0; padding: .15rem 0; white-space: normal !important; }
  table.pieges td:first-child { font-weight: 600; }
}
