/* ============================================
   MES RÉVISIONS CM2 — Feuille de style
   ============================================ */

:root {
  --primary:       #6C63FF;
  --primary-dark:  #5A52D5;
  --primary-light: #EEF0FF;
  --success:       #22C55E;
  --success-light: #DCFCE7;
  --error:         #EF4444;
  --error-light:   #FEE2E2;
  --warning:       #F59E0B;
  --warning-light: #FEF3C7;
  --bg:            #F0F4FF;
  --card-bg:       #FFFFFF;
  --text:          #1E293B;
  --text-muted:    #64748B;
  --border:        #E2E8F0;
  --shadow:        0 2px 12px rgba(108, 99, 255, 0.10);
  --shadow-hover:  0 8px 30px rgba(108, 99, 255, 0.20);
  --radius:        18px;
  --radius-sm:     10px;
  --font:          'Nunito', 'Segoe UI', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---- Layout ---- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- Header (home) ---- */
.main-header {
  background: linear-gradient(135deg, #6C63FF 0%, #9B8FF5 100%);
  color: #fff;
  padding: 36px 0 28px;
  text-align: center;
}
.main-header .header-icon { font-size: 3rem; margin-bottom: 8px; }
.main-header h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.5px; }
.main-header .subtitle { font-size: 1.05rem; opacity: 0.85; margin-top: 4px; font-weight: 600; }

/* ---- Header (exercise page) ---- */
.page-header {
  background: linear-gradient(135deg, #6C63FF 0%, #9B8FF5 100%);
  color: #fff;
  padding: 20px 0 16px;
}
.page-header .header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}
.back-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 10px;
  color: #fff;
  padding: 8px 14px;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,0.32); }
.page-header h1 { font-size: 1.4rem; font-weight: 800; }
.page-header .page-subtitle { font-size: 0.85rem; opacity: 0.85; font-weight: 600; }

/* ---- Home: categories & cards ---- */
.category { margin: 32px 0; }
.category-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.exercises-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.exercise-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 2px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
  color: var(--text);
}
.exercise-card.available:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}
.exercise-card.disabled {
  opacity: 0.5;
  cursor: default;
  filter: grayscale(0.25);
}
.exercise-icon { font-size: 2.4rem; }
.exercise-info h3 { font-size: 1rem; font-weight: 700; margin-bottom: 3px; }
.exercise-info p { font-size: 0.83rem; color: var(--text-muted); line-height: 1.35; }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  align-self: flex-start;
}
.badge-available { background: #EEF0FF; color: var(--primary); }
.badge-soon { background: var(--warning-light); color: #92400E; }

/* ---- Progress bar (sticky) ---- */
.progress-section {
  background: var(--card-bg);
  padding: 12px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  position: sticky;
  top: 0;
  z-index: 10;
}
.progress-inner { display: flex; align-items: center; gap: 12px; }
.progress-bar-track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #9B8FF5);
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}
.progress-text { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.score-display { font-size: 0.9rem; font-weight: 800; color: var(--success); white-space: nowrap; }

/* ---- Question screen ---- */
.question-screen { padding: 28px 0 48px; }

.sentence-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 24px;
}
.sentence-card .sentence-text {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.7;
  color: var(--text);
}
.sentence-text .blank {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 2px;
  vertical-align: middle;
  transition: background 0.2s, color 0.2s;
}
.sentence-text .blank-correct {
  background: var(--success-light);
  color: #15803D;
  letter-spacing: normal;
}
.sentence-text .blank-incorrect {
  background: var(--error-light);
  color: #B91C1C;
  letter-spacing: normal;
}

.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.choices-grid-2 .choice-btn {
  font-size: 1.5rem;
  padding: 22px 12px;
}

.choice-btn {
  background: var(--card-bg);
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 12px;
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.choice-btn:not(:disabled):hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  transform: scale(1.03);
}
.choice-btn:active:not(:disabled) { transform: scale(0.97); }
.choice-btn:disabled { cursor: default; }

.choice-btn.correct {
  background: var(--success-light);
  border-color: var(--success);
  color: #15803D;
  animation: pulse-correct 0.4s ease;
}
.choice-btn.incorrect {
  background: var(--error-light);
  border-color: var(--error);
  color: #B91C1C;
  animation: shake 0.4s ease;
}

@keyframes pulse-correct {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ---- Highlight (complements exercise) ---- */
.highlight {
  background: #FEF3C7;
  color: #92400E;
  border-radius: 6px;
  padding: 1px 8px;
  font-weight: 800;
  border-bottom: 2.5px solid #F59E0B;
}
.highlight-demo {
  background: #FEF3C7;
  color: #92400E;
  border-radius: 5px;
  padding: 0 6px;
  font-weight: 800;
  border-bottom: 2px solid #F59E0B;
}
.question-label {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ---- 3-choice grid ---- */
.choices-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.choices-grid-3 .choice-btn {
  font-size: 1rem;
  padding: 18px 6px;
}

/* ---- Next question button ---- */
.next-btn-wrap {
  margin-top: 16px;
  text-align: center;
}
.btn-next {
  width: 100%;
  justify-content: center;
  font-size: 1.05rem;
  padding: 16px;
}

/* ---- Explanation box (after wrong answer) ---- */
.explanation-box {
  background: #FFFBEB;
  border: 2px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.92rem;
  line-height: 1.65;
  animation: slide-down 0.3s ease;
}
.explanation-box strong { color: var(--text); }
.explanation-box .expl-sentence {
  display: inline-block;
  margin-top: 4px;
  font-style: italic;
  color: var(--text-muted);
}
.explanation-box u {
  text-decoration-color: var(--warning);
  text-decoration-thickness: 2px;
  font-style: normal;
  font-weight: 800;
  color: var(--text);
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Rule reminder ---- */
.rule-toggle-btn {
  display: block;
  width: 100%;
  background: none;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
  margin-bottom: 18px;
  text-align: center;
  transition: all 0.15s;
}
.rule-toggle-btn:hover { border-color: var(--primary); color: var(--primary); }

.rule-box {
  background: #FAFAFF;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 18px;
  font-size: 0.88rem;
  line-height: 1.6;
}
.rule-box h4 { font-size: 0.95rem; font-weight: 800; margin-bottom: 10px; color: var(--primary); }
.rule-box ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rule-box li {
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
}
.rule-box li strong { color: var(--primary); }

/* ---- Results screen ---- */
.result-screen { padding: 40px 0 60px; text-align: center; }

.result-emoji-big {
  font-size: 4.5rem;
  margin-bottom: 8px;
  display: block;
  animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bounce-in {
  0%   { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-score-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
}
.stars-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 2rem;
  margin-bottom: 8px;
}
.result-message {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.wrong-answers-section {
  text-align: left;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}
.wrong-answers-section h3 { font-size: 1rem; font-weight: 800; margin-bottom: 12px; }

.wrong-item {
  border-left: 3px solid var(--error);
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 0 8px 8px 0;
  background: var(--error-light);
}
.wrong-item:last-child { margin-bottom: 0; }
.wrong-sentence { font-size: 0.95rem; font-weight: 600; margin-bottom: 3px; }
.wrong-sentence .given-wrong {
  background: var(--error);
  color: #fff;
  padding: 0 6px;
  border-radius: 5px;
  font-weight: 700;
}
.correct-answer-note { font-size: 0.85rem; color: #15803D; font-weight: 700; }

.all-correct-msg {
  color: #15803D;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  padding: 12px 0;
}

/* ---- Buttons ---- */
.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(108, 99, 255, 0.35);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.45);
}
.btn-outline {
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
}

/* ---- Footer ---- */
footer {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---- Responsive mobile ---- */
@media (max-width: 520px) {
  .main-header h1 { font-size: 1.9rem; }
  .main-header .header-icon { font-size: 2.4rem; }
  .exercises-grid { grid-template-columns: 1fr; }
  .sentence-card .sentence-text { font-size: 1.2rem; }
  .sentence-text .blank { font-size: 1.3rem; }
  .choice-btn { font-size: 1.1rem; padding: 16px 10px; }
  .result-score-big { font-size: 2.4rem; }
  .result-emoji-big { font-size: 3.5rem; }
  .btn { padding: 12px 20px; font-size: 0.95rem; }
  .page-header h1 { font-size: 1.15rem; }
}
