/* app.css — la fabrique de fiches. Un outil d'adulte, sur grand écran : les
   réglages à gauche, la page telle qu'elle sortira de l'imprimante à droite.
   À l'impression, tout disparaît sauf la feuille. */

@font-face {
  font-family: 'JLJECursive';
  src: url('../fonts/JLJECursive.woff2') format('woff2');
  font-display: block;
}

:root {
  --fond-appli: #F2F3EF;
  --papier: #FFFFFF;
  --texte: #212121;
  --texte-doux: #6B6F72;
  --bordure: #D6D9D2;
  --appui: #E4E7E0;
  --principal: #37474F;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--fond-appli);
  color: var(--texte);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.barre-haut {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 6px 18px;
  flex-shrink: 0;
}

.barre-haut h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
}

.infos-appli {
  display: flex;
  align-items: center;
  margin-left: auto;
  font-size: 13px;
  color: var(--texte-doux);
}

.etat-hors-ligne {
  margin-right: 14px;
  font-weight: 600;
}

.etat-hors-ligne[hidden] {
  display: none;
}

.etat-hors-ligne.ok { color: #2E7D32; }
.etat-hors-ligne.alerte { color: #B26A00; }

.corps {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 18px;
  padding: 0 18px 18px;
}

/* ── Les réglages ─────────────────────────────────────────────────────────── */

.reglages {
  width: 300px;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px;
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 14px;
}

.reglages h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--texte-doux);
}

.grille-lettres {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
}

.grille-lettres button {
  width: 38px;
  height: 46px;
  padding: 0;
  font-family: 'JLJECursive', serif;
  font-size: 21px;
  color: var(--texte);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.grille-lettres button:hover {
  background: var(--appui);
}

.grille-lettres button.actif {
  border-color: var(--principal);
  background: var(--appui);
}

/* Les mots sont plus larges qu'une lettre. */
.grille-lettres button.mot {
  width: auto;
  min-width: 52px;
  padding: 0 8px;
}

.segments {
  display: flex;
  margin-bottom: 10px;
  padding: 3px;
  background: var(--fond-appli);
  border: 1px solid var(--bordure);
  border-radius: 10px;
}

.segments button {
  flex: 1;
  height: 38px;
  font: inherit;
  font-size: 15px;
  color: var(--texte);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.segments button.actif {
  font-weight: 600;
  color: #FFFFFF;
  background: var(--principal);
}

.reglage[hidden],
section[hidden] {
  display: none;
}

.reglage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 15px;
}

.reglage select {
  font: inherit;
  padding: 7px 10px;
  color: var(--texte);
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 8px;
}

/* Un seul exercice par fiche : des boutons, pas des cases. */
.choix {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.choix button {
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  text-align: left;
  color: var(--texte);
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 9px;
  cursor: pointer;
}

.choix button:hover {
  background: var(--appui);
}

.choix button.actif {
  font-weight: 600;
  color: #FFFFFF;
  background: var(--principal);
  border-color: var(--principal);
}

.case {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 14.5px;
  line-height: 1.3;
  cursor: pointer;
}

.case input {
  margin: 2px 0 0;
  flex-shrink: 0;
  width: 17px;
  height: 17px;
}

.avertissement {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.35;
  color: #B26A00;
}

.avertissement[hidden] {
  display: none;
}

.bouton {
  min-height: 48px;
  padding: 8px 16px;
  font: inherit;
  font-size: 17px;
  color: var(--texte);
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 11px;
  cursor: pointer;
}

.bouton.principal {
  margin-top: auto;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--principal);
  border-color: var(--principal);
}

.bouton.principal:hover {
  background: #263238;
}

/* ── L'aperçu ─────────────────────────────────────────────────────────────── */

.apercu {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 4px 0 24px;
}

.feuille {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
}

.feuille svg {
  display: block;
  /* La page garde ses proportions ; sa taille réelle est en millimètres. */
  height: auto;
  max-width: 100%;
}

.message {
  position: absolute;
  top: 40%;
  margin: 0;
  color: var(--texte-doux);
  white-space: pre-line;
  text-align: center;
}

.message[hidden] {
  display: none;
}

/* ── À l'impression : la feuille, et rien d'autre ─────────────────────────── */

@page {
  margin: 0;
}

@media print {
  body {
    background: #FFFFFF;
  }

  .barre-haut,
  .reglages,
  .message {
    display: none;
  }

  .corps,
  .apercu {
    display: block;
    padding: 0;
    overflow: visible;
  }

  .feuille {
    box-shadow: none;
  }

  .feuille svg {
    max-width: none;
  }
}
