:root {
  --bg: #050505;
  --card: #0c0c0c;
  --accent: #00ff95;
  --accent-dim: rgba(0, 255, 149, 0.1);
  --text: #ffffff;
  --rail-w: 80px;
  --rail-expanded: 280px;
  --accent-2: #00ff95b0;
}

/* Thème clair (override des variables) */
body.light-theme {
  --bg: #f5f7fb;
  --card: #ffffff;
  --accent: #0066cc; /* accent plus sombre pour le clair */
  --accent-dim: rgba(0, 102, 204, 0.08);
  --text: #0b1220;
  --rail-w: 80px;
  --rail-expanded: 280px;
  --accent-2: #0066ccb0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "arial", sans-serif;
  display: flex;
  margin: 0;
  overflow-x: hidden;
}

/* --- RAIL & NAVIGATION --- */
#nav-rail {
  width: var(--rail-w);
  height: 100vh;
  background: var(--card);
  border-right: 1px solid #1a1a1a;
  transition: width 0.5s cubic-bezier(0.8, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
}

#nav-rail.expanded {
  width: var(--rail-expanded);
}

/* --- BURGER MENU ANIMÉ --- */
.nav-header {
  padding: 30px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--accent);
  transition: 0.3s;
  flex-shrink: 0;
  background: transparent; /* remove any background */
  border: none; /* remove default button border */
  padding: 0;
  cursor: pointer;
}
.nav-item-theme {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 20px;
  margin-top: 500px;
}
.theme-toggle i {
  width: 20px;
  height: 20px;
}

.burger-wrapper {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.burger-icon {
  width: 24px;
  height: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.burger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animation en X */
.burger-icon.open span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.burger-icon.open span:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}
.burger-icon.open span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.logo-text {
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 0.8rem;
  color: var(--accent);
  opacity: 0;
  transition: 0.3s;
}

#nav-rail.expanded .logo-text {
  opacity: 1;
}

/* --- ITEMS --- */
.nav-links {
  flex: 1;
  list-style: none;
  padding: 20px 0;
}

.nav-item {
  padding: 15px 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 20px;
}

.icon-box {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #444;
  transition: 0.3s;
  flex-shrink: 0;
}

.nav-item.active .icon-box {
  color: var(--accent);
  background: var(--accent-dim);
}

.content-expanded {
  opacity: 0;
  transform: translateX(-10px);
  transition: 0.4s;
  white-space: nowrap;
}

#nav-rail.expanded .content-expanded {
  opacity: 1;
  transform: translateX(0);
}

.title {
  font-weight: 500;
  font-size: 0.9rem;
  color: #888;
}
.nav-item.active .title {
  color: #fff;
}

.progress-track {
  width: 140px;
  height: 2px;
  background: #1a1a1a;
  margin-top: 8px;
}

.nav-item.active .fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transition: width 1s;
}

/* --- CONTENU --- */
main {
  flex: 1;
  padding: 10vh 8vw;
}

.tab-content {
  display: none;
  animation: fadeIn 0.8s ease;
}
.tab-content.active {
  display: block;
}

.kicker {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 4px;
  font-size: 0.7rem;
  font-weight: bold;
}
h1 {
  font-size: clamp(2.5rem, 6vw, 5rem);
  margin: 20px 0;
  line-height: 1.1;
  font-weight: 800;
  font-family: "Inter", sans-serif;
}

.code-visualizer {
  background: #0a0a0a;
  padding: 30px;
  border-radius: 20px;
  border: 1px solid #1a1a1a;
  font-family: "Fira Code", monospace;
  margin-top: 40px;
}

.sel {
  color: #fade73;
}
.var {
  color: #f469fe;
}
.val {
  color: #ff5151;
}
.prop {
  color: #93edbc;
}
.func {
  color: #c90000;
}
.comment {
  color: #6272a4;
  display: block;
  margin-bottom: 5px;
  font-size: 0.9rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.description-text {
  max-width: 800px;
  line-height: 1.6;
}

h3 {
  color: var(--accent);
  margin-top: 50px;
}
strong {
  color: var(--accent-2);
}

.hero-text {
  margin-top: 150px;
}
ul {
  line-height: 1.8;
  max-width: 600px;
}

ol {
  line-height: 1.8;
  max-width: 600px;
}

/* 1. La variable par défaut (Globale) */
:root {
  --btn-color: #00ff95; /* Vert par défaut */
}

/* 2. Le bouton utilise TOUJOURS la même variable */
.btn-scope {
  background-color: transparent;
  border: 2px solid var(--btn-color);
  color: var(--btn-color);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
}

/* 3. On crée une zone qui REDÉFINIT la variable (Portée Locale) */
.zone-speciale {
  --btn-color: #ff00d4; /* Ici, le "tiroir" est remplacé par du Rose */
  padding: 20px;
  border-radius: 12px;
}

.zone-normale {
  padding: 20px;
}

.scope-demo {
  display: flex;
  gap: 20px;
}

.next-step-container {
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.next-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 15px 30px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 15px;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 40px;
}

.next-btn:hover {
  background: var(--accent);
  color: var(
    --bg
  ); /* Le texte devient de la couleur du fond pour le contraste */
  transform: translateX(10px);
  box-shadow: 0 0 20px var(--accent-dim);
}

.next-btn i {
  width: 20px;
  height: 20px;
  .theme-toggle:hover {
    background: transparent; /* ensure no hover background */
  }
  .theme-toggle:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 8px;
  }
}
.button-nav-container {
  display: flex;
  margin-top: 90px;
  border-top: 1px solid var(--border);
  justify-content: space-between; /* Un à gauche, un à droite */
}
/* Optionnel : Une animation différente pour le bouton retour */
.next-btn:has(.data-lucide-arrow-left):hover {
  transform: translateX(-10px); /* Il bouge vers la gauche */
}
/* --- PAGE LAB DÉDIÉE --- */
.lab-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr; /* L'éditeur est un peu plus large */
  gap: 30px;
  margin-top: 40px;
  height: 60vh; /* Prend 60% de la hauteur de l'écran */
}

.card-editor,
.card-preview {
  background: #080808;
  border: 1px solid #1a1a1a;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#css-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 30px;
  color: #a5ff90; /* Couleur typique éditeur */
  font-family: "Fira Code", monospace;
  font-size: 1rem;
  line-height: 1.6;
  resize: none;
  outline: none;
}

#preview-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #111 0%, #050505 100%);
  padding: 40px;
}

/* Styles par défaut pour les éléments du lab */
.card {
  transition: all 0.3s ease;
  text-align: center;
}
.le-bouton {
  border: none;
  padding: 12px 24px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 15px;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

@media (max-width: 1000px) {
  .lab-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  #css-input {
    height: 300px;
  }
}

/* --- FIX POUR LE MODE EXPERT --- */
.exercise-grid.expert-mode {
  display: grid;
  grid-template-columns: 1fr 1fr; /* Force les deux colonnes */
  gap: 30px;
  align-items: start;
}

.editors-stack {
  display: flex;
  flex-direction: column;
  gap: 20px; /* Espace entre l'éditeur HTML et CSS */
}

/* Force la hauteur des zones de texte */
#html-expert-input,
#css-expert-input {
  min-height: 200px;
  width: 100%;
  background: #080808;
  color: #a5ff90;
  border: none;
  padding: 20px;
  font-family: "Fira Code", monospace;
  resize: vertical; /* Permet à l'élève d'agrandir si besoin */
  outline: none;
}

.preview-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#preview-expert-target {
  background: var(--card);
  padding: 30px;
  border-radius: 0 0 20px 20px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
