/* ==========================================================================
   components.css — chapitres, quiz, leçons, écran final, panneau latéral
   ========================================================================== */

/* === PREVIEW CARDS (aperçu des chapitres) === */
.preview-card {
  background: white;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  border: 1px solid rgba(26, 46, 42, 0.06);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px);
  display: flex;
  flex-direction: column;
}
.preview-card.in-view {
  opacity: 1;
  transform: translateY(0);
}
.preview-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.preview-card-image {
  position: relative;
  height: 160px;
  overflow: hidden;
  background: var(--card-grad, var(--grad-hero));
}
.preview-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  display: block;
}
.preview-card:hover .preview-card-image img {
  transform: scale(1.08);
}
.preview-card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--card-grad, var(--grad-hero));
  opacity: 0.35;
  mix-blend-mode: multiply;
  transition: opacity 0.4s;
}
.preview-card:hover .preview-card-image::after {
  opacity: 0.2;
}

.preview-card-emoji {
  position: absolute;
  bottom: -20px;
  left: 1.5rem;
  width: 52px; height: 52px;
  border-radius: 14px;
  background: white;
  display: grid; place-items: center;
  font-size: 1.6rem;
  box-shadow: var(--shadow-md);
  z-index: 2;
  transition: transform 0.3s;
}
.preview-card:hover .preview-card-emoji {
  transform: translateY(-4px) rotate(-8deg);
}
.preview-card-num-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.3rem 0.7rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--ink);
  z-index: 2;
  box-shadow: var(--shadow-sm);
}
.preview-card-body {
  padding: 2rem 1.5rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.preview-card-title {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}
.preview-card-meta {
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.8rem;
  justify-content: space-between;
}
.preview-card-arrow {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(26, 46, 42, 0.04);
  display: grid; place-items: center;
  transition: all 0.3s;
  font-size: 0.9rem;
}
.preview-card:hover .preview-card-arrow {
  background: var(--card-grad, var(--grad-hero));
  color: white;
  transform: translateX(4px);
}

/* === EN-TÊTE DE CHAPITRE === */
.chapter-header { margin-bottom: 2rem; }
.chapter-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  border-radius: 14px;
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 1.3rem;
  color: white;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
}
.chapter-header h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  margin-bottom: 0.5rem;
}
.chapter-subtitle {
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 500;
}

/* === CARTE DE CONTENU (leçon) === */
.content-card {
  background: var(--grad-card);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  animation: fadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  border: 1px solid rgba(26, 46, 42, 0.04);
}
.content-card p {
  margin-bottom: 1rem;
  color: var(--ink);
  font-size: 1.05rem;
}
.content-card u {
  text-decoration: none;
  font-weight: 700;
  color: var(--sage-1);
  display: inline-block;
  margin-top: 0.5rem;
}
.content-card b { color: var(--ink); font-weight: 700; }

/* Liste de piliers (items colorés animés) */
.pillar-list { list-style: none; margin: 1.2rem 0; }
.pillar-list li {
  padding: 0.9rem 1.2rem;
  margin-bottom: 0.6rem;
  background: white;
  border-radius: 14px;
  border-left: 4px solid var(--sage-2);
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.98rem;
  animation: slideIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.pillar-list li:nth-child(1) { animation-delay: 0.05s; }
.pillar-list li:nth-child(2) { animation-delay: 0.1s; border-left-color: var(--coral-1); }
.pillar-list li:nth-child(3) { animation-delay: 0.15s; border-left-color: var(--amber); }
.pillar-list li:nth-child(4) { animation-delay: 0.2s; border-left-color: var(--violet-2); }
.pillar-list li:nth-child(5) { animation-delay: 0.25s; border-left-color: var(--sky); }
.pillar-list li:nth-child(6) { animation-delay: 0.3s; }
.pillar-list li:hover {
  transform: translateX(6px);
  box-shadow: var(--shadow-sm);
}
.pillar-list li::before {
  content: '✓';
  width: 24px; height: 24px;
  background: var(--grad-hero);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.85rem;
  font-weight: bold;
  flex-shrink: 0;
}

/* Image hero d'une leçon */
.lesson-hero {
  position: relative;
  width: 100%;
  height: 240px;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 1.8rem;
  background: var(--lesson-grad, var(--grad-hero));
}
.lesson-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lesson-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--lesson-grad, var(--grad-hero));
  opacity: 0.4;
  mix-blend-mode: multiply;
}
.lesson-hero-emoji {
  position: absolute;
  bottom: 1.2rem;
  left: 1.2rem;
  width: 64px; height: 64px;
  border-radius: 18px;
  background: white;
  display: grid; place-items: center;
  font-size: 2rem;
  box-shadow: var(--shadow-md);
  z-index: 2;
}
.lesson-hero-tag {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  padding: 0.4rem 0.9rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  z-index: 2;
  box-shadow: var(--shadow-sm);
}

/* Navigation entre chapitres (boutons précédent/suivant) */
.chapter-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
}

/* === QUIZ === */
.quiz-intro {
  text-align: center;
  padding: 2rem;
  background: var(--grad-card);
  border-radius: 20px;
  margin-bottom: 2rem;
  border: 2px dashed rgba(13, 148, 136, 0.3);
}
.quiz-intro-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  display: inline-block;
  animation: wiggle 2s ease-in-out infinite;
}

.question-card {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  border: 1px solid rgba(26, 46, 42, 0.04);
}
.question-num {
  display: inline-block;
  font-family: 'Fraunces', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--sage-2);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.question-text {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
  line-height: 1.4;
}

.quiz-option {
  padding: 1rem 1.2rem;
  margin-bottom: 0.7rem;
  border: 2px solid rgba(26, 46, 42, 0.08);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  background: white;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.98rem;
  position: relative;
  overflow: hidden;
}
.quiz-option:hover:not(.disabled) {
  border-color: var(--sage-2);
  transform: translateX(4px);
  background: linear-gradient(90deg, rgba(13, 148, 136, 0.04), transparent);
}
.option-marker {
  width: 26px; height: 26px;
  border: 2px solid rgba(26, 46, 42, 0.15);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
  flex-shrink: 0;
  transition: all 0.25s;
}
.quiz-option.selected {
  border-color: var(--sage-2);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08), rgba(5, 150, 105, 0.04));
}
.quiz-option.selected .option-marker {
  background: var(--grad-hero);
  color: white;
  border-color: transparent;
}
.quiz-option.correct {
  border-color: var(--emerald);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.05));
  animation: correctPop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.quiz-option.correct .option-marker {
  background: var(--grad-sage);
  color: white;
  border-color: transparent;
}
.quiz-option.incorrect {
  border-color: var(--coral-2);
  background: linear-gradient(135deg, rgba(249, 112, 102, 0.1), rgba(239, 68, 68, 0.05));
  animation: shake 0.4s;
}
.quiz-option.incorrect .option-marker {
  background: var(--grad-coral);
  color: white;
  border-color: transparent;
}
.quiz-option.disabled { cursor: default; }

/* === PANNEAU LATÉRAL (map des chapitres) === */
.map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 46, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.map-overlay.open { opacity: 1; pointer-events: auto; }

.map-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(440px, 90vw);
  height: 100vh;
  background: var(--cream);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}
.map-panel.open { transform: translateX(0); }

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.map-header h3 { font-size: 1.4rem; }
.map-close {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(26, 46, 42, 0.1);
  background: white;
  cursor: pointer;
  font-size: 1.2rem;
}

.map-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 14px;
  background: white;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid rgba(26, 46, 42, 0.04);
}
.map-item:hover {
  transform: translateX(-4px);
  box-shadow: var(--shadow-sm);
  border-color: var(--sage-2);
}
.map-item.active {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08), rgba(5, 150, 105, 0.04));
  border-color: var(--sage-2);
}
.map-item-num {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-family: 'Fraunces', serif;
  font-weight: 900;
  color: white;
  flex-shrink: 0;
}
.map-item-body { flex: 1; min-width: 0; }
.map-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-item-status {
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(26, 46, 42, 0.15);
  margin-right: 0.4rem;
  vertical-align: middle;
}
.dot-green { background: var(--emerald); }
.dot-amber { background: var(--amber); }
.dot-coral { background: var(--coral-2); }

.map-final {
  margin-top: 1rem;
  padding: 1.2rem;
  border-radius: 16px;
  background: var(--grad-amber);
  color: white;
  cursor: pointer;
  text-align: center;
  font-weight: 700;
  display: none;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s;
}
.map-final:hover { transform: translateY(-2px); }
.map-final.visible { display: block; animation: fadeUp 0.5s; }

/* === ÉCRAN FINAL (bilan) === */
.final-hero {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--grad-card);
  border-radius: 28px;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(26, 46, 42, 0.05);
}
.final-hero::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: var(--grad-hero);
  opacity: 0.05;
  animation: rotate 30s linear infinite;
}
.final-hero > * { position: relative; z-index: 1; }

.score-circle {
  width: 200px; height: 200px;
  margin: 1.5rem auto;
  position: relative;
}
.score-circle svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.score-circle-bg {
  fill: none;
  stroke: rgba(26, 46, 42, 0.08);
  stroke-width: 10;
}
.score-circle-fg {
  fill: none;
  stroke: url(#scoreGrad);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 565.48;
  stroke-dashoffset: 565.48;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-number {
  font-family: 'Fraunces', serif;
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  background: var(--grad-hero);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.score-total {
  font-size: 1rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

.final-message {
  font-size: 1.1rem;
  color: var(--ink-soft);
  max-width: 560px;
  margin: 1.5rem auto;
}
.final-quote {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink);
  max-width: 600px;
  margin: 2rem auto;
  padding: 1.5rem;
  border-left: 4px solid var(--sage-2);
  text-align: left;
}

.final-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .content-card { padding: 1.5rem; border-radius: 18px; }
  .chapter-nav { flex-direction: column-reverse; }
  .chapter-nav .btn { width: 100%; justify-content: center; }
  .final-actions .btn { width: 100%; justify-content: center; }
}
