:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #e2e8f0;
  --border: #dbeafe;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --max-width: 1200px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

img {
  max-width: 100%;
  display: block;
}

iframe {
  width: 100%;
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  font-family: inherit;
}

.container {
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 78px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--primary);
}

.menu-toggle {
  display: none;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.menu-toggle:hover {
  background: #f8fafc;
  border-color: #93c5fd;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.main-nav > a,
.dropdown-toggle {
  color: var(--text);
  font-weight: 600;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}

.main-nav > a:hover,
.dropdown-toggle:hover {
  color: var(--primary);
}

.nav-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  min-width: 260px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.75rem;
  display: none;
  z-index: 20;
}

.dropdown-menu a {
  display: block;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  color: var(--muted);
  transition: 0.2s ease;
}

.dropdown-menu a:hover {
  background: #eff6ff;
  color: var(--primary);
}

.nav-dropdown.open .dropdown-menu,
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu {
  display: block;
}

/* Hero */
.hero {
  padding: 4.5rem 0 3rem;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.1), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 2rem;
}

.eyebrow,
.section-tag,
.mini-badge {
  display: inline-block;
  margin: 0 0 0.9rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.9rem;
  font-weight: 700;
}

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.hero-description {
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

.hero-card,
.card,
.video-card,
.generator-box,
.quiz-box,
.quiz-score-card,
.reassurance-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 1.6rem;
  border: 1px solid #e2e8f0;
}

.hero-card h2 {
  margin-top: 0;
  margin-bottom: 0.8rem;
}

.hero-card p {
  color: var(--muted);
}

.mini-grid {
  display: grid;
  gap: 0.9rem;
  margin: 1rem 0;
}

.mini-item {
  display: block;
  padding: 1rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #dbeafe;
  font-weight: 700;
  transition: 0.2s ease;
}

.mini-link:hover {
  background: #eff6ff;
  color: var(--primary);
  transform: translateY(-1px);
}

/* Sections */
.section {
  padding: 4.5rem 0;
}

.alt-section {
  background: var(--surface-alt);
}

.section-heading {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 2rem;
}

.section-heading.left {
  text-align: left;
  margin: 0 0 1.5rem;
}

.section-heading h2 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.2;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
}

/* Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.card,
.video-card,
.generator-box,
.quiz-box,
.quiz-score-card,
.reassurance-card {
  border: 1px solid #e2e8f0;
}

.card {
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
}

.card-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #eff6ff;
  color: var(--primary);
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.6rem;
}

.card p {
  color: var(--muted);
  margin-top: 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Ajustements utiles pour la page Fractions */
#cours .card,
#operations .card,
#ressources-fractions .card,
#ressources-fractions .video-card {
  height: 100%;
}

#operations .card p,
#cours .card p {
  line-height: 1.7;
}

#operations .card strong,
#cours .card strong,
.generator-box strong,
.quiz-box strong {
  color: var(--text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.85rem 1.15rem;
  border-radius: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible,
.menu-toggle:focus-visible,
.dropdown-toggle:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-small {
  padding: 0.7rem 0.95rem;
  font-size: 0.95rem;
}

.full-width {
  width: 100%;
}

/* Video */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.video-card {
  padding: 1rem;
}

.video-wrapper {
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #0f172a;
}

.video-wrapper iframe {
  width: 100%;
  height: 100%;
}

.video-card h3 {
  margin-bottom: 0.5rem;
}

.video-card p {
  color: var(--muted);
  margin-top: 0;
}

/* Two columns */
.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

/* Generator */
.generator-box,
.quiz-box {
  padding: 1.5rem;
}

.generator-box label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.generator-box select {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  margin-bottom: 1rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.generator-box select:hover {
  border-color: #93c5fd;
}

.generated-list {
  display: grid;
  gap: 0.9rem;
  margin: 1rem 0;
  min-height: 40px;
}

.generated-list p {
  padding: 1rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: var(--muted);
  margin: 0;
}

.generator-placeholder {
  text-align: center;
}

.generated-content {
  padding: 1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #dbeafe;
}

.generated-content > p {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0 0 0.9rem;
  color: var(--text);
}

.generated-title {
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.5rem;
}

.generated-list ol {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.8rem;
}

.generated-list li {
  padding: 1rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #dbeafe;
  color: var(--text);
}

/* Ajout pour fractions.html */
.generated-item {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #dbeafe;
  color: var(--text);
  margin-bottom: 0.85rem;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.06);
}

.generated-item:last-child {
  margin-bottom: 0;
}

.generated-item strong {
  color: var(--primary-dark);
}

.exercise-item {
  padding: 1rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #dbeafe;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.06);
}

.exercise-item h4 {
  margin: 0 0 0.5rem;
  color: var(--primary);
  font-size: 1rem;
}

.exercise-item p {
  margin: 0;
  color: var(--text);
}

.chapter-link {
  margin-top: 0.75rem;
}

/* Quiz */
.quiz-form {
  margin-top: 1rem;
}

.quiz-score-card {
  margin-bottom: 1rem;
  padding: 1.2rem;
  background: #eff6ff;
  text-align: center;
  border: 1px solid #bfdbfe;
}

.quiz-score-card p {
  margin: 0.25rem 0;
}

#quizScorePercent {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

#quizScoreText {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.quiz-progress {
  margin-bottom: 1.2rem;
}

.quiz-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.quiz-progress-bar {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.quiz-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  transition: width 0.25s ease;
}

.quiz-actions {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.quiz-question {
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  margin-bottom: 1rem;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.quiz-question:hover {
  transform: translateY(-1px);
}

.quiz-question h3,
.quiz-question h4 {
  margin: 0 0 0.75rem;
  font-weight: 700;
}

.quiz-question p {
  margin-top: 0;
  margin-bottom: 0.8rem;
}

.quiz-options {
  display: grid;
  gap: 0.7rem;
}

.quiz-question label,
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  margin-bottom: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  transition: 0.2s ease;
}

.quiz-question label:hover,
.quiz-option:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.quiz-question input[type="radio"],
.quiz-option input[type="radio"] {
  margin-top: 0.2rem;
  accent-color: var(--primary);
  transform: scale(1.05);
}

.quiz-option span {
  flex: 1;
  line-height: 1.5;
}

.quiz-option.correct,
.option-correct {
  border-color: #86efac !important;
  background: #dcfce7 !important;
}

.quiz-option.wrong,
.option-wrong {
  border-color: #fca5a5 !important;
  background: #fee2e2 !important;
}

.option-answer {
  border-color: #93c5fd !important;
  background: #dbeafe !important;
}

.quiz-question.correct {
  border-color: #86efac;
  background: #f0fdf4;
}

.quiz-question.incorrect {
  border-color: #fca5a5;
  background: #fef2f2;
}

.quiz-question.unanswered {
  border-color: #fcd34d;
  background: #fffbeb;
}

.quiz-feedback {
  margin-top: 0.9rem;
  padding: 1rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: var(--muted);
}

.quiz-feedback p {
  margin: 0.35rem 0;
}

.quiz-question.correct .quiz-feedback {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}

.quiz-question.incorrect .quiz-feedback {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.quiz-question.unanswered .quiz-feedback {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.quiz-explanation {
  margin-top: 0.8rem;
  padding: 0.9rem;
  border-radius: 12px;
  background: #ffffff;
  border-left: 4px solid var(--primary);
  color: var(--muted);
}

.quiz-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-weight: 600;
}

.quiz-result p {
  margin: 0.35rem 0;
}

.quiz-correction {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 14px;
  display: none;
  border-left: 6px solid transparent;
}

.quiz-correction.correct {
  display: block;
  background: #f0fdf4;
  border-left-color: #16a34a;
  color: #166534;
}

.quiz-correction.incorrect {
  display: block;
  background: #fef2f2;
  border-left-color: #dc2626;
  color: #991b1b;
}

.quiz-correction p {
  margin: 0.35rem 0;
}

.result-good {
  color: var(--success);
}

.result-mid {
  color: #9a6700;
}

.result-bad {
  color: var(--danger);
}

/* Reassurance */
.reassurance-card {
  padding: 2rem;
  text-align: center;
}

/* Footer */
.site-footer {
  background: #0f172a;
  color: #e2e8f0;
  padding: 3rem 0;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 2rem;
}

.footer-inner h3 {
  margin-top: 0;
  color: white;
}

.footer-links {
  display: grid;
  gap: 0.5rem;
}

.footer-links a {
  color: #cbd5e1;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: white;
}

/* Utilitaires maths */
.math-vector {
  display: inline-block;
  position: relative;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding-top: 0.15rem;
}

.math-vector::before {
  content: "→";
  position: absolute;
  left: 0;
  right: 0;
  top: -0.72em;
  text-align: center;
  font-size: 0.9em;
  line-height: 1;
  color: var(--primary);
}

/* Responsive */
@media (max-width: 980px) {
  .hero-grid,
  .two-columns,
  .footer-inner,
  .video-grid,
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 3rem;
  }
}

@media (max-width: 780px) {
  .menu-toggle {
    display: inline-flex;
  }

  .main-nav {
    position: absolute;
    top: 78px;
    left: 1rem;
    right: 1rem;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
    padding: 1rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    box-shadow: var(--shadow);
  }

  .main-nav.open {
    display: flex;
  }

  .dropdown-menu {
    position: static;
    display: none;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    margin-top: 0.7rem;
  }

  .nav-dropdown:hover .dropdown-menu,
  .nav-dropdown:focus-within .dropdown-menu {
    display: none;
  }

  .nav-dropdown.open .dropdown-menu {
    display: block;
  }
}

@media (max-width: 560px) {
  .container {
    width: min(var(--max-width), calc(100% - 1.2rem));
  }

  .card,
  .generator-box,
  .quiz-box,
  .video-card,
  .hero-card,
  .quiz-score-card,
  .reassurance-card {
    padding: 1.1rem;
  }

  .hero-actions,
  .card-actions {
    flex-direction: column;
  }

  .btn,
  .btn-small {
    width: 100%;
  }

  .quiz-question label,
  .quiz-option {
    padding: 0.8rem;
  }

  .header-inner {
    min-height: 72px;
  }

  .main-nav {
    top: 72px;
  }

  .hero h1 {
    font-size: clamp(1.9rem, 8vw, 2.6rem);
  }

  .section {
    padding: 3.5rem 0;
  }
}

.hero-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-image img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  object-fit: cover;
}

.path-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.3rem;
  background: var(--surface);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.path-step:hover {
  transform: translateY(-3px);
  border-color: #93c5fd;
  background: #ffffff;
}

.path-step h3 {
  margin: 0 0 0.35rem;
  color: var(--text);
}

.path-step p {
  margin: 0;
  color: var(--muted);
}

.step-number {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 800;
}

.main-nav > a.active {
  color: var(--primary);
}

.main-nav > a.active::after {
  content: "";
  display: block;
  width: 100%;
  height: 3px;
  margin-top: 0.25rem;
  border-radius: 999px;
  background: var(--primary);
}

.reassurance-section {
  padding-top: 2rem;
}

.lesson-box,
.tip-box {
  background: var(--surface);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.lesson-box h3,
.tip-box h3 {
  margin-top: 0;
  margin-bottom: 0.8rem;
}

.lesson-box p,
.tip-box p {
  color: var(--muted);
}

.lesson-box ul,
.tip-box ul {
  margin: 0;
  padding-left: 1.25rem;
}

.lesson-box li,
.tip-box li {
  margin-bottom: 0.45rem;
}

#faqAnswer {
  margin-top: 20px;
  padding: 20px;
  background: #ffffff;
  border-radius: 14px;
  line-height: 1.7;
  font-size: 1rem;
  color: #1f2937;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  white-space: pre-line;
}

.MathJax {
  font-size: 1.1em !important;
}
