/* Test de niveau ILS : mobile d'abord, police du système, aucune ressource externe.
   Compatible Chrome 61 : espacements par marges, positions par top/left, aucun sélecteur récent. */

:root {
  color-scheme: only light;
  --fond: #eef3f6;
  --carte: #fff;
  --texte: #15232d;
  --texte-doux: #4b5d6b;
  --primaire: #0b5470;
  --primaire-fonce: #083d52;
  --primaire-clair: #e3f0f5;
  --bord: #cdd9e1;
  --bord-fort: #8aa1b1;
  --focus: #b45309;
  --ok: #1d7a46;
  --erreur: #b42318;
  --erreur-fond: #fdecea;
  --alerte-texte: #5c3200;
  --alerte-fond: #fff4e0;
  --alerte-bord: #e9a23b;
  --wa: #25d366;
  --wa-actif: #1fbf5b;
  --wa-texte: #0b1f14;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--fond);
  color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 1.0625rem; /* 17 px */
  line-height: 1.5;
  word-wrap: break-word;     /* un mot très long (saisie, message du serveur) ne fait pas déborder l'écran */
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
p { margin: 0 0 14px; }

/* ---------- Barre du haut : marque discrète + avancement ---------- */

.barre { position: -webkit-sticky; position: sticky; top: 0; z-index: 10; background: var(--primaire); color: #fff; }
.barre-contenu { max-width: 560px; min-height: 34px; margin: 0 auto; padding: 7px 16px; }
.marque { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 255, 255, 0.82); }
.progression { height: 5px; background: rgba(255, 255, 255, 0.22); }
.progression-remplie { width: 0; height: 100%; background: #7fd8cf; transition: width 0.3s ease; }

/* ---------- Mise en page ---------- */

main { display: block; max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
main:focus { outline: none; }

.carte {
  padding: 24px 20px;
  border-radius: 16px;
  background: var(--carte);
  box-shadow: 0 1px 2px rgba(16, 42, 60, 0.06), 0 6px 20px rgba(16, 42, 60, 0.08);
  animation: apparaitre 0.18s ease-out;
}

@keyframes apparaitre {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.chargement-initial, .noscript { margin: 24px 0; text-align: center; color: var(--texte-doux); }
.noscript { padding: 16px; border-radius: 12px; background: var(--alerte-fond); color: var(--alerte-texte); }

/* Message de secours de index.html : app.js le remplace aussitôt ; s'il est encore là après 15 s, le script n'a pas pu tourner. */
.secours {
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  background: var(--alerte-fond);
  color: var(--alerte-texte);
  text-align: center;
  visibility: hidden;
  opacity: 0;
  -webkit-animation: secours 0.3s ease-out 15s forwards;
  animation: secours 0.3s ease-out 15s forwards;
}

@-webkit-keyframes secours { to { visibility: visible; opacity: 1; } }
@keyframes secours { to { visibility: visible; opacity: 1; } }

h1 { margin: 0 0 16px; font-size: 1.5rem; line-height: 1.25; font-weight: 700; text-wrap: balance; }
h1:focus, h2:focus { outline: none; }
.sous-titre { margin: 22px 0 8px; font-size: 1rem; font-weight: 700; color: var(--texte-doux); }
.etiquette { margin: 0 0 6px; font-size: 0.9375rem; font-weight: 700; color: var(--primaire); }
.aide, .indice { color: var(--texte-doux); }
.indice { margin: -2px 0 8px; font-size: 1rem; }
.insecable { white-space: nowrap; }

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

.bouton {
  display: block;
  width: 100%;
  min-height: 52px;
  margin: 20px 0 0;
  padding: 12px 20px;
  border: 2px solid var(--primaire);
  border-radius: 12px;
  background: var(--primaire);
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.bouton:active { background: var(--primaire-fonce); border-color: var(--primaire-fonce); }
.bouton.secondaire { margin-top: 12px; background: transparent; color: var(--primaire); }
.bouton.secondaire:active { background: var(--primaire-clair); }

.precedent, .lien {
  display: inline-block;
  min-height: 48px;
  padding: 12px 8px;
  border: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.precedent { margin: 16px 0 0 -8px; color: var(--primaire); font-size: 1rem; font-weight: 600; }
.lien { display: block; margin: 8px auto 0; color: var(--texte-doux); font-size: 0.9375rem; }

/* Focus visible au clavier ; les titres reçoivent le focus sans contour (ils ne sont pas cliquables). */
a:focus, button:focus, input:focus, select:focus, textarea:focus, summary:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
a:focus:not(:focus-visible), button:focus:not(:focus-visible), summary:focus:not(:focus-visible) { outline: none; }

/* ---------- Accueil ---------- */

.atouts { margin: 0 0 18px; padding: 0; list-style: none; }
.atouts li { position: relative; margin: 0 0 6px; padding-left: 30px; font-weight: 600; }

.atouts li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  top: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primaire-clair);
  color: var(--primaire);
  font-size: 0.8125rem;
  line-height: 22px;
  text-align: center;
}

.consignes { padding: 14px 16px 2px; border: 1px solid var(--bord); border-radius: 12px; background: #f4f8fa; }

/* ---------- Choix de réponse ---------- */

.choix-liste { min-width: 0; margin: 0; padding: 0; border: 0; }

.choix {
  position: relative;
  display: block;
  width: 100%;
  min-height: 56px;
  margin: 0 0 12px;
  padding: 14px 16px 14px 52px;
  border: 2px solid var(--bord);
  border-radius: 12px;
  background: var(--carte);
  color: var(--texte);
  font: inherit;
  font-size: 1.125rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.choix::before { /* le rond de sélection */
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border: 2px solid var(--bord-fort);
  border-radius: 50%;
  background: #fff;
}

.choix:active { background: var(--primaire-clair); }
.choix.choisi { border-color: var(--primaire); background: var(--primaire-clair); }
.choix.choisi::before { border-color: var(--primaire); background: radial-gradient(circle, var(--primaire) 45%, #fff 50%); }
.choix.jnsp { margin-top: 20px; border-style: dashed; background: transparent; color: var(--texte-doux); font-size: 1.0625rem; }
.choix.jnsp.choisi { background: var(--primaire-clair); color: var(--texte); }
@media (hover: hover) { .choix:hover { border-color: var(--primaire); } }

.enonce { margin: 6px 0 20px; font-size: 1.3125rem; font-weight: 600; line-height: 1.45; }
.trou { display: inline-block; width: 3.2em; height: 1.1em; margin: 0 0.15em; border-bottom: 3px solid var(--primaire); vertical-align: -0.2em; }

/* ---------- Texte de lecture, audio ---------- */

.texte { line-height: 1.6; }
.texte-titre { font-weight: 700; }
.relire { margin: 0 0 16px; border: 1px solid var(--bord); border-radius: 12px; background: #f7fafc; }
.relire summary { min-height: 48px; padding: 12px 16px; color: var(--primaire); font-weight: 700; cursor: pointer; }
.relire[open] summary { border-bottom: 1px solid var(--bord); }
.relire .texte { max-height: 45vh; padding: 12px 16px 2px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.audio { display: block; width: 100%; margin: 0 0 16px; }

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

.champ { margin: 0 0 20px; }
.libelle { display: block; margin: 0 0 6px; font-weight: 700; }

.saisie {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--bord-fort);
  border-radius: 10px;
  background: #fff;
  color: var(--texte);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.saisie:focus { border-color: var(--primaire); }
.saisie[aria-invalid="true"] { border-color: var(--erreur); }
.zone { min-height: 180px; resize: vertical; }
.liste { padding-right: 44px; }
.cadre-liste { position: relative; display: block; }

.cadre-liste::after { /* chevron dessiné en CSS : pas d'image */
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -7px;
  border-right: 2.5px solid var(--primaire);
  border-bottom: 2.5px solid var(--primaire);
  transform: rotate(45deg);
  pointer-events: none;
}

.erreur { margin: 6px 0 0; color: var(--erreur); font-size: 1rem; font-weight: 600; }
.case { display: flex; align-items: flex-start; min-height: 48px; margin: 0 -10px; padding: 10px; border-radius: 10px; cursor: pointer; }
.case input { flex: none; width: 24px; height: 24px; margin: 1px 12px 0 0; accent-color: var(--primaire); }
.case span { line-height: 1.45; }
.autre { margin: 4px 0 0; }
.compteur { margin: 8px 0 0; color: var(--texte-doux); font-size: 1rem; }
.compteur.ok { color: var(--ok); font-weight: 700; }
.compteur.ok::before { content: "\2713\00a0"; }

/* ---------- Envoi ---------- */

.attente { padding-top: 36px; padding-bottom: 36px; text-align: center; }

.roue {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 20px;
  border: 4px solid var(--primaire-clair);
  border-top-color: var(--primaire);
  border-radius: 50%;
  animation: tourner 0.9s linear infinite;
}

@keyframes tourner { to { transform: rotate(360deg); } }

/* ---------- Résultat ---------- */

.badge { display: flex; align-items: center; margin: 4px 0 18px; padding: 16px 18px; border-radius: 14px; background: var(--primaire); color: #fff; }
.badge-niveau { flex: none; margin-right: 16px; padding-right: 16px; border-right: 2px solid rgba(255, 255, 255, 0.35); font-size: 3rem; font-weight: 800; line-height: 1; }
.badge-libelle { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.25; }
.badge-score { display: block; margin-top: 2px; }
.reperes { margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--bord); border-radius: 12px; background: #f4f8fa; }
.repere { margin: 0 0 2px; }
.repere-nom { display: inline-block; min-width: 4em; font-weight: 700; }
.repere-note { margin: 6px 0 0; color: var(--texte-doux); font-size: 0.9375rem; font-style: italic; }
.ecart strong { color: var(--primaire); }
.niveaux { margin: 0 0 16px; padding: 0; list-style: none; }
.niveaux li { display: flex; align-items: center; margin: 0 0 6px; font-size: 0.9375rem; }
.niveau-nom { flex: none; width: 2.4em; font-weight: 700; }
.jauge { flex: 1; height: 8px; margin: 0 10px; border-radius: 4px; background: #e2eaf0; overflow: hidden; }
.jauge-remplie { display: block; width: 0; height: 100%; border-radius: 4px; background: var(--bord-fort); }
.niveau-score { flex: none; width: 2.8em; text-align: right; color: var(--texte-doux); }
.niveaux .estime .niveau-nom { color: var(--primaire); }
.niveaux .estime .jauge-remplie { background: var(--primaire); }
.alerte { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--alerte-bord); border-left-width: 5px; border-radius: 10px; background: var(--alerte-fond); color: var(--alerte-texte); }
.erreur-serveur { border-color: var(--erreur); background: var(--erreur-fond); color: var(--erreur); font-weight: 600; }
.message-fin { font-weight: 600; }

.bouton-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  margin: 22px 0 14px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--wa);
  color: var(--wa-texte);
  font-size: 1.1875rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(18, 140, 126, 0.35);
}

.bouton-whatsapp:active { background: var(--wa-actif); }
.vocal { margin: 0 0 8px; }
.vocal span { font-weight: 600; }
.ref { margin: 22px 0 0; color: var(--texte-doux); font-size: 0.875rem; text-align: center; }

/* ---------- Lecteurs d'écran ---------- */

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

/* ---------- Petits écrans (320 px), mouvements réduits ---------- */

@media (max-width: 359px) {
  main { padding: 12px 10px 32px; }
  .carte { padding: 20px 14px; }
  h1 { font-size: 1.375rem; }
  .enonce { font-size: 1.25rem; }
  .badge-niveau { font-size: 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
