/* TosaQCM — mobile-first, clair/sombre, palette inspirée de l'admin WordPress */

:root {
  --fond: #f0f0f1;
  --surface: #ffffff;
  --surface-2: #f6f7f7;
  --texte: #1d2327;
  --texte-2: #50575e;
  --bordure: #dcdcde;
  --accent: #2271b1;
  --accent-fort: #135e96;
  --sur-accent: #ffffff;
  --succes: #007a3d;
  --succes-fond: #e6f4ec;
  --erreur: #d63638;
  --erreur-fond: #fbeaea;
  --alerte: #996800;
  --alerte-fond: #fcf9e8;
  --d1: #2271b1;
  --d2: #007a3d;
  --d3: #7c3aed;
  --d4: #c2570a;
  --rayon: 12px;
  --ombre: 0 1px 3px rgb(0 0 0 / 0.09), 0 4px 14px rgb(0 0 0 / 0.05);
  --nav-basse-h: calc(58px + env(safe-area-inset-bottom));
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1d2327;
    --surface: #2c3338;
    --surface-2: #23282d;
    --texte: #f0f0f1;
    --texte-2: #b5b9bd;
    --bordure: #3f474e;
    --accent: #72aee6;
    --accent-fort: #9ec2e6;
    --sur-accent: #10171d;
    --succes: #55c579;
    --succes-fond: #1c3325;
    --erreur: #f8807f;
    --erreur-fond: #40272a;
    --alerte: #e5c15c;
    --alerte-fond: #3a331c;
    --d1: #72aee6;
    --d2: #55c579;
    --d3: #b79af0;
    --d4: #eda15c;
    --ombre: 0 1px 3px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.icone { width: 24px; height: 24px; flex: none; }

/* ---------- Entête & navigation ---------- */

.entete {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}

.entete-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  text-decoration: none;
  color: var(--texte);
}
.entete-logo .icone { color: var(--accent); }
.entete-logo strong { color: var(--accent); }

.entete-nav { display: none; gap: 4px; }
.entete-nav a {
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--texte-2);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s, background-color 0.2s;
}
.entete-nav a:hover { color: var(--texte); background: var(--surface-2); }
.entete-nav a[aria-current="page"] { color: var(--accent); background: var(--surface-2); }

.nav-basse {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--bordure);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-basse a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  min-height: 44px;
  font-size: 11px;
  color: var(--texte-2);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-basse a .icone { width: 22px; height: 22px; }
.nav-basse a[aria-current="page"] { color: var(--accent); }

@media (min-width: 768px) {
  .entete-nav { display: flex; }
  .nav-basse { display: none; }
  :root { --nav-basse-h: 0px; }
}

/* ---------- Structure ---------- */

.contenu {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px calc(24px + var(--nav-basse-h));
  outline: none;
}

.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px;
  margin-bottom: 16px;
}

.carte h2 { margin: 0 0 4px; font-size: 20px; }
.carte > p:first-of-type { margin-top: 0; }

.sous-titre { color: var(--texte-2); font-size: 14px; margin: 0 0 12px; }

a.carte {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--texte);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
a.carte:hover { border-color: var(--accent); }
a.carte .icone { width: 30px; height: 30px; color: var(--accent); }
a.carte .fleche { margin-left: auto; color: var(--texte-2); width: 20px; }
a.carte h2 { font-size: 17px; }
a.carte p { margin: 0; font-size: 14px; color: var(--texte-2); }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primaire { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.btn-primaire:hover:not(:disabled) { background: var(--accent-fort); border-color: var(--accent-fort); color: var(--sur-accent); }

.btn-danger { color: var(--erreur); border-color: var(--erreur); background: transparent; }
.btn-danger:hover { background: var(--erreur-fond); color: var(--erreur); }

.btn-large { width: 100%; min-height: 54px; font-size: 17px; }

.groupe-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---------- Formulaires ---------- */

label.champ { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
label.champ select,
select.selection-inline {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-height: 48px;
  padding: 8px 12px;
  font: inherit;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  cursor: pointer;
}

select.selection-inline {
  display: inline-block;
  width: auto;
  min-height: 42px;
  margin: 4px 2px;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Questions ---------- */

.q-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--texte-2);
}
.pastille {
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  font-weight: 600;
}
.pastille-domaine-1 { color: var(--d1); }
.pastille-domaine-2 { color: var(--d2); }
.pastille-domaine-3 { color: var(--d3); }
.pastille-domaine-4 { color: var(--d4); }

.q-enonce { font-size: 17.5px; font-weight: 600; margin: 0 0 16px; line-height: 1.5; }

.options { display: grid; gap: 10px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  color: var(--texte);
  background: var(--surface);
  border: 2px solid var(--bordure);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option .coche {
  flex: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--bordure);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: border-color 0.15s, background-color 0.15s;
}
.option.multi .coche { border-radius: 6px; }
.option.choisie { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.option.choisie .coche { border-color: var(--accent); background: var(--accent); color: var(--sur-accent); }
.option.choisie .coche svg { width: 14px; height: 14px; }

.option.correcte { border-color: var(--succes); background: var(--succes-fond); }
.option.correcte .coche { border-color: var(--succes); background: var(--succes); color: #fff; }
.option.incorrecte { border-color: var(--erreur); background: var(--erreur-fond); }
.option.incorrecte .coche { border-color: var(--erreur); background: var(--erreur); color: #fff; }

/* Association : deux colonnes de puces à apparier */
.assoc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.assoc-col { display: grid; gap: 10px; align-content: start; }
.puce {
  position: relative;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  text-align: left;
  color: var(--texte);
  background: var(--surface);
  border: 2px solid var(--bordure);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.puce:hover:not(:disabled) { border-color: var(--accent); }
.puce:disabled { cursor: default; }
.puce.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.puce.appariee { border-style: solid; }
.puce .no-paire {
  position: absolute;
  top: -9px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--sur-accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.puce.correcte { border-color: var(--succes); background: var(--succes-fond); }
.puce.incorrecte { border-color: var(--erreur); background: var(--erreur-fond); }
.assoc-aide { grid-column: 1 / -1; font-size: 13px; color: var(--texte-2); margin: 0; }

/* Texte à trous */
.texte-trous { font-size: 16.5px; }
.selection-inline.correcte { border-color: var(--succes); background: var(--succes-fond); color: var(--succes); }
.selection-inline.incorrecte { border-color: var(--erreur); background: var(--erreur-fond); color: var(--erreur); }

/* Correction */
.explication {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  border-left: 4px solid var(--succes);
  background: var(--succes-fond);
  font-size: 15px;
}
.explication.mauvaise { border-left-color: var(--erreur); background: var(--erreur-fond); }
.explication .verdict {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 6px;
}
.explication .verdict .icone { width: 20px; height: 20px; }
.explication .verdict.ok { color: var(--succes); }
.explication .verdict.ko { color: var(--erreur); }
.explication p { margin: 6px 0 0; }
.explication .bonne-rep { font-weight: 600; }

/* ---------- Barres de progression & jauges ---------- */

.barre {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  overflow: hidden;
}
.barre > div {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.barre.fine { height: 6px; }
.barre-d1 > div { background: var(--d1); }
.barre-d2 > div { background: var(--d2); }
.barre-d3 > div { background: var(--d3); }
.barre-d4 > div { background: var(--d4); }

.ligne-domaine { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.ligne-domaine .nom { flex: 1; font-size: 14px; font-weight: 600; }
.ligne-domaine .barre { flex: 2; }
.ligne-domaine .valeur { width: 52px; text-align: right; font-size: 14px; color: var(--texte-2); font-variant-numeric: tabular-nums; }

/* Bandeau examen (progression + chrono) */
.bandeau-examen {
  position: sticky;
  top: 58px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.bandeau-examen .barre { flex: 1; }
.minuteur {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 17px;
}
.minuteur .icone { width: 20px; height: 20px; }
.minuteur.urgent { color: var(--erreur); }

/* Score final */
.score-final { text-align: center; padding: 28px 20px; }
.score-final .score { font-size: 56px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score-final .sur-1000 { font-size: 18px; color: var(--texte-2); }
.badge-niveau {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 18px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 15px;
  border: 2px solid;
}
.niveau-initial { color: var(--texte-2); border-color: var(--texte-2); }
.niveau-basique { color: var(--alerte); border-color: var(--alerte); background: var(--alerte-fond); }
.niveau-operationnel { color: var(--accent); border-color: var(--accent); }
.niveau-avance { color: var(--d3); border-color: var(--d3); }
.niveau-expert { color: var(--succes); border-color: var(--succes); background: var(--succes-fond); }

.echelle-niveaux {
  display: flex;
  margin-top: 20px;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--bordure);
  font-size: 0;
}
.echelle-niveaux span { height: 12px; }

/* ---------- Fiches de révision ---------- */

.accordeon { border: 1px solid var(--bordure); border-radius: var(--rayon); background: var(--surface); margin-bottom: 12px; box-shadow: var(--ombre); }
.accordeon summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  min-height: 52px;
}
.accordeon summary::-webkit-details-marker { display: none; }
.accordeon summary .icone { color: var(--texte-2); width: 20px; transition: transform 0.2s; }
.accordeon[open] summary .icone { transform: rotate(90deg); }
.accordeon .fiche-corps { padding: 0 18px 18px; }

.fiche-corps h3 { font-size: 16px; margin: 18px 0 6px; color: var(--accent); }
.fiche-corps h3:first-child { margin-top: 0; }
.fiche-corps p { margin: 6px 0; }
.fiche-corps ul { margin: 6px 0; padding-left: 20px; }
.fiche-corps li { margin: 4px 0; }
.fiche-corps code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: 5px;
  padding: 1px 6px;
}
.fiche-corps .tableau { overflow-x: auto; }
.fiche-corps table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
.fiche-corps th, .fiche-corps td { border: 1px solid var(--bordure); padding: 7px 10px; text-align: left; vertical-align: top; }
.fiche-corps th { background: var(--surface-2); }
.fiche-corps .astuce {
  border-left: 4px solid var(--alerte);
  background: var(--alerte-fond);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 14.5px;
}

/* ---------- Statistiques ---------- */

.grille-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tuile { background: var(--surface-2); border: 1px solid var(--bordure); border-radius: 10px; padding: 14px; text-align: center; }
.stat-tuile .valeur { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-tuile .libelle { font-size: 12.5px; color: var(--texte-2); }

.graphique-scores { width: 100%; height: auto; margin-top: 8px; }

.liste-examens { list-style: none; margin: 0; padding: 0; }
.liste-examens li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--bordure);
  font-size: 14.5px;
}
.liste-examens li:last-child { border-bottom: none; }
.liste-examens .date { color: var(--texte-2); flex: 1; }
.liste-examens .score { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Checklist Jour J ---------- */

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { margin: 8px 0; }
.checklist label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.checklist label:hover { border-color: var(--accent); }
.checklist input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--accent); cursor: pointer; }
.checklist input:checked + span { color: var(--texte-2); text-decoration: line-through; }

/* ---------- Divers ---------- */

.vide {
  text-align: center;
  color: var(--texte-2);
  padding: 32px 16px;
}

.avertissement {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-left: 4px solid var(--alerte);
  background: var(--alerte-fond);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 14.5px;
}
.avertissement .icone { color: var(--alerte); width: 20px; flex: none; margin-top: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.contenu:focus, .contenu:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media (min-width: 768px) {
  .contenu { padding-top: 28px; }
  .grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .grille-2 > .carte, .grille-2 > a.carte { margin-bottom: 0; }
  .bandeau-examen { top: 66px; }
}
