/* =====================================================
   Fonctions affines — feuille de style (design moderne)
   ===================================================== */

:root {
  --indigo: #4f46e5;
  --indigo-clair: #6366f1;
  --violet: #8b5cf6;
  --indigo-pale: #eef2ff;
  --vert: #10b981;
  --vert-pale: #ecfdf5;
  --rouge: #ef4444;
  --rouge-pale: #fef2f2;
  --ambre: #f59e0b;
  --ambre-pale: #fffbeb;

  --encre: #1e1b39;
  --gris: #6b7280;
  --gris-clair: #f1f3f9;
  --bord: #e6e8f0;
  --surface: #ffffff;

  --ombre-s: 0 1px 2px rgba(30, 27, 57, 0.06);
  --ombre-m: 0 8px 24px rgba(30, 27, 57, 0.08);
  --ombre-l: 0 16px 48px rgba(79, 70, 229, 0.16);

  --rayon: 18px;
  --rayon-s: 11px;
  --degrade: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  color: var(--encre);
  background:
    radial-gradient(900px 500px at 88% -8%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(800px 500px at 0% 0%, rgba(99, 102, 241, 0.14), transparent 55%),
    #f5f6fc;
  line-height: 1.6;
  min-height: 100vh;
}

/* ------------------ En-tête ------------------ */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bord);
}

.barre {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.marque {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--encre);
  text-decoration: none;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--degrade);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: var(--ombre-l);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-left: auto;
}

nav a {
  color: var(--gris);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.18s, color 0.18s;
}

nav a:hover { background: var(--indigo-pale); color: var(--indigo); }

nav a.actif {
  background: var(--degrade);
  color: #fff;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

/* ------------------ Contenu ------------------ */
main {
  max-width: 1040px;
  margin: 2.2rem auto 1rem;
  padding: 0 1.5rem;
}

.entete-page {
  margin-bottom: 1.6rem;
}

.fil {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--violet);
  margin-bottom: 0.3rem;
}

h1 {
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.intro {
  color: var(--gris);
  margin-top: 0.4rem;
  max-width: 60ch;
}

/* ------------------ Cartes ------------------ */
.carte {
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 1.6rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--ombre-m);
}

.carte h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.numero {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--indigo-pale);
  color: var(--indigo);
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 800;
  flex: none;
}

.sous-titre {
  color: var(--gris);
  font-size: 0.93rem;
  margin: -0.5rem 0 1rem;
}

/* ------------------ Formulaires ------------------ */
.champs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: flex-end;
}

.champ {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.champ label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gris);
}

.champ input {
  width: 130px;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--bord);
  border-radius: var(--rayon-s);
  font-size: 1.05rem;
  font-family: inherit;
  background: #fcfcff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.champ input:focus,
.champ select:focus {
  outline: none;
  border-color: var(--indigo-clair);
  box-shadow: 0 0 0 4px var(--indigo-pale);
}

.champ select {
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--bord);
  border-radius: var(--rayon-s);
  font-size: 1.05rem;
  font-family: inherit;
  background: #fcfcff;
  cursor: pointer;
}

button {
  font-family: inherit;
  background: var(--degrade);
  color: #fff;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: var(--rayon-s);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.32);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

button:hover { transform: translateY(-2px); filter: brightness(1.05); }
button:active { transform: translateY(0); }

button.secondaire {
  background: #fff;
  color: var(--indigo);
  border: 1.5px solid var(--bord);
  box-shadow: var(--ombre-s);
}

/* ------------------ Formule ------------------ */
.formule {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--indigo);
  background: var(--indigo-pale);
  padding: 0.55rem 1.1rem;
  border-radius: var(--rayon-s);
  display: inline-block;
  font-family: "Cambria Math", Georgia, serif;
}

/* ------------------ Résultats ------------------ */
.resultat {
  margin-top: 1.3rem;
  padding-top: 1.3rem;
  border-top: 1px dashed var(--bord);
  animation: apparition 0.35s ease;
}

.resultat:empty { display: none; }

@keyframes apparition {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ligne-formule {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.etiquette {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.etiquette.affine { background: var(--indigo-pale); color: var(--indigo); }
.etiquette.lineaire { background: var(--vert-pale); color: #047857; }
.etiquette.constante { background: var(--ambre-pale); color: #b45309; }
.etiquette.croissante { background: var(--vert-pale); color: #047857; }
.etiquette.decroissante { background: var(--rouge-pale); color: #b91c1c; }

.etapes {
  list-style: none;
  margin-top: 0.9rem;
}

.etapes li {
  padding: 0.5rem 0 0.5rem 1.8rem;
  position: relative;
  border-bottom: 1px solid var(--gris-clair);
}

.etapes li:before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.95rem;
  width: 9px;
  height: 9px;
  border-right: 2.5px solid var(--indigo-clair);
  border-bottom: 2.5px solid var(--indigo-clair);
  transform: rotate(-45deg);
}

.etapes li:last-child { border-bottom: none; }

.calcul { font-family: "Cambria Math", Georgia, serif; font-size: 1.08rem; }

.valeur {
  font-weight: 800;
  color: var(--vert);
  background: var(--vert-pale);
  padding: 0.05rem 0.45rem;
  border-radius: 6px;
}

.conclusion {
  margin-top: 1rem;
  padding: 0.85rem 1.1rem;
  background: var(--indigo-pale);
  border-radius: var(--rayon-s);
  font-weight: 600;
}

.erreur {
  color: #b91c1c;
  font-weight: 600;
  background: var(--rouge-pale);
  padding: 0.75rem 1rem;
  border-radius: var(--rayon-s);
  border: 1px solid #fecaca;
}

/* ------------------ Tableaux maths ------------------ */
.tableau {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  font-family: "Cambria Math", Georgia, serif;
  text-align: center;
}

.tableau th,
.tableau td {
  border: 1.5px solid var(--bord);
  padding: 0.7rem 0.5rem;
  font-size: 1.05rem;
}

.tableau .tete {
  background: var(--indigo-pale);
  color: var(--indigo);
  font-weight: 800;
  width: 64px;
}

.tableau .borne { color: var(--gris); font-weight: 700; }
.tableau .pos { color: var(--vert); font-weight: 800; }
.tableau .neg { color: var(--rouge); font-weight: 800; }
.tableau .zero { color: var(--gris); font-weight: 800; }
.tableau .fleche { font-size: 1.6rem; font-weight: 700; }
.tableau .fleche.haut { color: var(--vert); }
.tableau .fleche.bas { color: var(--rouge); }
.tableau .fleche.plat { color: var(--ambre); }

/* ------------------ Graphique ------------------ */
canvas {
  background: #fff;
  border: 1px solid var(--bord);
  border-radius: var(--rayon-s);
  max-width: 100%;
  height: auto;
  display: block;
  margin-top: 0.7rem;
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.8rem;
  font-size: 0.88rem;
  color: var(--gris);
}

.legende span { display: flex; align-items: center; gap: 0.4rem; }

.pastille {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex: none;
}

/* ------------------ Accueil ------------------ */
.hero {
  position: relative;
  background: var(--degrade);
  color: #fff;
  border-radius: 26px;
  padding: 2.8rem 2.4rem;
  overflow: hidden;
  box-shadow: var(--ombre-l);
  margin-bottom: 2rem;
}

.hero:before,
.hero:after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
}

.hero:before { width: 260px; height: 260px; top: -120px; right: -60px; }
.hero:after { width: 180px; height: 180px; bottom: -90px; right: 130px; }

.hero .badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.18);
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}

.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); position: relative; }

.hero p {
  margin-top: 0.7rem;
  max-width: 54ch;
  color: rgba(255, 255, 255, 0.92);
  position: relative;
}

.hero .formule-hero {
  margin-top: 1.3rem;
  display: inline-block;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.55rem 1.2rem;
  border-radius: var(--rayon-s);
  font-family: "Cambria Math", Georgia, serif;
  font-size: 1.4rem;
  font-weight: 800;
  position: relative;
}

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.1rem;
}

a.tuile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--encre);
  box-shadow: var(--ombre-s);
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}

a.tuile:hover {
  transform: translateY(-5px);
  box-shadow: var(--ombre-l);
  border-color: var(--indigo-clair);
}

.icone {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--indigo-pale);
  display: grid;
  place-items: center;
  color: var(--indigo);
}

.icone svg { width: 24px; height: 24px; }

a.tuile h3 { font-size: 1.08rem; font-weight: 700; }
a.tuile p { color: var(--gris); font-size: 0.92rem; }

a.tuile .suite {
  margin-top: auto;
  padding-top: 0.4rem;
  color: var(--indigo);
  font-weight: 700;
  font-size: 0.9rem;
}

.tuile.accent {
  background: linear-gradient(135deg, #1e1b39, #4f46e5);
  border: none;
  color: #fff;
}

.tuile.accent p { color: rgba(255, 255, 255, 0.85); }
.tuile.accent .icone { background: rgba(255, 255, 255, 0.16); color: #fff; }
.tuile.accent .suite { color: #c7d2fe; }

.rappel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.6rem;
}

.rappel .item {
  background: var(--gris-clair);
  border-radius: var(--rayon-s);
  padding: 1rem 1.1rem;
}

.rappel .item strong { display: block; margin-bottom: 0.2rem; }
.rappel .item.bleu { border-left: 4px solid var(--indigo); }
.rappel .item.vert { border-left: 4px solid var(--vert); }
.rappel .item.ambre { border-left: 4px solid var(--ambre); }

.aide {
  background: var(--indigo-pale);
  border-radius: var(--rayon-s);
  padding: 0.85rem 1.1rem;
  font-size: 0.9rem;
  color: #4338ca;
  margin-top: 1.1rem;
}

/* ------------------ Quiz / Exercices ------------------ */
.quiz-haut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.compteur { font-weight: 700; color: var(--gris); }

.score-puce {
  background: var(--indigo-pale);
  color: var(--indigo);
  font-weight: 800;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.barre-progression {
  height: 9px;
  background: var(--gris-clair);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.barre-progression .remplissage {
  height: 100%;
  background: var(--degrade);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.question {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.enonce-formule {
  font-family: "Cambria Math", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--indigo);
  margin: 0.5rem 0 1.2rem;
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
}

.option {
  background: #fcfcff;
  border: 1.5px solid var(--bord);
  border-radius: var(--rayon-s);
  padding: 0.9rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--encre);
  cursor: pointer;
  text-align: center;
  box-shadow: none;
  transition: border-color 0.14s, background 0.14s, transform 0.1s;
}

.option:hover { transform: none; border-color: var(--indigo-clair); background: var(--indigo-pale); }
.option:disabled { cursor: default; }
.option.juste { border-color: var(--vert); background: var(--vert-pale); color: #047857; }
.option.faux { border-color: var(--rouge); background: var(--rouge-pale); color: #b91c1c; }

.zone-saisie { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }

.retour {
  margin-top: 1.2rem;
  padding: 0.95rem 1.1rem;
  border-radius: var(--rayon-s);
  font-weight: 600;
  animation: apparition 0.3s ease;
}

.retour.bon { background: var(--vert-pale); color: #047857; border: 1px solid #a7f3d0; }
.retour.mauvais { background: var(--rouge-pale); color: #b91c1c; border: 1px solid #fecaca; }

.actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.2rem; }

.bilan { text-align: center; padding: 1rem 0; }

.bilan .note {
  font-size: 3.4rem;
  font-weight: 800;
  background: var(--degrade);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bilan .message { font-size: 1.15rem; font-weight: 600; margin: 0.3rem 0 1.3rem; }

.choix-themes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.7rem;
  margin: 0.5rem 0 1.2rem;
}

.theme-case {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #fcfcff;
  border: 1.5px solid var(--bord);
  border-radius: var(--rayon-s);
  padding: 0.8rem 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.14s, background 0.14s;
}

.theme-case:has(input:checked) { border-color: var(--indigo-clair); background: var(--indigo-pale); }
.theme-case input { width: 18px; height: 18px; accent-color: var(--indigo); }

/* ------------------ Pied de page ------------------ */
footer {
  text-align: center;
  color: var(--gris);
  font-size: 0.85rem;
  padding: 2.5rem 1rem 2rem;
}

footer a { color: var(--indigo); text-decoration: none; font-weight: 600; }

/* ------------------ Responsive ------------------ */
@media (max-width: 640px) {
  .barre { padding: 0.7rem 1rem; }
  nav { margin-left: 0; width: 100%; }
  .hero { padding: 2rem 1.4rem; }
  .carte { padding: 1.2rem; }
  main { padding: 0 1rem; }
}
