/* =====================================================================
   RoboLab — pages.css
   Styles propres à chaque page : accueil, niveaux, bases, projets,
   page projet, matériel, parcours, crédits.
   ===================================================================== */

.texte-doux { color: var(--texte-doux); font-weight: 600; }
.sous-titre { margin-top: 1.4em; }
/* Les sections ne passent pas sous l'en-tête collant lors du défilement */
section[id], .base-section { scroll-margin-top: 80px; }

/* ===================== Accueil ===================== */
.heros {
  display: grid; gap: 20px; align-items: center;
  background: linear-gradient(135deg, var(--bleu-nuit), var(--bleu) 60%, #3b82f6);
  color: #fff; border-radius: 26px; padding: 28px 22px; overflow: hidden; position: relative;
}
.heros::after {
  content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%;
  background: rgba(249, 115, 22, .35); inset-inline-end: -80px; top: -90px; filter: blur(10px);
}
.heros h1 { color: #fff; margin-bottom: .3em; }
.heros-surtitre {
  display: inline-block; background: rgba(255,255,255,.15); padding: 3px 12px; border-radius: 999px;
  font-weight: 800; font-size: .85rem; margin-bottom: 10px;
}
.heros-accroche { font-size: 1.1rem; color: #dbeafe; max-width: 52ch; }
.heros-boutons { display: flex; flex-wrap: wrap; gap: 10px; }
.heros-texte, .heros-image { position: relative; z-index: 1; }
.heros-image img { border-radius: 20px; box-shadow: 0 12px 30px rgba(0,0,0,.25); animation: flotte 5s ease-in-out infinite; }
@keyframes flotte { 50% { transform: translateY(-8px); } }
@media (min-width: 800px) {
  .heros { grid-template-columns: 1.2fr 1fr; padding: 44px 40px; }
}

.progression-accueil { margin-top: 18px; }
.progression-chiffres { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
@media (min-width: 640px) { .progression-chiffres { grid-template-columns: repeat(4, 1fr); } }
.progression-chiffres div { display: flex; flex-direction: column; }
.progression-chiffres strong { font-size: 1.6rem; color: var(--bleu); line-height: 1.2; }
.progression-chiffres span { color: var(--texte-doux); font-weight: 700; font-size: .9rem; }

.carte-niveau { padding: 18px; border-top: 6px solid var(--c); }
.carte-niveau-haut { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.carte-niveau-emoji { font-size: 1.8rem; }
.carte-niveau-num { font-weight: 800; color: var(--c); font-size: .85rem; text-transform: uppercase; }
.carte-niveau p { color: var(--texte-doux); flex: 1; }
.carte-niveau-bas { margin-top: auto; }

.prochain { display: grid; }
.prochain .prochain-image { width: 100%; height: 100%; object-fit: cover; max-height: 260px; }
@media (min-width: 700px) { .prochain { grid-template-columns: 1fr 1.2fr; align-items: center; } }

.etape-accueil { position: relative; }
.etape-accueil-num {
  position: absolute; top: 14px; inset-inline-end: 16px; font-size: 2.2rem; font-weight: 800; color: var(--bleu-pale);
}
.etape-accueil-emoji { font-size: 2rem; display: block; margin-bottom: 6px; }

/* ===================== Niveaux ===================== */
.niveau-bloc { margin-bottom: 20px; }
.niveau-bloc-entete {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px;
  background: color-mix(in srgb, var(--c) 14%, white); border-bottom: 3px solid var(--c);
}
.niveau-bloc-entete h2 { margin: 0; }
.niveau-bloc-emoji { font-size: 2.2rem; }
.niveau-bloc-num { font-weight: 800; font-size: .85rem; color: var(--c); text-transform: uppercase; }
.notions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; margin: 0; }
.notions li {
  background: var(--bleu-clair); color: var(--bleu-fonce); font-weight: 700; font-size: .9rem;
  padding: 4px 12px; border-radius: 999px;
}
.liste-projets-niveau { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
@media (min-width: 700px) { .liste-projets-niveau { grid-template-columns: repeat(2, 1fr); } }
.liste-projets-niveau a {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
  padding: 8px; border-radius: 12px; border: 1px solid var(--bord); background: #fff; transition: background .15s;
}
.liste-projets-niveau a:hover { background: var(--bleu-clair); }
.liste-projets-niveau .mini { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; flex: 0 0 64px; }
.liste-projets-niveau .nom { flex: 1; font-weight: 700; }
.liste-projets-niveau li.grise a { opacity: .6; filter: grayscale(.8); }

/* ===================== Bases ===================== */
.sommaire { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.base-section { margin-bottom: 18px; }
.formule {
  font-family: var(--police-code); font-size: 1.6rem; font-weight: 800; text-align: center;
  color: var(--orange-fonce); background: var(--orange-clair); border-radius: 14px; padding: 14px; margin: 8px 0 14px;
}
.schema-bloc {
  text-align: center; font-weight: 800; font-size: 1.15rem; color: var(--bleu-nuit);
  background: var(--bleu-clair); border: 2px dashed var(--bleu-pale); border-radius: 14px; padding: 14px;
}
.etapes-base { padding-inline-start: 0; list-style: none; counter-reset: e; margin: 0; }
.etapes-base li { counter-increment: e; position: relative; padding-inline-start: 46px; margin-bottom: 12px; min-height: 34px; }
.etapes-base li::before {
  content: counter(e); position: absolute; inset-inline-start: 0; top: 0;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--orange); color: #fff; font-weight: 800;
}

/* ===================== Bloc de code ===================== */
pre.bloc-code, .code-boite pre {
  margin: 0; border-radius: 0 0 14px 14px; font-size: .9rem; line-height: 1.55;
  max-height: 520px; overflow: auto; text-align: left;
}
pre.bloc-code { background: #1e293b; color: #e2e8f0; padding: 16px; border-radius: 14px; }
.code-boite pre.bloc-code { border-radius: 0 0 14px 14px; }
pre.bloc-code code { font-family: var(--police-code); white-space: pre; }
.code-boite { border-radius: 14px; overflow: hidden; box-shadow: var(--ombre); }
.code-barre {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #0f172a; color: #94a3b8; padding: 8px 12px; font-family: var(--police-code); font-size: .85rem;
}
.explication summary code {
  font-family: var(--police-code); font-size: .88rem; background: #1e293b; color: #e2e8f0;
  padding: 3px 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-word;
}
.explication summary { padding: 10px 14px; }
.simulation { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 16px; background: var(--bleu-clair); }
.simulation p { margin: 0; color: var(--texte-doux); }

/* ===================== Cartes projets ===================== */
.carte-projet-image { position: relative; aspect-ratio: 4 / 3; background: var(--bleu-clair); }
.carte-projet-image img { width: 100%; height: 100%; object-fit: cover; }
.carte-projet-etat { position: absolute; top: 10px; inset-inline-start: 10px; }
.carte-projet-haut { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.carte-projet h3 { margin-bottom: .3em; }
.carte-projet p { color: var(--texte-doux); font-size: .95rem; }
.carte-projet .carte-pad { display: flex; flex-direction: column; flex: 1; }
.carte-projet .metas { margin-top: auto; }
.carte-projet .barre { margin-top: 10px; }
.points-projet { color: var(--orange-fonce); }
.carte-projet.grise { filter: grayscale(.9); opacity: .65; }
.carte-projet.grise:hover { opacity: .85; }

/* ===================== Page projet ===================== */
.projet-entete { display: grid; }
.projet-entete-image { background: var(--bleu-clair); }
.projet-entete-image img { width: 100%; height: 100%; object-fit: cover; max-height: 320px; }
@media (min-width: 820px) { .projet-entete { grid-template-columns: 1fr 1.3fr; } .projet-entete-image img { max-height: none; } }
.projet-metas { margin: 6px 0 14px; }
.sommaire-projet {
  position: sticky; top: 58px; z-index: 20; margin: 16px -16px; padding: 8px 16px;
  background: rgba(245, 248, 255, .94); backdrop-filter: blur(6px);
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin;
}
.sommaire-projet .filtre { white-space: nowrap; min-height: 36px; padding: 4px 12px; font-size: .9rem; }

.resultat { margin: 0; display: flex; flex-direction: column; }
.resultat figcaption { padding: 12px 16px; font-weight: 800; color: var(--bleu-nuit); }
.resultat img { width: 100%; flex: 1; object-fit: cover; background: var(--bleu-clair); }

.liste-materiel .materiel-item { flex-direction: row; align-items: center; }
.materiel-image { position: relative; background: #f8fafc; display: grid; place-items: center; aspect-ratio: 4 / 3; }
.materiel-image { overflow: hidden; }
.materiel-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.liste-materiel .materiel-image { width: 96px; flex: 0 0 96px; aspect-ratio: 1; }
.materiel-texte { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; align-items: flex-start; }
.quantite {
  position: absolute; bottom: 4px; inset-inline-end: 4px; background: var(--orange); color: #fff;
  font-weight: 800; font-size: .8rem; padding: 0 8px; border-radius: 999px;
}
.materiel-item.manquant { border: 2px solid #fecaca; background: #fff5f5; }

.cablage { padding: 12px; background: #fff; }
.cablage img { width: 100%; max-height: 560px; object-fit: contain; margin: 0 auto; }
.broche-carte { background: var(--bleu-clair); color: var(--bleu-fonce); }

.etapes { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.etape { display: grid; transition: border-color .2s, background .2s; border: 2px solid transparent; }
@media (min-width: 700px) { .etape { grid-template-columns: 260px 1fr; } }
.etape-image { background: var(--bleu-clair); }
.etape-image img { width: 100%; height: 100%; object-fit: cover; max-height: 220px; }
.etape-titre { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.etape-titre h3 { margin: 0; }
.etape-num {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bleu); color: #fff; font-weight: 800;
}
.etape.faite { border-color: #86efac; background: #f0fdf4; }
.etape.faite .etape-num { background: var(--vert); }

.question { margin-bottom: 12px; border: 2px solid transparent; }
.question.juste { border-color: #bbf7d0; }
.question.faux { border-color: #fed7aa; }
.question-num { font-size: .85rem; font-weight: 800; color: var(--orange-fonce); text-transform: uppercase; }
.choix { display: grid; gap: 8px; margin: 10px 0; }
.choix-btn {
  font: inherit; text-align: start; cursor: pointer; display: flex; align-items: center; gap: 10px;
  background: #fff; border: 2px solid var(--bord); border-radius: 12px; padding: 10px 12px; min-height: 48px;
  transition: border-color .15s, background .15s, transform .1s;
}
.choix-btn:not([disabled]):hover { border-color: var(--bleu); background: var(--bleu-clair); }
.choix-btn:not([disabled]):active { transform: scale(.98); }
.choix-btn[disabled] { cursor: default; color: var(--texte-doux); }
.choix-lettre {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--bleu-clair); color: var(--bleu-fonce); font-weight: 800;
}
.choix-btn.bon { border-color: var(--vert); background: #dcfce7; color: #14532d; animation: pop .3s; }
.choix-btn.bon .choix-lettre { background: var(--vert); color: #fff; }
.choix-btn.mauvais { border-color: var(--rouge); background: #fee2e2; color: #7f1d1d; animation: secoue .35s; }
.choix-btn.mauvais .choix-lettre { background: var(--rouge); color: #fff; }
@keyframes pop { 50% { transform: scale(1.03); } }
@keyframes secoue { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.correction { margin-bottom: 0; }
.quiz-score { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.quiz-score .succes { margin: 0; }

.defi { background: linear-gradient(135deg, #fff7ed, #ffedd5); border: 2px dashed #fdba74; }

.fin-projet { text-align: center; background: linear-gradient(135deg, var(--bleu-clair), #fff); }
.fin-emoji { font-size: 3rem; }
.fin-actions { margin-top: 14px; display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }

/* ===================== Matériel ===================== */
.kit-barre { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; position: sticky; top: 64px; z-index: 15; }
.kit-boutons { display: flex; gap: 8px; flex-wrap: wrap; }
.titre-categorie { border-inline-start: 5px solid var(--orange); padding-inline-start: 10px; }
.carte-materiel { display: flex; flex-direction: column; border: 2px solid transparent; transition: border-color .2s, transform .2s; }
.carte-materiel:hover { transform: translateY(-3px); }
.carte-materiel-lien { color: inherit; text-decoration: none; flex: 1; }
.carte-materiel h3 { margin-bottom: .2em; }
.carte-materiel p { color: var(--texte-doux); font-size: .9rem; margin: 0; }
.carte-materiel-bas { padding: 0 16px 16px; }
.carte-materiel-bas .case { width: 100%; justify-content: center; }
.carte-materiel.dans-kit { border-color: #86efac; }

.fiche { display: grid; }
.fiche-image { background: #f8fafc; display: grid; place-items: center; }
.fiche-image img { width: 100%; max-height: 380px; object-fit: contain; padding: 16px; }
@media (min-width: 820px) { .fiche { grid-template-columns: 1fr 1.2fr; } }
.broches-liste { background: #f1f5f9; border-radius: 12px; padding: 12px 12px 12px 34px; font-family: var(--police-code); font-size: .9rem; text-align: left; }

/* ===================== Parcours ===================== */
.equipe { display: grid; gap: 18px; align-items: center; }
@media (min-width: 720px) { .equipe { grid-template-columns: auto 1fr; } }
.equipe-score { display: flex; align-items: center; gap: 12px; }
.equipe-etoile { font-size: 2.6rem; animation: tourne 2.5s ease-in-out infinite; }
.equipe-score strong { display: block; font-size: 2.2rem; color: var(--orange-fonce); line-height: 1; }
.equipe-score span { font-weight: 700; color: var(--texte-doux); }
.equipe-form label { font-weight: 800; display: block; margin-bottom: 6px; }
.equipe-champ { display: flex; gap: 8px; flex-wrap: wrap; }
.equipe-champ input {
  flex: 1; min-width: 180px; font: inherit; padding: 10px 14px; border-radius: 12px;
  border: 2px solid var(--bord); min-height: 44px;
}
.equipe-champ input:focus { border-color: var(--bleu); outline: none; }
.stats { margin-top: 16px; }
.stat { display: flex; flex-direction: column; align-items: center; text-align: center; }
.stat-emoji { font-size: 1.8rem; }
.stat strong { font-size: 1.6rem; color: var(--bleu); }
.stat span:last-child { color: var(--texte-doux); font-weight: 700; font-size: .9rem; }
.niveaux-barres { display: grid; gap: 12px; margin-top: 18px; }
@media (min-width: 700px) { .niveaux-barres { grid-template-columns: repeat(2, 1fr); } }

.badge { padding: 18px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.badge-emoji {
  font-size: 2.6rem; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  margin-bottom: 8px; background: #f1f5f9; filter: grayscale(1); opacity: .5;
}
.badge h3 { margin-bottom: .2em; }
.badge p { color: var(--texte-doux); font-size: .9rem; flex: 1; }
.badge:not(.obtenu) h3 { color: var(--texte-doux); }
.badge.obtenu { border: 2px solid #fdba74; }
.badge.obtenu .badge-emoji { filter: none; opacity: 1; background: radial-gradient(circle, #fff7ed 40%, #fed7aa); }

.reset { text-align: center; }
.confirmation { background: #fff1f2; border: 2px solid #fecaca; border-radius: var(--rayon); padding: 18px; max-width: 560px; margin: 0 auto; }
.confirmation p { color: #9f1239; }
.confirmation-boutons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ===================== Crédits ===================== */
.credit dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0 0 12px; font-size: .9rem; }
.credit dt { font-weight: 800; color: var(--bleu-nuit); }
.credit dd { margin: 0; word-break: break-word; }
[dir="rtl"] .credit dd { text-align: right; }

/* ---------- Quiz : recommencer / Projet terminé : raison du blocage ---------- */
.quiz-score-texte { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.quiz-note { margin-top: 12px; }
.fin-raison {
  max-width: 520px; margin: 14px auto 0; padding: 12px 16px; border-radius: 14px;
  background: var(--orange-clair); border: 1px dashed #fdba74; color: #9a3412; font-weight: 600;
}
.fin-raison p { margin: 0 0 8px; }
.fin-compte { font-size: .95rem; }
