/* mathandco
   Mise en page : grandes sections centrées façon Apple, colonne de 980 px ; la page de cahier (quadrillage +
   marge rouge) est le seul objet décoratif, reprise des corrections animées. */
:root {
  --fond: #fbfbfd;          /* page */
  --fond-2: #f0f2f6;        /* sections alternées, tuiles */
  --encre: #1d1d1f;         /* texte */
  --gris: #6b6e76;          /* texte secondaire */
  --filet: #d8dbe3;         /* séparateurs */
  --bleu: #0a5fd1;          /* liens, boutons */
  --bleu-fond: #e3eefc;
  --rouge: #d4322c;         /* marge du cahier, conclusion encadrée */
  --pastille: #cfe8fb;      /* surlignage bleu ciel des corrections */
  --vert: #1f8f4e;          /* termes regroupés */
  --violet: #7a3fc4;
  --carreau: #dbe9f5;       /* quadrillage */
  --papier: #ffffff;
  --verre: rgba(251, 251, 253, .78);
  --ombre: 0 18px 50px rgba(30, 40, 70, .10), 0 2px 6px rgba(30, 40, 70, .06);

  --f-texte: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-maths: "STIX Two Text", "Cambria Math", "Times New Roman", serif;

  --t-geant: clamp(3.4rem, 10vw, 7.5rem);
  --t-titre: clamp(2.2rem, 5.4vw, 3.6rem);
  --t-sous: clamp(1.25rem, 2.4vw, 1.6rem);
  --t-corps: 1.0625rem;
  --t-petit: .875rem;
  --largeur: 980px;
  --courbe: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #000000; --fond-2: #141518; --encre: #f5f5f7; --gris: #a1a4ad; --filet: #2c2e34;
    --bleu: #4a9bff; --bleu-fond: #10233d; --rouge: #ff5c55; --pastille: #17405f; --vert: #4cc985; --violet: #b38cf0;
    --carreau: #1f2a36; --papier: #0e1116; --verre: rgba(0, 0, 0, .72);
    --ombre: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #000000; --fond-2: #141518; --encre: #f5f5f7; --gris: #a1a4ad; --filet: #2c2e34;
  --bleu: #4a9bff; --bleu-fond: #10233d; --rouge: #ff5c55; --pastille: #17405f; --vert: #4cc985; --violet: #b38cf0;
  --carreau: #1f2a36; --papier: #0e1116; --verre: rgba(0, 0, 0, .72);
  --ombre: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font-family: var(--f-texte); font-size: var(--t-corps); line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--verre); }
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
.maths { font-family: var(--f-maths); font-style: italic; }
.mx { font-family: var(--f-maths); }

.gouttiere { padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.colonne { max-width: var(--largeur); margin: 0 auto; }

/* ---------- barre de navigation (verre dépoli) ---------- */
.nav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--verre); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid transparent; transition: border-color .3s;
}
.nav.defile { border-bottom-color: var(--filet); }
.nav-int { display: flex; align-items: center; gap: 28px; height: 52px; }
.logo { display: inline-flex; align-items: baseline; gap: 1px; font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; color: var(--encre); }
.logo:hover { text-decoration: none; }
.logo .esperluette { font-family: var(--f-maths); font-style: italic; font-weight: 500; color: var(--rouge); font-size: 1.05em; padding: 0 1px; }
.nav-liens { display: flex; gap: 24px; margin-left: auto; font-size: var(--t-petit); }
.nav-liens a { color: var(--encre); opacity: .82; }
.nav-liens a:hover { opacity: 1; text-decoration: none; }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 22px; border-radius: 980px; border: 0; cursor: pointer;
  font: 600 1rem/1 var(--f-texte); background: var(--bleu); color: #fff;
  transition: transform .25s var(--courbe), filter .2s;
}
.bouton:hover { text-decoration: none; filter: brightness(1.08); }
.bouton:active { transform: scale(.97); }
.bouton.petit { min-height: 32px; padding: 0 14px; font-size: var(--t-petit); }
.bouton.discret { background: var(--bleu-fond); color: var(--bleu); }
.lien-fleche { font-size: var(--t-sous); font-weight: 500; }

/* ---------- accueil : en-tête ---------- */
.hero { text-align: center; padding-block: clamp(56px, 10vw, 110px) 0; }
.hero h1 { font-size: var(--t-geant); font-weight: 700; letter-spacing: -.045em; line-height: .95; }
.hero h1 .esperluette { font-family: var(--f-maths); font-style: italic; font-weight: 500; color: var(--rouge); letter-spacing: 0; padding: 0 .02em; }
.hero .accroche { font-size: var(--t-sous); color: var(--gris); margin-top: 18px; letter-spacing: -.01em; }
.hero .actions { display: flex; gap: 14px 28px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 30px; }

/* page de cahier animée */
.cahier-scene { padding-block: clamp(40px, 7vw, 72px) clamp(64px, 10vw, 120px); }
.cahier {
  position: relative; max-width: 900px; margin: 0 auto; border-radius: 22px; overflow: hidden;
  background-color: var(--papier);
  background-image: linear-gradient(var(--carreau) 1px, transparent 1px), linear-gradient(90deg, var(--carreau) 1px, transparent 1px);
  background-size: 22px 22px; background-position: -1px -1px;
  box-shadow: var(--ombre);
  transform-origin: 50% 0; will-change: transform;
}
.cahier::before { content: ""; position: absolute; top: 0; bottom: 0; left: 64px; width: 2px; background: var(--rouge); opacity: .7; }
.cahier-tete { display: flex; align-items: baseline; gap: 14px; padding: 22px 26px 0 88px; flex-wrap: wrap; }
.cahier-tete .q { font-weight: 700; color: var(--rouge); font-size: 1.25rem; position: absolute; left: 24px; top: 20px; }
.cahier-tete .consigne { font-size: 1rem; color: var(--gris); }
.calcul { position: relative; padding: 26px 26px 34px 88px; overflow-x: auto; }
.calcul-zone { position: relative; display: inline-block; min-width: 100%; }
.ligne { display: flex; align-items: center; white-space: nowrap; font-family: var(--f-maths); font-size: clamp(1.35rem, 3.3vw, 2.15rem); height: 2.5em; }
.ligne .g { min-width: 0; }
.ligne .egal { width: 1.6em; text-align: center; }
.t { display: inline-block; padding: 0 .06em; border-radius: .5em; transition: opacity .45s var(--courbe), transform .45s var(--courbe), background-color .4s; }
.t.cache { opacity: 0; transform: translateY(.25em); }
.t.sur-vert { background: color-mix(in srgb, var(--vert) 22%, transparent); }
.t.sur-ciel { background: var(--pastille); }
.t i { font-style: italic; }
.barre { position: relative; }
.barre::after { content: ""; position: absolute; left: -2%; right: -2%; top: 52%; height: 2px; background: var(--rouge); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--courbe); }
.barre.on::after { transform: scaleX(1); }
.cadre { outline: 2px solid transparent; outline-offset: 6px; border-radius: 4px; transition: outline-color .4s; }
.cadre.on { outline-color: var(--rouge); }
svg.fleches { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
svg.fleches path { fill: none; stroke-width: 2; stroke-linecap: round; }
.cahier-pied { display: flex; align-items: center; gap: 16px; padding: 0 26px 18px 88px; font-size: var(--t-petit); color: var(--gris); flex-wrap: wrap; }
.etape { font-variant-numeric: tabular-nums; }
.progression { flex: 1 1 140px; height: 3px; border-radius: 3px; background: var(--filet); overflow: hidden; min-width: 100px; }
.progression span { display: block; height: 100%; width: 0; background: var(--bleu); transition: width .5s var(--courbe); }
.cahier-pied button { font: inherit; color: var(--bleu); background: none; border: 0; padding: 6px 2px; cursor: pointer; }
.signature { margin-left: auto; font-size: .72rem; }

/* ---------- sections ---------- */
.section { padding-block: clamp(72px, 11vw, 130px); }
.section.alt { background: var(--fond-2); }
.section-tete { text-align: center; max-width: 720px; margin: 0 auto clamp(40px, 6vw, 64px); }
.section-tete h2 { font-size: var(--t-titre); font-weight: 700; letter-spacing: -.035em; line-height: 1.05; }
.section-tete p { font-size: var(--t-sous); color: var(--gris); margin-top: 14px; line-height: 1.35; }

.tuiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tuile { background: var(--fond); border-radius: 26px; padding: 34px 32px 0; display: flex; flex-direction: column; gap: 10px; overflow: hidden; min-width: 0; }
.section.alt .tuile { background: var(--papier); }
.tuile h3 { font-size: 1.6rem; letter-spacing: -.025em; line-height: 1.15; }
.tuile p { color: var(--gris); max-width: 40ch; }
.tuile .vue { margin-top: auto; padding-top: 26px; min-height: 170px; display: flex; align-items: flex-end; justify-content: center; }

/* petites illustrations des tuiles */
.mini-cahier { width: 100%; max-width: 340px; height: 150px; border-radius: 14px 14px 0 0; position: relative;
  background-color: var(--fond-2); background-image: linear-gradient(var(--carreau) 1px, transparent 1px), linear-gradient(90deg, var(--carreau) 1px, transparent 1px);
  background-size: 16px 16px; padding: 18px 18px 0 46px; font-family: var(--f-maths); font-size: 1.15rem; }
.section.alt .mini-cahier { background-color: var(--papier); }
.mini-cahier::before { content: ""; position: absolute; left: 32px; top: 0; bottom: 0; width: 2px; background: var(--rouge); opacity: .6; }
.mini-cahier .l { height: 1.9em; display: flex; align-items: center; gap: .3em; }
.clic { display: inline-flex; align-items: center; justify-content: center; font-family: var(--f-texte); font-size: .7rem; font-weight: 700; width: 22px; height: 22px; border-radius: 50%; background: var(--bleu); color: #fff; font-style: normal; }
.attente { color: var(--gris); letter-spacing: .1em; }
.enonce-mini { width: 100%; max-width: 340px; border-radius: 14px 14px 0 0; background: var(--papier); padding: 18px 20px; font-size: .92rem; line-height: 1.6; box-shadow: 0 -1px 0 var(--filet) inset; border: 1px solid var(--filet); border-bottom: 0; }
.section.alt .enonce-mini { background: var(--fond-2); }
.enonce-mini b { font-weight: 700; }
.souligne { text-decoration: underline; text-decoration-color: var(--bleu); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.encadre-r { outline: 2px solid var(--rouge); outline-offset: 2px; border-radius: 2px; }
.rappel { width: 100%; max-width: 340px; border-radius: 14px 14px 0 0; padding: 16px 20px; background: var(--bleu-fond); font-size: .92rem; }
.rappel .rt { font-weight: 700; color: var(--bleu); margin-bottom: 6px; }
.rappel .mx { font-size: 1.15rem; }
.lecteur { width: 100%; max-width: 340px; border-radius: 14px 14px 0 0; background: var(--papier); border: 1px solid var(--filet); border-bottom: 0; padding: 16px 18px; display: grid; gap: 12px; font-size: .85rem; }
.section.alt .lecteur { background: var(--fond-2); }
.lecteur .rang { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lecteur .k { border: 1px solid var(--filet); border-radius: 8px; padding: 4px 10px; background: var(--fond); }
.lecteur .k.on { background: var(--encre); color: var(--fond); border-color: var(--encre); }
.lecteur .barre-p { height: 3px; border-radius: 3px; background: var(--filet); overflow: hidden; }
.lecteur .barre-p span { display: block; width: 46%; height: 100%; background: var(--bleu); }

/* classes */
.classes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 20px; }
.classe { display: flex; flex-direction: column; gap: 8px; padding: 34px 32px 30px; border-radius: 26px; background: var(--fond-2); color: var(--encre); min-width: 0;
  transition: transform .45s var(--courbe), box-shadow .45s var(--courbe); }
.classe:hover { text-decoration: none; transform: translateY(-4px); box-shadow: var(--ombre); }
.classe h3 { font-size: 1.9rem; letter-spacing: -.03em; }
.classe-total { color: var(--gris); }
.classe ul { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; gap: 10px; }
.classe li { display: flex; gap: 12px; align-items: baseline; font-size: 1.05rem; }
.ch-num { flex: none; font-size: var(--t-petit); color: var(--gris); font-variant-numeric: tabular-nums; min-width: 6.2em; }
.classe-lien { margin-top: auto; color: var(--bleu); font-weight: 500; }

/* appel final */
.appel { text-align: center; }
.appel h2 { font-size: var(--t-titre); letter-spacing: -.035em; line-height: 1.05; }
.appel p { font-size: var(--t-sous); color: var(--gris); margin: 16px auto 30px; max-width: 32ch; line-height: 1.35; }

.pied { border-top: 1px solid var(--filet); padding-block: 26px calc(26px + env(safe-area-inset-bottom, 0px)); font-size: .8rem; color: var(--gris); }
.pied .colonne { display: flex; gap: 12px 24px; flex-wrap: wrap; justify-content: space-between; }

/* apparition douce au défilement : départ visible, léger glissement seulement */
.revele { transition: transform .9s var(--courbe), opacity .9s var(--courbe); }
.js .revele.attend { transform: translateY(28px); opacity: .55; }

/* ---------- espace élèves ---------- */
.porte { min-height: calc(100vh - 52px - env(safe-area-inset-top, 0px)); display: grid; place-items: center; padding-block: 48px; }
.porte form { width: min(420px, 100%); text-align: center; display: grid; gap: 14px; }
.porte h1 { font-size: clamp(2.4rem, 6vw, 3.4rem); letter-spacing: -.04em; line-height: 1; }
.porte .aide { color: var(--gris); font-size: 1.1rem; margin-bottom: 10px; }
.champ { position: relative; }
.champ input { width: 100%; height: 56px; border-radius: 14px; border: 1.5px solid var(--filet); background: var(--fond); color: var(--encre);
  font: 500 1.15rem var(--f-texte); padding: 0 18px; transition: border-color .2s, box-shadow .2s; }
.champ input:focus { outline: none; border-color: var(--bleu); box-shadow: 0 0 0 4px var(--bleu-fond); }
.porte .bouton { width: 100%; min-height: 52px; font-size: 1.05rem; }
.porte .bouton:disabled { opacity: .6; cursor: progress; }
.souvenir { display: flex; gap: 10px; justify-content: center; align-items: center; color: var(--gris); font-size: .95rem; cursor: pointer; }
.souvenir input { width: 18px; height: 18px; accent-color: var(--bleu); }
.message { min-height: 1.5em; font-size: .95rem; color: var(--gris); }
.message.erreur { color: var(--rouge); }
.secoue { animation: secoue .45s var(--courbe); }
@keyframes secoue { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.biblio-tete { padding-block: clamp(36px, 6vw, 64px) 8px; display: flex; flex-wrap: wrap; gap: 18px 24px; align-items: flex-end; justify-content: space-between; }
.biblio-tete h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); letter-spacing: -.04em; line-height: 1; }
.biblio-tete p { color: var(--gris); margin-top: 10px; }
.outils { position: sticky; top: calc(52px + env(safe-area-inset-top, 0px)); z-index: 40; background: var(--verre);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); padding-block: 12px; border-bottom: 1px solid var(--filet); }
.outils .colonne { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.segments { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--fond-2); gap: 2px; max-width: 100%; overflow-x: auto; }
.segments button { border: 0; background: none; color: var(--encre); font: 500 .92rem var(--f-texte); padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; transition: background-color .25s, box-shadow .25s; }
.segments button[aria-pressed="true"] { background: var(--fond); box-shadow: 0 1px 4px rgba(20, 30, 60, .14); font-weight: 600; }
.recherche { flex: 1 1 220px; min-width: 0; height: 40px; border-radius: 12px; border: 1px solid var(--filet); background: var(--fond); color: var(--encre); padding: 0 14px; font: 1rem var(--f-texte); }
.recherche:focus { outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px var(--bleu-fond); }

.classe-bloc { padding-block: 44px 8px; }
.classe-bloc > h2 { font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -.035em; }
.chapitre { margin-top: 30px; }
.chapitre-tete { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--filet); margin-bottom: 18px; }
.chapitre-tete .n { color: var(--gris); font-size: var(--t-petit); font-variant-numeric: tabular-nums; }
.chapitre-tete h3 { font-size: 1.35rem; letter-spacing: -.02em; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 14px; }
.fiche { position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 132px; padding: 18px 18px 16px; border-radius: 18px; background: var(--fond-2); color: var(--encre); min-width: 0;
  transition: transform .4s var(--courbe), box-shadow .4s var(--courbe), background-color .3s; }
.fiche:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--ombre); background: var(--papier); }
.fiche .num { font-size: 2.3rem; font-weight: 700; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.fiche .num small { font-size: .95rem; font-weight: 500; color: var(--gris); letter-spacing: 0; margin-right: 6px; }
.fiche .titre { font-weight: 600; line-height: 1.3; }
.fiche .detail { color: var(--gris); font-size: .86rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fiche.speciale { background: var(--bleu-fond); }
.fiche.speciale .num { font-size: 1.35rem; letter-spacing: -.02em; color: var(--bleu); }
.vide { padding: 60px 0; text-align: center; color: var(--gris); }
.deconnexion { font: inherit; font-size: var(--t-petit); color: var(--bleu); background: none; border: 0; cursor: pointer; padding: 6px 0; }

@media (max-width: 720px) {
  .tuiles { grid-template-columns: 1fr; }
  .nav-liens .masque-tel { display: none; }
  .nav-int { gap: 16px; }
  .cahier::before { left: 40px; }
  .cahier-tete { padding-left: 56px; }
  .cahier-tete .q { left: 12px; }
  .calcul { padding-left: 56px; padding-right: 16px; }
  .cahier-pied { padding-left: 56px; padding-right: 16px; }
  .tuile { padding: 28px 24px 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .js .revele.attend { transform: none; opacity: 1; }
}
