/* Manuels de cours en ligne — l'étude. Cahier Seyès, marge rouge, encre bleue ; en sombre, tableau noir et craie. */
:root {
  --papier: #f5f7fc;
  --feuille: #ffffff;
  --encre: #1b1f31;
  --encre-douce: #50566e;
  --bleu: #2245c4;
  --bleu-fond: #e8edfc;
  --marge: #d23a4b;
  --seyes: #c8cfee;
  --seyes-fin: #e4e8f7;
  --surligneur: #fff07a;
  --filet: #dde1ef;
  --ok: #1d7a4f;
  --corrige: #a15c00;
  --infirme: #b3263a;
  --ombre: 0 1px 2px rgb(27 31 49 / 6%), 0 8px 24px rgb(27 31 49 / 6%);
  --f-titre: "Young Serif", Georgia, serif;
  --f-texte: "Lexend", system-ui, sans-serif;
  --f-code: "IBM Plex Mono", ui-monospace, monospace;
  --mesure: 72ch;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #16211c; --feuille: #1c2a24; --encre: #e8ebe3; --encre-douce: #a9b3aa; --bleu: #9fb6ff; --bleu-fond: #26354a;
    --marge: #ff7d89; --seyes: #2b3a33; --seyes-fin: #22302a; --surligneur: #5e5718; --filet: #2e3d36;
    --ok: #6fd3a2; --corrige: #f0b45c; --infirme: #ff8a97; --ombre: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papier: #16211c; --feuille: #1c2a24; --encre: #e8ebe3; --encre-douce: #a9b3aa; --bleu: #9fb6ff; --bleu-fond: #26354a;
  --marge: #ff7d89; --seyes: #2b3a33; --seyes-fin: #22302a; --surligneur: #5e5718; --filet: #2e3d36;
  --ok: #6fd3a2; --corrige: #f0b45c; --infirme: #ff8a97; --ombre: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0; background: var(--papier); color: var(--encre);
  font: 300 1.0625rem/1.7 var(--f-texte); font-feature-settings: "kern";
}
a { color: var(--bleu); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--surligneur); color: var(--encre); }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.evitement { position: absolute; left: -999px; top: 0; background: var(--feuille); padding: .5rem 1rem; z-index: 10; }
.evitement:focus { left: 1rem; }

/* Bandeau : une bande de cahier Seyès */
.bandeau {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem clamp(1rem, 3vw, 2rem); background-color: var(--feuille);
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 7px, var(--seyes-fin) 7px 8px),
    linear-gradient(to right, transparent 0 calc(clamp(1rem, 3vw, 2rem) - 6px), var(--marge) calc(clamp(1rem, 3vw, 2rem) - 6px) calc(clamp(1rem, 3vw, 2rem) - 4px), transparent 0);
  border-bottom: 1px solid var(--filet);
}
.marque { font-family: var(--f-titre); font-size: 1.15rem; color: var(--encre); text-decoration: none; display: flex; align-items: center; gap: .55rem; margin-left: .4rem; }
.marque em { font-style: normal; font-family: var(--f-texte); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--marge); }
.marque-trait { width: 1.4rem; height: 1rem; border-radius: 2px; background:
  repeating-linear-gradient(to bottom, var(--bleu) 0 2px, transparent 2px 5px); opacity: .85; }
.nav { display: flex; gap: .2rem .9rem; flex-wrap: wrap; margin-left: auto; font-size: .95rem; }
.nav a { color: var(--encre-douce); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--encre); }
.nav a[aria-current="page"] { color: var(--encre); border-bottom-color: var(--marge); }
.theme, .menu-bouton { font: inherit; background: none; border: 1px solid var(--filet); color: var(--encre); border-radius: 6px; padding: .25rem .6rem; cursor: pointer; }
.menu-bouton { display: none; margin-left: auto; }

/* Cadre */
.cadre { max-width: 1280px; margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem) 4rem; }
.avec-sommaire .cadre { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 3rem; align-items: start; }
main { min-width: 0; }
.fil { font-size: .85rem; color: var(--encre-douce); margin-bottom: 1.2rem; display: flex; gap: .45rem; flex-wrap: wrap; }
.fil a { color: var(--encre-douce); }
.fil .sep { opacity: .5; }

/* Sommaire */
.sommaire { position: sticky; top: 5rem; max-height: calc(100vh - 6rem); overflow: auto; font-size: .88rem; padding-right: .5rem; }
.sommaire summary { font-family: var(--f-titre); font-size: 1rem; cursor: pointer; margin-bottom: .5rem; }
.sommaire ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--filet); }
.sommaire li a { display: block; padding: .22rem 0 .22rem .8rem; color: var(--encre-douce); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; line-height: 1.35; }
.sommaire li.n3 a { padding-left: 1.6rem; font-size: .84rem; }
.sommaire li a:hover, .sommaire li a.actif { color: var(--encre); border-left-color: var(--marge); }

/* En-tête de document */
.tete-doc { max-width: var(--mesure); margin-bottom: 2rem; }
.surtitre { font-size: .8rem; letter-spacing: .09em; text-transform: uppercase; color: var(--marge); margin: 0 0 .6rem; font-weight: 600; }
h1, h2, h3, h4 { font-family: var(--f-titre); font-weight: 400; line-height: 1.2; letter-spacing: -.005em; }
h1 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.7rem); margin: 0 0 .8rem; text-wrap: balance; }
.chapo { font-size: 1.15rem; color: var(--encre-douce); margin: 0; max-width: 62ch; }
.code { font-family: var(--f-code); font-size: .82em; font-weight: 500; color: var(--bleu); letter-spacing: .02em; }

/* Prose : la marge rouge du cahier */
.prose { max-width: var(--mesure); position: relative; padding-left: clamp(1rem, 2.5vw, 1.8rem); border-left: 2px solid var(--marge); }
.prose.large { max-width: none; }
.prose h2 { font-size: 1.6rem; margin: 3rem 0 1rem; padding-top: .3rem; }
.prose h3 { font-size: 1.25rem; margin: 2.2rem 0 .7rem; }
.prose h4 { font-size: 1.05rem; margin: 1.6rem 0 .5rem; font-family: var(--f-texte); font-weight: 700; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose :is(h2, h3, h4) { position: relative; }
.prose .ancre { position: absolute; left: calc(-1 * clamp(1rem, 2.5vw, 1.8rem) - 1.4rem); width: 1.2rem; text-align: center; color: var(--marge); text-decoration: none; opacity: 0; font-family: var(--f-code); font-size: .8em; }
.prose :is(h2, h3, h4):hover .ancre, .prose .ancre:focus { opacity: 1; }
.prose p, .prose li { overflow-wrap: anywhere; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .3rem 0; }
.prose li::marker { color: var(--marge); }
.prose strong { font-weight: 600; }
.prose blockquote { margin: 1.2rem 0; padding: .2rem 0 .2rem 1rem; border-left: 3px solid var(--bleu); color: var(--encre-douce); }
.prose code { font-family: var(--f-code); font-size: .85em; background: var(--bleu-fond); padding: .05em .3em; border-radius: 3px; overflow-wrap: anywhere; }
.prose pre { overflow-x: auto; background: var(--feuille); padding: 1rem; border: 1px solid var(--filet); border-radius: 6px; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--filet); margin: 2rem 0; }
.tableau { overflow-x: auto; margin: 1.2rem 0; border: 1px solid var(--filet); border-radius: 6px; background: var(--feuille); }
.tableau table { border-collapse: collapse; width: 100%; font-size: .9rem; line-height: 1.45; }
.tableau th, .tableau td { padding: .55rem .7rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--filet); min-width: 8rem; }
.tableau th { font-weight: 700; background: var(--papier); position: sticky; top: 0; }
.tableau tr:last-child td { border-bottom: 0; }

/* Renvois : la signature — chaque référence devient une étiquette d'encre bleue */
a.renvoi { font-family: var(--f-code); font-size: .82em; font-weight: 500; text-decoration: none; color: var(--bleu); background: var(--bleu-fond); padding: .06em .38em; border-radius: 4px; white-space: nowrap; }
a.renvoi:hover { background: var(--bleu); color: var(--feuille); }
a.renvoi-local { background: none; border-bottom: 1px dotted var(--bleu); border-radius: 0; padding: 0; }
a.externe { overflow-wrap: anywhere; }

/* Suite */
.suite { display: flex; justify-content: space-between; gap: 1rem; max-width: var(--mesure); margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--filet); font-size: .95rem; }
.suite a { max-width: 48%; }

/* Listes de documents */
.liste-docs { list-style: none; padding: 0; margin: 0; max-width: 60rem; }
.liste-docs a { display: grid; grid-template-columns: 3.4rem 1fr; gap: .8rem; padding: .7rem .2rem; border-bottom: 1px solid var(--filet); text-decoration: none; color: var(--encre); align-items: baseline; }
.liste-docs a:hover .t { color: var(--bleu); text-decoration: underline; }
.vague { margin-top: 2.5rem; }
.vague h2 { font-size: 1.4rem; border-bottom: 2px solid var(--marge); padding-bottom: .4rem; display: flex; gap: .8rem; align-items: baseline; }
.vague h2 small, .matiere h2 small { font-family: var(--f-texte); font-size: .85rem; color: var(--encre-douce); }
.filtre { display: grid; gap: .3rem; margin-top: 1.5rem; max-width: 30rem; font-size: .9rem; color: var(--encre-douce); }
.filtre input, .cherche-une input { font: inherit; color: var(--encre); padding: .6rem .8rem; border: 1px solid var(--seyes); border-radius: 6px; background: var(--feuille); }
.cache { display: none !important; }

/* Base */
.cartes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.cartes a { display: grid; gap: .3rem; padding: 1.2rem; background: var(--feuille); border: 1px solid var(--filet); border-top: 3px solid var(--bleu); border-radius: 6px; text-decoration: none; color: var(--encre); box-shadow: var(--ombre); height: 100%; }
.cartes .nombre { font-family: var(--f-code); color: var(--bleu); font-size: 1.1rem; }
.cartes .t { font-family: var(--f-titre); font-size: 1.3rem; }
.cartes .d { color: var(--encre-douce); font-size: .92rem; }
.liste-fiches { list-style: none; padding: 0; margin: 1rem 0 0; columns: 2 26rem; column-gap: 2rem; }
.liste-fiches li { break-inside: avoid; }
.liste-fiches a { display: grid; padding: .5rem 0; border-bottom: 1px solid var(--filet); text-decoration: none; color: var(--encre); }
.liste-fiches .t { font-weight: 600; }
.liste-fiches a:hover .t { color: var(--bleu); text-decoration: underline; }
.liste-fiches .meta, .meta { font-size: .82rem; color: var(--encre-douce); }
.fiche { background: var(--feuille); border: 1px solid var(--filet); border-radius: 6px; padding: 1.2rem 1.3rem; margin: 0 0 1.2rem; box-shadow: var(--ombre); }
.fiche-tete { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin: 0 0 .6rem; }
.verif { font-size: .78rem; padding: .1rem .5rem; border-radius: 99px; border: 1px solid currentColor; }
.v-confirme { color: var(--ok); } .v-corrige { color: var(--corrige); } .v-infirme { color: var(--infirme); }
.porteur { font-weight: 700; margin: 0 0 .4rem; }
.attributs { display: grid; gap: .5rem; margin: 1rem 0; }
.attributs div { display: grid; grid-template-columns: 6rem 1fr; gap: .6rem; }
.attributs dt { font-size: .82rem; color: var(--encre-douce); padding-top: .15rem; }
.attributs dd { margin: 0; }
.etiquette { display: inline-block; font-size: .82rem; padding: .05rem .45rem; border-radius: 4px; background: var(--papier); border: 1px solid var(--filet); margin: 0 .2rem .25rem 0; }
.note-verif { font-size: .92rem; color: var(--encre-douce); border-top: 1px dashed var(--seyes); padding-top: .6rem; }
.sources summary { cursor: pointer; font-size: .9rem; color: var(--encre-douce); }
.sources ul { font-size: .85rem; }

/* Matières */
.sauts { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin-top: 1.4rem; font-size: .92rem; }
.matiere { margin-bottom: 2.5rem; }
.niveau { border: 1px solid var(--filet); border-radius: 6px; background: var(--feuille); margin: .5rem 0; }
.niveau summary { cursor: pointer; padding: .7rem 1rem; display: flex; gap: .8rem; align-items: baseline; flex-wrap: wrap; }
.niveau[open] summary { border-bottom: 1px solid var(--filet); }
.niveau > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
.bloc h4 { margin: 1.2rem 0 .3rem; }

/* Accueil */
.accueil .cadre { max-width: 1120px; }
.une { position: relative; padding: clamp(2rem, 6vw, 4.5rem) 0 2.5rem clamp(1.2rem, 4vw, 3rem); border-left: 3px solid var(--marge);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--seyes) 31px 32px), repeating-linear-gradient(to bottom, transparent 0 7px, var(--seyes-fin) 7px 8px); }
.une h1 { font-size: clamp(2.1rem, 1.2rem + 4vw, 4rem); max-width: 18ch; line-height: 1.08; }
.une .chapo { font-size: 1.2rem; background: var(--papier); display: inline; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.cherche-une { display: flex; gap: .5rem; margin-top: 2rem; max-width: 34rem; }
.cherche-une input { flex: 1; min-width: 0; }
.cherche-une button { font: inherit; font-weight: 600; background: var(--bleu); color: var(--feuille); border: 0; border-radius: 6px; padding: .6rem 1.1rem; cursor: pointer; }
.branche { margin: 3.5rem 0; max-width: 60rem; }
.branche h2 { font-size: 1.5rem; }
.branche blockquote { margin: 0; font-size: 1.2rem; line-height: 1.6; padding: 1.4rem 1.6rem; background: var(--feuille); border: 1px solid var(--filet); border-left: 4px solid var(--bleu); border-radius: 0 6px 6px 0; box-shadow: var(--ombre); }
.branche blockquote p { margin: 0; }
.branche blockquote ::selection, .branche mark { background: var(--surligneur); }
.lien-fort { display: inline-block; margin-top: 1rem; font-weight: 700; }
.entrees { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.entree { display: block; padding: 1.3rem; background: var(--feuille); border: 1px solid var(--filet); border-radius: 6px; text-decoration: none; color: var(--encre); box-shadow: var(--ombre); }
.entree h3 { margin: 0 0 .4rem; font-size: 1.35rem; color: var(--bleu); }
.entree p { margin: 0; color: var(--encre-douce); font-size: .95rem; }
.entree:hover { border-color: var(--bleu); }
.dernieres { margin-top: 3rem; }

/* Pied */
.pied { border-top: 1px solid var(--filet); padding: 1.5rem clamp(1rem, 3vw, 2rem); color: var(--encre-douce); font-size: .88rem; max-width: 1280px; margin: 0 auto; }

/* Recherche (Pagefind) */
#recherche { --pagefind-ui-primary: var(--bleu); --pagefind-ui-text: var(--encre); --pagefind-ui-background: var(--feuille); --pagefind-ui-border: var(--seyes); --pagefind-ui-tag: var(--bleu-fond); --pagefind-ui-font: var(--f-texte); max-width: var(--mesure); }

/* Écrans étroits */
@media (max-width: 960px) {
  .avec-sommaire .cadre { display: block; }
  .sommaire { position: static; max-height: none; margin-bottom: 1.5rem; padding: .8rem 1rem; background: var(--feuille); border: 1px solid var(--filet); border-radius: 6px; }
}
@media (max-width: 760px) {
  .bandeau { gap: .5rem; padding-top: .5rem; padding-bottom: .5rem; }
  .marque { font-size: 1rem; margin-left: .2rem; white-space: nowrap; }
  .marque em, .marque-trait { display: none; }
  .menu-bouton { display: inline-block; }
  .theme, .menu-bouton { padding: .2rem .5rem; }
  html { scroll-padding-top: 4rem; }
  .nav { display: none; width: 100%; flex-direction: column; gap: 0; margin: 0; }
  .nav.ouvert { display: flex; }
  .nav a { padding: .55rem 0; border-bottom: 1px solid var(--filet); }
  .prose { padding-left: .9rem; }
  .prose .ancre { display: none; }
  .liste-docs a { grid-template-columns: 3rem 1fr; }
  .attributs div { grid-template-columns: 1fr; gap: .1rem; }
  .suite { flex-direction: column; } .suite a { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print { .bandeau, .sommaire, .pied, .suite { display: none; } .prose { border: 0; padding: 0; } }
