/* ==========================================================
   Les mathématiques pour les jeunes : le style des activités.
   Le même que les labos de La physique pour les jeunes (engrenages,
   aimants) : ciel pointillé, encre foncée, boutons « autocollants ».
   Chaque page choisit la couleur de son titre avec --bar.
   ========================================================== */
:root {
  --sky: #e7eef7;
  --ink: #17233d;
  --red: #e23b2e;
  --blue: #2464d6;
  --purple: #7a62c9;
  --orange: #ff8a1f;
  --green: #1c7a55;
  --sticker: #ffd23f;
  --mint: #c9eedb;
  --rose: #ffd6cf;
  --lilac: #e3dcf7;
  --note: #fff3b0;
  --muted: rgba(23, 35, 61, .62);
  --line: rgba(23, 35, 61, .18);
  --bar: var(--blue);
  --font: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
/* hidden cache toujours, même un élément dont la classe fixe display. */
[hidden] { display: none !important; }
body {
  background-color: var(--sky);
  background-image: radial-gradient(rgba(23, 35, 61, .08) 1.2px, transparent 1.4px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
/* Les deux langues sont dans la page ; on cache celle qui n'est pas choisie. */
html[lang="en"] [lang="fr"], html[lang="fr"] [lang="en"] { display: none !important; }

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) clamp(12px, 3vw, 24px) max(28px, env(safe-area-inset-bottom));
}

/* En-tête : le titre sur sa bande de couleur, puis le bouton de langue. */
header { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; margin: 8px 0 18px; }
.title { min-width: 0; }
.title p { margin: 8px 0 0 4px; font-size: 16px; font-weight: 600; opacity: .72; }
.bar {
  display: inline-flex; align-items: center; gap: .35em;
  margin: 0; padding: .02em .4em;
  font-size: clamp(26px, 4.8vw, 44px); font-weight: 800; line-height: 1.2; letter-spacing: .01em;
  color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .2);
  background: var(--bar);
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 5px 0 var(--ink);
}
.bar .sym { font-size: .8em; }
.settings { display: flex; gap: 10px; margin-left: auto; align-self: flex-start; }

button, input { font: inherit; color: inherit; }
.chunky {
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  padding: 5px 14px; font-weight: 700; cursor: pointer;
  transition: transform .06s, box-shadow .06s;
  touch-action: manipulation;
}
.chunky:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.chunky:focus-visible, .num-input:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.chunky[aria-pressed="true"] { background: var(--sticker); }
.chunky:disabled { opacity: .45; cursor: not-allowed; }
.chunky.go { background: var(--sticker); }
.lang { min-width: 46px; height: 42px; padding: 0 8px; font-size: 18px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.center { justify-content: center; }
.label { display: block; margin: 0 0 6px; font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* Les cartes blanches, cerclées d'encre. */
.card {
  background: #fff;
  border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink);
  padding: clamp(14px, 3vw, 26px);
  margin-bottom: 22px;
}
.card h2 { margin: 0 0 6px; font-size: 24px; line-height: 1.2; }
.card h3 { margin: 18px 0 4px; font-size: 19px; }
.card p { margin: 6px 0; }
.card ul, .card ol { margin: 6px 0; padding-left: 1.3em; }
.card a, .note a { color: var(--blue); font-weight: 600; }
.center { text-align: center; }

/* Les nombres : chiffres de même largeur. */
.big { font-size: clamp(34px, 7vw, 54px); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hl { padding: 0 .3em; border-radius: 6px; background: var(--note); font-weight: 700; white-space: nowrap; }
.num-input {
  width: 4.2em; height: 1.9em; text-align: center;
  font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 12px;
  box-shadow: inset 0 3px 0 rgba(23, 35, 61, .08);
  -moz-appearance: textfield; appearance: textfield;
}
.num-input::-webkit-outer-spin-button, .num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input.small { width: 3.4em; height: 1.7em; font-size: 22px; }
.num-input:disabled { background: #f1f4f8; }

/* Réponses : juste, pas encore, conseil. */
.feedback { min-height: 1.6em; margin: 12px 0 0; font-weight: 700; text-align: center; }
.good { color: var(--green); }
.bad { color: #b3261e; }
.info { color: var(--ink); }

/* Le pense-bête jaune, comme dans les labos de physique. */
.note {
  background: var(--note); padding: 14px 18px 16px; margin-bottom: 22px;
  border-radius: 3px 3px 22px 3px; transform: rotate(-.6deg);
  box-shadow: 0 12px 18px -12px rgba(23, 35, 61, .55);
}
.note h2 { margin: 0 0 4px; font-size: 22px; line-height: 1.2; }
.note p, .note ul { margin: 4px 0; }
.note ul { padding-left: 1.2em; }

footer { margin-top: 28px; font-size: 14px; }
footer p { margin: 8px 0 0; opacity: .6; }
footer .links { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 16px; font-weight: 700; }
footer a { color: var(--blue); }

@media (max-width: 720px) {
  body { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .chunky { transition: none; }
}
