/* Académie DEVOLUTION : feuille unique, partagée par l'accueil et les modules.
   Les couleurs vivent dans des variables ; le thème sombre les redéfinit. */

:root {
  --fond: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #EEF1F5;
  --texte: #0F172A;
  --texte-doux: #475569;
  --ligne: #DCE1E8;
  --accent: #0369A1;
  --accent-fort: #075985;
  --accent-pale: #E0F2FE;
  --ok: #15803D;
  --ok-pale: #DCFCE7;
  --alerte: #B45309;
  --alerte-pale: #FEF3C7;
  --danger: #B91C1C;
  --danger-pale: #FEE2E2;
  --violet: #6D28D9;
  --violet-pale: #EDE9FE;
  --ombre: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --rayon: 10px;
  --titre: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --corps: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0A0E14;
    --surface: #111722;
    --surface-2: #182130;
    --texte: #E2E8F0;
    --texte-doux: #94A3B8;
    --ligne: #243044;
    --accent: #38BDF8;
    --accent-fort: #7DD3FC;
    --accent-pale: #0C2A3D;
    --ok: #4ADE80;
    --ok-pale: #0F2E1C;
    --alerte: #FBBF24;
    --alerte-pale: #33260A;
    --danger: #F87171;
    --danger-pale: #3A1414;
    --violet: #A78BFA;
    --violet-pale: #241A3F;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --fond: #0A0E14;
  --surface: #111722;
  --surface-2: #182130;
  --texte: #E2E8F0;
  --texte-doux: #94A3B8;
  --ligne: #243044;
  --accent: #38BDF8;
  --accent-fort: #7DD3FC;
  --accent-pale: #0C2A3D;
  --ok: #4ADE80;
  --ok-pale: #0F2E1C;
  --alerte: #FBBF24;
  --alerte-pale: #33260A;
  --danger: #F87171;
  --danger-pale: #3A1414;
  --violet: #A78BFA;
  --violet-pale: #241A3F;
  --ombre: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 17px/1.65 var(--corps);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { font-family: var(--titre); line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin: .2em 0 .4em; }
h2 { font-size: 1.6rem; margin: 2.6rem 0 .8rem; padding-top: 1.4rem; border-top: 1px solid var(--ligne); }
h3 { font-size: 1.2rem; margin: 1.8rem 0 .5rem; }
h4 { font-size: 1rem; margin: 1.2rem 0 .3rem; }
p, ul, ol { margin: 0 0 1rem; }
li { margin-bottom: .35rem; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-fort); }
strong { font-weight: 650; }
code, kbd { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--ligne); margin: 2rem 0; }
blockquote { margin: 1.2rem 0; padding: .8rem 1.1rem; background: var(--surface-2); border-radius: var(--rayon); color: var(--texte-doux); font-style: italic; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barre du haut ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ligne);
}
.topbar .marque { font-family: var(--titre); font-weight: 700; letter-spacing: .08em; color: var(--texte); text-decoration: none; white-space: nowrap; }
.topbar .marque span { color: var(--accent); font-weight: 500; letter-spacing: 0; }
.topbar nav { display: flex; gap: .3rem; margin-left: auto; flex-wrap: wrap; }
.topbar nav a, .bouton-theme {
  font-size: .9rem; color: var(--texte-doux); text-decoration: none;
  padding: .35rem .7rem; border-radius: 6px; border: 1px solid transparent; background: none; cursor: pointer; font-family: inherit;
}
.topbar nav a:hover, .bouton-theme:hover { color: var(--texte); background: var(--surface-2); }
.topbar nav a[aria-current="page"] { color: var(--accent); border-color: var(--ligne); }
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: .35rem; padding: .6rem 1rem; }
  .topbar nav { margin-left: 0; gap: .15rem; }
  .topbar nav a, .bouton-theme { font-size: .8rem; padding: .3rem .45rem; }
  html { scroll-padding-top: 9rem; }
}

.progression-module { height: 3px; background: var(--ligne); }
.progression-module > div { height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s; }

/* ---------- Mise en page module ---------- */

.layout {
  display: grid; gap: 3rem;
  max-width: 1180px; margin: 0 auto;
  padding: 2rem clamp(1rem, 3vw, 2rem) 5rem;
}
@media (min-width: 1000px) { .layout { grid-template-columns: 230px minmax(0, 1fr); } }

.sommaire { display: none; }
.sommaire-mobile { margin: 1rem 0; padding: .75rem 1rem; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); }
.sommaire-mobile summary { font-weight: 600; cursor: pointer; }
.sommaire-mobile ol { margin-top: 1rem; padding-left: 1.25rem; }
.sommaire-mobile a { display: inline-block; padding: .3rem 0; }
@media (min-width: 1000px) {
  .sommaire-mobile { display: none; }
  .sommaire { display: block; position: sticky; top: 5rem; align-self: start; max-height: calc(100vh - 6rem); overflow: auto; font-size: .88rem; }
  .sommaire p { font-family: var(--titre); font-weight: 600; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; margin-bottom: .6rem; }
  .sommaire ol { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--ligne); }
  .sommaire li { margin: 0; }
  .sommaire a { display: block; padding: .3rem 0 .3rem .9rem; color: var(--texte-doux); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
  .sommaire a:hover, .sommaire a.actif { color: var(--texte); border-left-color: var(--accent); }
}

main { max-width: 760px; min-width: 0; }

.entete-module .surtitre { font-family: var(--mono); font-size: .8rem; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; margin: 0; }
.chapeau { font-size: 1.15rem; color: var(--texte-doux); }
.meta { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 1rem 0 0; }
.meta li { margin: 0; font-size: .82rem; padding: .25rem .65rem; border: 1px solid var(--ligne); border-radius: 999px; color: var(--texte-doux); background: var(--surface); }

/* ---------- Tableaux ---------- */

.tableau { overflow-x: auto; margin: 1.2rem 0 1.6rem; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; vertical-align: top; padding: .65rem .8rem; border-bottom: 1px solid var(--ligne); }
th { font-family: var(--titre); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* ---------- Blocs pédagogiques ---------- */

.bloc {
  margin: 1.5rem 0; padding: 1.1rem 1.25rem;
  border: 1px solid var(--ligne);
  border-radius: var(--rayon); background: var(--surface); box-shadow: var(--ombre);
}
.bloc > :last-child { margin-bottom: 0; }
.bloc-titre { font-family: var(--titre); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .09em; margin: 0 0 .5rem; color: var(--accent); }

.cle { border-color: color-mix(in srgb, var(--accent) 35%, var(--ligne)); background: var(--accent-pale); }
.piege { border-color: color-mix(in srgb, var(--danger) 35%, var(--ligne)); background: var(--danger-pale); }
.piege .bloc-titre { color: var(--danger); }
.exemple { border-color: color-mix(in srgb, var(--violet) 35%, var(--ligne)); }
.exemple .bloc-titre { color: var(--violet); }
.exercice { border-color: color-mix(in srgb, var(--alerte) 40%, var(--ligne)); }
.exercice .bloc-titre { color: var(--alerte); }
.defi { border: 2px solid var(--ok); background: var(--ok-pale); }
.defi .bloc-titre { color: var(--ok); font-size: .9rem; }
.expert { background: var(--surface-2); }
.expert .bloc-titre { color: var(--texte-doux); }

/* Script de dialogue : une réplique par paragraphe, locuteur en tête. */
.script { margin: 1.5rem 0; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); overflow: hidden; }
.script .bloc-titre { padding: .7rem 1.1rem; margin: 0; background: var(--surface-2); border-bottom: 1px solid var(--ligne); color: var(--texte-doux); }
.script p { margin: 0; padding: .6rem 1.1rem; border-bottom: 1px dashed var(--ligne); }
.script p:last-child { border-bottom: 0; }
.script b { display: inline-block; min-width: 6.5rem; font-family: var(--mono); font-size: .8rem; font-weight: 600; color: var(--accent); text-transform: uppercase; }
.script .note { font-size: .88rem; color: var(--texte-doux); font-style: italic; }

/* Modèle à copier (email, DM, post). */
.modele { position: relative; margin: 1.2rem 0; padding: 1rem 1.2rem; border: 1px dashed var(--accent); border-radius: var(--rayon); background: var(--surface); white-space: pre-line; font-size: .95rem; }
.modele .copier { position: absolute; top: .5rem; right: .5rem; font-size: .75rem; padding: .2rem .55rem; border: 1px solid var(--ligne); border-radius: 5px; background: var(--surface-2); color: var(--texte-doux); cursor: pointer; font-family: inherit; }
.modele .copier:hover { color: var(--texte); }

/* ---------- Cases à cocher persistées ---------- */

.coches { list-style: none; padding: 0; }
.coches li { margin: 0 0 .4rem; }
.coches label { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem .75rem; border: 1px solid var(--ligne); border-radius: 8px; background: var(--surface); cursor: pointer; }
.coches label:hover { border-color: var(--accent); }
.coches input { margin-top: .35rem; width: 1.05rem; height: 1.05rem; accent-color: var(--ok); flex: none; }
.coches input:checked + span { color: var(--texte-doux); text-decoration: line-through; text-decoration-color: var(--ok); }
.defi .coches label { background: var(--surface); }

/* ---------- Quiz ---------- */

.quiz { margin: 1.5rem 0; }
.question { margin: 0 0 1.2rem; padding: 1rem 1.2rem; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); }
.question .enonce { font-weight: 600; margin-bottom: .6rem; }
.question label { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem .6rem; border-radius: 6px; cursor: pointer; }
.question label:hover { background: var(--surface-2); }
.question input { margin-top: .4rem; accent-color: var(--accent); flex: none; }
.question .explication { display: none; margin: .7rem 0 0; padding: .7rem .9rem; border-radius: 6px; font-size: .92rem; background: var(--surface-2); }
.question.corrigee .explication { display: block; }
.question.corrigee label.bonne { background: var(--ok-pale); color: var(--texte); }
.question.corrigee label.fausse { background: var(--danger-pale); }
.question.corrigee.juste { border-color: var(--ok); }
.question.corrigee.faux { border-color: var(--danger); }
.quiz-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
.quiz-score { font-family: var(--titre); font-weight: 700; }

/* ---------- Boutons ---------- */

.btn { display: inline-flex; align-items: center; gap: .4rem; font: 600 .95rem var(--corps); padding: .6rem 1.1rem; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--fond); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-fort); color: var(--fond); }
.btn-second { background: transparent; color: var(--accent); }
.btn-second:hover { background: var(--accent-pale); color: var(--accent-fort); }

/* ---------- Navigation entre modules ---------- */

.nav-modules { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--ligne); }
.nav-modules a { display: block; padding: .9rem 1rem; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); text-decoration: none; color: var(--texte); }
.nav-modules a:hover { border-color: var(--accent); }
.nav-modules small { display: block; color: var(--texte-doux); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; }
.nav-modules .suivant { text-align: right; grid-column: 2; }

/* ---------- Accueil ---------- */

.accueil { max-width: 1180px; margin: 0 auto; padding: 3rem clamp(1rem, 3vw, 2rem) 5rem; }
.hero { max-width: 820px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.hero .chapeau { font-size: 1.25rem; }
.cycle-commercial { margin: 2.5rem 0; padding: 1.3rem 0; border-block: 1px solid var(--ligne); }
.cycle-commercial figcaption { font-family: var(--titre); font-size: 1.15rem; }
.cycle-commercial ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); list-style: none; padding: 0; gap: 1rem; margin-top: 1rem; }
.cycle-commercial li { border-left: 3px solid var(--accent); padding-left: .8rem; }
.cycle-commercial a { text-decoration: none; }
.cycle-commercial b, .cycle-commercial span { display: block; }
.cycle-commercial span { color: var(--texte-doux); font-size: .85rem; }
.cycle-commercial p { font-size: .9rem; margin-bottom: 0; }
@media (max-width: 600px) { .cycle-commercial ol { grid-template-columns: 1fr 1fr; } }
.jauge-globale { margin: 2rem 0; padding: 1.2rem 1.4rem; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); display: grid; gap: .6rem; max-width: 820px; }
.jauge { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.jauge > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); transform: scaleX(0); transform-origin: left; transition: transform .4s; }
.jauge-ligne { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .92rem; color: var(--texte-doux); }

.grille-3 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 1.2rem 0 2rem; }
.carte-info { padding: 1.1rem 1.2rem; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); }
.carte-info h3 { margin-top: 0; font-size: 1.05rem; }
.carte-info p:last-child { margin-bottom: 0; }

.phase { margin-top: 2.8rem; }
.phase-entete { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--ligne); padding-bottom: .6rem; }
.phase-entete h2 { margin: 0; padding: 0; border: 0; }
.phase-entete span { font-family: var(--mono); font-size: .8rem; color: var(--texte-doux); }
.cartes-modules { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 1.2rem; }
.carte-module { display: flex; flex-direction: column; gap: .4rem; padding: 1.1rem 1.2rem; border: 1px solid var(--ligne); border-radius: var(--rayon); background: var(--surface); text-decoration: none; color: var(--texte); box-shadow: var(--ombre); transition: border-color .15s, transform .15s; }
.carte-module:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--texte); }
@media (prefers-reduced-motion: reduce) { .carte-module:hover { transform: none; } }
.carte-module .num { font-family: var(--mono); font-size: .78rem; color: var(--accent); }
.carte-module h3 { margin: 0; font-size: 1.08rem; }
.carte-module p { margin: 0; font-size: .9rem; color: var(--texte-doux); flex: 1; }
.carte-module .jauge { height: 5px; margin-top: .5rem; }
.carte-module .etat { font-size: .78rem; color: var(--texte-doux); }
.carte-module.fini { border-color: var(--ok); }
.carte-module.fini .etat { color: var(--ok); font-weight: 600; }

.pied { max-width: 1180px; margin: 0 auto; padding: 2rem clamp(1rem, 3vw, 2rem); color: var(--texte-doux); font-size: .85rem; border-top: 1px solid var(--ligne); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pied button { font: inherit; color: var(--danger); background: none; border: 1px solid var(--ligne); border-radius: 6px; padding: .3rem .7rem; cursor: pointer; }

/* ---------- Impression ---------- */
.outils-module { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; font-size: .9rem; }

@media print {
  .topbar, .sommaire, .sommaire-mobile, .outils-module, .nav-modules, .progression-module, .quiz-actions, .copier, .pied button { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  .bloc, .question, .script { box-shadow: none; break-inside: avoid; }
  .question .explication { display: block; }
  a { color: #000; }
}

/* Quiz figé après correction, jusqu'à « Recommencer ». */
.btn:disabled { opacity: .45; cursor: not-allowed; }
.question input:disabled + * , .question label:has(input:disabled) { cursor: default; }
