/* ─────────────────────────────────────────────────────────────────────────
   Anciens exercices « carte .exercice sur image de fond »
   (comparer, décimaux, fractions impropres, simplifier, conversions, ranger…)
   Couche commune chargée APRÈS le <style> de chaque page.

   Règle d'or : on modernise les styles PAR DÉFAUT sans écraser les couleurs
   propres à un exercice. Les sélecteurs d'éléments passent par :where() (poids
   nul) : une règle de la page qui vise une classe (.btn-signe, .number-box…)
   garde donc la main, et un style écrit dans un attribut style="" aussi.
   ───────────────────────────────────────────────────────────────────────── */

:root:not(.fv-dys) body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body {
  background-size: cover;
  background-attachment: fixed;
}

/* ─── La carte ─── */
.exercice {
  box-sizing: border-box;
  width: min(680px, calc(100% - 24px));
  max-width: 680px;
  padding: 22px 24px 24px;
  border-radius: 24px;
  background-color: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.28), inset 0 1px 0 #fff;
  color: #1e293b;
  text-shadow: none;
}
.exercice * { text-shadow: none; }
.exercice h1, .exercice h2 {
  margin: 4px 0 14px;
  font-size: clamp(1.55em, 3.6vw, 2.1em);
  font-weight: 800;
  line-height: 1.2;
  color: #0f172a;
  text-wrap: balance;
}

/* Score / question / score max : des pastilles */
.exercice .score-chrono {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 0 10px;
  font-size: 0.95em;
}
.exercice .score-chrono > * {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ─── Saisies : plus grandes, centrées, faciles à toucher ─── */
:where(.exercice) input:not([type]),
:where(.exercice) input[type="text"],
:where(.exercice) input[type="number"] {
  box-sizing: border-box;
  min-width: 120px; /* « Numérateur » ne doit plus être coupé (la taille du texte reste celle de la page) */
  min-height: 46px;
  padding: 6px 8px;
  font-family: inherit;
  font-weight: 700;
  text-align: center;
  color: #0f172a;
  background: #fff;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
:where(.exercice) input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}
:where(.exercice) input::placeholder { color: #94a3b8; font-weight: 700; font-size: 0.85em; } /* textes courts (« ? », Entier, Heures…) */
/* les flèches des champs numériques gênent sur tablette */
:where(.exercice) input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
:where(.exercice) input[type="number"]::-webkit-inner-spin-button,
:where(.exercice) input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ─── Boutons par défaut : pastilles en relief ─── */
:where(.exercice) button {
  min-height: 48px;
  padding: 10px 26px;
  margin: 6px;
  font: inherit;
  font-size: 1.1em;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: none;
  border-radius: 999px;
  box-shadow: 0 4px 0 #15803d, 0 8px 16px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.07s, box-shadow 0.07s, filter 0.15s;
}
:where(.exercice) button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #15803d, 0 3px 8px rgba(0, 0, 0, 0.15);
}
:where(.exercice) button:disabled { opacity: 0.5; cursor: default; }
@media (hover: hover) {
  :where(.exercice) button:hover:not(:disabled) { filter: brightness(1.06); }
}

/* Le bouton « Vérifier » commun (#validate, 11 pages) : sa page lui imposait un fond
   blanc ou vert-gris ; on le reprend entièrement (sélecteur plus fort que #validate) */
.exercice #validate {
  min-height: 52px;
  margin-top: 14px;
  padding: 10px 34px;
  font-family: inherit;
  font-size: 1.3em;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: none;
  border-radius: 999px;
  box-shadow: 0 5px 0 #15803d, 0 10px 18px rgba(0, 0, 0, 0.18);
  touch-action: manipulation;
}
.exercice #validate:hover { transform: none; filter: brightness(1.06); }
.exercice #validate:active { transform: translateY(4px); box-shadow: 0 1px 0 #15803d, 0 3px 8px rgba(0, 0, 0, 0.18); }

/* Cases cliquables de « Comparer » : même relief, couleurs de la page conservées */
.exercice .number-box {
  border: none;
  border-radius: 18px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25), 0 10px 20px rgba(0, 0, 0, 0.15);
  touch-action: manipulation;
}
.exercice .number-box:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }

/* ─── Messages ─── */
.exercice #feedback, .exercice .feedback {
  font-size: 1.25em;
  font-weight: 800;
  min-height: 1.3em;
}
.toast {
  border: none;
  border-radius: 14px;
  color: #fff;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

@media (max-width: 560px) {
  .exercice { padding: 16px 14px 18px; border-radius: 18px; }
  :where(.exercice) button { padding: 10px 20px; }
}

/* ─── Titre posé HORS de la carte (Mixte ↔ Impropre, Simplifier) ───
   Sans position, il passait SOUS la couche décor des thèmes (invisible en thème
   sombre) et son ombre blanche ne se lisait que sur fond clair : on le met dans
   une étiquette claire, au-dessus du décor, lisible sur tous les fonds. */
body > h1 {
  position: relative;
  z-index: 10;
  display: table;
  margin: 16px auto 0;
  padding: 8px 24px;
  font-size: clamp(1.5em, 3.6vw, 2.1em);
  font-weight: 800;
  color: #0f172a;
  text-shadow: none;
  background: rgba(255, 255, 255, 0.93);
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.25);
}
body[class*="theme-"] > h1 { color: #0f172a !important; }

/* Encadrer (unité / dixième) : « [ ? ] < 7,54 < [ ? ] » en grand */
.exercice #borneInf, .exercice #borneSup { font-size: 1.4em; width: 120px; }
.exercice #valeurCentre { font-size: 1.5em; font-weight: 800; margin: 0 8px; white-space: nowrap; }
