/* ============================================================
   Cahier de texte v6 — thème « Cahier »
   Papier crème, coutures, titres manuscrits, accent brique.
   Mêmes sélecteurs que la v6 claire : seules les couleurs changent.
   v2 : PJ ré-attachées différenciées (a.pj.rec, marqueur ↻).
   Bonus : classes .m-<matière> pour une couleur par matière
   (repli : couleur d'accent unique si absentes).
   ============================================================ */

:root {
  --fond: #f8f1e3;
  --carte: #fffdf7;
  --encre: #4a3820;
  --doux: #8a7a5d;
  --bord: #e5d9bf;
  --accent: #d9480f;
  --accent-fonce: #b03d10;
  --vert: #1d7a3f;
  --vert-clair: #d9f2e0;
  --orange: #a85500;
  --orange-clair: #ffe9d1;
  --rouge: #c92a2a;
  --rouge-clair: #ffe8e3;
  --indigo: #e8590c;
  --mat: #d9480f;
  --ombre: 0 2px 0 rgba(122, 98, 55, 0.08);
  --ombre-forte: 0 12px 34px rgba(90, 64, 20, 0.3);
  --manuscrit: "Comic Sans MS", "Chalkboard SE", "Segoe Print", system-ui, sans-serif;
}

/* Couleur par matière (activée quand build_site ajoute la classe) */
.m-conjugaison { --mat: #4263eb; }
.m-grammaire   { --mat: #4263eb; }
.m-vocabulaire { --mat: #2f9e44; }
.m-dictee      { --mat: #e64980; }
.m-calcul      { --mat: #e8590c; }
.m-numeration  { --mat: #9c36b5; }
.m-poesie      { --mat: #d9480f; }
.m-lecture     { --mat: #1098ad; }
.m-devoirs     { --mat: #d9480f; }
.m-evaluation  { --mat: #c92a2a; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fond);
  color: var(--encre);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* --- En-tête collant : synchro en haut + menu toujours visibles --- */

header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: linear-gradient(135deg, #e8590c 0%, #f7902f 100%);
  color: #fff;
  box-shadow: 0 3px 14px rgba(150, 84, 18, 0.35);
}

.entete-contenu {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.8rem 1rem 0.8rem;
  transition: padding 0.2s ease;
}

.synchro {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  opacity: 0.95;
}

.entete-haut {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
}

header h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  font-family: var(--manuscrit);
}


.bandeau {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* compact au scroll : synchro conservée */
header.compacte .entete-contenu { padding: 0.35rem 1rem 0.5rem; }
header.compacte h1 { font-size: 1rem; }

nav {
  display: flex;
  gap: 0.4rem;
  margin: 0;
  flex-wrap: wrap;
}

nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  transition: background 0.15s ease;
}

nav a:hover { background: rgba(255, 255, 255, 0.34); }

nav a.actif {
  background: #fff;
  color: var(--accent-fonce);
}

/* --- Corps --- */

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.2rem 1rem 2.5rem;
}

/* --- Hero : quizz général, juste le bouton --- */

.hero {
  background: var(--carte);
  border: 2px solid #eadfc6;
  border-radius: 16px;
  box-shadow: var(--ombre);
  padding: 1rem 1.2rem;
  margin-bottom: 1.6rem;
  display: flex;
  justify-content: center;
}

.btn-general {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(122, 98, 55, 0.18);
  transition: background 0.15s, transform 0.12s;
}

.btn-general span {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.85;
}

.btn-general:hover { background: var(--accent-fonce); }
.btn-general:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(122, 98, 55, 0.18); }

/* --- Bloc par jour : panneau crème façon cahier, couture dorée --- */

.jour {
  background: #f3e9d2;
  background-image: repeating-linear-gradient(
    to bottom, transparent 0, transparent 1.55rem, rgba(122, 98, 55, 0.05) 1.55rem);
  border-radius: 16px;
  border: 2px dashed #dcc99a;
  padding: 0.8rem 0.85rem 0.3rem;
  margin-bottom: 1.6rem;
}

.jour-tete {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
  padding: 0 0.15rem;
}

.jour-tete h2 {
  margin: 0;
  font-size: 1.14rem;
  font-weight: 800;
  color: var(--encre);
  text-transform: capitalize;
  font-family: var(--manuscrit);
}

.btn-jour {
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  background: var(--indigo);
  color: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.38rem 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(122, 98, 55, 0.18);
  transition: filter 0.15s, transform 0.12s;
}

.btn-jour:hover { filter: brightness(1.08); }
.btn-jour:active { transform: translateY(1px); }

/* --- Sous-blocs devoir : carte papier, liseré épais de matière --- */

.carte {
  background: var(--carte);
  border: 2px solid #eadfc6;
  border-left: 7px solid var(--mat);
  border-radius: 16px;
  box-shadow: var(--ombre);
  padding: 0.85rem 1.05rem 0.95rem;
  margin-bottom: 0.6rem;
}

.carte-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}

.carte-tete h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  font-family: var(--manuscrit);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.carte-tete h3::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--mat);
  flex: none;
}

.etiquettes {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Badges : rares et discrets --- */

.niveau, .eva, .delai {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: middle;
}

.niveau.ce1 { background: #dfe7fb; color: #1d5a99; }
.niveau.ce2 { background: #def3d5; color: #2f7a1d; }
.niveau.ce1-ce2 { background: #eee6fb; color: #6731a8; }

.eva { background: var(--rouge-clair); color: var(--rouge); }

.delai { background: #f0e6cf; color: #8a6d1a; }
.delai.j1 { background: #ffe9b8; color: #a06800; }
.delai.j0 { background: #ffd9d2; color: var(--rouge); }

/* --- Lignes de devoir --- */

.items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.items li {
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--bord);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.items li:last-child { border-bottom: none; }

.items .texte { flex: 1 1 12rem; }

.pj-mark { font-size: 0.85rem; cursor: help; }

/* --- Boutons de ligne : Exercice / Quizz (uniquement à venir) --- */

.btn-ligne {
  flex: none;
  margin-left: auto;
  padding: 0.28rem 0.75rem;
  border: 1.5px solid;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.12s;
}

.btn-ligne:hover { filter: brightness(0.94); }
.btn-ligne:active { transform: scale(0.95); }

.btn-ligne.exo {
  border-color: #f0982f;
  background: var(--orange-clair);
  color: var(--orange);
}

.btn-ligne.quizz {
  border-color: #5dae74;
  background: var(--vert-clair);
  color: var(--vert);
}

.items li .btn-ligne + .btn-ligne { margin-left: 0; }

/* --- Pièces jointes : étiquettes papier agrafées --- */

.pjs {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--bord);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

a.pj {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff6e9;
  color: #a85a10;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  border: 1.5px dashed #d9a355;
  border-left: 4px solid var(--mat);
  transition: background 0.12s, transform 0.12s;
}

a.pj:hover { background: #ffedd0; transform: translateY(-1px); }

/* PJ ré-attachées (variante B « deux colonnes ») : colonne de droite atténuée,
   séparée des PJ natives par un filet pointillé — clairement identifiée (↻),
   mais moins visible que les PJ du devoir */
.pjs.duo { display: flex; gap: 0.8rem; align-items: flex-start; flex-wrap: wrap; }
.pjs.duo .col { display: flex; flex-direction: column; gap: 0.35rem; }
.pjs.duo .col.recs-col { border-left: 2px dotted var(--bord); padding-left: 0.8rem; opacity: 0.8; }

.col-label {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--doux);
}

.pjs.duo a.pj.rec {
  background: #f6efdc;
  color: #97783f;
  border: 1.5px dotted #c9b070;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.26rem 0.65rem;
}
.pjs.duo a.pj.rec::before { content: "↻ "; font-weight: 800; }
.pjs.duo a.pj.rec:hover { background: #efe4c5; }

/* Légende : distinguer PJ du devoir / PJ ré-attachée */
.legende {
  margin: -0.9rem 0 1.3rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--doux);
}
.legende .ex-rec { color: var(--accent); font-weight: 800; }

.pj.manquante {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f4efe2;
  color: var(--doux);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  border: 1.5px dashed #d5c9a6;
}

.pj.manquante em { font-style: normal; font-weight: 400; opacity: 0.85; }

/* --- États vides --- */

.vide { color: var(--doux); }

.vide.centre {
  text-align: center;
  font-size: 1rem;
  background: var(--carte);
  border: 2px dashed #dcc99a;
  border-radius: 14px;
  padding: 2rem 1rem;
}

/* --- Modal quizz --- */

.qmodal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(74, 56, 32, 0.55);
  backdrop-filter: blur(3px);
  padding: 16px;
  overflow-y: auto;
}

.qmodal.ouvert { display: flex; align-items: flex-start; }

.q-boite {
  width: 100%;
  max-width: 500px;
  margin: 6vh auto 0;
  background: var(--carte);
  border: 2px solid #eadfc6;
  border-radius: 18px;
  box-shadow: var(--ombre-forte);
  padding: 18px 18px 22px;
  animation: qpop 0.22s ease-out;
}

@keyframes qpop {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.q-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.q-titre {
  font-weight: 800;
  color: var(--accent-fonce);
  font-size: 1.02rem;
  font-family: var(--manuscrit);
}

.q-fermer {
  border: 0;
  background: #f0e8d2;
  color: var(--doux);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  flex: none;
}

.q-compte {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.q-lien {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.q-lien:hover { text-decoration: underline; }

.q-question {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 6px 0 14px;
}

.q-options { display: flex; flex-direction: column; gap: 10px; }

.q-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 2px solid #e5d9bf;
  border-radius: 13px;
  background: #fbf5e8;
  font-size: 1rem;
  font-family: inherit;
  color: var(--encre);
  cursor: pointer;
  transition: all 0.15s;
}

.q-opt:hover:not(:disabled) { border-color: var(--accent); background: #fff1d6; }

.q-lettre {
  flex: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f0e8d2;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--doux);
}

.q-opt.bonne { border-color: var(--vert); background: var(--vert-clair); }
.q-opt.bonne .q-lettre { background: var(--vert); color: #fff; }

.q-opt.fausse { border-color: var(--rouge); background: var(--rouge-clair); }
.q-opt.fausse .q-lettre { background: var(--rouge); color: #fff; }

.q-opt:disabled { cursor: default; }

.q-retour { min-height: 24px; margin: 12px 0 4px; font-weight: 650; }

.q-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.q-suivant {
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s;
}

.q-suivant:disabled { opacity: 0.45; cursor: default; }
.q-suivant:not(:disabled):hover { filter: brightness(1.1); }

.q-score { text-align: center; padding: 18px 6px; }

.q-score-nombre {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--accent-fonce);
  font-family: var(--manuscrit);
}

/* --- Pied de page --- */

footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--doux);
  font-size: 0.8rem;
  text-align: center;
}

footer .sep { margin: 0 0.4rem; }

/* --- Petit écran --- */

@media (max-width: 480px) {
  header h1 { font-size: 1.15rem; }
  .synchro { font-size: 0.72rem; }
  .items li { align-items: flex-start; }
  .items .texte { flex: 1 1 100%; }
  .btn-ligne { margin-left: 0; }
  .jour-tete h2 { font-size: 1.05rem; }
  .jour { padding: 0.65rem 0.6rem 0.2rem; border-radius: 13px; }
  .carte { padding: 0.75rem 0.85rem 0.85rem; }
}

/* --- Impression --- */

@media print {
  header { background: none; color: var(--encre); position: static; }
  nav, footer, .btn-ligne, .btn-jour, .btn-general { display: none; }
  .carte { box-shadow: none; border: 1px solid var(--bord); }
  a.pj { color: var(--accent-fonce); background: none; box-shadow: none; border: 1px dashed #d9a355; }
  body { background: #fff; }
}
