/* Quintesens — Formation produit
   Mobile d'abord, mise en page élargie au-delà de 760 px. */

:root {
  --fond: #f6f8ec;
  --carte: #ffffff;
  --carte-2: #f0f3e2;
  --bord: #dfe4cb;
  --texte: #23281a;
  --texte-doux: #6a7359;
  --vert: #3e5622;
  --vert-clair: #6d8a45;
  --ocre: #b8901f;
  --ocre-fond: #fdf4dc;
  --juste: #2f7a44;
  --juste-fond: #e7f4ea;
  --faux: #b3352b;
  --faux-fond: #fbeae8;
  --sur-vert: #ffffff;   /* texte posé sur un aplat vert */
  --ombre: 0 1px 2px rgba(35, 40, 26, .06), 0 6px 18px rgba(35, 40, 26, .06);
  --rayon: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* Trois états de thème : « système » ne pose aucun attribut, d'où la media-query ;
   un choix explicite pose data-theme et doit l'emporter dans les deux sens. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #12160e;
    --carte: #1c2116;
    --carte-2: #232a1b;
    --bord: #333c28;
    --texte: #e8ecdd;
    --texte-doux: #9aa588;
    --vert: #8fb055;
    --vert-clair: #a6c46e;
    --ocre: #d9b451;
    --ocre-fond: #2a2415;
    --juste: #6cc189;
    --juste-fond: #172b1d;
    --faux: #e88b80;
    --faux-fond: #2c1a18;
    --sur-vert: #12160e;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
    --fond: #12160e;
    --carte: #1c2116;
    --carte-2: #232a1b;
    --bord: #333c28;
    --texte: #e8ecdd;
    --texte-doux: #9aa588;
    --vert: #8fb055;
    --vert-clair: #a6c46e;
    --ocre: #d9b451;
    --ocre-fond: #2a2415;
    --juste: #6cc189;
    --juste-fond: #172b1d;
    --faux: #e88b80;
    --faux-fond: #2c1a18;
    --sur-vert: #12160e;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    color-scheme: dark;
}

* { box-sizing: border-box; }

/* Sans cela, les `display: flex/grid` ci-dessous l'emportent sur l'attribut hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- barre de titre ---------- */
.barre {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px calc(12px) 14px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  background: var(--fond);
  border-bottom: 1px solid var(--bord);
}
.barre-titre { flex: 1; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.retour {
  border: 1px solid var(--bord); background: var(--carte);
  width: 34px; height: 34px; border-radius: 10px; font-size: 22px; line-height: 1;
  display: grid; place-items: center; padding: 0 0 3px 0;
}
.profil-pastille {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--vert); color: var(--sur-vert); font-weight: 700; font-size: 14px;
  display: grid; place-items: center; flex: none;
}

/* ---------- structure ---------- */
main {
  padding: 16px 14px calc(84px + var(--safe-b)) 14px;
  max-width: 900px; margin: 0 auto;
}
/* pendant une série, le bouton d'action est fixé en bas : on dégage la place */
main.quiz { padding-bottom: calc(150px + var(--safe-b)); }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 18px 0 6px; }
p { margin: 0 0 10px; }
.doux { color: var(--texte-doux); font-size: 14px; }
.centre { text-align: center; }

.carte {
  background: var(--carte); border: 1px solid var(--bord);
  border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre);
  margin-bottom: 12px;
}
.rangee { display: flex; align-items: center; gap: 12px; }
.grille { display: grid; gap: 12px; }
@media (min-width: 700px) { .grille.deux { grid-template-columns: 1fr 1fr; } }

/* ---------- boutons ---------- */
.bouton {
  display: block; width: 100%; padding: 15px 18px; border: none;
  border-radius: 12px; background: var(--vert); color: var(--sur-vert);
  font-weight: 650; font-size: 16px; text-align: center;
}
.bouton.secondaire {
  background: var(--carte); color: var(--texte); border: 1px solid var(--bord);
}
.bouton:disabled { opacity: .45; cursor: not-allowed; }
.bouton + .bouton { margin-top: 10px; }
.lien {
  background: none; border: none; color: var(--vert); font-weight: 600;
  padding: 6px 0; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- niveaux ---------- */
.niveau {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--carte); border: 1px solid var(--bord);
  border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 10px;
  text-align: left; box-shadow: var(--ombre);
}
.niveau[disabled] { opacity: .55; }
.niveau .num {
  flex: none; width: 40px; height: 40px; border-radius: 11px;
  background: var(--carte-2); color: var(--vert);
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
}
.niveau.valide .num { background: var(--juste-fond); color: var(--juste); }
.niveau .txt { flex: 1; min-width: 0; }
.niveau .txt b { display: block; font-size: 15px; }
.niveau .txt span { font-size: 13px; color: var(--texte-doux); }
.niveau .fin { flex: none; font-size: 13px; color: var(--texte-doux); }

.jauge { height: 6px; background: var(--carte-2); border-radius: 99px; overflow: hidden; margin-top: 7px; }
.jauge > i { display: block; height: 100%; background: var(--vert-clair); border-radius: 99px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
  padding: 12px 10px; text-align: center;
}
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--texte-doux); }

.pastilles { display: flex; flex-wrap: wrap; gap: 6px; }
.pastille {
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 99px;
  background: var(--carte-2); color: var(--texte-doux);
}
.pastille.ok { background: var(--juste-fond); color: var(--juste); }
.pastille.ocre { background: var(--ocre-fond); color: var(--ocre); }

/* ---------- quiz ---------- */
.progression {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  font-size: 13px; color: var(--texte-doux);
}
.progression .jauge { flex: 1; margin: 0; }

.enonce { font-size: 19px; font-weight: 600; line-height: 1.35; margin: 4px 0 16px; letter-spacing: -.01em; }

.reponse {
  display: flex; align-items: flex-start; gap: 11px; width: 100%; text-align: left;
  background: var(--carte); border: 1.5px solid var(--bord); border-radius: 12px;
  padding: 14px 15px; margin-bottom: 9px; line-height: 1.4;
}
.reponse .puce {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--bord); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--texte-doux);
}
.reponse:not([disabled]):active { transform: scale(.995); }
.reponse.juste { border-color: var(--juste); background: var(--juste-fond); }
.reponse.juste .puce { border-color: var(--juste); background: var(--juste); color: var(--sur-vert); }
.reponse.faux { border-color: var(--faux); background: var(--faux-fond); }
.reponse.faux .puce { border-color: var(--faux); background: var(--faux); color: var(--sur-vert); }
.reponse[disabled] { cursor: default; }

.vf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vf .reponse { justify-content: center; font-weight: 650; font-size: 17px; }
.vf .reponse .puce { display: none; }

/* association */
.assoc-consigne { font-size: 13px; color: var(--texte-doux); margin-bottom: 10px; }
.assoc-ligne {
  display: flex; align-items: center; gap: 10px; margin-bottom: 9px;
  background: var(--carte); border: 1.5px solid var(--bord);
  border-radius: 12px; padding: 11px 13px;
}
.assoc-ligne.juste { border-color: var(--juste); background: var(--juste-fond); }
.assoc-ligne.faux { border-color: var(--faux); background: var(--faux-fond); }
.assoc-ligne .gauche { flex: 1; font-weight: 600; font-size: 15px; min-width: 0; }
.assoc-ligne select {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 9px 10px;
  border-radius: 9px; border: 1px solid var(--bord);
  background: var(--carte-2); color: var(--texte); appearance: none;
}
.assoc-ligne .attendu { font-size: 12px; color: var(--juste); font-weight: 600; }

.explication {
  border-radius: 12px; padding: 14px 15px; margin: 14px 0 4px;
  background: var(--carte-2); border: 1px solid var(--bord);
}
.explication.juste { background: var(--juste-fond); border-color: color-mix(in srgb, var(--juste) 30%, transparent); }
.explication.faux { background: var(--faux-fond); border-color: color-mix(in srgb, var(--faux) 30%, transparent); }
.explication .verdict { font-weight: 700; margin-bottom: 6px; }
.explication .verdict.juste { color: var(--juste); }
.explication .verdict.faux { color: var(--faux); }
.explication .src { font-size: 12px; color: var(--texte-doux); margin-top: 8px; }

.pied-quiz {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 12px 14px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--fond) 65%, transparent);
}
.pied-quiz .bouton { max-width: 872px; margin: 0 auto; }

/* ---------- résultat ---------- */
.score-cercle {
  width: 132px; height: 132px; border-radius: 50%; margin: 8px auto 14px;
  display: grid; place-items: center; font-size: 34px; font-weight: 750;
  border: 7px solid var(--vert-clair); letter-spacing: -.02em;
}
.score-cercle.echec { border-color: var(--faux); }

/* ---------- fiches produit ---------- */
.filtres { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.filtres button {
  flex: none; border: 1px solid var(--bord); background: var(--carte);
  border-radius: 99px; padding: 7px 13px; font-size: 13.5px; font-weight: 600;
  color: var(--texte-doux);
}
.filtres button.actif { background: var(--vert); border-color: var(--vert); color: var(--sur-vert); }

.liste-produits { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .liste-produits { grid-template-columns: 1fr 1fr; } }
.produit {
  display: flex; align-items: center; gap: 13px; text-align: left;
  background: var(--carte); border: 1px solid var(--bord);
  border-radius: var(--rayon); padding: 11px; box-shadow: var(--ombre);
}
.produit img {
  width: 54px; height: 60px; object-fit: contain; flex: none;
  background: var(--carte-2); border-radius: 9px;
}
.produit .txt { min-width: 0; }
.produit .txt b { display: block; font-size: 14.5px; line-height: 1.3; }
.produit .txt span { font-size: 12.5px; color: var(--texte-doux); }

.fiche-photo {
  width: 100%; max-width: 300px; margin: 0 auto 6px; display: block;
  border-radius: var(--rayon); background: var(--carte-2);
}
.bloc { margin-bottom: 6px; }
.bloc ul { margin: 6px 0; padding-left: 20px; }
.bloc li { margin-bottom: 3px; }
.tableau { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tableau td { padding: 7px 6px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.tableau td:first-child { color: var(--texte-doux); }
.tableau td:not(:first-child) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.defilant { overflow-x: auto; }

.repli { border-top: 1px solid var(--bord); }
.repli summary {
  padding: 13px 2px; font-weight: 620; font-size: 15px; cursor: pointer;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.repli summary::-webkit-details-marker { display: none; }
.repli summary::after { content: "+"; color: var(--texte-doux); font-size: 19px; }
.repli[open] summary::after { content: "–"; }
.repli .corps { padding: 0 2px 14px; font-size: 14.5px; }

/* ---------- onglets bas ---------- */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 18;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--carte); border-top: 1px solid var(--bord);
  padding-bottom: var(--safe-b);
  /* sur grand écran, on regroupe les onglets au centre plutôt que de les étaler */
  padding-inline: max(0px, calc((100% - 620px) / 2));
}
.onglets button {
  border: none; background: none; padding: 9px 4px 8px;
  font-size: 11px; font-weight: 600; color: var(--texte-doux);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.onglets button span { font-size: 17px; line-height: 1; }
.onglets button.actif { color: var(--vert); }

/* ---------- divers ---------- */
.vide { text-align: center; padding: 40px 16px; color: var(--texte-doux); }
.vide .gros { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }
.champ {
  width: 100%; font: inherit; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--bord); background: var(--carte); color: var(--texte);
  margin-bottom: 10px;
}
.avis {
  background: var(--ocre-fond); border: 1px solid color-mix(in srgb, var(--ocre) 35%, transparent);
  border-radius: 12px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 12px;
}
.profil-ligne {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--carte); border: 1px solid var(--bord);
  border-radius: 12px; padding: 13px 14px; margin-bottom: 9px;
}
.profil-ligne .pastille-nom {
  width: 36px; height: 36px; border-radius: 50%; background: var(--vert); color: var(--sur-vert);
  display: grid; place-items: center; font-weight: 700; flex: none;
}

@media (prefers-reduced-motion: no-preference) {
  main > * { animation: entree .18s ease-out; }
  @keyframes entree { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
