/* ============================================================
   TEF Entraînement — feuille de style
   Sobre, responsive, contrastes AA, focus visibles.
   ============================================================ */

:root {
  --bleu: #1a5276;        /* couleur principale */
  --bleu-clair: #d6eaf8;
  --orange: #b9770e;      /* accent (rappel de la maquette du livre) */
  --vert: #1e7d43;
  --vert-fond: #e6f4ea;
  --rouge: #b03a2e;
  --rouge-fond: #fdecea;
  --jaune-fond: #fef9e7;
  --encre: #1c2833;
  --gris: #5d6d7e;
  --fond: #f4f6f7;
  --carte: #ffffff;
  --bord: #d5dbdb;
  --focus: #8e44ad;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

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

/* Focus clavier bien visible partout */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Barre supérieure ---------- */
.topbar {
  background: var(--bleu);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .6rem 1.2rem;
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.brand {
  background: none; border: 0; color: #fff; font: inherit;
  font-weight: 800; letter-spacing: .05em; cursor: pointer;
}
.brand span { font-weight: 400; opacity: .85; }
.nav-btn {
  background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 6px; padding: .4rem .9rem;
  font-size: .95rem; cursor: pointer;
  margin-left: .4rem;
}
.nav-btn:hover, .nav-btn[aria-current="true"] { background: rgba(255,255,255,.18); }

/* ---------- Mise en page ---------- */
#app { max-width: 900px; margin: 0 auto; padding: 1.2rem; }
.view > h2 { color: var(--bleu); }

.card {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin: 1rem 0;
}

.muted { color: var(--gris); font-size: .92rem; }

/* ---------- Boutons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .55rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
}
.btn-lg { padding: .75rem 1.6rem; font-size: 1.08rem; }
.btn-sm { padding: .35rem .7rem; font-size: .88rem; }
.btn-primary { background: var(--bleu); color: #fff; }
.btn-primary:hover { background: #154360; }
.btn-primary:disabled { background: #aab7c4; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--bleu); border-color: var(--bleu); }
.btn-ghost:hover { background: var(--bleu-clair); }
.btn-danger { background: #fff; color: var(--rouge); border-color: var(--rouge); }
.btn-danger:hover { background: var(--rouge-fond); }

/* ---------- Formulaire de configuration ---------- */
fieldset { border: 1px solid var(--bord); border-radius: 8px; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .4rem; }
.radio-row { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
.radio-row label { display: flex; align-items: center; gap: .4rem; padding: .2rem 0; }
.radio-row small { color: var(--gris); }
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1rem;
}
.config-grid label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
select, textarea, input[type="text"] {
  font: inherit; color: inherit;
  border: 1px solid var(--bord); border-radius: 6px;
  padding: .45rem .6rem; background: #fff;
}

/* ---------- Bandeaux ---------- */
.banner { border-radius: 8px; padding: .7rem 1rem; margin: .8rem 0; }
.banner-info { background: var(--bleu-clair); border: 1px solid var(--bleu); }
.banner-warn { background: var(--jaune-fond); border: 1px solid var(--orange); }
.banner-actions { display: flex; gap: .6rem; margin-top: .5rem; }

/* ---------- Quiz ---------- */
.quiz-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: .5rem;
}
.badge {
  display: inline-block; background: var(--bleu); color: #fff;
  border-radius: 999px; padding: .15rem .7rem; font-size: .85rem; font-weight: 600;
}
.badge-ajoutee { background: var(--orange); }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 1.3rem;
  padding: .2rem .7rem; border-radius: 8px;
  background: var(--carte); border: 1px solid var(--bord);
}
.timer.alerte { background: var(--rouge-fond); color: var(--rouge); border-color: var(--rouge); }

.progress {
  height: 8px; background: var(--bord); border-radius: 999px;
  overflow: hidden; margin: .6rem 0 1rem;
}
.progress-fill { height: 100%; width: 0; background: var(--bleu); transition: width .25s; }

.consigne { font-weight: 600; color: var(--bleu); margin-top: 0; }
.support { background: var(--jaune-fond); border: 1px solid var(--bord); border-radius: 8px; padding: .5rem .9rem; margin-bottom: .8rem; }
.support summary { cursor: pointer; font-weight: 600; }
.support-court, #q-support {
  white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
}
.support-court {
  background: var(--jaune-fond); border: 1px solid var(--bord);
  border-radius: 8px; padding: .7rem 1rem; margin-bottom: .8rem;
}
.enonce { font-size: 1.12rem; margin: .6rem 0; }

.options { display: flex; flex-direction: column; gap: .5rem; }
.option {
  display: flex; align-items: flex-start; gap: .6rem;
  border: 1px solid var(--bord); border-radius: 8px;
  padding: .6rem .8rem; cursor: pointer; background: #fff;
}
.option:hover { border-color: var(--bleu); }
.option input { margin-top: .25rem; }
.option .lettre { font-weight: 700; color: var(--bleu); min-width: 1.2rem; }
.option.correcte { background: var(--vert-fond); border-color: var(--vert); }
.option.fausse { background: var(--rouge-fond); border-color: var(--rouge); }
.option.desactivee { pointer-events: none; }

.feedback { margin-top: 1rem; border-top: 1px dashed var(--bord); padding-top: .8rem; }
.verdict { font-weight: 700; }
.verdict.ok { color: var(--vert); }
.verdict.ko { color: var(--rouge); }

.quiz-nav { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0 2rem; }
.quiz-nav .btn-danger { margin-left: auto; }

/* ---------- Résultats ---------- */
.res-global { text-align: center; }
.res-global .gros-score { font-size: 2.6rem; font-weight: 800; color: var(--bleu); margin: .2rem 0; }
.niveau-pill {
  display: inline-block; font-weight: 800; font-size: 1.15rem;
  border-radius: 999px; padding: .25rem 1rem; color: #fff; background: var(--bleu);
}
.niveau-pill.atteint { background: var(--vert); }
.niveau-pill.sous-objectif { background: var(--orange); }

.res-ligne { margin: .7rem 0; }
.res-ligne .res-barre {
  height: 14px; border-radius: 999px; background: var(--bord);
  overflow: hidden; margin-top: .25rem; position: relative;
}
.res-ligne .res-barre > div { height: 100%; background: var(--bleu); }
.res-ligne .objectif-c1 {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--vert); left: 75%;
}
.res-ligne .entete { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }

.bareme table { border-collapse: collapse; margin: .5rem 0; }
.bareme th, .bareme td { border: 1px solid var(--bord); padding: .3rem .8rem; text-align: left; }

.arevoir-item { border: 1px solid var(--bord); border-radius: 8px; padding: .7rem 1rem; margin: .7rem 0; }
.arevoir-item .q-meta { color: var(--gris); font-size: .88rem; }
.arevoir-item .bonne { color: var(--vert); font-weight: 700; }
.arevoir-item .donnee { color: var(--rouge); font-weight: 700; }

/* ---------- Expression écrite ---------- */
.tabs { display: flex; gap: .4rem; margin: 1rem 0 0; }
.tab {
  border: 1px solid var(--bord); border-bottom: none;
  border-radius: 8px 8px 0 0; background: #e8ecee;
  padding: .55rem 1.1rem; font-size: 1rem; cursor: pointer;
}
.tab.active { background: var(--carte); font-weight: 700; color: var(--bleu); }
#panel-ee { border-top-left-radius: 0; margin-top: 0; }
#panel-ee label { display: block; font-weight: 600; margin: .7rem 0; }
#panel-ee select, #panel-ee textarea { width: 100%; margin-top: .3rem; }
#ee-texte { font-size: 1.05rem; line-height: 1.7; resize: vertical; }

.ee-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: .8rem; margin: .8rem 0;
}
.ee-timer-box { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.compteur { font-weight: 700; font-size: 1.05rem; padding: .3rem .8rem; border-radius: 8px; }
.compteur-bas { background: var(--rouge-fond); color: var(--rouge); }
.compteur-proche { background: var(--jaune-fond); color: var(--orange); }
.compteur-ok { background: var(--vert-fond); color: var(--vert); }

.ee-actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .8rem 0 .3rem; }
.copie-ok { color: var(--vert); font-weight: 700; }

/* ---------- Historique ---------- */
.histo-table { width: 100%; border-collapse: collapse; margin-bottom: .8rem; }
.histo-table th, .histo-table td { border: 1px solid var(--bord); padding: .4rem .7rem; text-align: left; }
.histo-table th { background: var(--bleu-clair); }
.legende { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .5rem; }
.legende span::before {
  content: ""; display: inline-block; width: 12px; height: 12px;
  border-radius: 3px; margin-right: .35rem; background: var(--c, var(--bleu));
}

/* ---------- Pied de page ---------- */
.footer { text-align: center; color: var(--gris); font-size: .85rem; padding: 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .quiz-nav .btn-danger { margin-left: 0; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* Pages multi-questions (texte lacunaire, article à plusieurs questions…) */
.q-item + .q-item { margin-top: 1.4rem; border-top: 1px solid var(--bord); padding-top: 1rem; }

/* Audio et documents en images (livrets officiels) */
.q-audio { width: 100%; margin: .6rem 0; }
.q-figures { display: flex; flex-wrap: wrap; gap: .8rem; margin: .6rem 0; }
.q-figure { margin: 0; flex: 1 1 260px; max-width: 340px; }
.q-figure img { max-width: 100%; height: auto; border: 1px solid var(--bord); border-radius: 6px; background: #fff; }
.q-figure figcaption { font-size: .85rem; color: var(--texte-muted, #5d6d7e); text-align: center; margin-top: .25rem; }
.badge-officiel { background: #1a5276; color: #fff; }
