/* Révimaths — feuille de styles commune.
   Concept : la page d'un cahier d'élève. Bandeau d'en-tête réglé Seyès avec marge rouge,
   encre bleue de stylo pour les actions, papier légèrement bleuté. Téléphone d'abord. */

@font-face {
  font-family: "Inter";
  src: url("polices/inter-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("polices/inter-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  /* Couleurs */
  --papier: #f7f8fb;          /* fond de page */
  --carte: #ffffff;           /* surfaces */
  --texte: #192131;           /* texte courant, foncé */
  --texte-doux: #4c5568;      /* légendes */
  --trait: #d5dbe8;           /* bordures, réglure */
  --encre: #1d48c9;           /* bleu stylo : actions, liens */
  --encre-fond: #e8eefc;
  --sur-encre: #ffffff;        /* texte posé sur l'encre */
  --marge: #c62f3b;           /* rouge de marge Seyès */
  --juste: #17703f; --juste-fond: #e4f4ea;
  --faux: #b3261e;  --faux-fond: #fbe9e7;
  /* Code couleur des fiches (spécification § 4.2) */
  --c-definition: #17703f;
  --c-propriete: #b3261e;
  --c-regle: #192131;
  --c-exemple: #1d48c9;
  --c-erreurs: #a14a00;
  --motcle: #b3261e;
  /* Typographie */
  --police: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --t-xs: .75rem; --t-s: .8125rem; --t-m: .875rem; --t-l: 1.125rem; --t-xl: 1.375rem;
  --rayon: 10px;
  --largeur: 40rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #10141d; --carte: #181e2b; --texte: #e6eaf3; --texte-doux: #a7b0c3; --trait: #2c3548;
    --encre: #8eaefc; --encre-fond: #1f2a45; --sur-encre: #0f1730; --marge: #ff7c86;
    --juste: #6fd49a; --juste-fond: #13301f; --faux: #ff8f86; --faux-fond: #3a1714;
    --c-definition: #6fd49a; --c-propriete: #ff8f86; --c-regle: #e6eaf3; --c-exemple: #8eaefc; --c-erreurs: #ffb366;
    --motcle: #ff8f86;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papier: #10141d; --carte: #181e2b; --texte: #e6eaf3; --texte-doux: #a7b0c3; --trait: #2c3548;
  --encre: #8eaefc; --encre-fond: #1f2a45; --sur-encre: #0f1730; --marge: #ff7c86;
  --juste: #6fd49a; --juste-fond: #13301f; --faux: #ff8f86; --faux-fond: #3a1714;
  --c-definition: #6fd49a; --c-propriete: #ff8f86; --c-regle: #e6eaf3; --c-exemple: #8eaefc; --c-erreurs: #ffb366;
  --motcle: #ff8f86;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--papier); color: var(--texte);
  font-family: var(--police); font-size: var(--t-m); line-height: 1.55;
}
a { color: var(--encre); }
:focus-visible { outline: 3px solid var(--encre); outline-offset: 2px; }
.m { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* En-tête : réglure Seyès et marge rouge */
.entete {
  background-color: var(--carte);
  background-image:
    linear-gradient(to right, transparent 2.25rem, var(--marge) 2.25rem, var(--marge) calc(2.25rem + 2px), transparent calc(2.25rem + 2px)),
    repeating-linear-gradient(to bottom, transparent 0 7px, var(--trait) 7px 8px);
  border-bottom: 1px solid var(--trait);
}
.entete-in {
  max-width: var(--largeur); margin: 0 auto;
  padding-block: .9rem .8rem;
  padding-left: max(3rem, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.marque { font-weight: 700; font-size: var(--t-l); color: var(--texte); text-decoration: none; letter-spacing: .01em; }
.marque span { color: var(--encre); }
.fil { font-size: var(--t-s); color: var(--texte-doux); }
.fil a { color: var(--texte-doux); }

main {
  max-width: var(--largeur); margin: 0 auto;
  padding-block: 1.25rem 2.5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 1.25rem;
}
h1 { font-size: var(--t-xl); line-height: 1.2; margin: 0; text-wrap: balance; }
h2 { font-size: var(--t-l); line-height: 1.25; margin: 0; text-wrap: balance; }
h3 { font-size: var(--t-m); margin: 0; }
.surtitre { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--texte-doux); font-weight: 700; margin: 0; }
p { margin: 0; }

/* Boutons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3.25rem; padding: .7rem 1.1rem; width: 100%;
  border-radius: var(--rayon); border: 2px solid var(--encre);
  background: var(--encre); color: var(--sur-encre);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
}
.btn.secondaire { background: transparent; color: var(--encre); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.pile { display: flex; flex-direction: column; gap: .75rem; }
.rangee { display: flex; gap: .75rem; flex-wrap: wrap; }
.rangee > * { flex: 1 1 8rem; }

/* Accueil */
.carte-chapitre {
  display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; align-items: center;
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: 1rem; text-decoration: none; color: var(--texte);
}
.carte-chapitre .num {
  grid-row: span 2; font-weight: 700; font-size: var(--t-xl); color: var(--encre);
  width: 3rem; height: 3rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--encre-fond); font-variant-numeric: tabular-nums;
}
.carte-chapitre .titre { font-weight: 700; }
.carte-chapitre .details { font-size: var(--t-s); color: var(--texte-doux); }
.note { font-size: var(--t-s); color: var(--texte-doux); }

/* Quiz */
.barre { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: var(--t-s); color: var(--texte-doux); flex-wrap: wrap; }
.barre strong { color: var(--texte); }
.ident { font-size: var(--t-xs); color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.lien-bouton { background: none; border: none; color: var(--encre); font: inherit; font-size: var(--t-s); text-decoration: underline; cursor: pointer; padding: .25rem; }
.progression { height: 6px; background: var(--trait); border-radius: 3px; overflow: hidden; }
.progression > div { height: 100%; background: var(--encre); transition: width .25s; }
.enonce { font-size: var(--t-l); line-height: 1.45; overflow-x: auto; }
.choix { display: flex; flex-direction: column; gap: .6rem; }
.option {
  display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
  min-height: 3.25rem; padding: .7rem .9rem; border-radius: var(--rayon);
  border: 2px solid var(--trait); background: var(--carte); color: var(--texte); font: inherit; cursor: pointer;
}
.option .puce { flex: none; width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 2px solid var(--texte-doux); }
.option[aria-checked="true"] { border-color: var(--encre); background: var(--encre-fond); }
.option[aria-checked="true"] .puce { border-color: var(--encre); background: radial-gradient(var(--encre) 45%, transparent 50%); }
.option.est-juste { border-color: var(--juste); background: var(--juste-fond); }
.option.est-faux { border-color: var(--faux); background: var(--faux-fond); }
.option:disabled { cursor: default; }
.vf { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.vf .option { justify-content: center; font-weight: 700; }

/* Saisie : clavier intégré */
.ecran-saisie {
  min-height: 3.5rem; display: flex; align-items: center; justify-content: flex-end;
  padding: .5rem 1rem; border: 2px solid var(--encre); border-radius: var(--rayon);
  background: var(--carte); font-size: var(--t-xl); font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.ecran-saisie.vide { color: var(--texte-doux); font-size: var(--t-m); }
.aide-saisie { font-size: var(--t-s); color: var(--texte-doux); margin: .4rem 0 .75rem; }
.aide-saisie.alerte { color: var(--faux); font-weight: 700; }
.clavier { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.touche {
  min-height: 3.25rem; border-radius: var(--rayon); border: 1px solid var(--trait);
  background: var(--carte); color: var(--texte); font: inherit; font-size: var(--t-l); font-weight: 700; cursor: pointer;
}
.touche:active { background: var(--encre-fond); }
.touche.effacer { grid-column: span 3; font-size: var(--t-m); }

/* Association */
.asso { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.asso .colonne { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.asso .option { justify-content: space-between; }
.badge {
  flex: none; min-width: 1.6rem; height: 1.6rem; border-radius: .8rem; display: grid; place-items: center;
  font-size: var(--t-xs); font-weight: 700; background: var(--encre); color: var(--sur-encre);
}
.option.selection { border-style: dashed; border-color: var(--encre); }

/* Retour */
.retour { border-radius: var(--rayon); padding: 1rem; display: flex; flex-direction: column; gap: .5rem; border: 2px solid; }
.retour.juste { background: var(--juste-fond); border-color: var(--juste); }
.retour.faux { background: var(--faux-fond); border-color: var(--faux); }
.verdict { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: var(--t-l); }
.retour.juste .verdict { color: var(--juste); }
.retour.faux .verdict { color: var(--faux); }
.verdict svg { width: 1.6rem; height: 1.6rem; flex: none; }
.retour .etiquette { font-weight: 700; }
.retour p, .option > span:last-child, .enonce, .bloc .ligne { min-width: 0; overflow-x: auto; }
@media (prefers-reduced-motion: no-preference) {
  .retour.juste { animation: pulse .45s ease-out; }
  @keyframes pulse { 0% { transform: scale(.97); } 60% { transform: scale(1.015); } 100% { transform: scale(1); } }
}

/* Bilan */
.score { font-size: 2.75rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.score small { font-size: var(--t-l); color: var(--texte-doux); font-weight: 400; }
.ratees { display: flex; flex-direction: column; gap: .75rem; padding: 0; margin: 0; list-style: none; }
.ratees li { background: var(--carte); border: 1px solid var(--trait); border-left: 4px solid var(--faux); border-radius: var(--rayon); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .3rem; overflow-x: auto; }

/* Fenêtre de confirmation */
.voile { position: fixed; inset: 0; background: rgba(10, 14, 22, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.boite { background: var(--carte); border-radius: var(--rayon); padding: 1.25rem; max-width: 22rem; width: 100%; display: flex; flex-direction: column; gap: 1rem; }

/* Fiche de révision */
.sommaire { font-size: var(--t-s); display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.fiche { display: flex; flex-direction: column; gap: 1rem; }
.fiche h2 { padding-top: .5rem; border-top: 2px solid var(--trait); }
.fiche h3 { color: var(--texte-doux); }
.bloc {
  background: var(--carte); border: 1px solid var(--trait); border-left: 5px solid var(--c);
  border-radius: 0 var(--rayon) var(--rayon) 0; padding: .75rem 1rem; display: flex; flex-direction: column; gap: .4rem;
  overflow-x: auto; break-inside: avoid;
}
.bloc .nom { font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--c); }
.bloc.definition { --c: var(--c-definition); }
.bloc.propriete { --c: var(--c-propriete); }
.bloc.regle, .bloc.methode { --c: var(--c-regle); }
.bloc.exemple { --c: var(--c-exemple); }
.bloc.erreurs { --c: var(--c-erreurs); }
.bloc ul, .bloc ol { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .3rem; }
.bloc .ligne { font-variant-numeric: tabular-nums; }
.bloc .groupe { display: flex; flex-direction: column; gap: .1rem; }
.motcle { font-weight: 700; color: var(--motcle); }
.tableau { overflow-x: auto; }
.tableau table { border-collapse: collapse; font-size: var(--t-s); width: 100%; }
@media (max-width: 26rem) { .tableau table { font-size: var(--t-xs); } }
.tableau th, .tableau td { border: 1px solid var(--trait); padding: .35rem .4rem; text-align: center; }
.tableau td { white-space: nowrap; }
.tableau th { font-size: var(--t-xs); color: var(--texte-doux); }
.bandeau-brouillon { background: var(--faux-fond); color: var(--faux); border: 2px dashed var(--faux); border-radius: var(--rayon); padding: .6rem .9rem; font-weight: 700; }
.pied { font-size: var(--t-xs); color: var(--texte-doux); border-top: 1px solid var(--trait); padding-top: .75rem; }
.mention h3 { margin-bottom: .25rem; }
.mention p { margin: 0; }
.apropos-liste { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .4rem; }

@media (min-width: 48rem) {
  .rangee-large { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
}

/* Impression de la fiche : A4, noir et blanc lisible */
@page { size: A4 portrait; margin: 11mm 12mm 12mm; }
@media print {
  :root { --papier: #fff; --carte: #fff; --texte: #000; --texte-doux: #333; --trait: #999;
          --c-definition: #17703f; --c-propriete: #b3261e; --c-regle: #000; --c-exemple: #1d48c9; --c-erreurs: #a14a00; --motcle: #b3261e; color-scheme: light; }
  body { font-size: 9.5pt; line-height: 1.3; }
  .entete, .actions-fiche, .sommaire, .non-imprime { display: none !important; }
  main { padding: 0; max-width: none; gap: .5rem; }
  .fiche { gap: .45rem; }
  .bloc { padding: .35rem .6rem; gap: .2rem; overflow: visible; }
  .fiche h2 { padding-top: .2rem; font-size: 13pt; }
  h1 { font-size: 16pt; }
  .tableau { overflow: visible; }
  .tableau table { font-size: 7.6pt; }
  .tableau th, .tableau td { padding: .1rem .2rem; }
  .pied { padding-top: .3rem; }
  .pied::after { content: " — " attr(data-adresse); }
  .fiche { display: block; column-count: 2; column-gap: 7mm; }
  .fiche > * { margin-bottom: .3rem; }
  .fiche h2, .fiche h3 { break-after: avoid; }
  .fiche h2:first-child { padding-top: 0; border-top: none; }
}
