/* ============================================================
   Cahiers d'automatismes — feuille de style des fiches
   Reprend les conventions visuelles des fiches de calcul
   ============================================================ */

:root {
  --bleu: #4B46C7;
  --bleu-clair: #D9D9FF;
  --vert: #1D9E75;
  --vert-clair: #E1F5EE;
  --rouge: #E24B4A;
  --rouge-clair: #FCEBEB;
  --orange: #D97706;
  --orange-clair: #FEF3C7;
  --gris: #5F5E5A;
  --gris-clair: #F1EFE8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Georgia', 'Times New Roman', serif;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 12px 60px;
  color: #1a1a1a;
  background: #fff;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ---------- Navigation ---------- */
.barre-navigation {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.nav-btn {
  flex: 1 1 auto;
  text-align: center;
  font-size: 12.5px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--bleu-clair);
  background: white;
  color: var(--bleu);
  text-decoration: none;
  font-family: Georgia, serif;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:hover { background: var(--bleu-clair); }
.nav-btn-sommaire {
  background: var(--bleu);
  color: white;
  border-color: var(--bleu);
  flex: 0 0 auto;
  padding: 9px 16px;
}
.nav-btn-sommaire:hover { background: #3a36a0; }
.nav-btn-disabled { color: #ccc; border-color: #eee; cursor: default; }
.nav-btn-disabled:hover { background: white; }

.fil-ariane {
  font-size: 14px;
  color: var(--gris);
  margin: 0 0 10px;
}
.fil-ariane a { color: var(--gris); text-decoration: none; }
.fil-ariane a:hover { color: var(--bleu); text-decoration: underline; }
.fil-ariane .separateur { margin: 0 5px; color: #ccc; }

/* ---------- En-tête ---------- */
.entete {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.badge {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: var(--bleu);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
}
.badge-sujet { background: #1a1a1a; font-size: 15px; }
h1 { font-size: 19px; margin: 0; line-height: 1.25; }
.sous-titre { font-size: 13px; color: var(--gris); margin: 2px 0 0; }
.filet {
  height: 3px;
  background: var(--bleu);
  width: 60%;
  max-width: 220px;
  margin: 6px 0 18px 54px;
}
.bandeau-calculatrice {
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  color: var(--rouge);
  background: var(--rouge-clair);
  border-radius: 8px;
  padding: 9px 14px;
  margin: 0 0 14px;
}
.consigne-epreuve {
  font-size: 12.5px;
  color: var(--gris);
  background: var(--gris-clair);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  line-height: 1.45;
}

/* ---------- Panneau de mode ---------- */
.mode-panneau {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: white;
  border: 1.5px solid var(--bleu-clair);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.mode-label {
  font-size: 13px;
  font-weight: bold;
  color: var(--gris);
  width: 100%;
}
.mode-btn {
  background: white;
  border: 1.5px solid #ccc;
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: Georgia, serif;
  cursor: pointer;
  color: var(--gris);
  min-height: 40px;
  flex: 1 1 auto;
}
.mode-btn:hover { border-color: var(--bleu); }
.mode-btn.mode-actif {
  background: var(--bleu);
  border-color: var(--bleu);
  color: white;
  font-weight: bold;
}
.mode-btn.mode-actif-sombre {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: white;
  font-weight: bold;
}
.niveau-btn { letter-spacing: 0.01em; }
.mode-explication {
  font-size: 12px;
  color: var(--gris);
  font-style: italic;
  width: 100%;
  margin-top: 2px;
}
.mode-panneau select {
  font-family: Georgia, serif;
  font-size: 13px;
  padding: 8px 10px;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  background: white;
  min-height: 40px;
}

/* Devoir en cours (sujet-blanc.html) : niveau/mode/duree imposes, resume
   non cliquable a la place des boutons de choix habituels. */
.mode-panneau-verrouille { background: var(--bleu-clair); }
.mode-verrouille-resume {
  display: inline-block;
  background: var(--bleu);
  color: white;
  font-weight: bold;
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 13px;
}

/* ---------- Figures : agrandissement ---------- */
.figure-zoom {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.zoom-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1.3px solid var(--bleu-clair);
  color: var(--bleu);
  cursor: zoom-in;
  line-height: 0;
}
.zoom-btn:hover { background: var(--bleu); border-color: var(--bleu); color: white; }
.opt .zoom-btn { width: 20px; height: 20px; top: 3px; right: 3px; }
/* figures sans marge intérieure (tableaux, arbres, boîtes) : la loupe se place
   au-dessus du dessin plutôt que par-dessus une donnée */
.figure-zoom-dense { padding-top: 28px; }
.figure-zoom-dense > .zoom-btn { top: 0; right: 0; }
.opt .figure-zoom-dense { padding-top: 24px; }

/* curseur de lecture des coordonnées : bouton sous la loupe, état commun à tous les repères
   (classe curseur-actif sur <html>) ; sans survol réel (tablette, téléphone) il serait inutile */
.curseur-btn {
  position: absolute;
  top: 32px;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1.3px solid var(--bleu-clair);
  color: var(--bleu);
  cursor: pointer;
  line-height: 0;
}
.curseur-btn:hover, .curseur-actif .curseur-btn { background: var(--bleu); border-color: var(--bleu); color: white; }
.modal-figure-corps { position: relative; }
.modal-figure-corps .curseur-btn { top: -26px; left: -8px; right: auto; }
.curseur-actif .carte-figure svg[data-repere], .curseur-actif .modal-figure-corps svg[data-repere] { cursor: crosshair; }
@media (hover: none) { .curseur-btn { display: none; } }

/* la règle display ci-dessous l'emporterait sur l'attribut hidden : on le rétablit */
.modal-figure[hidden] { display: none; }
.modal-figure {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(20, 20, 25, 0.78);
  cursor: zoom-out;
}
.modal-figure-contenu {
  position: relative;
  background: white;
  border-radius: 10px;
  padding: 34px 16px 16px;
  width: min(94vw, 620px);
  max-height: 92vh;
  overflow: auto;
  cursor: default;
}
.modal-figure-corps svg {
  display: block;
  margin: 0 auto;
  width: 100%;
  height: auto;
  border: none;
}
.modal-figure-fermer {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--gris);
  cursor: pointer;
  padding: 2px 8px;
}
.modal-figure-fermer:hover { color: var(--rouge); }

/* ---------- Pop-up d'information sur un devoir (28/09/2026) -----------
   Remplace le petit texte gris #suivi-etat, jugé trop discret par David :
   même langage visuel que .modal-figure (fond assombri, carte blanche
   centrée), en plus étroit et avec un bouton d'action explicite plutôt
   qu'un simple clic sur le fond pour fermer. */
.modal-devoir[hidden] { display: none; }
.modal-devoir {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(20, 20, 25, 0.78);
}
.modal-devoir-contenu {
  position: relative;
  background: white;
  border-radius: 10px;
  padding: 30px 22px 22px;
  width: min(94vw, 420px);
  max-height: 92vh;
  overflow: auto;
  text-align: center;
}
.modal-devoir-titre {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--orange);
}
.modal-devoir-texte { margin: 0 0 20px; font-size: 0.95rem; line-height: 1.45; color: var(--gris); }
.modal-devoir-ok {
  background: var(--bleu);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 26px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.modal-devoir-ok:hover { opacity: 0.9; }
.modal-devoir-fermer {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--gris);
  cursor: pointer;
  padding: 2px 8px;
}
.modal-devoir-fermer:hover { color: var(--rouge); }

/* ---------- Figures : tableaux de signes ---------- */
.tab-signes-svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2px auto;
}
.opt-texte .tab-signes-svg { max-width: 100%; }

/* ---------- Figures : repères quadrillés ---------- */
.repere-svg {
  display: block;
  max-width: 100%;
  height: auto;
  background: white;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
}
.carte-figure .repere-svg { margin: 0 auto; }
/* dans une option : petite figure centrée, l'option passe en colonne */
.opt-texte .repere-svg { margin: 2px auto; max-width: 190px; }
.opt { align-items: center; }

/* ---------- Figures : arbres, tableaux croisés, diagrammes en boîte ---------- */
.arbre-svg,
.tab-croise-svg,
.boite-svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2px auto;
}
.carte-figure .arbre-svg,
.carte-figure .tab-croise-svg,
.carte-figure .boite-svg { margin: 0 auto; }

/* ---------- Bandeau des thèmes tirés au sort ---------- */
.themes-bandeau {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  background: #D8EEDF;               /* vert pastel, distinct du bleu du site */
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}
.themes-label { font-weight: bold; color: #255C3E; }
.theme-puce {
  background: #B4DFC5;
  color: #17492E;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: bold;
}

/* ---------- Cartes de question ---------- */
.liste-questions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.carte {
  background: white;
  border-radius: 10px;
  padding: 14px 14px 12px;
  border: 1.5px solid #e2e2e2;
  transition: border-color 0.15s, background-color 0.15s;
}
.carte.correct { border-color: var(--vert); background: var(--vert-clair); }
.carte.incorrect { border-color: var(--rouge); background: var(--rouge-clair); }
.carte.sans-reponse { border-color: var(--orange); background: var(--orange-clair); }
.carte-entete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.carte-num {
  font-weight: bold;
  color: #990000;
  font-size: 14px;
}
.carte-famille {
  font-size: 11px;
  color: var(--gris);
  font-style: italic;
  text-align: right;
}
/* barème par question (sujet blanc) : pastille à droite de l'en-tête de la carte */
.carte-entete .carte-famille { margin-left: auto; }
.carte-points {
  margin-left: auto;
  padding: 1px 9px;
  border: 1.3px solid #e6b94d;
  border-radius: 10px;
  background: #fff4d6;
  color: #7a5200;
  font-size: 12.5px;
  font-weight: bold;
  white-space: nowrap;
}
.carte-entete .carte-famille + .carte-points { margin-left: 0; }
.bareme-total {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1.3px solid #e6b94d;
  border-radius: 8px;
  background: #fff4d6;
  color: #4a3500;
  font-size: 14px;
}
.carte-corps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.carte-enonce { font-size: 15px; line-height: 1.55; }
.carte-enonce p { margin: 0 0 6px; }
.carte-enonce p:last-child { margin-bottom: 0; }
.carte-figure {
  display: flex;
  justify-content: center;
  overflow-x: auto;
}
.carte-figure svg { max-width: 100%; height: auto; }
.carte-figure table { margin: 0 auto; }

@media (min-width: 640px) {
  .carte-corps.avec-figure {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 18px;
    align-items: center;
  }
  .carte-corps.avec-figure .carte-figure { grid-column: 2; grid-row: 1; }
  .carte-corps.avec-figure .carte-enonce { grid-column: 1; grid-row: 1; }
  .carte-corps.avec-figure .carte-options { grid-column: 1 / -1; }
}

.carte-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 2px;
}
@media (min-width: 560px) {
  .carte-options { grid-template-columns: 1fr 1fr; }
  .carte-options.options-larges { grid-template-columns: 1fr; }
}
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-family: Georgia, serif;
  font-size: 15px;
  background: white;
  border: 1.5px solid #d4d4d4;
  border-radius: 8px;
  padding: 9px 12px;
  min-height: 46px;
  cursor: pointer;
  color: #1a1a1a;
  transition: border-color 0.12s, background-color 0.12s;
}
.opt:hover { border-color: var(--bleu); background: #f7f7ff; }
.opt:disabled { cursor: default; }
.opt:disabled:hover { border-color: #d4d4d4; background: white; }
.opt-lettre {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: 1.4px solid #555;
  border-radius: 50%;
  font-size: 13px;
  font-style: italic;
  flex-shrink: 0;
}
.opt-texte { flex: 1 1 auto; }
.opt-texte table { display: inline-table; vertical-align: middle; }
.opt.choisie { border-color: var(--bleu); background: var(--bleu-clair); }
.opt.choisie .opt-lettre { background: var(--bleu); border-color: var(--bleu); color: white; font-style: normal; font-weight: bold; }
.opt.bonne { border-color: var(--vert); background: var(--vert-clair); }
.opt.bonne .opt-lettre { background: var(--vert); border-color: var(--vert); color: white; font-style: normal; font-weight: bold; }
.opt.fausse { border-color: var(--rouge); background: var(--rouge-clair); }
.opt.fausse .opt-lettre { background: var(--rouge); border-color: var(--rouge); color: white; font-style: normal; font-weight: bold; }
.opt.fausse .opt-texte { text-decoration: line-through; text-decoration-color: var(--rouge); }
.opt.bonne:disabled:hover { border-color: var(--vert); background: var(--vert-clair); }
.opt.fausse:disabled:hover { border-color: var(--rouge); background: var(--rouge-clair); }
.opt.choisie:disabled:hover { border-color: var(--bleu); background: var(--bleu-clair); }

.carte-retour {
  display: none;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.5;
  background: rgba(255,255,255,0.7);
}
.carte-retour.visible { display: block; }
.carte-retour .verdict { font-weight: bold; }
.carte.correct .verdict { color: var(--vert); }
.carte.incorrect .verdict { color: var(--rouge); }
.carte.sans-reponse .verdict { color: var(--orange); }
.carte-retour .explication { margin-top: 4px; color: #333; }
.explication-figure { margin-top: 8px; overflow-x: auto; }

/* ---------- Mode chrono ---------- */
.chrono-intro {
  background: var(--gris-clair);
  border-radius: 10px;
  padding: 22px 18px;
  text-align: center;
  margin-bottom: 14px;
}
.chrono-intro h2 { font-size: 18px; margin: 0 0 8px; }
.chrono-intro p { margin: 0 0 6px; font-size: 14px; color: #333; }
.chrono-intro .btn-principal { margin-top: 12px; width: auto; min-width: 220px; }
.chrono-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 14px;
}
.chrono-entete .position { font-weight: bold; }
.chrono-temps {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: bold;
  color: var(--bleu);
  min-width: 60px;
  text-align: right;
}
.chrono-temps.alerte { color: var(--rouge); }
#recap-temps.alerte { color: var(--rouge); }
.chrono-barre {
  height: 8px;
  background: #e5e5e5;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}
.chrono-remplissage {
  height: 100%;
  width: 100%;
  background: var(--bleu);
  border-radius: 4px;
  transition: width 0.25s linear, background-color 0.3s;
}
.chrono-remplissage.alerte { background: var(--rouge); }
.chrono-infini { font-size: 13px; color: var(--gris); font-style: italic; }
.progression {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.progression span {
  flex: 1 1 0;
  height: 6px;
  border-radius: 3px;
  background: #e5e5e5;
  min-width: 14px;
}
.progression span.faite { background: var(--bleu); }
.progression span.courante { background: var(--bleu-clair); border: 1px solid var(--bleu); }

/* ---------- Barre de contrôle et boutons ---------- */
.barre-controle {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 22px 0 10px;
}
.btn-principal, .btn-secondaire {
  font-size: 15px;
  cursor: pointer;
  font-family: Georgia, serif;
  border-radius: 8px;
  padding: 12px 18px;
  min-height: 46px;
  width: 100%;
}
.btn-principal { background: var(--bleu); color: white; border: none; }
.btn-principal:hover { background: #3a36a0; }
.btn-principal:disabled { background: #b9b8d6; cursor: default; }
.btn-secondaire { background: white; color: var(--bleu); border: 1.5px solid var(--bleu); }
.btn-secondaire:hover { background: var(--bleu-clair); }

.score-panneau {
  display: none;
  background: var(--gris-clair);
  border-radius: 8px;
  padding: 16px 14px;
  margin: 20px 0;
  font-size: 16px;
}
.score-panneau.visible { display: block; }
.score-chiffre { font-size: 26px; font-weight: bold; color: var(--bleu); }
.score-points { font-size: 14px; color: var(--gris); margin-top: 4px; }
.score-detail { font-size: 13.5px; color: #333; margin-top: 8px; }
.score-panneau .barre-controle { margin: 12px 0 0; }

/* ---------- Tableaux (tableaux croisés, tableaux de signes, séries) ---------- */
.tab-croise, .tab-signes, .tab-serie {
  border-collapse: collapse;
  font-size: 13.5px;
  font-family: Georgia, serif;
}
.tab-croise th, .tab-croise td,
.tab-serie th, .tab-serie td {
  border: 1px solid #333;
  padding: 4px 10px;
  text-align: center;
}
.tab-croise th { background: #fafafa; font-weight: normal; }
.tab-croise td.total, .tab-croise th.total { font-weight: bold; }
.tab-signes td, .tab-signes th { border: 1px solid #333; padding: 4px 8px; text-align: center; font-weight: normal; }
.tab-signes .ligne-x td { font-style: italic; background: #fafafa; }

/* ---------- Tablettes et plus ---------- */
@media (min-width: 600px) {
  body { padding: 24px 24px 60px; }
  h1 { font-size: 24px; }
  .badge { width: 52px; height: 52px; min-width: 52px; font-size: 22px; }
  .badge-sujet { font-size: 17px; }
  .filet { margin-left: 68px; }
  .barre-controle { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .btn-principal, .btn-secondaire { width: auto; }
  .mode-label { width: auto; margin-right: 4px; }
  .mode-btn { flex: 0 0 auto; }
}

/* ---------- Impression ---------- */
.carte { break-inside: avoid; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  @page { margin: 1.4cm; }
  body { padding: 0; max-width: 100%; }
  .barre-navigation, .mode-panneau, .bandeau-calculatrice, .barre-controle,
  .chrono-barre, .chrono-entete, .progression,
  .zoom-btn, .curseur-btn, .curseur-groupe, .modal-figure, .modal-devoir { display: none !important; }
  .opt { border-color: #999; }
}

/* Telephone (25/10/2026) : une reponse dont la formule est plus large que l'ecran elargissait la page (QCM Terminale, sujet blanc,
   debordement de 6 a 13 px selon le tirage, avant la refonte du telephone). Les cases de reponse peuvent retrecir et la formule se reduit a leur largeur. */
@media (max-width: 560px) {
  .carte-options { grid-template-columns: minmax(0, 1fr); }
  .opt { min-width: 0; }
  .opt-texte { min-width: 0; overflow-wrap: anywhere; }
  .opt-texte mjx-container > svg { max-width: 100%; height: auto; }
}

/* Réglages repliés (25/10/2026) : une ligne « Mode fiche · ★★ Niveau 2 — Changer » à la place des deux panneaux de mode et de niveau
   (choisis sur la page d'entrée, assets/reglages-entree.js). « Changer » rouvre les panneaux. */
.reglages-recap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border: 1.5px solid var(--bleu-clair);
  border-radius: 10px;
  padding: 0 6px 0 14px;
  margin-bottom: 8px;
  background: white;
}
.reglages-recap-texte { flex: 1 1 auto; font-size: 14px; font-weight: bold; color: var(--gris); }
.reglages-recap-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: none;
  color: var(--bleu);
  font-family: Georgia, serif;
  font-size: 14.5px;
  font-weight: bold;
  cursor: pointer;
}
.reglages-recap-btn:hover { text-decoration: underline; }
.reglages-recap-indice { font-size: 13px; font-style: italic; color: var(--gris); margin: 0 2px 12px; }
.reglages-reduire { text-align: right; margin: -6px 0 10px; }
