/* ==========================================================================
   MDSSUP — Test de niveau (test-niveau.html). Préfixe .tn-*
   Reprend les jetons de style.css ; couleurs de niveau vérifiées sur --bg
   (contraste > 9:1). La couleur n'est jamais le seul porteur d'information :
   chaque niveau a aussi son libellé et sa pastille.
   ========================================================================== */
:root {
  --tn-debutant: #7ef0b2;
  --tn-intermediaire: #ffc857;
  --tn-avance: #ff8fa3;
}

.tn-section { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.tn-section:focus { outline: none; }
.tn-h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); margin: .2rem 0 .6rem; line-height: 1.2; }
.tn-h2 { display: flex; align-items: center; gap: .6rem; font-size: 1.2rem; margin: 2rem 0 1rem; }
.tn-etape {
  display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; flex: none;
  border-radius: 50%; background: var(--gradient); color: var(--accent-dark);
  font-family: var(--font-display); font-size: .85rem;
}
.tn-attente { color: var(--text-muted); }

/* ---------- Grille des disciplines ---------- */
.tn-grille { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.tn-disc {
  display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; text-align: left;
  padding: 1rem 1.1rem; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); color: var(--text);
  font: inherit; transition: border-color .2s, box-shadow .2s, transform .2s;
}
.tn-disc:hover { border-color: var(--neon-cyan); transform: translateY(-2px); }
.tn-disc:focus-visible { outline: 3px solid var(--neon-cyan); outline-offset: 2px; }
.tn-disc[aria-checked="true"] { border-color: var(--neon-cyan); box-shadow: var(--glow-cyan); background: var(--bg-soft); }
.tn-disc-ico { width: 2.2rem; height: 2.2rem; color: var(--neon-cyan); }
.tn-disc-nom { font-family: var(--font-title); font-weight: 700; line-height: 1.3; }
.tn-disc-meta { font-size: .85rem; color: var(--text-muted); }

/* ---------- Niveaux ---------- */
.tn-niveaux { display: flex; flex-wrap: wrap; gap: .8rem; }
.tn-niv {
  --c: var(--tn-debutant);
  display: grid; grid-template-columns: .8rem auto; column-gap: .6rem; row-gap: .1rem; align-items: center;
  text-align: left; padding: .75rem 1.1rem; border-radius: var(--radius);
  background: transparent; border: 2px solid var(--border); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; transition: border-color .2s, background .2s;
}
.tn-niv::before { content: ""; width: .8rem; height: .8rem; border-radius: 50%; background: var(--c); flex: none; }
.tn-niv--intermediaire { --c: var(--tn-intermediaire); }
.tn-niv--avance { --c: var(--tn-avance); }
.tn-niv:hover { border-color: var(--c); }
.tn-niv:focus-visible { outline: 3px solid var(--c); outline-offset: 2px; }
.tn-niv[aria-checked="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.tn-niv small { grid-column: 2; font-weight: 400; font-size: .82rem; color: var(--text-muted); }
@media (max-width: 560px) { .tn-niveaux { display: grid; } }

/* ---------- Coordonnées ---------- */
.tn-form { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); max-width: 820px; }
.tn-champ { display: flex; flex-direction: column; gap: .35rem; }
.tn-champ--large { grid-column: 1 / -1; }
.tn-champ label { font-weight: 600; }
.tn-champ input[type="text"], .tn-champ input[type="tel"] {
  padding: .75rem .9rem; border-radius: var(--radius); font: inherit;
  background: var(--bg-soft); color: var(--text); border: 2px solid var(--border);
}
.tn-champ input:focus { outline: none; border-color: var(--neon-cyan); box-shadow: var(--glow-cyan); }
.tn-champ input[aria-invalid="true"] { border-color: var(--error); }
.tn-consent { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400 !important; font-size: .92rem; color: var(--text-muted); }
.tn-consent input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; flex: none; accent-color: var(--neon-cyan); }
.tn-consent a { color: var(--neon-cyan); }

.tn-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 2rem; }
.tn-aide { margin: 0; color: var(--text-muted); font-size: .92rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---------- Carte question ---------- */
.tn-carte {
  max-width: 780px; margin: 0 auto 1.2rem; padding: clamp(1.2rem, 4vw, 2rem);
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px);
}
.tn-entete { display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); font-size: .92rem; }
.tn-chrono { font-family: var(--font-display); font-size: 1.25rem; color: var(--tn-debutant); font-variant-numeric: tabular-nums; }
.tn-chrono.is-moyen { color: var(--tn-intermediaire); }
.tn-chrono.is-urgent { color: var(--tn-avance); animation: tn-pulse 1s ease-in-out infinite; }
@keyframes tn-pulse { 50% { opacity: .45; } }
.tn-barre { height: 6px; margin: .6rem 0 1.2rem; background: var(--bg); border-radius: 99px; overflow: hidden; }
.tn-barre-remplie { height: 100%; width: 0; background: var(--gradient); transition: width .4s ease; }

.tn-pastilles { display: flex; gap: .5rem; margin-bottom: 1rem; }
.tn-pastille { padding: .2rem .75rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid var(--neon-cyan); color: var(--neon-cyan); }
.tn-pastille--cas { border-color: var(--tn-intermediaire); color: var(--tn-intermediaire); }
.tn-pastille--pts { border-color: var(--border); color: var(--text-muted); }
.tn-question { font-size: 1.1rem; line-height: 1.6; white-space: pre-line; margin: 0 0 1.3rem; overflow-wrap: anywhere; }

.tn-options { display: grid; gap: .7rem; }
.tn-option {
  display: flex; gap: .8rem; align-items: flex-start; width: 100%; text-align: left;
  padding: .85rem 1rem; border-radius: var(--radius); cursor: pointer;
  background: var(--bg-soft); border: 2px solid var(--border); color: var(--text); font: inherit;
  transition: border-color .15s, background .15s;
}
.tn-option:hover { border-color: var(--neon-cyan); }
.tn-option:focus-visible { outline: 3px solid var(--neon-cyan); outline-offset: 2px; }
.tn-option[aria-checked="true"] { border-color: var(--neon-cyan); background: rgba(0, 255, 255, .08); }
.tn-lettre {
  display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; flex: none;
  border-radius: 8px; border: 1px solid var(--border); font-family: var(--font-display); font-size: .8rem;
}
.tn-option[aria-checked="true"] .tn-lettre { background: var(--neon-cyan); color: var(--accent-dark); border-color: var(--neon-cyan); }

.tn-valider { width: 100%; margin-top: 1.4rem; }

.tn-centre { text-align: center; }
.tn-spinner {
  width: 3rem; height: 3rem; margin: 0 auto 1rem; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--neon-cyan); animation: tn-tour 1s linear infinite;
}
@keyframes tn-tour { to { transform: rotate(360deg); } }

/* ---------- Résultat ---------- */
.tn-res-tete { text-align: center; position: relative; }
.tn-res-tete.is-valide { border-color: var(--tn-debutant); box-shadow: 0 0 28px rgba(126, 240, 178, .18); }
.tn-anneau { width: 150px; height: 150px; transform: rotate(-90deg); }
.tn-anneau circle { fill: none; stroke-width: 10; }
.tn-anneau-fond { stroke: var(--bg); }
.tn-anneau-val { stroke: var(--neon-cyan); stroke-linecap: round; stroke-dasharray: 339.29; stroke-dashoffset: 339.29; transition: stroke-dashoffset 1.2s ease; }
.is-valide .tn-anneau-val { stroke: var(--tn-debutant); }
.tn-anneau-wrap { position: relative; width: 150px; height: 150px; margin: 0 auto .8rem; }
.tn-pourcent { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-family: var(--font-display); font-size: 1.7rem; }
.tn-res-titre { font-size: 1.5rem; margin: 0 0 .2rem; }
.tn-res-sous, .tn-res-score { color: var(--text-muted); margin: .2rem 0; }
.tn-reco { font-size: 1.05rem; margin-top: 0; }
.tn-formation {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem;
  padding: 1rem; border-radius: var(--radius); background: var(--bg-soft); border: 1px solid var(--border);
}
.tn-formation-nom { margin: 0; font-weight: 700; font-family: var(--font-title); }

.tn-detail summary { cursor: pointer; font-weight: 600; font-family: var(--font-title); }
.tn-mode { color: var(--text-muted); font-size: .88rem; }
.tn-detail-liste { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .8rem; }
.tn-detail-item { padding: .9rem 1rem; border-radius: var(--radius); background: var(--bg-soft); border-left: 4px solid var(--tn-avance); }
.tn-detail-item.is-juste { border-left-color: var(--tn-debutant); }
.tn-detail-item.is-partiel { border-left-color: var(--tn-intermediaire); }
.tn-detail-item p { margin: .25rem 0; overflow-wrap: anywhere; white-space: pre-line; }
.tn-detail-tete { display: flex; justify-content: space-between; gap: .6rem; font-weight: 600; }
.tn-lib { color: var(--text-muted); font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  .tn-disc, .tn-barre-remplie, .tn-anneau-val { transition: none; }
  .tn-chrono.is-urgent, .tn-spinner { animation: none; }
}
