/* ===========================================================================
   Quiz ENM — feuille de style
   Sombre, mobile d'abord. Retour visuel a l'appui (jamais au relachement),
   ressorts sobres, chrome translucide, respect des reglages d'accessibilite.
   =========================================================================== */

:root {
  --fond:            #0b0d12;
  --fond-eleve:      #141822;
  --fond-carte:      rgba(255, 255, 255, 0.045);
  --bord:            rgba(255, 255, 255, 0.09);
  --bord-net:        rgba(255, 255, 255, 0.16);
  --texte:           #f2f4f8;
  --texte-doux:      #9aa3b4;
  --texte-faible:    #6b7383;
  --accent:          #6c8cff;
  --accent-sourd:    rgba(108, 140, 255, 0.16);
  --juste:           #2fbf71;
  --juste-sourd:     rgba(47, 191, 113, 0.14);
  --faux:            #ff5f6d;
  --faux-sourd:      rgba(255, 95, 109, 0.13);
  --or:              #d9b56a;

  --r-s: 10px;  --r-m: 16px;  --r-l: 22px;
  --marge: 20px;
  --ressort: 380ms cubic-bezier(0.32, 0.72, 0, 1);   /* critiquement amorti */
  --vif: 120ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Un `display` explicite l'emporte sur l'attribut hidden : sans cette regle,
   la barre d'onglets et la barre d'action restent visibles quand on les cache. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--fond);
  color: var(--texte);
  font: 400 17px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  /* Halo tres doux en haut : de la profondeur sans image de fond. */
  background-image:
    radial-gradient(120% 60% at 50% -10%, rgba(108, 140, 255, 0.13), transparent 60%),
    radial-gradient(90% 50% at 100% 0%, rgba(217, 181, 106, 0.06), transparent 55%);
  background-attachment: fixed;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.021em; line-height: 1.15; }
h1 { font-size: 2rem; }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.0rem; letter-spacing: 0; }
p  { margin: 0; }

/* ── Ecrans ─────────────────────────────────────────────────────────────── */
.ecran {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.ecran.active { display: flex; }

.defilant {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 var(--marge) calc(112px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}
.defilant::-webkit-scrollbar { display: none; }
.defilant.centre { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 8vh; }

/* ── Entetes ────────────────────────────────────────────────────────────── */
.entete {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; padding: 22px var(--marge) 14px;
}
.salutation { color: var(--texte-doux); font-size: 0.92rem; letter-spacing: 0.01em; }
.titre-section {
  color: var(--texte-doux); text-transform: uppercase; font-size: 0.74rem;
  letter-spacing: 0.09em; font-weight: 600; margin: 26px 0 10px 2px;
}

/* ── Boutons ────────────────────────────────────────────────────────────── */
button {
  font: inherit; color: inherit; border: none; background: none;
  cursor: pointer; touch-action: manipulation;
}
/* Le retour visuel vit sur l'appui, pas sur le relachement. */
button:active { transform: scale(0.975); }
button { transition: transform var(--vif), background var(--vif), border-color var(--vif); }

.principal, .secondaire {
  display: block; width: 100%; padding: 16px; border-radius: var(--r-m);
  font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em;
}
.principal { background: var(--accent); color: #08101f; }
.principal:disabled { opacity: 0.4; }
.secondaire { background: var(--fond-carte); color: var(--texte); border: 1px solid var(--bord); }

.icone {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.05rem;
  background: var(--fond-carte); color: var(--texte-doux); border: 1px solid var(--bord);
  flex: none;
}

/* ── Connexion ──────────────────────────────────────────────────────────── */
.connexion {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 0 var(--marge) calc(24px + env(safe-area-inset-bottom));
  max-width: 420px; width: 100%; margin: 0 auto;
}
.marque { text-align: center; margin-bottom: 34px; }
.sceau {
  width: 62px; height: 62px; margin: 0 auto 18px; border-radius: 20px;
  display: grid; place-items: center; font-size: 1.9rem; font-weight: 500;
  color: var(--or);
  background: linear-gradient(160deg, rgba(217, 181, 106, 0.20), rgba(217, 181, 106, 0.05));
  border: 1px solid rgba(217, 181, 106, 0.28);
}
.sous-titre { color: var(--texte-doux); font-size: 0.95rem; margin-top: 6px; }

.profils { display: flex; gap: 8px; margin-bottom: 16px; }
.profil {
  flex: 1; padding: 11px 6px; border-radius: var(--r-s); font-size: 0.94rem; font-weight: 550;
  background: var(--fond-carte); border: 1px solid var(--bord); color: var(--texte-doux);
}
.profil[aria-pressed="true"] { background: var(--accent-sourd); border-color: var(--accent); color: var(--texte); }

input {
  width: 100%; padding: 15px 16px; margin-bottom: 10px;
  border-radius: var(--r-m); border: 1px solid var(--bord);
  background: var(--fond-carte); color: var(--texte); font: inherit;
}
input::placeholder { color: var(--texte-faible); }
input:focus { outline: none; border-color: var(--accent); background: rgba(108, 140, 255, 0.07); }

.erreur { color: var(--faux); font-size: 0.9rem; margin-top: 12px; text-align: center; }
#form-connexion .principal { margin-top: 6px; }

/* ── Resume et matieres ─────────────────────────────────────────────────── */
.resume {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px;
}
.tuile {
  background: var(--fond-carte); border: 1px solid var(--bord);
  border-radius: var(--r-m); padding: 14px 12px; text-align: center;
}
.tuile b { display: block; font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; }
.tuile span { display: block; color: var(--texte-doux); font-size: 0.73rem; margin-top: 3px; letter-spacing: 0.02em; }

.matieres { display: flex; flex-direction: column; gap: 9px; }
.matiere {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 15px 16px; border-radius: var(--r-m);
  background: var(--fond-carte); border: 1px solid var(--bord);
}
.matiere:active { background: rgba(255, 255, 255, 0.075); }
.matiere .nom { flex: 1; font-weight: 550; letter-spacing: -0.01em; }
.matiere .detail { display: block; color: var(--texte-faible); font-size: 0.8rem; font-weight: 400; margin-top: 3px; letter-spacing: 0; }
.matiere .taux { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.95rem; }
.anneau { width: 34px; height: 34px; flex: none; }
.anneau circle { fill: none; stroke-width: 3.5; stroke-linecap: round; }
.anneau .piste { stroke: rgba(255, 255, 255, 0.09); }
.anneau .part { stroke: var(--accent); transition: stroke-dasharray var(--ressort); }

.bandeau-hors-ligne {
  margin-top: 14px; padding: 11px 14px; border-radius: var(--r-s);
  background: rgba(217, 181, 106, 0.11); border: 1px solid rgba(217, 181, 106, 0.26);
  color: var(--or); font-size: 0.86rem;
}
.pied-note { color: var(--texte-faible); font-size: 0.78rem; text-align: center; margin-top: 28px; line-height: 1.6; }

/* ── Quiz ───────────────────────────────────────────────────────────────── */
.entete-quiz {
  display: flex; align-items: center; gap: 14px; padding: 14px var(--marge);
}
.jauge { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.jauge > div { height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width var(--ressort); }
.compteur { color: var(--texte-doux); font-size: 0.85rem; font-variant-numeric: tabular-nums; flex: none; }

.fil-ariane { color: var(--accent); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; margin: 10px 0 10px; }
.enonce { font-size: 1.32rem; line-height: 1.32; margin-bottom: 22px; }

.choix { display: flex; flex-direction: column; gap: 9px; }
.option {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  padding: 15px 16px; border-radius: var(--r-m); line-height: 1.4;
  background: var(--fond-carte); border: 1px solid var(--bord);
}
.option:active { background: rgba(255, 255, 255, 0.08); }
.option .lettre {
  flex: none; width: 25px; height: 25px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 650;
  background: rgba(255, 255, 255, 0.08); color: var(--texte-doux);
}
.option[data-etat="juste"]  { background: var(--juste-sourd); border-color: var(--juste); }
.option[data-etat="juste"]  .lettre { background: var(--juste); color: #052a15; }
.option[data-etat="faux"]   { background: var(--faux-sourd); border-color: var(--faux); }
.option[data-etat="faux"]   .lettre { background: var(--faux); color: #2c0308; }
.option[data-etat="eteint"] { opacity: 0.42; }
.option[disabled]:active { transform: none; }

.explication {
  margin-top: 20px; padding: 16px; border-radius: var(--r-m);
  background: var(--fond-eleve); border: 1px solid var(--bord);
  animation: apparait var(--ressort) both;
}
.verdict { font-weight: 650; margin-bottom: 8px; letter-spacing: -0.01em; }
.verdict[data-juste="oui"] { color: var(--juste); }
.verdict[data-juste="non"] { color: var(--faux); }
#texte-explication { color: var(--texte-doux); font-size: 0.95rem; line-height: 1.55; }
.source { color: var(--texte-faible); font-size: 0.82rem; margin-top: 10px; font-style: italic; }

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

/* ── Barre d'action flottante ───────────────────────────────────────────── */
.barre-action {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; gap: 10px;
  padding: 12px var(--marge) calc(12px + env(safe-area-inset-bottom));
  background: rgba(11, 13, 18, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--bord);
}
/* Deux boutons cote a cote : on resserre pour qu'aucun ne passe a la ligne. */
.barre-action > * + * { margin: 0; }
.barre-action:has(> * + *) .principal,
.barre-action:has(> * + *) .secondaire { font-size: 0.97rem; padding: 16px 10px; }

/* ── Resultat ───────────────────────────────────────────────────────────── */
.score {
  width: 128px; height: 128px; border-radius: 50%; margin-bottom: 22px;
  display: grid; place-items: center; align-content: center;
  background: var(--accent-sourd); border: 2px solid var(--accent);
  /* Element flex : sans flex none il se laisse ecraser en ellipse des que le
     recapitulatif deborde. */
  flex: none;
}
.score span { font-size: 2.6rem; font-weight: 680; letter-spacing: -0.03em; line-height: 1; }
.score small { color: var(--texte-doux); font-size: 0.85rem; margin-top: 3px; }
#score-detail { margin-top: 8px; max-width: 30ch; }

.recap { width: 100%; margin-top: 30px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.ligne-recap {
  display: flex; gap: 11px; align-items: flex-start; padding: 13px 14px;
  border-radius: var(--r-s); background: var(--fond-carte); border: 1px solid var(--bord);
  font-size: 0.9rem; line-height: 1.4;
}
.ligne-recap .puce { flex: none; font-size: 0.95rem; }

/* ── Progression ────────────────────────────────────────────────────────── */
.bloc { margin-bottom: 26px; }
.barre-theme { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.barre-theme .libelle { flex: 1; font-size: 0.92rem; }
.barre-theme .libelle small { display: block; color: var(--texte-faible); font-size: 0.76rem; margin-top: 2px; }
.piste-theme { width: 84px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.09); overflow: hidden; flex: none; }
.piste-theme > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.piste-theme > i[data-niveau="bas"]   { background: var(--faux); }
.piste-theme > i[data-niveau="moyen"] { background: var(--or); }
.piste-theme > i[data-niveau="haut"]  { background: var(--juste); }
.vide { color: var(--texte-faible); text-align: center; padding: 44px 20px; line-height: 1.6; }

/* ── Onglets ────────────────────────────────────────────────────────────── */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  padding: 8px var(--marge) calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 13, 18, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--bord);
}
.onglets button {
  flex: 1; padding: 10px 0; color: var(--texte-faible);
  font-size: 0.82rem; font-weight: 560; letter-spacing: 0.01em;
}
.onglets button.actif { color: var(--accent); }

/* ── Accessibilite ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .explication { animation: none; }
  button:active { transform: none; }
  .jauge > div, .anneau .part { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .barre-action, .onglets { background: #0b0d12; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --bord: rgba(255, 255, 255, 0.3); --texte-doux: #c4ccda; --fond-carte: rgba(255, 255, 255, 0.09); }
}

/* Ecrans larges : on centre au lieu d'etirer. Lorenzo l'ouvrira sur son Mac. */
@media (min-width: 700px) {
  .defilant > *, .barre-action { max-width: 640px; margin-left: auto; margin-right: auto; }
  .entete, .entete-quiz { max-width: 640px; margin: 0 auto; width: 100%; }
  .barre-action { left: 50%; transform: translateX(-50%); width: 100%; }
  .onglets { justify-content: center; gap: 40px; }
  .onglets button { flex: 0 0 160px; }
}
