/* ==========================================================================
   Site de mathématiques — feuille de style commune
   ========================================================================== */

:root {
  --bleu: #2563eb;
  --bleu-fonce: #1e40af;
  --bleu-clair: #eff6ff;
  --indigo: #4f46e5;
  --vert: #059669;
  --vert-clair: #ecfdf5;
  --ambre: #d97706;
  --ambre-clair: #fffbeb;
  --violet: #7c3aed;
  --violet-clair: #f5f3ff;

  --texte: #0f172a;
  --texte-doux: #475569;
  --texte-clair: #94a3b8;
  --fond: #f8fafc;
  --surface: #ffffff;
  --bordure: #e2e8f0;

  --ombre: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --ombre-md: 0 4px 12px rgba(15, 23, 42, .07), 0 2px 4px rgba(15, 23, 42, .04);
  --ombre-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 4px 8px rgba(15, 23, 42, .04);

  --radius: 14px;
  --radius-sm: 8px;
  --largeur: 1120px;
  --transition: 200ms cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------- Base ---------- */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 650; }
p  { margin: 0 0 1em; }

a { color: var(--bleu); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--bleu-fonce); }

.conteneur {
  width: 100%;
  max-width: var(--largeur);
  margin-inline: auto;
  padding-inline: 24px;
}

/* ---------------------------------------------------- Navigation --------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bordure);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 68px;
}

.nav__logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 1.1rem;
  color: var(--texte);
  letter-spacing: -.02em;
}

.nav__logo:hover { color: var(--texte); }

.nav__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bleu), var(--indigo));
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.nav__liens {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__liens a {
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 550;
  color: var(--texte-doux);
  transition: background var(--transition), color var(--transition);
}

.nav__liens a:hover,
.nav__liens a[aria-current="page"] {
  background: var(--bleu-clair);
  color: var(--bleu-fonce);
}

/* --------------------------------------------------------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 80px 0 64px;
  background:
    radial-gradient(60rem 30rem at 15% -10%, #dbeafe 0%, transparent 60%),
    radial-gradient(50rem 28rem at 90% 0%, #ede9fe 0%, transparent 60%);
}

.hero__badge {
  display: inline-block;
  padding: 6px 14px;
  margin-bottom: 20px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  box-shadow: var(--ombre);
  font-size: .82rem;
  font-weight: 600;
  color: var(--bleu-fonce);
  letter-spacing: .01em;
}

.hero h1 { max-width: 18ch; }

.hero__accent {
  background: linear-gradient(135deg, var(--bleu), var(--indigo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__intro {
  max-width: 58ch;
  font-size: 1.15rem;
  color: var(--texte-doux);
}

/* ------------------------------------------------------ Sections --------- */

.section { padding: 64px 0; }
.section--fin { padding-bottom: 88px; }

.section__titre { margin-bottom: 8px; }

.section__soustitre {
  max-width: 60ch;
  margin-bottom: 36px;
  color: var(--texte-doux);
}

/* --------------------------------------------------- Cartes niveau ------- */

.niveaux {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 24px;
}

.niveau {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 30px 28px 26px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  color: inherit;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition);
}

.niveau::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--accent, var(--bleu));
}

.niveau:hover {
  transform: translateY(-4px);
  box-shadow: var(--ombre-lg);
  border-color: color-mix(in srgb, var(--accent, var(--bleu)) 35%, var(--bordure));
  color: inherit;
}

.niveau__icone {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: var(--accent-clair, var(--bleu-clair));
  color: var(--accent, var(--bleu));
  font-size: 1.35rem;
  font-weight: 700;
}

.niveau h3 { margin-bottom: 6px; }

.niveau__meta {
  margin-bottom: 12px;
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent, var(--bleu));
}

.niveau p {
  flex: 1;
  font-size: .96rem;
  color: var(--texte-doux);
}

.niveau__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 18px;
  padding: 0;
  list-style: none;
}

.niveau__tags li {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--fond);
  border: 1px solid var(--bordure);
  font-size: .78rem;
  color: var(--texte-doux);
}

.niveau__cta {
  font-weight: 600;
  font-size: .95rem;
  color: var(--accent, var(--bleu));
}

.niveau__cta::after {
  content: " →";
  display: inline-block;
  transition: transform var(--transition);
}

.niveau:hover .niveau__cta::after { transform: translateX(4px); }

/* Variantes de couleur */
.niveau--seconde   { --accent: var(--bleu);   --accent-clair: var(--bleu-clair); }
.niveau--premiere  { --accent: var(--vert);   --accent-clair: var(--vert-clair); }
.niveau--terminale { --accent: var(--violet); --accent-clair: var(--violet-clair); }

/* ------------------------------------------------------ À propos --------- */

.apropos {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 48px;
  align-items: start;
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
}

.apropos p:last-child { margin-bottom: 0; }

.apropos__points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 14px;
}

.apropos__points li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: .95rem;
  color: var(--texte-doux);
}

.apropos__points li::before {
  content: "✓";
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--vert-clair);
  color: var(--vert);
  font-size: .75rem;
  font-weight: 700;
}

.formule {
  margin-top: 22px;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  background: var(--bleu-clair);
  border: 1px solid #dbeafe;
  text-align: center;
  overflow-x: auto;
}

/* ---------------------------------------------- Pages de chapitres ------- */

.page-entete {
  padding: 56px 0 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}

.fil {
  margin-bottom: 14px;
  font-size: .88rem;
  color: var(--texte-clair);
}

.fil a { color: var(--texte-doux); font-weight: 550; }

.page-entete p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--texte-doux);
}

.chapitres {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: chapitre;
}

.chapitre {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--radius-sm);
  box-shadow: var(--ombre);
  transition: transform var(--transition), box-shadow var(--transition);
}

.chapitre:hover { transform: translateY(-2px); box-shadow: var(--ombre-md); }

.chapitre::before {
  counter-increment: chapitre;
  content: counter(chapitre, decimal-leading-zero);
  flex: none;
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent, var(--bleu));
  padding-top: 2px;
}

.chapitre h3 { margin-bottom: 4px; font-size: 1.02rem; }

.chapitre p {
  margin: 0;
  font-size: .9rem;
  color: var(--texte-doux);
}

.avis {
  margin-top: 40px;
  padding: 18px 22px;
  border-left: 3px solid var(--ambre);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--ambre-clair);
  font-size: .95rem;
  color: #92400e;
}

.avis p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------- Footer ---------- */

.footer {
  padding: 48px 0 32px;
  background: var(--surface);
  border-top: 1px solid var(--bordure);
}

.footer__grille {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 32px;
}

.footer__grille h4 {
  margin: 0 0 12px;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--texte-clair);
}

.footer__grille p {
  max-width: 40ch;
  font-size: .92rem;
  color: var(--texte-doux);
}

.footer__grille ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: .92rem;
}

.footer__grille ul a { color: var(--texte-doux); }
.footer__grille ul a:hover { color: var(--bleu); }

.footer__bas {
  padding-top: 24px;
  border-top: 1px solid var(--bordure);
  font-size: .86rem;
  color: var(--texte-clair);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

/* ------------------------------------------------------ Responsive ------- */

@media (max-width: 860px) {
  .apropos { grid-template-columns: 1fr; gap: 32px; padding: 30px 26px; }
  .footer__grille { grid-template-columns: 1fr 1fr; gap: 28px; }
  .footer__grille > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .nav__inner { height: auto; padding: 12px 0; flex-direction: column; gap: 10px; }
  .nav__liens { flex-wrap: wrap; justify-content: center; }
  .hero { padding: 52px 0 44px; }
  .section { padding: 48px 0; }
  .conteneur { padding-inline: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
