/* ═══════════════════════════════════════════════
   Formation Backend & BDD — Design System
   PostgreSQL · MongoDB · Redis · Prisma
   ═══════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

:root {
  /* Base */
  --bg:        #0a0e1a;
  --bg-2:      #0d1117;
  --bg-3:      #161b22;
  --glass:     rgba(22, 27, 34, 0.70);
  --border:    rgba(255, 255, 255, 0.08);
  --border-h:  rgba(255, 255, 255, 0.18);
  --text:      #e6edf3;
  --muted:     #8b949e;
  --dim:       #484f58;
  --radius:    14px;
  --radius-sm: 8px;

  /* Statut */
  --green:  #3fb950;
  --yellow: #d29922;
  --red:    #f85149;
  --blue:   #58a6ff;

  /* PostgreSQL */
  --pg:        #336791;
  --pg-light:  #5ba3c9;
  --pg-dark:   #1e4b6e;
  --pg-bg:     rgba(51, 103, 145, 0.08);
  --glow-pg:   0 0 24px rgba(51, 103, 145, 0.28);

  /* MongoDB */
  --mongo:       #47A248;
  --mongo-light: #6dc26e;
  --mongo-dark:  #2d6e2e;
  --mongo-bg:    rgba(71, 162, 72, 0.08);
  --glow-mongo:  0 0 24px rgba(71, 162, 72, 0.22);

  /* Redis */
  --redis:       #DC382D;
  --redis-light: #f06355;
  --redis-dark:  #a0231a;
  --redis-bg:    rgba(220, 56, 45, 0.08);
  --glow-redis:  0 0 24px rgba(220, 56, 45, 0.22);

  /* Prisma */
  --prisma:       #5A67D8;
  --prisma-light: #7f8de8;
  --prisma-bg:    rgba(90, 103, 216, 0.08);

  /* Node.js */
  --node: #68A063;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
::selection { background: rgba(51, 103, 145, 0.22); }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  flex-wrap: wrap;
}
.header-title {
  font-weight: 700;
  font-size: 0.95rem;
  background: linear-gradient(135deg, var(--pg-light) 0%, var(--mongo-light) 50%, var(--redis-light) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-sub { color: var(--muted); font-size: 0.82rem; }
.back-link {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.8rem;
  transition: color .2s, border-color .2s;
}
.back-link:hover { color: var(--pg-light); border-color: var(--pg); }

/* ── Cards ── */
.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: var(--border-h); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.83rem; font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .1s;
  text-decoration: none;
}
.btn:hover {
  background: rgba(255,255,255,0.09);
  border-color: var(--border-h);
  color: var(--text);
  transform: translateY(-1px);
}
.btn-pg {
  color: var(--pg-light);
  background: var(--pg-bg);
  border-color: rgba(51,103,145,0.28);
}
.btn-pg:hover {
  background: rgba(51,103,145,0.16);
  border-color: var(--pg);
  color: var(--pg-light);
}
.btn-mongo {
  color: var(--mongo-light);
  background: var(--mongo-bg);
  border-color: rgba(71,162,72,0.28);
}
.btn-mongo:hover {
  background: rgba(71,162,72,0.16);
  border-color: var(--mongo);
  color: var(--mongo-light);
}
.btn-redis {
  color: var(--redis-light);
  background: var(--redis-bg);
  border-color: rgba(220,56,45,0.28);
}
.btn-redis:hover {
  background: rgba(220,56,45,0.16);
  border-color: var(--redis);
  color: var(--redis-light);
}
.btn-bdd {
  color: var(--pg-light);
  background: var(--pg-bg);
  border-color: rgba(51,103,145,0.28);
}
.btn-bdd:hover {
  background: rgba(51,103,145,0.16);
  border-color: var(--pg);
  color: var(--pg-light);
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.badge-pg     { background: rgba(51,103,145,0.12);  color: var(--pg-light);    border-color: rgba(51,103,145,0.3); }
.badge-mongo  { background: rgba(71,162,72,0.12);   color: var(--mongo-light); border-color: rgba(71,162,72,0.3); }
.badge-redis  { background: rgba(220,56,45,0.10);   color: var(--redis-light); border-color: rgba(220,56,45,0.3); }
.badge-prisma { background: rgba(90,103,216,0.10);  color: var(--prisma-light);border-color: rgba(90,103,216,0.3); }
.badge-sql    { background: rgba(51,103,145,0.10);  color: var(--pg-light);    border-color: rgba(51,103,145,0.25); }
.badge-nosql  { background: rgba(71,162,72,0.10);   color: var(--mongo-light); border-color: rgba(71,162,72,0.25); }

/* ── Progress bar ── */
.progress-bar {
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--pg), var(--mongo), var(--redis));
  border-radius: 99px;
  transition: width .6s ease;
}

/* ── Code blocks ── */
pre {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  position: relative;
}
code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
}
:not(pre) > code {
  background: rgba(255,255,255,0.07);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  font-size: 0.8em;
  color: var(--pg-light);
}

/* copy button */
.copy-btn {
  position: absolute; top: 0.6rem; right: 0.6rem;
  font-size: 0.7rem; padding: 0.25rem 0.6rem;
  border: 1px solid var(--border); border-radius: 5px;
  background: rgba(255,255,255,0.06); color: var(--muted);
  cursor: pointer; opacity: 0; transition: opacity .2s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,0.12); color: var(--text); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* ── Callout boxes ── */
.info-box, .tip-box, .warn-box, .danger-box {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  line-height: 1.6;
  margin: 1rem 0;
  border-left: 3px solid;
}
.info-box   { background: rgba(51,103,145,0.08);  border-color: var(--pg);    color: #b0cfe0; }
.tip-box    { background: rgba(71,162,72,0.08);   border-color: var(--mongo); color: #a8d5a9; }
.warn-box   { background: rgba(210,153,34,0.08);  border-color: var(--yellow);color: #d4b84a; }
.danger-box { background: rgba(220,56,45,0.08);   border-color: var(--redis); color: #e08a84; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
th {
  text-align: left;
  padding: 0.55rem 0.9rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
td {
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Nav sidebar (cours) ── */
.nav-sidebar {
  position: sticky; top: 68px;
  width: 230px; flex-shrink: 0;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding-right: 0.5rem;
}
.nav-sidebar::-webkit-scrollbar { width: 4px; }
.nav-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.nav-list { list-style: none; }
.nav-link {
  display: block;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: color .2s, background .2s, border-color .2s;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-link.active {
  background: rgba(51,103,145,0.10);
  color: var(--pg-light);
  border-left-color: var(--pg);
}

/* ── Layout cours ── */
.cours-layout {
  display: flex;
  gap: 2rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  align-items: flex-start;
}
.cours-content { flex: 1; min-width: 0; }
.section-anchor { scroll-margin-top: 80px; }

/* ── Headings ── */
h1 { font-size: 1.7rem; font-weight: 800; line-height: 1.25; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 2rem 0 0.75rem; color: var(--text); }
h3 { font-size: 0.95rem; font-weight: 600; margin: 1.4rem 0 0.5rem; color: var(--muted); }

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

/* ── Details / Exercices ── */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
  overflow: hidden;
}
summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  list-style: none;
  display: flex; align-items: center; gap: 0.5rem;
  transition: color .2s, background .2s;
}
summary:hover { color: var(--text); background: rgba(255,255,255,0.06); }
summary::before { content: '▶'; font-size: 0.6rem; transition: transform .2s; }
details[open] summary::before { transform: rotate(90deg); }
details > *:not(summary) { padding: 1rem; }

/* ── Hero section ── */
.hero-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 900;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--pg-light) 0%, var(--mongo-light) 50%, var(--redis-light) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub { color: var(--muted); font-size: 1rem; line-height: 1.6; max-width: 620px; }

/* ── Module grid ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}
.module-card {
  display: flex; flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  text-decoration: none; color: inherit;
}
.module-card:hover {
  border-color: var(--border-h);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.module-number { font-size: 0.72rem; color: var(--dim); font-weight: 600; margin-bottom: 0.4rem; }
.module-title  { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.3rem; }
.module-desc   { font-size: 0.8rem; color: var(--muted); line-height: 1.5; flex: 1; margin-bottom: 0.8rem; }
.module-footer { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ── Stats strip ── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.8rem;
}
.stat-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 0.7rem;
  text-align: center;
}
.stat-value { font-size: 1.5rem; font-weight: 800; display: block; }
.stat-label { font-size: 0.72rem; color: var(--muted); }

/* ── Section color accents ── */
.section-pg    { border-left: 3px solid var(--pg);    padding-left: 1rem; }
.section-mongo { border-left: 3px solid var(--mongo);  padding-left: 1rem; }
.section-redis { border-left: 3px solid var(--redis);  padding-left: 1rem; }

/* ══════════════════════════════════════════
   Responsive — Mobile & Tablet
   ══════════════════════════════════════════ */

/* ── Tablet ≤ 900px ── */
@media (max-width: 900px) {
  .cours-layout { flex-direction: column; padding: 1.5rem 1.2rem; }
  .nav-sidebar  { display: none; }
  .module-grid  { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ── Mobile large ≤ 640px ── */
@media (max-width: 640px) {
  body { font-size: 14px; }

  .site-header {
    height: auto; min-height: 52px;
    padding: 0.5rem 1rem;
    gap: 0.4rem;
  }
  .header-sub { display: none; }
  .back-link { padding: 0.2rem 0.6rem; font-size: 0.78rem; }

  .cours-layout { padding: 1rem 0.9rem; }

  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.05rem; margin: 1.5rem 0 0.6rem; }

  .hero-title { font-size: clamp(1.4rem, 7vw, 2rem); }
  .hero-sub   { font-size: 0.88rem; }

  .module-grid  { grid-template-columns: 1fr; }
  .stats-strip  { grid-template-columns: repeat(2, 1fr); }
  .stat-value   { font-size: 1.3rem; }

  pre {
    font-size: 0.76rem;
    padding: 0.85rem 0.9rem;
    border-radius: 6px;
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 0.78rem;
  }

  .info-box, .tip-box, .warn-box, .danger-box {
    padding: 0.7rem 0.85rem;
    font-size: 0.83rem;
  }

  .btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
  }

  details > *:not(summary) { padding: 0.75rem 0.9rem; }
}

/* ── Mobile small ≤ 400px ── */
@media (max-width: 400px) {
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .module-card { padding: 1rem 1.1rem; }
  .site-header { padding: 0.4rem 0.8rem; }
}
