/* ==========================================================
   La programmation pour les jeunes : ce qui s'ajoute au style des
   activités de maths (../Mathematics/maths.css) — le numéro de la leçon,
   la barre des leçons, l'éditeur de code, la console et les résultats.
   ========================================================== */
:root {
  --bar: #0e7c86;
  --code-bg: #17233d;
  --code-fg: #e8edf5;
  --console-bg: #0f1830;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.bar .num {
  display: inline-grid; place-items: center; width: 1.25em; height: 1.25em;
  font-size: .8em; color: var(--ink); text-shadow: none;
  background: #fff; border: 3px solid var(--ink); border-radius: 50%;
}
.title p#lessonOf { margin-top: 10px; }

/* Les leçons, en pastilles numérotées ; ✓ quand tous les exercices sont réussis. */
.lessons-nav { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.lessons-nav a {
  position: relative; display: inline-grid; place-items: center;
  width: 2.3em; height: 2.1em; padding: 0; color: var(--ink); text-decoration: none; font-size: 17px;
}
.lessons-nav a[aria-current="page"] { background: var(--sticker); }
.lessons-nav a.done::after {
  content: "✓"; position: absolute; top: -9px; right: -9px; width: 20px; height: 20px;
  display: grid; place-items: center; font-size: 12px; line-height: 1;
  color: #fff; background: var(--green); border: 2px solid var(--ink); border-radius: 50%;
}

/* Le texte des leçons */
.card code, .note code, .hint code {
  font-family: var(--mono); font-size: .86em;
  padding: .05em .3em; border: 1px solid var(--line); border-radius: 6px; background: #eef2f8;
}
.card h3 { font-size: 20px; }
.card .lead { font-size: 19px; }
.card table.ops { border-collapse: collapse; margin: 8px 0; }
.card table.ops td, .card table.ops th { padding: 3px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.card table.ops th { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.task { margin-top: 26px; padding-top: 16px; border-top: 2.5px dashed var(--line); }
.task:first-of-type { margin-top: 8px; padding-top: 0; border-top: 0; }
.task h3 { margin-top: 0; }
pre.snippet { margin: 10px 0; padding: 10px 14px; overflow-x: auto; background: var(--code-bg); color: var(--code-fg); border-radius: 12px; font: 15px/1.5 var(--mono); }
pre.snippet code { padding: 0; border: 0; background: none; font-size: 1em; color: inherit; }

/* Un éditeur complet */
.ide {
  margin: 14px 0 18px; overflow: hidden; background: #fff;
  border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
}
.ide-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 5px 12px; background: var(--sky); border-bottom: 2.5px solid var(--ink);
  font-weight: 700; font-size: 16px;
}
.ide.is-ex .ide-head { background: #fff3b0; }
.ide-tag { text-transform: uppercase; letter-spacing: .05em; font-size: 14px; }
.ide-given { font: 600 14px var(--mono); }
.ide-status { margin-left: auto; color: var(--green); }

/* L'éditeur : la zone de texte, transparente, est posée sur le code coloré.
   Les deux doivent avoir exactement la même police, la même marge et les mêmes lignes. */
.ed {
  --fs: 15px; --pad: 10px;
  display: flex; font-size: var(--fs);
  height: calc(var(--lines, 3) * var(--fs) * 1.5 + 2 * var(--pad) + 14px);
  background: var(--code-bg);
}
.ed:focus-within { box-shadow: inset 0 0 0 3px #8fc1ff; }
.ed-gutter {
  flex: none; min-width: 2.8em; padding: var(--pad) 8px var(--pad) 6px; overflow: hidden;
  font: var(--fs)/1.5 var(--mono); text-align: right; white-space: pre;
  color: #6b7a99; background: #132036; user-select: none;
}
.ed-area { position: relative; flex: 1; min-width: 0; }
.ed-hl, .ed-src {
  position: absolute; inset: 0; margin: 0; padding: var(--pad) 12px;
  font: var(--fs)/1.5 var(--mono); font-variant-ligatures: none; letter-spacing: 0;
  white-space: pre; overflow-wrap: normal; word-wrap: normal; tab-size: 2;
  border: 0; border-radius: 0;
}
.ed-hl { overflow: hidden; pointer-events: none; color: var(--code-fg); background: transparent; }
.ed-hl code { font: inherit; padding: 0; background: none; border: 0; }
.ed-src {
  width: 100%; height: 100%; resize: none; overflow: auto; outline: none;
  color: transparent; background: transparent; caret-color: #fff;
  -webkit-text-fill-color: transparent;
}
.ed-src::selection { background: rgba(143, 193, 255, .35); }

.ide-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-top: 2.5px solid var(--ink); }
.ide-bar .chunky { font-size: 15px; padding: 2px 12px; box-shadow: 0 3px 0 var(--ink); }
.ide-bar .run { background: var(--mint); }
.ide-bar .check { background: var(--sticker); }
.ide-bar .reset { margin-left: auto; }

.console {
  min-height: 2.6em; max-height: 320px; overflow: auto; padding: 8px 12px;
  font: 14px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word;
  color: #dfe6f3; background: var(--console-bg); border-top: 2.5px solid var(--ink);
}
.console:empty::before { content: attr(data-empty); color: #8494b3; font-family: var(--font); }
.console .note { color: #8494b3; font-style: italic; font-family: var(--font); }
.console .err { margin-top: 4px; padding: 4px 8px; border-radius: 8px; color: #ffd0c9; background: rgba(226, 59, 46, .22); font-family: var(--font); font-weight: 600; }

.results { padding: 8px 12px 10px; border-top: 2.5px solid var(--ink); }
.results .sum { margin: 2px 0 6px; font-weight: 800; }
.results .sum.good { color: var(--green); }
.results .sum.bad { color: #b3261e; }
.row { display: flex; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); }
.row .mk { flex: none; width: 1.4em; font-weight: 800; text-align: center; }
.row.ok .mk { color: var(--green); }
.row.ko .mk { color: #b3261e; }
.row-body { flex: 1; min-width: 0; }
.row .lbl { font: 600 14px var(--mono); }
.cmp { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-top: 4px; }
.cmp-h { display: block; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.cmp pre { margin: 2px 0 0; padding: 6px 10px; overflow-x: auto; font: 14px/1.45 var(--mono); background: #f1f4f8; border: 1px solid var(--line); border-radius: 8px; }
.row .problem { margin: 4px 0 0; color: #b3261e; font-weight: 600; font-size: 16px; }

.hint, .sol { padding: 10px 14px; border-top: 2.5px solid var(--ink); background: var(--note); }
.hint p { margin: 4px 0; }
.sol-h { margin: 0 0 6px; font-weight: 700; }
.sol-code { margin: 0 0 10px; padding: 10px 12px; overflow-x: auto; border-radius: 10px; background: var(--code-bg); color: var(--code-fg); font: 14px/1.5 var(--mono); }
.sol .chunky { font-size: 15px; padding: 2px 12px; }

/* Précédente · Toutes les leçons · Suivante */
.pager {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px 20px; align-items: baseline;
  margin-top: 24px; font-weight: 700;
}
.pager a { color: var(--blue); }
.pg-next { text-align: right; }

@media (max-width: 720px) {
  .ed { --fs: 16px; }   /* sous 16 px, iOS agrandit la page quand on écrit */
  .pager { grid-template-columns: 1fr 1fr; }
  .pg-all { grid-column: 1 / -1; grid-row: 2; text-align: center; }
  .ide-bar .reset { margin-left: 0; }
}
