/* ═══════════════════════════════════════════════
   Formation Web — Design System Glassmorphism
   ═══════════════════════════════════════════════ */

:root {
  --bg:          #0a0e1a;
  --bg2:         #0d1117;
  --glass:       rgba(22, 27, 34, 0.72);
  --glass-hover: rgba(30, 37, 46, 0.85);
  --border:      rgba(255, 255, 255, 0.08);
  --border-h:    rgba(255, 255, 255, 0.18);
  --text:        #e6edf3;
  --muted:       #8b949e;
  --dim:         #484f58;

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

  /* Glows */
  --glow-o: rgba(247, 129, 102, 0.35);
  --glow-y: rgba(240, 196, 25, 0.35);
  --glow-b: rgba(121, 192, 255, 0.35);
  --glow-g: rgba(63, 185, 80, 0.35);
  --glow-p: rgba(210, 168, 255, 0.35);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.site-header .logo {
  font-weight: 700; font-size: 0.95rem;
  background: linear-gradient(135deg, var(--orange), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}
.site-header nav { display: flex; gap: 1.2rem; align-items: center; }
.site-header nav a {
  color: var(--muted); font-size: 0.82rem; text-decoration: none;
  transition: color 0.2s;
}
.site-header nav a:hover { color: var(--text); }

/* ── Back link ───────────────────────────────── */
.back-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--muted); font-size: 0.82rem; text-decoration: none;
  margin-bottom: 1.2rem; transition: color 0.2s;
}
.back-link:hover { color: var(--text); }

/* ── Container ───────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1.5rem; }

/* ── Hero ────────────────────────────────────── */
.hero { text-align: center; padding: 3rem 1rem 2rem; }
.hero-title {
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 800; letter-spacing: -1px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--yellow) 35%, var(--blue) 65%, var(--purple) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1.2; margin-bottom: 0.8rem;
}
.hero-sub { color: var(--muted); font-size: clamp(0.9rem, 2vw, 1.05rem); max-width: 560px; margin: 0 auto 2rem; }

/* ── Stats ───────────────────────────────────── */
.stats-row {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 1.5rem; margin: 1.5rem 0 2.5rem;
}
.stat-item { text-align: center; }
.stat-item .num {
  font-size: 1.9rem; font-weight: 700;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; display: block;
}
.stat-item .lbl { font-size: 0.75rem; color: var(--muted); }

/* ── Progress bar ────────────────────────────── */
.progress-wrap { max-width: 500px; margin: 0 auto 3rem; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }
.progress-bar { height: 6px; background: rgba(255,255,255,0.07); border-radius: 3px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--orange), var(--yellow), var(--blue), var(--purple));
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

/* ── Section header ──────────────────────────── */
.section-header {
  display: flex; align-items: center; gap: 0.8rem;
  margin: 3rem 0 1.2rem;
}
.section-header h2 { font-size: 1.1rem; font-weight: 700; }
.section-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.section-line { flex: 1; height: 1px; background: var(--border); }
.section-count { font-size: 0.72rem; color: var(--muted); }

/* ── Module grid ─────────────────────────────── */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

/* ── Card ────────────────────────────────────── */
.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.3rem;
  display: flex; flex-direction: column; gap: 0.7rem;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  backdrop-filter: blur(10px);
}
.card:not(.bientot):hover {
  transform: translateY(-4px);
  border-color: var(--border-h);
}
.card.bientot { opacity: 0.55; cursor: default; }

.card-top { display: flex; align-items: flex-start; gap: 0.8rem; }
.card-emoji { font-size: 1.8rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.card-body { flex: 1; min-width: 0; }
.card-num { font-size: 0.68rem; color: var(--muted); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.card-title { font-size: 0.98rem; font-weight: 700; margin-top: 0.1rem; line-height: 1.3; }
.card-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }

.card-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-size: 0.68rem; padding: 0.15rem 0.55rem;
  border-radius: 20px; font-weight: 600;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* Status badge */
.status-badge {
  position: absolute; top: 0.8rem; right: 0.8rem;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.5px;
  padding: 0.15rem 0.5rem; border-radius: 4px;
}
.status-dispo  { background: rgba(63,185,80,0.15); color: var(--green); border: 1px solid rgba(63,185,80,0.3); }
.status-bientot { background: rgba(255,255,255,0.06); color: var(--dim); border: 1px solid var(--border); }
.status-externe { background: rgba(240,196,25,0.15); color: var(--yellow); border: 1px solid rgba(240,196,25,0.3); }

/* Carte spéciale JS */
.card.card-js {
  grid-column: 1 / -1;
  flex-direction: row; align-items: center; gap: 1.5rem;
  border-color: rgba(240,196,25,0.25);
  background: rgba(240,196,25,0.04);
  padding: 1.6rem;
}
.card.card-js:hover {
  border-color: rgba(240,196,25,0.45);
  box-shadow: 0 0 32px rgba(240,196,25,0.1);
}
.card.card-js .card-emoji { font-size: 2.8rem; }
.card.card-js .card-title { font-size: 1.2rem; color: var(--yellow); }
.card.card-js .js-stats {
  display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem;
}
.card.card-js .js-stat {
  font-size: 0.72rem; background: rgba(240,196,25,0.1);
  color: var(--yellow); border: 1px solid rgba(240,196,25,0.2);
  padding: 0.15rem 0.55rem; border-radius: 20px; font-weight: 600;
}
.card.card-js .card-body { flex: 1; }

/* ── Boutons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem; border-radius: 8px;
  font-weight: 700; font-size: 0.85rem;
  text-decoration: none; border: none; cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-yellow  { background: var(--yellow); color: #0a0e1a; }
.btn-orange  { background: var(--orange); color: #0a0e1a; }
.btn-blue    { background: rgba(121,192,255,0.15); color: var(--blue); border: 1px solid rgba(121,192,255,0.3); }
.btn-green   { background: rgba(63,185,80,0.15); color: var(--green); border: 1px solid rgba(63,185,80,0.3); }
.btn-ghost   { background: rgba(255,255,255,0.06); color: var(--muted); border: 1px solid var(--border); }
.btn-sm      { padding: 0.4rem 0.9rem; font-size: 0.78rem; }
.btn-block   { display: flex; justify-content: center; width: 100%; }

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

/* ── Footer ──────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.78rem;
  color: var(--dim);
  margin-top: 4rem;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 1.5rem 1rem; }
  .site-header { padding: 0.7rem 1rem; }
  .card.card-js { flex-direction: column; }
  .modules-grid { grid-template-columns: 1fr; }
  .stats-row { gap: 1rem; }
}
@media (max-width: 480px) {
  .hero { padding: 2rem 0.5rem 1.5rem; }
}

/* ═══════════════════════════════════════════════
   Layout COURS (sidebar + contenu)
   ═══════════════════════════════════════════════ */

.cours-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  position: sticky; top: 70px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
  backdrop-filter: blur(10px);
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-h); border-radius: 2px; }

.sidebar-title {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 0.8rem; padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-link {
  display: block; padding: 0.45rem 0.7rem;
  border-radius: 6px; font-size: 0.82rem;
  color: var(--muted); text-decoration: none;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 0.15rem;
}
.sidebar-link:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.sidebar-link.active { background: rgba(255,255,255,0.08); color: var(--text); font-weight: 600; }

.sidebar-section-title {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--dim);
  margin: 1rem 0 0.4rem 0.7rem;
}

/* ── Main content ────────────────────────────── */
.cours-content { min-width: 0; }

/* ── Cours header ────────────────────────────── */
.cours-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.cours-header .module-num {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem;
}
.cours-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800; letter-spacing: -0.5px;
  line-height: 1.2; margin-bottom: 0.6rem;
}
.cours-header .cours-desc { color: var(--muted); font-size: 1rem; max-width: 600px; }

.cours-meta {
  display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem;
}
.cours-meta .meta-item {
  font-size: 0.75rem; padding: 0.2rem 0.65rem;
  border-radius: 20px; font-weight: 600;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border); color: var(--muted);
}

/* ── Sections de cours ───────────────────────── */
.cours-section { margin-bottom: 3rem; scroll-margin-top: 80px; }
.cours-section h2 {
  font-size: 1.3rem; font-weight: 700;
  margin-bottom: 1rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem;
}
.cours-section h3 {
  font-size: 1.05rem; font-weight: 700;
  margin: 1.5rem 0 0.7rem;
}
.cours-section p { margin-bottom: 0.8rem; color: var(--muted); line-height: 1.7; }
.cours-section p strong { color: var(--text); }
.cours-section ul, .cours-section ol {
  padding-left: 1.4rem; margin-bottom: 0.8rem; color: var(--muted);
}
.cours-section li { margin-bottom: 0.3rem; line-height: 1.6; }

/* ── Code blocks ─────────────────────────────── */
.cours-section pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
  margin: 0.8rem 0 1.2rem;
  position: relative;
}
.cours-section code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.84rem;
}
.cours-section p code, .cours-section li code {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.82em;
  color: var(--blue);
}

/* ── Copy button ─────────────────────────────── */
.copy-btn {
  position: absolute; top: 0.6rem; right: 0.6rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted); font-size: 0.72rem;
  padding: 0.2rem 0.55rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.copy-btn:hover { background: rgba(255,255,255,0.13); color: var(--text); }

/* ── Info / Warning / Tip boxes ──────────────── */
.info-box, .warn-box, .tip-box {
  border-radius: 8px; padding: 0.9rem 1.1rem;
  margin: 1rem 0; font-size: 0.87rem; line-height: 1.6;
  border-left: 3px solid;
}
.info-box { background: rgba(121,192,255,0.08); border-color: var(--blue); color: var(--blue); }
.warn-box { background: rgba(240,196,25,0.08); border-color: var(--yellow); color: var(--yellow); }
.tip-box  { background: rgba(63,185,80,0.08); border-color: var(--green); color: var(--green); }
.info-box strong, .warn-box strong, .tip-box strong { display: block; margin-bottom: 0.3rem; }

/* ── Exercise cards ──────────────────────────── */
.exercice-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem;
  margin-bottom: 1.4rem;
  /* Les cartes exercice sont toujours visibles — pas d'animation reveal */
  opacity: 1 !important;
  transform: none !important;
}
.exercice-card .exo-header {
  display: flex; align-items: center; gap: 0.7rem;
  margin-bottom: 0.8rem;
}
.exercice-card .exo-num {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted);
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  padding: 0.15rem 0.5rem; border-radius: 4px;
}
.exercice-card h3 { font-size: 0.95rem; font-weight: 700; }
.exercice-card p { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }

.editor-area {
  width: 100%; min-height: 100px;
  background: #0d1117; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.8rem;
  color: var(--text); font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem; line-height: 1.6; resize: vertical;
  outline: none; transition: border-color 0.2s;
}
.editor-area:focus { border-color: var(--border-h); }

.output-area {
  display: none;
}
.output-area.show {
  display: block;
  background: #0d1117; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.8rem;
  font-size: 0.85rem; color: var(--green);
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  margin-top: 0.6rem;
  white-space: pre-wrap; line-height: 1.5;
  animation: outFadeIn .2s ease;
}
.output-area.show.error { color: var(--red); }
@keyframes outFadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* ── Mini-projet banner ───────────────────────── */
.projet-banner {
  background: rgba(240,196,25,0.06);
  border: 1px solid rgba(240,196,25,0.2);
  border-radius: 14px;
  padding: 1.6rem;
  margin-bottom: 2rem;
  display: flex; align-items: center; gap: 1.2rem;
}
.projet-banner .projet-icon { font-size: 2.5rem; flex-shrink: 0; }
.projet-banner h2 { font-size: 1.1rem; font-weight: 700; color: var(--yellow); margin-bottom: 0.3rem; }
.projet-banner p { font-size: 0.85rem; color: var(--muted); }

/* ── QCM button banner ───────────────────────── */
.qcm-banner {
  background: rgba(121,192,255,0.06);
  border: 1px solid rgba(121,192,255,0.2);
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  margin: 2rem 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.qcm-banner .qcm-info h3 { font-size: 1rem; font-weight: 700; color: var(--blue); margin-bottom: 0.2rem; }
.qcm-banner .qcm-info p { font-size: 0.82rem; color: var(--muted); }

/* Nav modules ─────────────────────────────────── */
.modules-nav {
  display: flex; justify-content: space-between;
  gap: 1rem; margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.modules-nav .nav-btn {
  flex: 1; background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 0.9rem 1.2rem;
  text-decoration: none; transition: border-color 0.2s, transform 0.2s;
  max-width: 220px;
}
.modules-nav .nav-btn:hover { border-color: var(--border-h); transform: translateY(-2px); }
.modules-nav .nav-btn.next { margin-left: auto; text-align: right; }
.modules-nav .nav-btn .nav-dir { font-size: 0.68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.modules-nav .nav-btn .nav-title { font-size: 0.88rem; font-weight: 700; margin-top: 0.2rem; }

/* ── Responsive cours ────────────────────────── */
@media (max-width: 900px) {
  .cours-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
}
@media (max-width: 480px) {
  .cours-layout { padding: 1rem 0.8rem; }
  .projet-banner { flex-direction: column; }
}

/* ── Bouton accueil ─────────────────────────────── */
.site-home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm, 8px);
  color: var(--muted);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  transition: all 0.2s ease;
  flex-shrink: 0;
  text-decoration: none;
}
.site-home-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.20);
}


/* ══ Mobile Complet (640 · 420 px) ══════════════════════ */
@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; }
  .content { padding: 1rem 0.9rem !important; }
  .sidebar { display: none !important; }
  .layout { flex-direction: column !important; }
  .modules-grid { grid-template-columns: 1fr !important; }
  .hero-stats, .stats-row { gap: 1rem; }
}
@media (max-width: 420px) {
  h1 { font-size: 1.3rem !important; }
}