/* =========================================================================
   Mes tables de multiplication — Coloriage pédagogique
   styles.css : écran + impression A4 portrait (2 pages exactement),
   noir & blanc, contours nets.
   ========================================================================= */

/* ---------- 1. Variables & réglages de base ---------- */
:root {
  --encre: #000;
  --papier: #fff;
  --trait-epais: 3px;
  --trait-fin: 2px;
  --rayon: 12px;
  --police-titre: "Baloo 2", "Comic Sans MS", cursive, sans-serif;
  --police-texte: "Nunito", "Segoe UI", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #ececec; /* écran uniquement : le fond gris fait ressortir la feuille */
  color: var(--encre);
  font-family: var(--police-texte);
  font-size: 15px;
  line-height: 1.4;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------- 2. La « feuille » A4 à l'écran ---------- */
.feuille {
  max-width: 210mm;
  margin: 72px auto 40px;
  padding: 12mm 11mm;
  background: var(--papier);
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.18);
}

/* ---------- 3. Barre d'outils (écran uniquement) ---------- */
.toolbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--encre);
  color: var(--papier);
}

.toolbar__progress {
  margin: 0;
  font-weight: 700;
}

.toolbar__actions {
  display: flex;
  gap: 10px;
}

.btn {
  font: 700 14px/1 var(--police-texte);
  padding: 9px 16px;
  border: 2px solid var(--papier);
  border-radius: 999px;
  background: var(--papier);
  color: var(--encre);
  cursor: pointer;
}

.btn--ghost {
  background: transparent;
  color: var(--papier);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible,
.etoile-btn:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

/* ---------- 4. En-tête de la feuille ---------- */
.entete {
  text-align: center;
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  padding: 8px 14px 12px;
  margin-bottom: 6mm;
}

.entete__eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.entete__titre {
  margin: 0;
  font-family: var(--police-titre);
  font-size: 36px;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  /* Titre en lettres « à colorier » : contour noir, intérieur blanc */
  color: var(--papier);
  -webkit-text-stroke: 2px var(--encre);
  paint-order: stroke fill;
}

.entete__regle {
  max-width: 70ch;
  margin: 6px auto 8px;
  font-size: 13.5px;
}

.entete__identite {
  display: flex;
  gap: 24px;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.ligne-ecriture {
  min-width: 200px;
  text-align: left;
  border-bottom: 2px dotted var(--encre);
  padding-bottom: 2px;
}

/* ---------- 5. Grille des dix tables ---------- */
.tables {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4mm;
}

.carte-table {
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  padding: 6px 10px 8px;
  break-inside: avoid;
  page-break-inside: avoid;
}

/* Rangée des 5 étoiles au-dessus de chaque table */
.rangee-etoiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 2px;
}

.etoile-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
}

.etoile-btn svg {
  width: 100%;
  height: 100%;
  fill: #fff; /* étoile vide, prête à colorier */
}

/* État « coloriée » : remplissage hachuré noir & blanc (hérité par le tracé) */
.etoile-btn.est-coloriee svg,
.etoile-btn[aria-pressed="true"] svg {
  fill: url(#hachures);
}

.carte-table__titre {
  margin: 0 0 4px;
  text-align: center;
  font-family: var(--police-titre);
  font-size: 18px;
  text-transform: uppercase;
  border-bottom: var(--trait-fin) dashed var(--encre);
  padding-bottom: 3px;
}

/* Les 10 opérations sur 2 mini-colonnes : 1–5 à gauche, 6–10 à droite */
.carte-table ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(5, auto);
  grid-template-columns: 1fr 1fr;
  column-gap: 10px;
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.carte-table li {
  display: grid;
  grid-template-columns: 1fr auto 1.1fr;
  column-gap: 5px;
  padding: 1px 2px;
  border-bottom: 1px dotted rgb(0 0 0 / 0.35);
}

.carte-table li:nth-child(5n) {
  border-bottom: 0;
}

.operation {
  text-align: right;
}

.egal {
  text-align: center;
}

.resultat {
  text-align: left;
}

/* ---------- 6. Section techniques de calcul mental ---------- */
.section-titre {
  margin: 0 0 4px;
  text-align: center;
  font-family: var(--police-titre);
  font-size: 28px;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--papier);
  -webkit-text-stroke: 2px var(--encre);
  paint-order: stroke fill;
}

.methodes {
  margin-top: 8mm;
}

.methodes__intro {
  max-width: 72ch;
  margin: 0 auto 5mm;
  text-align: center;
  font-size: 13.5px;
}

.astuces {
  list-style: none;
  counter-reset: astuce;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3.5mm;
  margin: 0;
  padding: 0;
}

.astuce {
  counter-increment: astuce;
  position: relative;
  border: var(--trait-fin) solid var(--encre);
  border-radius: var(--rayon);
  padding: 8px 34px 8px 42px;
  break-inside: avoid;
  page-break-inside: avoid;
}

/* Numéro dans une pastille à colorier */
.astuce::before {
  content: counter(astuce);
  position: absolute;
  top: 9px;
  left: 9px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: var(--trait-fin) solid var(--encre);
  border-radius: 50%;
  font-family: var(--police-titre);
  font-size: 14px;
}

.astuce h3 {
  margin: 0 0 2px;
  font-family: var(--police-titre);
  font-size: 15px;
}

.astuce p {
  margin: 0;
  font-size: 12.5px;
}

/* Case « j'ai essayé » à cocher au crayon */
.astuce__case {
  position: absolute;
  top: 11px;
  right: 11px;
  width: 15px;
  height: 15px;
  border: var(--trait-fin) solid var(--encre);
  border-radius: 3px;
}

/* ---------- 7. Commutativité + mascotte, côte à côte ---------- */
.commutativite {
  margin-top: 7mm;
  text-align: center;
}

.commutativite__consigne {
  max-width: 68ch;
  margin: 3px auto 4mm;
  font-size: 13.5px;
}

.duo-figures {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 4mm;
  align-items: stretch;
}

.commutativite__figure,
.mascotte {
  margin: 0;
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  break-inside: avoid;
  page-break-inside: avoid;
}

.commutativite__figure svg,
.mascotte svg {
  width: 100%;
  height: auto;
  max-height: 62mm;
}

figcaption {
  font-size: 11.5px;
  font-style: italic;
  margin-top: 3px;
}

.svg-legende {
  font: 800 26px var(--police-titre);
  fill: var(--encre);
}

.svg-pancarte {
  font: 800 20px var(--police-titre);
  fill: var(--encre);
}

/* ---------- 8. Pied de page ---------- */
.pied {
  margin-top: 5mm;
  padding-top: 3mm;
  border-top: var(--trait-fin) dashed var(--encre);
  text-align: center;
  font-weight: 700;
  font-size: 12.5px;
}

.pied p {
  margin: 0;
}

.noscript-info {
  border: var(--trait-fin) dashed var(--encre);
  border-radius: var(--rayon);
  padding: 12px;
  text-align: center;
}

/* ---------- 9. Accessibilité & mouvement ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
  .btn:hover {
    transform: none;
  }
}

/* ---------- 10. Écrans étroits (consultation sur téléphone) ---------- */
@media (max-width: 640px) {
  .feuille {
    margin-top: 96px;
    padding: 16px 12px;
  }
  .tables,
  .astuces,
  .duo-figures {
    grid-template-columns: 1fr;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .entete__titre {
    font-size: 26px;
  }
  .entete__identite {
    flex-direction: column;
    gap: 10px;
  }
}

/* =========================================================================
   11. IMPRESSION — A4 portrait, EXACTEMENT 2 PAGES
   Page 1 : en-tête + les 10 tables (2 colonnes × 5 rangées)
   Page 2 : les 10 techniques + commutativité + mascotte + pied de page
   ========================================================================= */
@page {
  size: A4 portrait;
  margin: 9mm 10mm;
}

@media print {
  body {
    background: var(--papier);
    font-size: 12.5px;
    line-height: 1.32;
  }

  .toolbar,
  .noscript-info {
    display: none !important;
  }

  .feuille {
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  /* --- Page 1 : en-tête compact --- */
  .entete {
    padding: 7px 12px 10px;
    margin-bottom: 4.5mm;
  }

  .entete__eyebrow {
    font-size: 10px;
    margin-bottom: 1px;
  }

  .entete__titre {
    font-size: 28px;
    -webkit-text-stroke-width: 1.8px;
  }

  .entete__regle {
    font-size: 11.5px;
    margin: 4px auto 6px;
  }

  .entete__identite {
    font-size: 12.5px;
    gap: 22px;
  }

  .ligne-ecriture {
    min-width: 190px;
  }

  /* --- Page 1 : tables serrées --- */
  .tables {
    gap: 3.6mm;
  }

  .carte-table {
    border-width: 2.5px;
    padding: 5px 10px 7px;
  }

  .rangee-etoiles {
    gap: 6px;
    margin-bottom: 2px;
  }

  .etoile-btn {
    width: 24px;
    height: 24px;
  }

  .carte-table__titre {
    font-size: 16px;
    margin-bottom: 3px;
    padding-bottom: 3px;
  }

  .carte-table ol {
    font-size: 12px;
  }

  .carte-table li {
    padding: 1.5px 2px;
  }

  /* --- Page 2 commence ici --- */
  .saut-de-page {
    break-before: page;
    page-break-before: always;
    margin-top: 0;
  }

  .section-titre {
    font-size: 25px;
    -webkit-text-stroke-width: 1.7px;
  }

  .methodes__intro {
    font-size: 11.5px;
    margin-bottom: 4mm;
  }

  .astuces {
    gap: 3.2mm;
  }

  .astuce {
    padding: 7px 32px 7px 40px;
  }

  .astuce::before {
    width: 23px;
    height: 23px;
    top: 8px;
    left: 9px;
    font-size: 13px;
  }

  .astuce h3 {
    font-size: 13.5px;
  }

  .astuce p {
    font-size: 11px;
  }

  .astuce__case {
    width: 14px;
    height: 14px;
    top: 10px;
    right: 10px;
  }

  .commutativite {
    margin-top: 5mm;
  }

  .commutativite__consigne {
    font-size: 11.5px;
    margin-bottom: 3.5mm;
  }

  .duo-figures {
    gap: 3mm;
  }

  .commutativite__figure svg,
  .mascotte svg {
    max-height: 66mm;
  }

  figcaption {
    font-size: 10px;
    margin-top: 3px;
  }

  .pied {
    margin-top: 4mm;
    padding-top: 2.5mm;
    font-size: 11px;
  }

  /* Aucun cadre coupé entre deux pages */
  .carte-table,
  .astuce,
  .commutativite__figure,
  .mascotte,
  .entete,
  .duo-figures,
  .pied {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  a {
    color: var(--encre);
    text-decoration: none;
  }
}

/* =========================================================================
   12. COMPOSANTS PARTAGÉS DE LA COLLECTION « Colorier pour comprendre »
   ========================================================================= */

/* Lien retour dans la barre d'outils */
.toolbar__retour {
  text-decoration: none;
  white-space: nowrap;
}

/* Grille générique à 2 colonnes (mêmes réglages que .tables) */
.grille-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4mm;
}

/* Cadre-exemple mis en valeur (phrase, formule, schéma…) */
.encadre-exemple {
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  padding: 10px 14px;
  margin: 0 0 5mm;
  text-align: center;
  break-inside: avoid;
  page-break-inside: avoid;
}

.encadre-exemple--grand {
  font-size: 19px;
  font-weight: 800;
}

/* Boîtes de mots à colorier (grammaire) : trois contours différents
   pour rester lisibles même sans couleur */
.boite-mot {
  display: inline-block;
  padding: 3px 10px;
  margin: 2px 3px;
  border-radius: 8px;
  font-weight: 800;
}

.boite-sujet {
  border: 3px solid var(--encre);
}

.boite-verbe {
  border: 4px double var(--encre);
  border-width: 5px;
}

.boite-complement {
  border: 3px dashed var(--encre);
}

.legende-codes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
}

/* Frise chronologique (histoire) */
.frise {
  display: flex;
  gap: 0;
  margin: 0 0 4mm;
  break-inside: avoid;
  page-break-inside: avoid;
}

.frise__periode {
  flex: 1;
  border: var(--trait-fin) solid var(--encre);
  margin-left: -2px;
  padding: 6px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.frise__periode:first-child {
  border-radius: 10px 0 0 10px;
  margin-left: 0;
}

.frise__periode:last-child {
  border-radius: 0 10px 10px 0;
}

.frise__periode strong {
  display: block;
  font-family: var(--police-titre);
  font-size: 12.5px;
}

/* Escalier des conversions (mesures) */
.escalier {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 420px;
  text-align: left;
}

.escalier li {
  border: var(--trait-fin) solid var(--encre);
  border-radius: 8px;
  padding: 3px 12px;
  margin-bottom: 3px;
  font-weight: 800;
  background: var(--papier);
}

.escalier li span {
  font-weight: 400;
  font-size: 12px;
}

/* Figure encadrée générique (schémas SVG à colorier) */
.figure-cadre {
  margin: 0;
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  break-inside: avoid;
  page-break-inside: avoid;
}

.figure-cadre svg {
  width: 100%;
  height: auto;
  max-height: 62mm;
}

/* ---------- Page maîtresse (sommaire de la collection) ---------- */
.hub {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4mm;
}

.hub-carte {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  padding: 10px 10px 12px;
  text-align: center;
  color: var(--encre);
  text-decoration: none;
  break-inside: avoid;
  page-break-inside: avoid;
}

.hub-carte:hover {
  box-shadow: 4px 4px 0 var(--encre);
}

.hub-carte:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

.hub-carte svg {
  width: 58px;
  height: 58px;
}

.hub-carte h2 {
  margin: 0;
  font-family: var(--police-titre);
  font-size: 16px;
  line-height: 1.1;
  text-transform: uppercase;
}

.hub-carte p {
  margin: 0;
  font-size: 11.5px;
}

/* Badge « fiche terminée » à colorier, en haut à droite de chaque carte */
.hub-carte .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border: var(--trait-fin) solid var(--encre);
  border-radius: 50%;
}

.hub-mode-emploi {
  border: var(--trait-fin) dashed var(--encre);
  border-radius: var(--rayon);
  padding: 10px 14px;
  margin: 6mm 0 0;
  font-size: 13px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.hub-mode-emploi h2 {
  margin: 0 0 4px;
  font-family: var(--police-titre);
  font-size: 17px;
  text-transform: uppercase;
}

.hub-mode-emploi ol {
  margin: 0;
  padding-left: 20px;
}

/* ---------- Réactivité des nouveaux composants ---------- */
@media (max-width: 640px) {
  .grille-2,
  .hub {
    grid-template-columns: 1fr;
  }
  .frise {
    flex-direction: column;
  }
  .frise__periode {
    margin-left: 0;
    margin-top: -2px;
    border-radius: 0;
  }
  .frise__periode:first-child {
    border-radius: 10px 10px 0 0;
    margin-top: 0;
  }
  .frise__periode:last-child {
    border-radius: 0 0 10px 10px;
  }
}

/* ---------- Impression des nouveaux composants ---------- */
@media print {
  .grille-2 {
    gap: 3mm;
  }

  .hub {
    gap: 3mm;
  }

  .hub-carte:hover {
    box-shadow: none;
  }

  .encadre-exemple {
    padding: 7px 10px;
    margin-bottom: 3.5mm;
  }

  .encadre-exemple--grand {
    font-size: 15px;
  }

  .legende-codes {
    font-size: 10.5px;
  }

  .frise__periode {
    font-size: 9px;
    padding: 4px 3px;
  }

  .frise__periode strong {
    font-size: 10px;
  }

  .escalier li {
    padding: 2px 10px;
    font-size: 11px;
  }

  .escalier li span {
    font-size: 9.5px;
  }

  .figure-cadre svg {
    max-height: 52mm;
  }

  .hub-carte h2 {
    font-size: 13.5px;
  }

  .hub-carte p {
    font-size: 9.5px;
  }

  .hub-carte svg {
    width: 46px;
    height: 46px;
  }

  .encadre-exemple,
  .figure-cadre,
  .hub-carte,
  .hub-mode-emploi,
  .frise {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* =========================================================================
   13. IMAGES À COLORIER (générées par IA ou dessinées à la main)
   ========================================================================= */

/* Corps de carte : texte à gauche, image à colorier à droite */
.carte-corps {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 10px;
  align-items: start;
}

.carte-texte > p:first-child {
  margin-top: 0;
}

.carte-texte > p:last-child {
  margin-bottom: 0;
}

.image-coloriage {
  position: relative;
  margin: 0;
}

.image-coloriage__zone {
  aspect-ratio: 1 / 1;
  border: var(--trait-fin) dashed var(--encre);
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--papier);
}

.image-coloriage.a-une-image .image-coloriage__zone {
  border-style: solid;
}

.image-coloriage__attente {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.3;
  padding: 4px;
}

.image-coloriage__attente em {
  font-weight: 400;
}

.image-coloriage__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Double sécurité : même une image imparfaite ressort en noir & blanc net */
  filter: grayscale(1) contrast(1.15);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Bouton régénérer (écran uniquement) */
.image-coloriage__regen {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border: 2px solid var(--encre);
  border-radius: 50%;
  background: var(--papier);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.image-coloriage:hover .image-coloriage__regen,
.image-coloriage__regen:focus-visible {
  opacity: 1;
}

.image-coloriage.en-cours .image-coloriage__zone {
  animation: pulsation 1s ease-in-out infinite;
}

@keyframes pulsation {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- Panneau de génération IA (écran uniquement) ---------- */
.panneau-ia {
  max-width: 210mm;
  margin: 66px auto -46px;
  padding: 14px 18px;
  background: var(--papier);
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.18);
}

.panneau-ia h2 {
  margin: 0 0 4px;
  font-family: var(--police-titre);
  font-size: 19px;
  text-transform: uppercase;
}

.panneau-ia p {
  margin: 0 0 8px;
  font-size: 13.5px;
}

.panneau-ia a {
  color: var(--encre);
  font-weight: 800;
}

.panneau-ia__ligne {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.panneau-ia__ligne label {
  font-weight: 800;
  font-size: 13.5px;
}

.panneau-ia__ligne input {
  flex: 1;
  min-width: 200px;
  font: 700 14px/1 var(--police-texte);
  padding: 9px 12px;
  border: 2px solid var(--encre);
  border-radius: 999px;
}

.panneau-ia__ligne input:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

.panneau-ia__ligne .btn {
  border-color: var(--encre);
}

.panneau-ia__ligne .btn--ghost {
  color: var(--encre);
}

.panneau-ia__note {
  font-size: 11.5px;
  font-style: italic;
}

.panneau-ia__statut {
  min-height: 1.2em;
  font-weight: 800;
  font-size: 13px;
}

@media (max-width: 640px) {
  .panneau-ia {
    margin-top: 150px;
    margin-left: 10px;
    margin-right: 10px;
  }
  .carte-corps {
    grid-template-columns: 1fr 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-coloriage.en-cours .image-coloriage__zone {
    animation: none;
    opacity: 0.5;
  }
}

/* ---------- Impression des images à colorier ---------- */
@media print {
  .panneau-ia,
  .image-coloriage__regen {
    display: none !important;
  }

  .carte-corps {
    grid-template-columns: 1fr 25mm;
    gap: 2.5mm;
  }

  .image-coloriage__zone {
    border-radius: 6px;
  }

  .image-coloriage__attente {
    font-size: 7.5px;
  }

  .image-coloriage__img {
    filter: grayscale(1) contrast(1.2);
  }

  .image-coloriage,
  .carte-corps {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* =========================================================================
   14. ÉCHELLE D'IMPRESSION DES FICHES ILLUSTRÉES (6 cadres + images)
   Ces fiches ont moins de cadres que la fiche multiplication : on agrandit
   tout pour remplir harmonieusement les 2 pages A4.
   ========================================================================= */
@media print {
  body.fiche-illustree {
    font-size: 13.5px;
  }

  .fiche-illustree .entete {
    padding: 8px 14px 12px;
    margin-bottom: 5mm;
  }

  .fiche-illustree .entete__titre {
    font-size: 31px;
  }

  .fiche-illustree .entete__regle {
    font-size: 12px;
    max-width: 78ch;
  }

  .fiche-illustree .entete__identite {
    font-size: 13px;
  }

  .fiche-illustree .grille-2 {
    gap: 4mm;
  }

  .fiche-illustree .carte-table {
    padding: 6px 11px 9px;
  }

  .fiche-illustree .etoile-btn {
    width: 27px;
    height: 27px;
  }

  .fiche-illustree .rangee-etoiles {
    gap: 7px;
  }

  .fiche-illustree .carte-table__titre {
    font-size: 16.5px;
    margin-bottom: 4px;
  }

  .fiche-illustree .carte-corps {
    grid-template-columns: 1fr 33mm;
    gap: 3.5mm;
  }

  .fiche-illustree .section-titre {
    font-size: 26px;
  }

  .fiche-illustree .methodes__intro,
  .fiche-illustree .commutativite__consigne {
    font-size: 12px;
  }

  .fiche-illustree .astuces {
    gap: 3.4mm;
  }

  .fiche-illustree .astuce {
    padding: 8px 34px 8px 42px;
  }

  .fiche-illustree .astuce h3 {
    font-size: 14.5px;
  }

  .fiche-illustree .astuce p {
    font-size: 11.5px;
  }

  .fiche-illustree .astuce::before {
    width: 25px;
    height: 25px;
    font-size: 14px;
  }

  .fiche-illustree .astuce__case {
    width: 15px;
    height: 15px;
  }

  .fiche-illustree .figure-cadre svg {
    max-height: 60mm;
  }

  .fiche-illustree figcaption {
    font-size: 10.5px;
  }

  .fiche-illustree .encadre-exemple--grand {
    font-size: 16.5px;
  }

  .fiche-illustree .legende-codes {
    font-size: 11.5px;
  }

  .fiche-illustree .frise__periode {
    font-size: 10px;
    padding: 5px 3px;
  }

  .fiche-illustree .frise__periode strong {
    font-size: 11px;
  }

  .fiche-illustree .escalier li {
    padding: 3px 12px;
    font-size: 12px;
  }

  .fiche-illustree .pied {
    font-size: 11.5px;
  }
}

/* =========================================================================
   15. AUDIT VISUEL — Images plus grandes, formats paysage & bandeau,
   consignes de coloriage sous chaque image
   ========================================================================= */

/* Images de carte agrandies */
.carte-corps {
  grid-template-columns: 1fr 150px;
}

/* Consigne de coloriage (avec les couleurs) sous chaque image */
.image-coloriage__consigne {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  font-style: italic;
}

.image-coloriage__consigne strong {
  font-style: normal;
}

/* Zones au format paysage (4:3) et bandeau (8:3) */
.image-coloriage--paysage .image-coloriage__zone {
  aspect-ratio: 4 / 3;
}

.image-coloriage--bandeau .image-coloriage__zone {
  aspect-ratio: 8 / 3;
  width: 100%;
}

/* Le schéma SVG dessiné sert de version « en attente » : centré, à l'échelle */
.image-coloriage__zone--attente-svg svg {
  max-width: 100%;
  max-height: 100%;
  height: 100%;
  width: auto;
}

/* La planche illustrable a DEUX états, et deux géométries.

   Tant qu'aucune image n'est arrivée, c'est le schéma SVG de secours qui
   s'imprime : il impose alors SA hauteur. Le rogner au format demandé
   couperait la tête du bonhomme ou la moitié d'une frise — un schéma
   faux est pire que pas de schéma.

   Dès qu'une image existe, le format demandé (data-format) reprend la
   main : c'est lui qui a servi à la commander au modèle. */
.planche__cadre.image-coloriage:not(.a-une-image) .image-coloriage__zone {
  aspect-ratio: auto;
  overflow: visible;
}

.planche__cadre.image-coloriage:not(.a-une-image) .image-coloriage__zone svg {
  width: 100%;
  height: auto;
  max-height: none;
  padding: 6px;
}

/* Les grandes scènes remplacent l'ancien duo : cadre pleine largeur */
.figure-cadre.image-coloriage--bandeau {
  width: 100%;
}

/* La mascotte multiplication garde une largeur raisonnable */
.mascotte.image-coloriage--paysage {
  max-width: 128mm;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 640px) {
  .carte-corps {
    grid-template-columns: 1fr 120px;
  }
}

/* ---------- Impression ---------- */
@media print {
  .fiche-illustree .carte-corps {
    grid-template-columns: 1fr 38mm;
    gap: 3mm;
  }

  .image-coloriage__consigne {
    font-size: 9px;
    margin-top: 2px;
  }

  .image-coloriage--bandeau .image-coloriage__zone {
    aspect-ratio: 8 / 3;
    max-height: none;
  }

  .fiche-illustree .figure-cadre.image-coloriage--bandeau svg {
    max-height: 100%;
  }

  .mascotte.image-coloriage--paysage {
    max-width: 96mm;
  }

  .image-coloriage--paysage .image-coloriage__zone svg {
    max-height: 100%;
  }
}

/* ---------- Ajustement spécifique : la fiche grammaire a un bloc
   d'exemple en plus, on resserre légèrement pour tenir sur 2 pages ---------- */
@media print {
  body[data-page="grammaire"] .carte-corps {
    grid-template-columns: 1fr 31mm;
  }

  body[data-page="grammaire"] .entete {
    margin-bottom: 3.5mm;
    padding-bottom: 8px;
  }

  body[data-page="grammaire"] .entete__regle {
    font-size: 11px;
    margin-bottom: 4px;
  }

  body[data-page="grammaire"] .encadre-exemple {
    padding: 5px 8px;
    margin-bottom: 3mm;
  }

  body[data-page="grammaire"] .encadre-exemple--grand {
    font-size: 14.5px;
  }

  body[data-page="grammaire"] .legende-codes {
    font-size: 10.5px;
  }

  body[data-page="grammaire"] .grille-2 {
    gap: 3.2mm;
  }

  body[data-page="grammaire"] .carte-table {
    padding: 4px 10px 7px;
  }

  body[data-page="grammaire"] .carte-table__titre {
    font-size: 15px;
    margin-bottom: 3px;
  }

  body[data-page="grammaire"] .etoile-btn {
    width: 23px;
    height: 23px;
  }

  body[data-page="grammaire"] .image-coloriage__consigne {
    font-size: 8.5px;
  }

  body[data-page="grammaire"] .astuce p {
    font-size: 11px;
  }
}

/* =========================================================================
   16. ÉLASTICITÉ — Champ mascotte personnalisée, générateur de fiches,
   listes clés / mini-cartes, atelier livre KDP
   ========================================================================= */

/* Champ libre sous la mascotte (écran uniquement) */
.perso-champ {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.perso-champ input {
  flex: 1;
  min-width: 0;
  font: 700 13px/1.2 var(--police-texte);
  padding: 8px 12px;
  border: 2px solid var(--encre);
  border-radius: 999px;
}

.perso-champ input:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

.perso-champ__btn {
  border-color: var(--encre);
  white-space: nowrap;
}

/* Ligne « fiche sur mesure » du panneau */
.panneau-ia__ligne--generateur {
  padding-top: 8px;
  border-top: 2px dashed var(--encre);
}

.panneau-ia__note--generateur {
  font-style: normal;
}

/* Liste des 10 dates / infos clés (fiches générées) */
.liste-cles {
  list-style: none;
  counter-reset: cle;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2.5mm 4mm;
  margin: 0;
  padding: 0;
}

.liste-cles li {
  counter-increment: cle;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 8px;
  border: var(--trait-fin) solid var(--encre);
  border-radius: 10px;
  padding: 6px 10px 6px 34px;
  position: relative;
  font-size: 13px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.liste-cles li::before {
  content: counter(cle);
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: var(--trait-fin) solid var(--encre);
  border-radius: 50%;
  font-family: var(--police-titre);
  font-size: 12px;
}

.liste-cles strong {
  font-family: var(--police-titre);
  white-space: nowrap;
}

/* Mini-cartes des personnages / symboles (fiches générées) */
.mini-cartes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3mm;
}

.mini-carte {
  border: var(--trait-fin) solid var(--encre);
  border-radius: var(--rayon);
  padding: 8px 12px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.mini-carte h3 {
  margin: 0 0 2px;
  font-family: var(--police-titre);
  font-size: 15px;
}

.mini-carte p {
  margin: 0;
  font-size: 12.5px;
}

/* ---------- Atelier livre (écran) ---------- */
.panneau-ia--livre {
  margin-bottom: 24px;
}

.feuille--livre {
  margin-top: 24px;
}

.livre-vide {
  text-align: center;
  padding: 24px 12px;
}

.livre-vide p {
  max-width: 66ch;
  margin: 8px auto;
}

.livre-page {
  border: var(--trait-epais) solid var(--encre);
  border-radius: var(--rayon);
  padding: 8mm;
  margin-bottom: 8mm;
  display: flex;
  flex-direction: column;
  min-height: 120mm;
}

.livre-page__entete {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4mm;
}

.livre-page__numero {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: var(--trait-fin) solid var(--encre);
  border-radius: 50%;
  font-family: var(--police-titre);
  font-size: 15px;
}

.livre-page__titre {
  margin: 0;
  font-family: var(--police-titre);
  font-size: 22px;
  text-transform: uppercase;
}

.image-coloriage--livre {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.image-coloriage--livre .image-coloriage__zone {
  aspect-ratio: 17 / 22;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
}

.image-coloriage--livre .image-coloriage__img {
  object-fit: contain;
}

.image-coloriage--livre .image-coloriage__consigne {
  font-size: 13px;
  margin-top: 3mm;
}

/* Couverture, page de garde, fin */
.livre-couverture,
.livre-garde,
.livre-fin {
  text-align: center;
  justify-content: center;
  gap: 6mm;
}

.livre-couverture__eyebrow {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 13px;
}

.livre-couverture__titre {
  margin: 0;
  font-family: var(--police-titre);
  font-size: 44px;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--papier);
  -webkit-text-stroke: 2.5px var(--encre);
  paint-order: stroke fill;
}

.livre-couverture__soustitre {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.livre-couverture__cadre {
  flex: 1;
  min-height: 40mm;
  border: 3px dashed var(--encre);
  border-radius: var(--rayon);
}

.livre-couverture__auteur {
  margin: 0;
  font-family: var(--police-titre);
  font-size: 20px;
}

.livre-garde__dedicace {
  font-size: 16px;
  font-style: italic;
}

.livre-garde__appartient {
  font-family: var(--police-titre);
  font-size: 20px;
  margin-bottom: 0;
}

.livre-garde__ligne {
  display: block;
  max-width: 70%;
  margin: 0 auto;
}

.livre-garde__copyright {
  margin-top: auto;
  font-size: 11px;
}

.livre-fin__bravo {
  margin: 0;
  font-family: var(--police-titre);
  font-size: 34px;
  text-transform: uppercase;
  color: var(--papier);
  -webkit-text-stroke: 2px var(--encre);
  paint-order: stroke fill;
}

.livre-fin__dos {
  max-width: 60ch;
  margin: 0 auto;
  font-size: 15px;
}

.livre-fin__note {
  font-size: 12px;
  font-style: italic;
}

.livre-aide {
  border: var(--trait-fin) dashed var(--encre);
  border-radius: var(--rayon);
  padding: 12px 16px;
  margin-top: 4mm;
}

.livre-aide h2 {
  margin: 0 0 6px;
  font-family: var(--police-titre);
  font-size: 18px;
  text-transform: uppercase;
}

.livre-aide ol {
  margin: 0;
  padding-left: 20px;
}

.livre-aide li {
  margin-bottom: 4px;
}

/* ---------- Impression des nouveaux éléments ---------- */
@media print {
  .perso-champ,
  .livre-vide,
  .livre-aide {
    display: none !important;
  }

  .fiche-illustree .liste-cles {
    gap: 2.2mm 3mm;
  }

  .fiche-illustree .liste-cles li {
    font-size: 11px;
    padding: 4px 8px 4px 30px;
  }

  .fiche-illustree .mini-carte h3 {
    font-size: 13px;
  }

  .fiche-illustree .mini-carte p {
    font-size: 10.5px;
  }

  /* Chaque .livre-page = une vraie page 8,5 × 11 */
  body[data-page="livre"] .feuille {
    margin: 0;
    padding: 0;
  }

  .livre-page {
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    height: 9.85in;
    min-height: 0;
    break-after: page;
    page-break-after: always;
  }

  .livre-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .image-coloriage--livre .image-coloriage__zone {
    aspect-ratio: auto;
    width: 100%;
    border-width: 3px;
  }

  .image-coloriage--livre .image-coloriage__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .livre-page__titre {
    font-size: 19px;
  }

  .livre-couverture__titre {
    font-size: 40px;
  }
}

/* =========================================================================
   17. GRANDES IMAGES — Image en pleine largeur de carte (empilée sous le
   texte), cartes héros pleine page, défis, pagination libre sans troncature
   ========================================================================= */

/* Le corps de carte s'empile : texte, puis image pleine largeur, puis défi */
.carte-corps {
  display: block;
}

.carte-corps .carte-texte {
  margin-bottom: 8px;
}

.carte-corps .image-coloriage {
  width: 100%;
}

/* Formats d'image dans les cartes */
.carte-table .image-coloriage[data-format="paysage"] .image-coloriage__zone {
  aspect-ratio: 4 / 3;
}

.carte-table .image-coloriage[data-format="bandeau"] .image-coloriage__zone {
  aspect-ratio: 8 / 3;
}

/* Carte héros : occupe toute la largeur de la grille */
.carte-table--pleine {
  grid-column: 1 / -1;
}

.carte-table--pleine .carte-texte {
  max-width: 76ch;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* Défi + ligne de réponse au crayon */
.carte-defi {
  margin: 8px 0 2px;
  font-size: 13px;
  border-top: 2px dashed var(--encre);
  padding-top: 6px;
}

.carte-defi strong {
  font-family: var(--police-titre);
}

.ligne-reponse {
  display: block;
  height: 0;
  border-bottom: 2px dotted var(--encre);
  margin: 12px 4px 2px;
}

.image-coloriage__consigne {
  font-size: 12px;
}

@media (max-width: 640px) {
  .carte-corps {
    display: block;
  }
}

/* ---------- Impression : pagination libre, zéro troncature ---------- */
@media print {
  /* Les fiches illustrées ne sont plus limitées à 2 pages : les sections
     s'enchaînent naturellement, chaque bloc reste entier */
  body.fiche-illustree .saut-de-page {
    break-before: auto;
    page-break-before: auto;
  }

  .fiche-illustree .methodes {
    margin-top: 6mm;
  }

  .fiche-illustree .carte-corps {
    display: block;
  }

  .fiche-illustree .carte-corps .carte-texte {
    margin-bottom: 2.5mm;
  }

  .fiche-illustree .carte-table .image-coloriage[data-format="paysage"] .image-coloriage__zone {
    aspect-ratio: 4 / 3;
    width: 100%;
  }

  .fiche-illustree .carte-table .image-coloriage[data-format="bandeau"] .image-coloriage__zone {
    aspect-ratio: 8 / 3;
    width: 100%;
  }

  .carte-defi {
    font-size: 11px;
    padding-top: 4px;
    margin-top: 6px;
  }

  .ligne-reponse {
    margin-top: 10px;
  }

  .fiche-illustree .image-coloriage__consigne {
    font-size: 10px;
  }

  /* Zéro troncature : tout bloc de contenu reste entier sur une page */
  .carte-table,
  .carte-table--pleine,
  .astuce,
  .figure-cadre,
  .encadre-exemple,
  .liste-cles li,
  .mini-carte,
  .frise {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ---------- Densité : le format paysage passe en 16:9 ---------- */
.carte-table .image-coloriage[data-format="paysage"] .image-coloriage__zone,
.image-coloriage--paysage .image-coloriage__zone {
  aspect-ratio: 16 / 9;
}

@media print {
  .fiche-illustree .carte-table .image-coloriage[data-format="paysage"] .image-coloriage__zone,
  .image-coloriage--paysage .image-coloriage__zone {
    aspect-ratio: 16 / 9;
  }
}

/* ---------- Les titres de section restent collés à leur contenu ---------- */
@media print {
  .section-titre,
  .methodes__intro,
  .commutativite__consigne {
    break-after: avoid;
    page-break-after: avoid;
  }
}
