/* ═══════════════════════════════════════════════════════
   Formation Tests & Qualité — Design System Partagé
   Dark Glassmorphism · Vitest Green · Responsive
   ═══════════════════════════════════════════════════════ */

/* ── 1. Variables ───────────────────────────────────── */
:root {
  --bg:         #0a0e0a;
  --bg-2:       #0d120d;
  --bg-3:       #141a14;

  --glass:      rgba(20, 26, 20, 0.75);
  --glass-lite: rgba(255, 255, 255, 0.04);
  --glass-hover:rgba(255, 255, 255, 0.07);

  --border:       rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.20);

  --text:   #e6edf3;
  --muted:  #8b949e;
  --faint:  #484f58;

  /* Couleur primaire Tests — vert Vitest */
  --tests:      #6E9F18;
  --tests-dark: #4d6e11;
  --tests-lite: #a3e635;

  --yellow: #f0c419;
  --blue:   #79c0ff;
  --green:  #3fb950;
  --purple: #d2a8ff;
  --red:    #f85149;
  --orange: #f78166;

  --sec:      #6E9F18;
  --sec-dark: #4d6e11;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --blur:    blur(20px);
  --blur-sm: blur(12px);

  --shadow:    0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.30);

  --glow-t: 0 0 28px rgba(110, 159, 24, 0.22);
  --glow-y: 0 0 24px rgba(240, 196,  25, 0.18);
  --glow-b: 0 0 24px rgba(121, 192, 255, 0.15);
  --glow-p: 0 0 24px rgba(210, 168, 255, 0.15);
  --glow-g: 0 0 24px rgba(63,  185,  80, 0.15);

  --transition: all 0.22s ease;
}

/* ── 2. Reset ───────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button {
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(110, 159, 24, 0.25); }

/* ── 3. Header ──────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 14, 10, 0.88);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  padding: 0 1.6rem;
  height: 58px;
  display: flex; align-items: center; gap: 1rem;
}
.header-title { font-weight: 800; font-size: 0.97rem; color: var(--tests-lite); }
.header-sub   { font-size: 0.78rem; color: var(--muted); flex: 1; }
.back-link {
  font-size: 0.78rem; color: var(--muted);
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border); border-radius: 6px;
  transition: var(--transition); white-space: nowrap;
}
.back-link:hover { color: var(--tests-lite); border-color: rgba(110,159,24,0.35); }

/* ── 4. Conteneur ───────────────────────────────────── */
.container {
  max-width: 960px; margin: 0 auto;
  padding: 2.5rem 1.4rem 4rem;
}
.container-wide {
  max-width: 1100px; margin: 0 auto;
  padding: 2.5rem 1.4rem 4rem;
}

/* ── 5. Card générique ──────────────────────────────── */
.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  transition: border-color 0.22s, box-shadow 0.22s;
  position: relative;
}
.card:hover {
  border-color: rgba(110,159,24,0.35);
  box-shadow: var(--glow-t);
}
.module-num {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.5px;
  color: var(--tests); border: 1px solid rgba(110,159,24,0.30);
  background: rgba(110,159,24,0.08);
  padding: 0.2rem 0.6rem; border-radius: 6px;
  flex-shrink: 0;
}

/* ── 6. Boutons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.8rem; font-weight: 600;
  padding: 0.45rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--glass-lite);
  color: var(--muted);
  cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--glass-hover); color: var(--text); border-color: var(--border-hover); }
.btn-primary {
  background: var(--tests); border-color: var(--tests-dark);
  color: #fff; font-weight: 700;
}
.btn-primary:hover { background: var(--tests-lite); border-color: var(--tests-lite); color: #0a0e0a; transform: translateY(-1px); }
.btn-sec {
  background: rgba(110,159,24,0.12); border-color: rgba(110,159,24,0.28);
  color: var(--tests-lite);
}
.btn-sec:hover { background: rgba(110,159,24,0.22); }
.btn-ts {
  background: rgba(110,159,24,0.10); border-color: rgba(110,159,24,0.30);
  color: var(--tests-lite);
}
.btn-ts:hover { background: rgba(110,159,24,0.20); border-color: rgba(110,159,24,0.50); }
.btn-yellow {
  background: rgba(240,196,25,0.10); border-color: rgba(240,196,25,0.28);
  color: var(--yellow);
}
.btn-yellow:hover { background: rgba(240,196,25,0.20); }
.btn-green {
  background: rgba(63,185,80,0.10); border-color: rgba(63,185,80,0.28);
  color: var(--green);
}
.btn-green:hover { background: rgba(63,185,80,0.20); }

/* ── 7. Tags ────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: 0.69rem; font-weight: 600;
  font-family: 'Consolas', 'Fira Code', monospace;
  padding: 0.18rem 0.48rem; border-radius: 5px;
  background: rgba(110,159,24,0.10);
  border: 1px solid rgba(110,159,24,0.20);
  color: var(--tests-lite);
}

/* ── 8. Progress bar ────────────────────────────────── */
.progress-bar-outer {
  height: 5px; background: rgba(255,255,255,0.06);
  border-radius: 3px; overflow: hidden;
}
.progress-bar-inner {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--tests), var(--tests-lite));
  transition: width 0.6s ease;
}

/* ── 9. Code blocks ─────────────────────────────────── */
.code-block {
  background: rgba(7, 11, 7, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.75;
  color: #c9d1d9;
  overflow-x: auto;
  position: relative;
}
.code-block .kw  { color: #ff7b72; }
.code-block .ty  { color: #79c0ff; }
.code-block .st  { color: #a5d6ff; }
.code-block .cm  { color: #8b949e; font-style: italic; }
.code-block .fn  { color: #d2a8ff; }
.code-block .nm  { color: #ffa657; }
.code-block .op  { color: #ff7b72; }
.code-block .ok  { color: #a3e635; font-weight: 600; }
.code-block .err { color: #f85149; }

/* ── 10. Info/Warn/Tip boxes ────────────────────────── */
.info, .warn, .tip {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.84rem;
  line-height: 1.6;
  margin: 1rem 0;
}
.info { background: rgba(110,159,24,0.08); border: 1px solid rgba(110,159,24,0.22); color: #bef264; }
.warn { background: rgba(240,196,25,0.08); border: 1px solid rgba(240,196,25,0.22); color: #fde68a; }
.tip  { background: rgba(63,185,80,0.08);  border: 1px solid rgba(63,185,80,0.22);  color: #86efac; }

/* ── 11. Exercice QCM ───────────────────────────────── */
.qcm-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}
.qcm-card.correct { border-color: rgba(63,185,80,0.40); }
.qcm-card.wrong   { border-color: rgba(248,81,73,0.35); }
.qcm-num {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 1px;
  color: var(--tests-lite); text-transform: uppercase; margin-bottom: 0.5rem;
}
.qcm-question { font-size: 0.92rem; font-weight: 600; margin-bottom: 1rem; line-height: 1.5; }
.qcm-opts { display: flex; flex-direction: column; gap: 0.5rem; }
.qcm-opt {
  background: var(--glass-lite);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  font-size: 0.83rem; cursor: pointer;
  transition: var(--transition); text-align: left;
  display: flex; align-items: flex-start; gap: 0.55rem;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.45;
  width: 100%;
}
.qcm-opt:hover:not(.disabled) { background: rgba(110,159,24,0.08); border-color: rgba(110,159,24,0.30); }
.qcm-opt.selected-correct { background: rgba(63,185,80,0.14); border-color: #3fb950; color: #86efac; opacity: 1 !important; }
.qcm-opt.selected-wrong   { background: rgba(248,81,73,0.13); border-color: #f85149; color: #fca5a5; opacity: 1 !important; }
.qcm-opt.show-correct     { background: rgba(63,185,80,0.09); border-color: rgba(63,185,80,0.45); color: #6ee7a0; opacity: 1 !important; }
.qcm-opt.disabled { pointer-events: none; opacity: 0.38; color: var(--faint); }
.qcm-label {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.35rem; height: 1.35rem; border-radius: 4px; flex-shrink: 0;
  font-size: 0.68rem; font-weight: 800;
  background: rgba(110,159,24,0.12); color: var(--tests-lite);
  margin-top: 1px; transition: background 0.2s, color 0.2s;
}
.qcm-opt.selected-correct .qcm-label { background: rgba(63,185,80,0.20); color: #86efac; }
.qcm-opt.selected-wrong   .qcm-label { background: rgba(248,81,73,0.20); color: #fca5a5; }
.qcm-opt.show-correct     .qcm-label { background: rgba(63,185,80,0.15); color: #6ee7a0; }
.qcm-feedback {
  font-size: 0.8rem; margin-top: 0.7rem; padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm); display: none; line-height: 1.55;
}
.qcm-feedback.ok,
.qcm-feedback.correct { background: rgba(63,185,80,0.08); border: 1px solid rgba(63,185,80,0.20); color: #86efac; display: block; }
.qcm-feedback.ko,
.qcm-feedback.wrong   { background: rgba(248,81,73,0.08); border: 1px solid rgba(248,81,73,0.20); color: #fca5a5; display: block; }

/* Aliases used by exercices.html inline check() — btn.disabled = true */
button.qcm-opt:disabled { opacity: 0.38; color: var(--faint); pointer-events: none; }
button.qcm-opt.correct,
button.qcm-opt:disabled.correct { background: rgba(63,185,80,0.14) !important; border-color: #3fb950 !important; color: #86efac !important; opacity: 1 !important; }
button.qcm-opt.wrong,
button.qcm-opt:disabled.wrong   { background: rgba(248,81,73,0.13) !important; border-color: #f85149 !important; color: #fca5a5 !important; opacity: 1 !important; }

/* ── 12. Cours — Sections ───────────────────────────── */
.cours-section { margin-bottom: 2.2rem; }
.cours-section h2 {
  font-size: 1.05rem; font-weight: 700;
  color: var(--tests-lite); margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.55rem;
}
.cours-section h3 {
  font-size: 0.88rem; font-weight: 700;
  color: var(--text); margin: 1rem 0 0.5rem;
}
.cours-section p { font-size: 0.87rem; color: var(--muted); line-height: 1.7; margin-bottom: 0.7rem; }
.cours-section ul, .cours-section ol {
  font-size: 0.85rem; color: var(--muted); line-height: 1.7;
  padding-left: 1.4rem; margin-bottom: 0.7rem;
}
.cours-section li { margin-bottom: 0.25rem; }

/* ── 13. Table ──────────────────────────────────────── */
.ts-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.81rem; margin: 0.8rem 0;
}
.ts-table th {
  background: rgba(110,159,24,0.10);
  color: var(--tests-lite); font-weight: 700; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 0.55rem 0.9rem; text-align: left;
  border-bottom: 1px solid rgba(110,159,24,0.25);
}
.ts-table td {
  padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--border);
  color: var(--muted); vertical-align: top;
}
.ts-table tr:hover td { background: rgba(255,255,255,0.02); }
.ts-table code {
  background: rgba(110,159,24,0.12); color: var(--tests-lite);
  padding: 0.1rem 0.35rem; border-radius: 4px;
  font-family: 'Consolas', monospace; font-size: 0.78rem;
}

/* ── 14. Editor area ────────────────────────────────── */
.editor-area {
  width: 100%;
  background: rgba(7,11,7,0.90);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.82rem;
  color: #c9d1d9;
  resize: vertical;
  outline: none;
  transition: border-color 0.18s;
  line-height: 1.65;
}
.editor-area:focus { border-color: rgba(110,159,24,0.45); }

/* ── 15. Footer ─────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.4rem 1.6rem;
  text-align: center;
  font-size: 0.75rem; color: var(--faint);
}

/* ── 16. Reveal animation ───────────────────────────── */
.reveal {
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible { opacity: 1; transform: none; }

/* ── 17. Completed state ────────────────────────────── */
.card.completed { border-color: rgba(110,159,24,0.30); }
.card.completed::after {
  content: '✓';
  position: absolute; top: 0.9rem; right: 1rem;
  font-size: 0.8rem; color: var(--tests-lite); font-weight: 800;
}


/* ══ Responsive Complet (900 · 640 · 420 px) ════════════ */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .content, main { max-width: 100%; padding: 1.5rem 1.2rem; }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .site-header { height: auto; min-height: 52px; padding: 0.5rem 0.9rem; }
  .site-header .header-sub { display: none; }
  pre, .code-block { font-size: 0.75rem; padding: 0.8rem 0.85rem; }
  table, .ts-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .container, .container-wide { padding-left: 0.9rem; padding-right: 0.9rem; }
  .modules-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  h1 { font-size: 1.3rem; }
}