/* =========================================================
   Algorithmique Zero to Hero — algorithme.boumlik.ma
   Palette : bleu-vert zellige + ocre, fond « papier »
   ========================================================= */
:root {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #E8EEEB;
  --ink: #18262B;
  --muted: #56666C;
  --line: #D3DCD8;
  --majorelle: #0B6E66;
  --majorelle-soft: #DCEFEB;
  --saffron: #D9822B;
  --saffron-soft: #FBEADA;
  --mint: #2E7D32;
  --mint-soft: #DDF1E7;
  --brick: #B3402A;
  --brick-soft: #F8E2DC;
  --on-accent: #FFFFFF;
  --code-bg: #1C2A30;
  --code-ink: #E4ECEA;
  --radius: 10px;
  --radius-lg: 18px;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-head: "Bricolage Grotesque", "Atkinson Hyperlegible", sans-serif;
  --font-code: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F171A; --surface: #162126; --surface-2: #1D2A30; --ink: #E5EDEB; --muted: #95A6AB;
    --line: #2A3A41; --majorelle: #5FD0C2; --majorelle-soft: #12332F; --saffron: #F0A04D;
    --saffron-soft: #3A2D16; --mint: #4CC38A; --mint-soft: #15362A; --brick: #F07D61;
    --brick-soft: #3F1F18; --code-bg: #0B1214; --code-ink: #E4ECEA; --on-accent: #0F171A; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F171A; --surface: #162126; --surface-2: #1D2A30; --ink: #E5EDEB; --muted: #95A6AB;
  --line: #2A3A41; --majorelle: #5FD0C2; --majorelle-soft: #12332F; --saffron: #F0A04D;
  --saffron-soft: #3A2D16; --mint: #4CC38A; --mint-soft: #15362A; --brick: #F07D61;
  --brick-soft: #3F1F18; --code-bg: #0B1214; --code-ink: #E4ECEA; --on-accent: #0F171A; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.6 var(--font-body);
  min-height: 100vh; display: flex; flex-direction: column;
}
main:focus, main:focus-visible { outline: none; }
main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 700; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--majorelle); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* ---------- barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--font-head); font-size: 1.05rem; white-space: nowrap; }
.brand b { color: var(--majorelle); }
.mainnav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: .95rem; }
.mainnav a:hover { color: var(--ink); background: var(--surface-2); }
.mainnav a.active { color: var(--majorelle); background: var(--majorelle-soft); font-weight: 700; }
.topmeta { display: flex; align-items: center; gap: 8px; }
.iconbtn { background: none; border: 1px solid var(--line); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem; }
.iconbtn:hover { background: var(--surface-2); }
.pystate { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.pystate::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--line); vertical-align: middle; }
.pystate[data-s="loading"]::before { background: var(--saffron); animation: pulse 1s infinite alternate; }
.pystate[data-s="ready"]::before { background: var(--mint); }
.pystate[data-s="error"]::before { background: var(--brick); }
@keyframes pulse { to { opacity: .3; } }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; }
  .mainnav { order: 3; flex-basis: 100%; }
  .pystate { display: none; }
  .topmeta { margin-left: auto; }
}

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 .95rem var(--font-body); padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--majorelle); background: var(--majorelle); color: #fff; text-decoration: none;
  transition: transform .08s ease, background .15s;
}
.btn { color: var(--on-accent); }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--majorelle); }
.btn.quiet { background: var(--surface-2); border-color: var(--surface-2); color: var(--ink); }
.btn.success { background: var(--mint); border-color: var(--mint); }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- accueil : le parcours ---------- */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: end; padding: 24px 0 40px; }
.hero h1 { max-width: 13ch; }
.hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 52ch; }
.hero-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.hero-card h3 { margin-bottom: .3em; }
.namefield { display: flex; gap: 8px; margin-top: 10px; }
.namefield input, .field input, .field textarea {
  flex: 1; font: inherit; padding: 10px 14px; border-radius: var(--radius); border: 1.5px solid var(--line);
  background: var(--bg); color: var(--ink); min-width: 0;
}
.meter { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.meter > span { display: block; height: 100%; background: var(--saffron); border-radius: 99px; transition: width .6s ease; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; gap: 20px; align-items: start; } }

.how { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin: 0 0 48px; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.how div { padding: 14px 14px 16px; border-right: 1px solid var(--line); }
.how div:last-child { border-right: 0; }
.how b { display: block; font-family: var(--font-head); font-size: 1.05rem; }
.how span { font-size: .85rem; color: var(--muted); }
.how i { font-style: normal; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--majorelle-soft); color: var(--majorelle); font-weight: 700; font-size: .8rem; margin-bottom: 6px; }
@media (max-width: 860px) { .how { grid-template-columns: repeat(2, 1fr); } .how div { border-bottom: 1px solid var(--line); } }

.phase { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.phase + .phase { margin-top: 8px; }
.phase-title { position: sticky; top: 80px; align-self: start; padding-top: 22px; }
.phase-title h2 { font-size: 1.35rem; margin-bottom: 4px; }
.phase-title p { color: var(--muted); font-size: .9rem; }
@media (max-width: 860px) { .phase { grid-template-columns: 1fr; gap: 0; } .phase-title { position: static; padding-top: 18px; } }

.line { list-style: none; margin: 0; padding: 0; position: relative; }
.station { position: relative; padding: 18px 0 18px 64px; }
.station::before { /* le rail */
  content: ""; position: absolute; left: 21px; top: 0; bottom: 0; width: 6px; background: var(--line);
}
.station.done::before { background: var(--saffron); }
.station.current::before { background: linear-gradient(var(--saffron) 50%, var(--line) 50%); }
.line .station:first-child::before { top: 30px; }
.phase:last-of-type .line .station:last-child::before { bottom: calc(100% - 30px); }
.stop {
  position: absolute; left: 6px; top: 18px; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font: 800 .95rem var(--font-head);
  background: var(--surface); border: 4px solid var(--line); color: var(--muted); z-index: 1;
}
.station.done .stop { background: var(--saffron); border-color: var(--saffron); color: #2a1d05; }
.station.current .stop { border-color: var(--majorelle); color: var(--majorelle); box-shadow: 0 0 0 6px var(--majorelle-soft); }
.station-body { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; color: inherit; text-decoration: none; }
a.station-body:hover { border-color: var(--majorelle); }
.station.locked .station-body { background: transparent; border-style: dashed; }
.station.locked h3 { color: var(--muted); }
.station-body h3 { margin: 0 0 4px; }
.station-body p { margin: 0; color: var(--muted); font-size: .95rem; }
.station-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .85rem; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag.go { background: var(--majorelle-soft); color: var(--majorelle); }
.tag.ok { background: var(--saffron-soft); color: color-mix(in srgb, var(--saffron) 60%, var(--ink)); }
.tag.soon { background: transparent; border: 1px dashed var(--line); }

/* ---------- page module ---------- */
.modhead { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.modhead .crumb { font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.modhead .crumb a { color: var(--muted); }
.modhead h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; }
.modlayout > * { min-width: 0; }
.modlayout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; align-items: start; }
.steps { position: sticky; top: 76px; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.steps a, .steps span.lockedstep {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-size: .95rem;
}
.steps a:hover { background: var(--surface-2); }
.steps a.here { background: var(--surface); box-shadow: inset 3px 0 0 var(--majorelle); font-weight: 700; }
.steps .dot { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--muted); }
.steps .ok .dot { background: var(--saffron); border-color: var(--saffron); color: #2a1d05; }
.steps .now .dot { border-color: var(--majorelle); color: var(--majorelle); }
.steps span.lockedstep { color: var(--muted); cursor: not-allowed; }
.steps .sep { height: 1px; background: var(--line); margin: 10px 12px; }
.steps .count { margin-left: auto; font-size: .78rem; color: var(--muted); }
@media (max-width: 860px) {
  .modlayout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .steps { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: thin; }
  .steps li { flex: none; }
  .steps a, .steps span.lockedstep { padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; white-space: nowrap; }
  .steps a.here { box-shadow: none; border-color: var(--majorelle); }
  .steps .sep { width: 1px; height: auto; margin: 4px; }
  .steps .count { display: none; }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.panel + .panel { margin-top: 16px; }
@media (max-width: 600px) { .panel { padding: 18px 16px; border-radius: var(--radius); } }
.panel-intro { margin-bottom: 18px; }
.panel-intro p { color: var(--muted); }

.prose { max-width: 74ch; }
.prose h2 { margin-top: 1.4em; }
.prose h3 { margin-top: 1.3em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: .25em 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 1.2em; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { font-family: var(--font-head); background: var(--surface-2); }
.prose blockquote { margin: 0 0 1em; padding: 12px 16px; border-left: 4px solid var(--saffron); background: var(--saffron-soft); border-radius: 0 var(--radius) var(--radius) 0; }
.prose blockquote p:last-child { margin: 0; }
code { font-family: var(--font-code); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
pre { position: relative; margin: 0 0 1.2em; }
pre code, pre code.hljs { display: block; padding: 16px 18px; background: var(--code-bg); color: var(--code-ink); border-radius: var(--radius); overflow-x: auto; font-size: .88rem; line-height: 1.55; }
.codetools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; opacity: .85; }
.codetools button { font: 700 .75rem var(--font-body); padding: 4px 10px; border-radius: 99px; border: 1px solid #3a4c53; background: #24353c; color: #e4ecea; cursor: pointer; }
.codetools button:hover { background: #31464e; }
/* coloration (highlight.js) */
.hljs-keyword, .hljs-built_in { color: #9DB0FF; }
.hljs-string { color: #F2C46D; }
.hljs-number, .hljs-literal { color: #F59B7C; }
.hljs-comment { color: #7E9097; font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-title.class_ { color: #7FDDB0; }
.hljs-meta, .hljs-params { color: #C9D5D2; }
.hljs-subst { color: #E4ECEA; }

/* niveaux */
.lvl { display: inline-block; font: 700 .75rem var(--font-body); padding: 2px 10px; border-radius: 99px; margin-bottom: 8px; }
.lvl-Basique { background: var(--mint-soft); color: var(--mint); }
.lvl-Intermédiaire { background: var(--majorelle-soft); color: var(--majorelle); }
.lvl-Avancé { background: var(--saffron-soft); color: color-mix(in srgb, var(--saffron) 55%, var(--ink)); }

/* sections de cours */
.section { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 22px; }
.section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.section-foot { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.readmark { color: var(--mint); font-weight: 700; font-size: .9rem; }
.next-hint { margin-top: 22px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }

/* éditeur */
.ide { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--code-bg); margin: 12px 0; }
.ide-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.ide-bar .grow { flex: 1; }
.CodeMirror { height: auto; min-height: 140px; font-family: var(--font-code); font-size: 14px; line-height: 1.55; background: var(--code-bg); color: var(--code-ink); }
.CodeMirror-scroll { min-height: 140px; max-height: 520px; }
.CodeMirror-gutters { background: var(--code-bg); border-right: 1px solid #2c3d43; }
.CodeMirror-linenumber { color: #5f737a; }
.CodeMirror-cursor { border-left: 2px solid var(--saffron); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: #33474f !important; }
.CodeMirror-matchingbracket { color: var(--saffron) !important; text-decoration: underline; }
.cm-s-default .cm-keyword, .cm-s-default .cm-builtin { color: #9DB0FF; }
.cm-s-default .cm-string { color: #F2C46D; }
.cm-s-default .cm-number { color: #F59B7C; }
.cm-s-default .cm-comment { color: #7E9097; font-style: italic; }
.cm-s-default .cm-def { color: #7FDDB0; }
.cm-s-default .cm-variable, .cm-s-default .cm-variable-2, .cm-s-default .cm-property { color: #E4ECEA; }
.cm-s-default .cm-operator { color: #C9D5D2; }
.cm-s-default .cm-variable-3, .cm-s-default .cm-type { color: #7FDDB0; }
.inputs { padding: 8px 10px; background: var(--surface); border-top: 1px solid var(--line); }
.inputs label { font-size: .82rem; color: var(--muted); display: block; margin-bottom: 4px; }
.inputs textarea { width: 100%; font: 13px/1.5 var(--font-code); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--bg); color: var(--ink); resize: vertical; min-height: 40px; }
.console { margin: 0; padding: 12px 14px; background: #0E1619; color: #D7E2DF; font: 13px/1.55 var(--font-code); white-space: pre-wrap; word-break: break-word; min-height: 48px; max-height: 340px; overflow: auto; border-top: 1px solid #2c3d43; }
.console:empty::before { content: "La sortie de ton programme s'affichera ici."; color: #6d8087; }
.console .err { color: #FFAE9A; }
.verdict { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--radius); font-weight: 700; white-space: pre-wrap; }
.verdict.ok { background: var(--mint-soft); color: var(--mint); }
.verdict.ko { background: var(--brick-soft); color: var(--brick); font-weight: 400; }
.verdict:empty { display: none; }

/* exercices */
.exlist { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.exlist a, .exlist span { display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1.5px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 700; font-size: .9rem; }
.exlist .ok { background: var(--saffron); border-color: var(--saffron); color: #2a1d05; }
.exlist .here { border-color: var(--majorelle); color: var(--majorelle); box-shadow: 0 0 0 3px var(--majorelle-soft); }
.exlist span { color: var(--muted); border-style: dashed; cursor: not-allowed; }
.stars { color: var(--saffron); letter-spacing: 2px; font-size: .9rem; }
.hint { margin: 8px 0; padding: 10px 14px; background: var(--majorelle-soft); border-radius: var(--radius); font-size: .95rem; }
.solution-box { margin-top: 14px; }

/* TP groupe */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.roles { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.roles li { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius); }
.roles b { display: block; font-family: var(--font-head); }
.grille { width: 100%; border-collapse: collapse; }
.grille td { border-bottom: 1px solid var(--line); padding: 8px 4px; }
.grille td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.codeentry { display: flex; gap: 8px; margin-top: 10px; }
.codeentry input { flex: 1; min-width: 0; font: 700 1rem var(--font-code); letter-spacing: 1px; padding: 10px 12px; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); text-transform: uppercase; }

/* examen */
.q { padding: 18px 0; border-top: 1px solid var(--line); }
.q:first-child { border-top: 0; }
.q-num { font: 700 .85rem var(--font-head); color: var(--muted); }
.choices { display: grid; gap: 8px; margin-top: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--majorelle); }
.choice input { margin-top: 5px; accent-color: var(--majorelle); }
.choice.right { border-color: var(--mint); background: var(--mint-soft); }
.choice.wrong { border-color: var(--brick); background: var(--brick-soft); }
.choice p { margin: 0; }
.explain { margin-top: 8px; font-size: .92rem; color: var(--muted); }
.score { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.score strong { font: 800 3rem var(--font-head); line-height: 1; }
.score.pass strong { color: var(--mint); }
.score.fail strong { color: var(--brick); }

/* fiches & outils */
.fiche { break-inside: avoid; }
.fiche + .fiche { margin-top: 24px; }
.toolcat { margin-bottom: 36px; }
.tool { padding: 16px 0; border-top: 1px solid var(--line); }
.tool h3 { margin-bottom: 4px; }
.searchbar { width: 100%; font: inherit; padding: 12px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); margin: 0 0 24px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.stats div { padding: 14px; background: var(--surface-2); border-radius: var(--radius); }
.stats b { display: block; font: 800 1.6rem var(--font-head); }
.stats span { font-size: .85rem; color: var(--muted); }

.notice { padding: 14px 16px; border-radius: var(--radius); background: var(--saffron-soft); margin-bottom: 16px; }
.lockpage { text-align: center; padding: 48px 16px; }
.lockpage .big { font-size: 2.5rem; }

/* dialogue « essayer » */
.playdialog { width: min(820px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--ink); }
.playdialog::backdrop { background: rgba(10, 20, 24, .55); }
.playhead { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); margin: 0; }
#playBody { padding: 4px 16px 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 99px; font-weight: 700; transition: transform .25s ease, opacity .25s; opacity: 0; visibility: hidden; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

.foot { border-top: 1px solid var(--line); padding: 18px 16px; text-align: center; font-size: .85rem; color: var(--muted); }
.foot p { margin: 0; }

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

@media print {
  .topbar, .foot, .steps, .btnrow, .codetools, .modhead .btnrow, .noprint { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  main { padding: 0; max-width: none; }
  .modlayout { display: block; }
  .panel { border: 0; padding: 0; }
  pre code, pre code.hljs { background: #f3f3f3 !important; color: #000 !important; border: 1px solid #ccc; }
  .hljs-keyword, .hljs-string, .hljs-number, .hljs-comment, .hljs-title { color: #000 !important; }
}

/* ---------- algorithmique : déroulement, exercices non-code, sélecteur de langage ---------- */
.ide-bar .lang { font: 700 .72rem var(--font-body); text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 99px; background: var(--majorelle-soft); color: var(--majorelle); }
.ide-bar .lang.py { background: var(--saffron-soft); color: color-mix(in srgb, var(--saffron) 55%, var(--ink)); }
.arrowbtn { font-family: var(--font-code) !important; }
.trace { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.trace-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.trace-head b { font-family: var(--font-head); }
.trace-head .grow { flex: 1; }
.trace-wrap { max-height: 340px; overflow: auto; }
.trace table { border-collapse: collapse; width: 100%; font: .85rem/1.35 var(--font-code); }
.trace th, .trace td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.trace th { position: sticky; top: 0; background: var(--surface-2); font-family: var(--font-body); font-size: .78rem; z-index: 1; }
.trace td.o { white-space: pre; color: var(--mint); }
.trace td.chg { background: var(--saffron-soft); font-weight: 600; }
.trace tr { cursor: pointer; }
.trace tr.cur td { background: var(--majorelle-soft); }
.trace tr.cur td.chg { background: color-mix(in srgb, var(--saffron-soft) 50%, var(--majorelle-soft)); }
.cm-trace-line { background: color-mix(in srgb, var(--saffron) 28%, transparent) !important; }
.quizex .qitem { padding: 14px 0; border-bottom: 1px solid var(--line); }
.quizex .qitem:last-child { border-bottom: 0; }
.quizex .qitem.right .q-num::after { content: " ✓"; color: var(--mint); }
.quizex .qitem.wrong .q-num::after { content: " ✗"; color: var(--brick); }
.sortex { display: grid; gap: 8px; margin: 12px 0; }
.sortex .row { display: grid; grid-template-columns: 1fr minmax(160px, 34%); gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.sortex .row.right { border-color: var(--mint); box-shadow: inset 4px 0 0 var(--mint); }
.sortex .row.wrong { border-color: var(--brick); box-shadow: inset 4px 0 0 var(--brick); }
.sortex select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; }
@media (max-width: 560px) { .sortex .row { grid-template-columns: 1fr; } }
.langswitch { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.langswitch button { border: 0; background: transparent; padding: 6px 14px; font: 700 .85rem var(--font-body); color: var(--muted); cursor: pointer; }
.langswitch button.on { background: var(--majorelle); color: var(--on-accent); }
.hljs-keyword { font-weight: 600; }
