/* =====================================================================
   Ma première API — apparence
   Couleurs en variables : mode clair par défaut, mode sombre selon le
   système ou le bouton (attribut data-theme sur <html>).
   ===================================================================== */

:root {
  --fond: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --bord: #dde1e7;
  --texte: #1d2330;
  --texte-doux: #5b6475;
  --accent: #2459c9;
  --accent-doux: #e7eefc;
  --code-fond: #f1f3f7;
  --code-texte: #1d2330;
  --com: #6b7a90;

  --rouge: #c62828;    --rouge-fond: #fdecec;
  --orange: #c25e00;   --orange-fond: #fff1e2;
  --vert: #2e7d32;     --vert-fond: #e8f5e9;
  --note: #2459c9;     --note-fond: #eef3fd;
  --attention: #a35a00; --attention-fond: #fff6e6;

  --rayon: 10px;
  --ombre: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .06);
  --police: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, Menlo, "Courier New", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="clair"]) {
    --fond: #161a21;
    --surface: #161a21;
    --surface-2: #222833;
    --bord: #2f3644;
    --texte: #e6e9ef;
    --texte-doux: #9aa3b4;
    --accent: #7aa2ff;
    --accent-doux: #1f2a44;
    --code-fond: #10131a;
    --code-texte: #dfe4ee;
    --com: #7d8aa0;
    --rouge: #ff8a80;    --rouge-fond: #3a1c1c;
    --orange: #ffb366;   --orange-fond: #3a2a17;
    --vert: #81c784;     --vert-fond: #1b2e1d;
    --note: #8fb0ff;     --note-fond: #1b2540;
    --attention: #ffc46b; --attention-fond: #352a14;
    --ombre: none;
    color-scheme: dark;
  }
}

:root[data-theme="sombre"] {
  --fond: #161a21;
  --surface: #161a21;
  --surface-2: #222833;
  --bord: #2f3644;
  --texte: #e6e9ef;
  --texte-doux: #9aa3b4;
  --accent: #7aa2ff;
  --accent-doux: #1f2a44;
  --code-fond: #10131a;
  --code-texte: #dfe4ee;
  --com: #7d8aa0;
  --rouge: #ff8a80;    --rouge-fond: #3a1c1c;
  --orange: #ffb366;   --orange-fond: #3a2a17;
  --vert: #81c784;     --vert-fond: #1b2e1d;
  --note: #8fb0ff;     --note-fond: #1b2540;
  --attention: #ffc46b; --attention-fond: #352a14;
  --ombre: none;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.6 var(--police);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; }
code, pre, .mono { font-family: var(--mono); font-size: .9em; }
:not(pre) > code {
  background: var(--code-fond);
  border-radius: 4px;
  padding: .05em .3em;
  white-space: normal;      /* le code dans une phrase passe à la ligne… */
  overflow-wrap: anywhere;  /* …même s'il est long, sans déborder de la page */
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.discret { color: var(--texte-doux); font-size: .92em; }

/* ---------- Système Windows / macOS ---------- */
body[data-os="windows"] .os-mac,
body[data-os="mac"] .os-windows { display: none; }

/* ---------- Barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--bord);
}
.marque { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.marque-logo { font-size: 1.6rem; }
.marque-titre { display: block; font-weight: 700; font-size: 1.05rem; }
.marque-sous-titre { display: block; font-size: .78rem; color: var(--texte-doux); }
.jalon-actuel {
  text-decoration: none;
  background: var(--accent-doux); color: var(--accent);
  border-radius: 999px; padding: 4px 12px; font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.outils { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.outils button {
  border: 1px solid transparent; background: none; color: var(--texte-doux);
  border-radius: 8px; padding: 6px 11px; font-size: .9rem; white-space: nowrap;
}
.outils button:hover { background: var(--surface-2); color: var(--texte); }
.bouton-menu { display: none; border: 1px solid var(--bord); background: var(--surface-2); border-radius: 8px; padding: 4px 10px; }

/* ---------- Mise en page ---------- */
.mise-en-page { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 62px); }
.cote {
  position: sticky; top: 62px; align-self: start;
  height: calc(100vh - 62px); overflow-y: auto;
  border-right: 1px solid var(--bord); background: var(--surface);
  display: flex; flex-direction: column; justify-content: space-between;
}
.page { padding: 28px 40px 80px; max-width: 900px; width: 100%; min-width: 0; outline: none; }

/* ---------- Menu ---------- */
.menu { padding: 14px 10px; }
.menu ul { list-style: none; margin: 0; padding: 0; }
.menu-groupe + .menu-groupe { margin-top: 14px; }
.menu-groupe-titre { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-doux); padding: 0 10px 4px; }
.menu a {
  display: flex; gap: 8px; align-items: baseline;
  padding: 6px 10px; border-radius: 7px;
  color: var(--texte); text-decoration: none; font-size: .95rem;
}
.menu a:hover { background: var(--surface-2); }
.menu a.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.menu a.bientot { color: var(--texte-doux); }
.menu-icone { display: none; }
.menu-fiches { display: none; margin: 2px 0 6px 14px !important; border-left: 1px solid var(--bord); }
li.ouvert > .menu-fiches { display: block; }
.menu-fiches a { font-size: .88rem; padding: 4px 10px; border-radius: 0 7px 7px 0; }

.reglages { padding: 12px; border-top: 1px solid var(--bord); display: grid; gap: 8px; font-size: .88rem; }
.reglages > button, .choix-os button {
  border: 1px solid var(--bord); background: var(--surface-2); border-radius: 7px; padding: 6px 10px;
}
.choix-os { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.choix-os span { color: var(--texte-doux); }
.choix-os button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Pages ---------- */
.section-entete { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.section-entete h1 { margin: 0; font-size: 1.9rem; }
.section-icone { font-size: 1.6rem; }
.etiquette {
  display: inline-block; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); color: var(--texte-doux);
  border-radius: 999px; padding: 1px 9px; vertical-align: middle; white-space: nowrap;
}
.fil-ariane { font-size: .88rem; color: var(--texte-doux); margin-bottom: 10px; }
.fiche-entete h1 { margin: 10px 0 8px; font-size: 1.9rem; }
.en-bref { margin: 0 0 18px; font-size: 1.05rem; color: var(--texte-doux); }
.frise-titre a { color: inherit; }

/* Badge de zone */
.badge-zone {
  display: inline-block; font-size: .82rem; font-weight: 700;
  border-radius: 999px; padding: 2px 10px; white-space: nowrap; cursor: help;
}
.zone-rouge .badge-zone, .badge-zone.zone-rouge { color: var(--rouge); background: var(--rouge-fond); }
.badge-zone.zone-orange { color: var(--orange); background: var(--orange-fond); }
.badge-zone.zone-verte { color: var(--vert); background: var(--vert-fond); }
.badge-cours {
  display: inline-block; font-size: .82rem; font-weight: 600; white-space: nowrap; cursor: help;
  border-radius: 999px; padding: 2px 10px;
  color: var(--texte-doux); background: var(--surface-2);
}

/* Parties d'une fiche */
.partie { padding: 6px 0 14px; margin: 0; border-top: 1px solid var(--bord); }
.partie h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; }
.partie-icone { font-size: 1rem; }
.partie-checkpoint h2 { color: var(--vert); }
.partie-aToi { border-left: 3px solid var(--accent); padding-left: 18px; }

.etapes { padding-left: 0; list-style: none; counter-reset: etape; }
.etapes > li { position: relative; padding-left: 36px; margin: 0 0 12px; counter-increment: etape; }
.etapes > li::before {
  content: counter(etape); position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); color: var(--texte-doux); font-weight: 700; font-size: .85rem;
  display: grid; place-items: center;
}
.etapes > li > p:first-child { margin-top: 0; }
.etapes > li > p:last-child { margin-bottom: 0; }

/* Code */
figure.code { margin: 14px 0; border: 0; border-radius: var(--rayon); overflow: hidden; background: var(--code-fond); }
figure.code figcaption {
  font-size: .8rem; color: var(--texte-doux); padding: 8px 14px 0;
}
figure.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; color: var(--code-texte); line-height: 1.5; }
.com { color: var(--com); font-style: italic; }
.explication { border-top: 1px solid var(--bord); padding: 6px 14px 4px; background: var(--surface); border-inline: 1px solid var(--surface-2); border-bottom: 1px solid var(--surface-2); font-size: .95rem; }
.explication-titre { display: block; font-weight: 700; font-size: .85rem; color: var(--texte-doux); margin-top: 6px; }

/* Commande à taper */
.commande { margin: 12px 0; border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden; }
.cmd-ligne {
  display: flex; align-items: center; gap: 10px;
  background: #1d2330; color: #e6e9ef; padding: 8px 10px 8px 14px;
}
.cmd-ligne code { flex: 1; background: none !important; border: 0 !important; color: inherit; white-space: pre-wrap !important; word-break: break-all; }
.cmd-invite { color: #7aa2ff; font-weight: 700; }
.cmd-os { font-size: .7rem; font-weight: 700; color: #1d2330; background: #9fc0ff; border-radius: 4px; padding: 1px 6px; }
.cmd-ligne + .cmd-ligne, .os-windows + .os-mac .cmd-ligne, .commande > div + div > .cmd-ligne { border-top: 1px solid #2f3644; }
.copier {
  flex: none; border: 1px solid #3c4658; background: #2a3242; color: #e6e9ef;
  border-radius: 6px; padding: 3px 10px; font-size: .8rem;
}
.copier:hover { background: #36405a; }
.copier.ok { background: #2e7d32; border-color: #2e7d32; }
.cmd-voir, .cmd-sinon { padding: 6px 14px; font-size: .93rem; background: var(--surface); }
.cmd-voir { border-top: 1px solid var(--bord); }
.cmd-sinon { border-top: 1px dashed var(--bord); }
.cmd-voir > strong, .cmd-sinon > strong { display: block; margin-top: 4px; font-size: .85rem; }
.cmd-voir p, .cmd-sinon p { margin: 4px 0; }

/* Encadrés */
.encadre { border-radius: 0 var(--rayon) var(--rayon) 0; padding: 2px 16px; margin: 12px 0; border-left: 3px solid; }
.encadre.note { background: var(--surface-2); border-color: var(--note); }
.encadre.attention { background: var(--surface-2); border-color: var(--attention); }

/* Erreurs fréquentes */
.erreur { border-left: 3px solid var(--rouge); margin: 12px 0; padding-left: 2px; }
.erreur-msg { color: var(--rouge); padding: 4px 14px 0; font-weight: 600; }
.erreur-msg code { background: transparent; border: 0; color: inherit; white-space: normal; }
.erreur dl { margin: 0; padding: 4px 14px 8px; display: grid; grid-template-columns: max-content 1fr; gap: 0 14px; }
.erreur dt { font-weight: 700; color: var(--texte-doux); padding-top: 9px; font-size: .88rem; }
.erreur dd { margin: 0; }
.erreur dd p { margin: 8px 0 0; }

/* Cases à cocher (lecture seule : on coche dans checklist.md) */
.cases { list-style: none; padding: 0; margin: 8px 0; }
.cases li { position: relative; padding: 4px 0 4px 30px; }
.cases li::before {
  content: ""; position: absolute; left: 2px; top: 8px;
  width: 15px; height: 15px; border: 1.5px solid var(--texte-doux); border-radius: 4px;
}
.rappel-commit { font-size: .9rem; color: var(--texte-doux); }

/* Points */
.point { border-left: 2px solid var(--bord); padding: 2px 0 2px 14px; margin: 10px 0; }
.point-titre { font-size: .95rem; }
.point p { margin: 4px 0; }

/* Navigation entre fiches */
.nav-fiches { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.nav-fiche {
  flex: 1; max-width: 48%; border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 10px 14px; text-decoration: none; background: var(--surface);
}
.nav-fiche small { display: block; color: var(--texte-doux); }
.nav-fiche.suiv { text-align: right; margin-left: auto; }

/* Liste des fiches d'une section */
.liste-fiches h2, .checklist h2, .frise h2, .zones h2 { font-size: 1.25rem; margin-top: 28px; }
.carte-fiche {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--surface);
  padding: 12px 16px; margin-bottom: 8px; text-decoration: none; color: inherit;
}
.carte-fiche:hover { border-color: var(--accent); }
.carte-fiche.brouillon { opacity: .7; }
.carte-num {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); color: var(--texte-doux); font-weight: 700; display: grid; place-items: center;
}
.carte-corps { flex: 1; }
.carte-titre { display: block; font-weight: 600; }
.carte-resume { display: block; font-size: .9rem; color: var(--texte-doux); }
.carte-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.checklist {
  border-top: 1px solid var(--bord);
  padding: 2px 0 10px; margin-top: 28px;
}
.checklist h3 { font-size: 1rem; margin: 14px 0 0; }

/* Frise des jalons */
.frise ol { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--bord); }
.frise li { position: relative; padding: 6px 0 6px 20px; display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.frise li::before {
  content: ""; position: absolute; left: -8px; top: 13px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--bord);
}
.frise li.passe { color: var(--texte-doux); }
.frise li.passe::before { background: var(--bord); }
.frise li.actuel { font-weight: 700; }
.frise li.actuel::before { border-color: var(--accent); background: var(--accent); }
.frise-date { width: 80px; font-variant-numeric: tabular-nums; color: var(--texte-doux); }

/* Zones (accueil) */
.zones-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.zone-carte { border-radius: var(--rayon); padding: 12px 16px; background: var(--surface-2) !important; border-top: 3px solid; }
.zone-carte.zone-rouge { background: var(--rouge-fond); border-color: var(--rouge); }
.zone-carte.zone-orange { background: var(--orange-fond); border-color: var(--orange); }
.zone-carte.zone-verte { background: var(--vert-fond); border-color: var(--vert); }
.zone-titre { font-weight: 700; }
.zone-contenu { font-size: .9rem; color: var(--texte-doux); margin: 4px 0; }
.zone-carte p { font-size: .92rem; margin: 6px 0 0; }

/* Fil rouge */
.tableau-defile { overflow-x: auto; }
.fil-rouge table { width: 100%; border-collapse: collapse; background: var(--surface); }
.fil-rouge th, .fil-rouge td { border: 1px solid var(--bord); padding: 8px 10px; text-align: left; vertical-align: top; }
.fil-rouge th { background: var(--surface-2); font-size: .85rem; }
.http { font-weight: 700; }
.http-post { color: var(--vert) !important; }
.http-get { color: var(--note) !important; }
.http-put { color: var(--orange) !important; }
.http-delete { color: var(--rouge) !important; }
.code-statut { white-space: nowrap; }

/* Glossaire */
.gloss {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline dotted; text-underline-offset: 3px; cursor: help;
}
.gloss:hover { text-decoration-style: solid; }
.gloss-absent { text-decoration: underline wavy var(--rouge); }
.recherche { width: 100%; padding: 9px 12px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); margin: 6px 0 16px; }
.glossaire { margin: 0; }
.glossaire .terme { border-bottom: 1px solid var(--bord); padding: 8px 0; }
.glossaire dt { font-weight: 700; }
.glossaire dd { margin: 2px 0 0; }
.glossaire dd p { margin: 4px 0; }
.exemple { color: var(--texte-doux); font-size: .95rem; }
.problemes li { margin: 4px 0; }

/* Checkpoint sans ligne de checklist */
.cases li.libre::before { border-style: dashed; border-color: var(--texte-doux); }

/* Schéma cliquable (vue d'ensemble) */
.schema { margin: 18px 0; }
.schema-ligne { display: flex; align-items: stretch; gap: 8px; }
.schema-boite {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 16px 10px; border-radius: 14px; border: 1.5px solid var(--bord); background: var(--surface);
  text-align: center;
}
.schema-boite small { color: var(--texte-doux); font-size: .82rem; }
.schema-icone { font-size: 2rem; }
.schema-front { border-color: #1e88e5; }
.schema-api { border-color: #43a047; }
.schema-bdd { border-color: #fb8c00; }
.schema-fleches { flex: 0 1 170px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.schema-fleche {
  border: 1px dashed var(--bord); background: var(--surface-2); border-radius: 8px;
  padding: 6px 8px; font-size: .8rem; line-height: 1.3;
}
.schema-boite:hover, .schema-fleche:hover { border-color: var(--accent); }
.schema [data-schema].actif { outline: 3px solid var(--accent); outline-offset: 2px; }
.schema-details {
  margin-top: 14px; min-height: 70px; background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--rayon); padding: 4px 18px 8px;
}
.schema-details h3 { margin: 12px 0 4px; }
@media (max-width: 700px) {
  .schema-ligne { flex-direction: column; }
  .schema-fleches { flex-basis: auto; flex-direction: row; }
  .schema-fleche { flex: 1; }
}

/* ---------- Fenêtres ---------- */
dialog.fenetre {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--bord); border-radius: 14px;
  background: var(--surface); color: var(--texte); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog.fenetre.large { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 15, 25, .45); }
.fenetre-entete {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--bord); background: var(--surface);
}
.fenetre-entete h2 { margin: 0; font-size: 1.15rem; }
.fermer { border: 0; background: none; font-size: 1.2rem; color: var(--texte-doux); }
.fenetre-corps { padding: 6px 18px 18px; }
.fenetre-corps label { display: block; font-weight: 600; font-size: .92rem; margin: 12px 0 0; }
.fenetre-corps input, .fenetre-corps select, .fenetre-corps textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--bord); border-radius: 8px; background: var(--fond); font-weight: 400;
}
.fenetre-corps textarea { resize: vertical; }
.rangee { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.requis { color: var(--rouge); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions button {
  border: 1px solid var(--bord); background: var(--surface-2); border-radius: 8px; padding: 8px 14px; font-weight: 600;
}
.actions button.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.actions button.discret { background: none; border-color: transparent; color: var(--texte-doux); font-weight: 400; }
.actions button.ok { background: var(--vert); border-color: var(--vert); color: #fff; }
.erreur-form { color: var(--rouge); font-weight: 600; }
.info-envoi { background: var(--note-fond); border-radius: 8px; padding: 8px 12px; }
.apercu {
  white-space: pre-wrap; background: var(--code-fond); border: 1px solid var(--bord);
  border-radius: 8px; padding: 10px 12px; font-size: .82rem; max-height: 280px; overflow: auto;
}
details summary { cursor: pointer; color: var(--texte-doux); margin-top: 14px; }
.petit-titre { font-size: .95rem; margin: 18px 0 4px; }
.profil-resume {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin-top: 12px; font-size: .9rem;
}
button.lien { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 600; }

/* ---------- Petits écrans ---------- */
@media (max-width: 1100px) {
  .marque-sous-titre { display: none; }
}
@media (max-width: 900px) {
  .bouton-menu { display: block; }
  .barre { flex-wrap: wrap; padding: 8px 16px; }
  .outils { width: 100%; justify-content: flex-start; margin-left: 0; }
  .mise-en-page { grid-template-columns: minmax(0, 1fr); } /* les blocs de code défilent au lieu d'élargir la page */
  .cote {
    display: none; position: fixed; top: 0; left: 0; bottom: 0; z-index: 30;
    width: min(300px, 85vw); height: 100vh; box-shadow: 0 0 40px rgba(0, 0, 0, .3);
  }
  body.menu-ouvert .cote { display: flex; }
  .page { padding: 20px 16px 60px; }
  .partie { padding: 4px 14px 12px; }
  .rangee { grid-template-columns: 1fr; }
  .nav-fiche { max-width: none; }
}
