/* Petit vadémécum de grammaire française — feuille de style
   Papier crème, encre chaude, filets discrets : l'esprit du livre imprimé. */

:root {
  color-scheme: light;
  --papier: #fbf8f2;
  --papier-creux: #f3ede2;
  --carte: #fffdf9;
  --encre: #241f1a;
  --encre-douce: #6a6055;
  --filet: #e0d6c6;
  --filet-fort: #cdbfa9;
  --accent: #8c2f2f;
  --accent-clair: #b8524a;
  --accent-fond: #f6ebe6;
  --exemple: #35624a;
  --exemple-fond: #edf3ee;
  --remarque: #6a5320;
  --remarque-fond: #f7f0e0;
  --exception: #8c2f2f;
  --exception-fond: #f8ecea;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
           Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --largeur: 40rem;
  --bandeau-h: 3.75rem;
}

html[data-theme="sombre"] {
  color-scheme: dark;
  --papier: #17161a;
  --papier-creux: #1d1c21;
  --carte: #212026;
  --encre: #e7e2d9;
  --encre-douce: #a29a8d;
  --filet: #33313a;
  --filet-fort: #4a4753;
  --accent: #e0857a;
  --accent-clair: #eda096;
  --accent-fond: #2c2124;
  --exemple: #8fc9a8;
  --exemple-fond: #1b2620;
  --remarque: #d9be7c;
  --remarque-fond: #262117;
  --exception: #e89b91;
  --exception-fond: #2b1e1e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bandeau-h) + 1rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font: 1.0625rem/1.7 var(--serif);
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------- accessibilité */

.visuellement-cachee {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.saut {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem;
}
.saut:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ bandeau */

.bandeau {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  height: var(--bandeau-h); padding: 0 1rem;
  background: color-mix(in srgb, var(--papier) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--filet);
}

.marque { display: flex; flex-direction: column; text-decoration: none;
          color: inherit; line-height: 1.15; margin-right: auto; }
.marque-titre { font-size: 1.0625rem; letter-spacing: .01em; }
.marque-sous { font-size: .75rem; color: var(--encre-douce); font-style: italic; }
.marque-court { display: none; }

.basculer-nav {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 2.25rem; height: 2.25rem; padding: 0 .4rem;
  background: none; border: 1px solid var(--filet); border-radius: 6px;
  cursor: pointer;
}
.basculer-nav span { display: block; height: 1.5px; background: var(--encre); }

.theme {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem;
  background: none; color: var(--encre-douce);
  border: 1px solid var(--filet); border-radius: 6px; cursor: pointer;
}
.theme:hover { color: var(--accent); border-color: var(--filet-fort); }
.theme .lune { display: none; }
html[data-theme="sombre"] .theme .soleil { display: none; }
html[data-theme="sombre"] .theme .lune { display: block; }

/* ---------------------------------------------------------------- recherche */

.recherche { position: relative; flex: 0 1 22rem; }

.recherche input {
  width: 100%; padding: .45rem .75rem;
  font: inherit; font-size: .9375rem; font-family: var(--sans);
  color: var(--encre); background: var(--carte);
  border: 1px solid var(--filet); border-radius: 999px;
}
.recherche input::placeholder { color: var(--encre-douce); }
.recherche input:focus { border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px var(--accent-fond); }

.resultats {
  position: absolute; top: calc(100% + .5rem); right: 0;
  width: min(30rem, 92vw); max-height: 65vh; overflow-y: auto;
  background: var(--carte); border: 1px solid var(--filet); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.16); padding: .35rem;
}
.resultats a {
  display: block; padding: .5rem .65rem; border-radius: 7px;
  text-decoration: none; color: inherit;
}
.resultats a:hover, .resultats a.vise { background: var(--papier-creux); }
.resultats .titre { display: block; font-weight: 600; }
.resultats .titre .n {
  font: .6875rem/1 var(--sans); color: var(--accent);
  background: var(--accent-fond); padding: .2rem .4rem; border-radius: 4px;
  margin-right: .4rem; vertical-align: .1em;
}
.resultats .extrait {
  display: block; font-size: .8125rem; color: var(--encre-douce);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.resultats mark { background: var(--accent-fond); color: var(--accent); }
.resultats .vide { padding: .75rem .65rem; color: var(--encre-douce);
  font-size: .9rem; }

/* ------------------------------------------------------------------ colonnes */

.page {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 15rem;
  gap: 2.5rem; max-width: 82rem; margin: 0 auto; padding: 2rem 1.5rem 4rem;
  align-items: start;
}

.nav-site, .aside {
  position: sticky; top: calc(var(--bandeau-h) + 1.5rem);
  max-height: calc(100vh - var(--bandeau-h) - 3rem); overflow-y: auto;
  font-family: var(--sans); font-size: .875rem; line-height: 1.45;
}

.nav-site h2, .sommaire h2 {
  margin: 0 0 .75rem; font: 600 .6875rem/1 var(--sans);
  letter-spacing: .1em; text-transform: uppercase; color: var(--encre-douce);
}

.nav-site ul, .sommaire ul { list-style: none; margin: 0; padding: 0; }

.nav-site li a {
  display: block; padding: .4rem .7rem; margin-bottom: .1rem;
  border-radius: 7px; text-decoration: none; color: var(--encre);
  border-left: 2px solid transparent;
}
.nav-site li a:hover { background: var(--papier-creux); }
.nav-site li a[aria-current] {
  background: var(--accent-fond); color: var(--accent);
  border-left-color: var(--accent); font-weight: 600;
}
.nav-site .sur {
  display: block; font-size: .625rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--encre-douce);
}
.nav-site li a[aria-current] .sur { color: var(--accent-clair); }

.signature {
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--filet);
  font-family: var(--serif); font-style: italic; font-size: .8125rem;
  color: var(--encre-douce);
}

.sommaire li a {
  display: block; padding: .22rem 0 .22rem .75rem;
  border-left: 2px solid var(--filet); text-decoration: none;
  color: var(--encre-douce);
}
.sommaire li a:hover { color: var(--accent); border-left-color: var(--filet-fort); }
.sommaire li a.actif { color: var(--accent); border-left-color: var(--accent); }
.sommaire li.n2 > a { font-weight: 600; color: var(--encre); margin-top: .5rem; }
.sommaire li.n3 > a { padding-left: 1.4rem; }
.sommaire li.n4 > a { padding-left: 2rem; }
.sommaire .n {
  font: .6875rem/1 var(--sans); color: var(--accent);
  margin-right: .25rem;
}

/* ------------------------------------------------------------------ contenu */

main { max-width: var(--largeur); }

.entete-page { margin-bottom: 2.5rem; }
.entete-page .sur {
  display: block; font: 600 .6875rem/1 var(--sans); letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .6rem;
}
h1 {
  margin: 0; font-size: clamp(1.75rem, 4vw, 2.4rem); font-weight: 500;
  line-height: 1.15; letter-spacing: -.01em;
}

h2 {
  margin: 3rem 0 1rem; font-size: 1.4rem; font-weight: 500;
  padding-bottom: .4rem; border-bottom: 1px solid var(--filet);
}
h3 { margin: 2rem 0 .6rem; font-size: 1.1rem; font-weight: 600; }
h4 { margin: 1.5rem 0 .4rem; font-size: 1rem; font-weight: 600;
     color: var(--encre-douce); }

h2:first-child, h3:first-child { margin-top: 0; }

.lien-ancre {
  margin-left: .4rem; text-decoration: none; color: var(--filet-fort);
  font-family: var(--sans); font-weight: 400; opacity: 0;
  transition: opacity .15s;
}
h2:hover .lien-ancre, h3:hover .lien-ancre, .lien-ancre:focus { opacity: 1; }

p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: .15em;
    text-decoration-thickness: .06em; }
strong { font-weight: 600; }

code {
  font: .875em/1 var(--mono); background: var(--papier-creux);
  padding: .15em .35em; border-radius: 4px;
}

.pc { font-variant: small-caps; font-style: normal; letter-spacing: .03em; }

.api {
  font-family: var(--sans); font-size: .9em; color: var(--encre-douce);
  white-space: nowrap;
}

.chapeau {
  font-size: 1.125rem; line-height: 1.6; color: var(--encre-douce);
  font-style: italic;
}

ol, ul { margin: 0 0 1rem; padding-left: 1.4rem; }
li { margin-bottom: .45rem; }
li::marker { color: var(--encre-douce); }

/* -------------------------------------------------------------------- règles */

.regle {
  position: relative;
  margin: 1.25rem 0; padding: 1.25rem 1.5rem;
  background: var(--carte);
  border: 1px solid var(--filet); border-left: 3px solid var(--filet-fort);
  border-radius: 4px;
}
.regle:target { border-left-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-fond); }
.regle h3 { margin: 0 0 .75rem; font-size: 1.0625rem; }
.regle .numero {
  display: block; font: 600 .625rem/1 var(--sans); letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .35rem;
}
.regle > *:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------- encadrés */

.encadre {
  display: block; margin: .75rem 0; padding: .55rem .85rem;
  border-left: 2px solid currentColor; border-radius: 0 4px 4px 0;
  font-size: .96875rem;
}
.encadre .etiq {
  font: 600 .6875rem/1 var(--sans); letter-spacing: .06em;
  text-transform: uppercase; margin-right: .3rem;
}
.encadre.exemple { color: var(--exemple); background: var(--exemple-fond); }
.encadre.remarque { color: var(--remarque); background: var(--remarque-fond); }
.encadre.exception { color: var(--exception); background: var(--exception-fond); }
.encadre em, .encadre code, .encadre strong { color: var(--encre); }
.encadre code { background: color-mix(in srgb, currentColor 12%, transparent); }

li .encadre { margin: .4rem 0 .2rem; }

.encadre ul, .encadre ol { margin: .5rem 0 .2rem; padding-left: 1.3rem; }
.encadre li { margin-bottom: .3rem; }
.encadre li::marker { color: currentColor; }

.bloc { margin: 0 0 1rem; }

.exc {
  border-bottom: 1px dotted currentColor;
  text-decoration: none;
}

.renvoi a { text-decoration: none; padding: 0 .15em; }

/* -------------------------------------------- dédicaces, exergues, sources */

.dedicace {
  margin: 1.5rem 0; padding: 0; border: none;
  font-style: italic; color: var(--encre-douce); text-align: right;
}
.dedicace p { margin: 0 0 .35rem; }

.exergue {
  margin: 2.5rem 0 .5rem; padding: 0 0 0 1.5rem;
  border-left: 2px solid var(--filet-fort);
  font-size: .96875rem; color: var(--encre-douce);
}
.exergue p:first-child::first-letter { font-size: 1.15em; }
.exergue > *:last-child { margin-bottom: 0; }
.exergue:target { border-left-color: var(--accent); }

.source {
  margin: .5rem 0 2rem; text-align: right;
  font-size: .875rem; color: var(--encre-douce); font-style: italic;
}
.source .pc { font-style: normal; }

.citation { margin: 1.5rem 0; padding-left: 1.5rem;
  border-left: 2px solid var(--filet); }
.a-droite { text-align: right; }
.au-centre { text-align: center; }

.credit {
  margin: 1.25rem 0 1.5rem; font-size: .875rem; font-style: italic;
  color: var(--encre-douce);
}

/* -------------------------------------------------------------- définitions */

.lexique {
  display: grid; grid-template-columns: max-content 1fr;
  gap: .3rem 1.25rem; margin: 1.25rem 0;
  padding: 1rem 1.25rem; background: var(--papier-creux);
  border-radius: 6px;
}
.lexique dt { font-weight: 600; }
.lexique dd { margin: 0; color: var(--encre-douce); }

/* ------------------------------------------------------------------ tableau */

.tableau { margin: 1.5rem 0; overflow-x: auto; }
.tableau figcaption {
  font-size: .875rem; color: var(--encre-douce); font-style: italic;
  margin-bottom: .6rem;
}
.tableau table { border-collapse: collapse; width: 100%; font-size: .96875rem; }
.tableau th, .tableau td {
  text-align: left; padding: .45rem .8rem; border-bottom: 1px solid var(--filet);
}
.tableau thead th { border-bottom: 1.5px solid var(--filet-fort);
  font: 600 .6875rem/1.4 var(--sans); letter-spacing: .08em;
  text-transform: uppercase; color: var(--encre-douce); }
.tableau tbody tr:last-child td { border-bottom: none; }

/* -------------------------------------------------------------------- notes */

.notes {
  margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--filet);
  font-size: .875rem; color: var(--encre-douce);
}
.notes h2 { font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase;
  border: none; margin: 0 0 .5rem; padding: 0; }
.notes .retour { text-decoration: none; }

/* --------------------------------------------------------------- pagination */

.pagination {
  display: flex; gap: 1rem; margin-top: 3.5rem; padding-top: 1.5rem;
  border-top: 1px solid var(--filet);
}
.pagination a {
  flex: 1; padding: .8rem 1rem; border: 1px solid var(--filet);
  border-radius: 6px; text-decoration: none; color: var(--encre);
  background: var(--carte);
}
.pagination a:hover { border-color: var(--accent); }
.pagination a span {
  display: block; font: .6875rem/1 var(--sans); letter-spacing: .08em;
  text-transform: uppercase; color: var(--encre-douce); margin-bottom: .3rem;
}
.pagination .suiv { text-align: right; }

/* ------------------------------------------------------------------ accueil */

.couverture {
  display: grid; grid-template-columns: 300px 1fr; gap: 2.5rem;
  align-items: center; margin-bottom: 3rem;
}
.couverture img {
  width: 100%; height: auto; border: 1px solid var(--filet);
  border-radius: 3px; background: #fff;
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
}
html[data-theme="sombre"] .couverture img { filter: invert(1) hue-rotate(180deg); }

.bouton {
  display: inline-block; margin: .35rem .5rem .35rem 0;
  padding: .55rem 1.1rem; border-radius: 999px;
  background: var(--accent); color: var(--papier);
  font-family: var(--sans); font-size: .875rem; text-decoration: none;
}
.bouton:hover { background: var(--accent-clair); }
.bouton.second { background: none; color: var(--accent);
  border: 1px solid var(--filet-fort); }
.bouton.second:hover { border-color: var(--accent); background: var(--accent-fond); }

.cartes { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.carte {
  display: block; padding: 1.1rem 1.25rem; text-decoration: none;
  color: inherit; background: var(--carte);
  border: 1px solid var(--filet); border-radius: 6px;
}
.carte:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.carte .sur {
  font: 600 .625rem/1 var(--sans); letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
}
.carte h3 { margin: .5rem 0 .35rem; font-size: 1.0625rem; }
.carte .compte { font: .75rem var(--sans); color: var(--encre-douce); }
.carte p { margin: .5rem 0 0; font-size: .8125rem; color: var(--encre-douce);
  line-height: 1.45; }

.page-accueil main { max-width: none; }

/* -------------------------------------------------------------------- index */

.alphabet {
  display: flex; flex-wrap: wrap; gap: .3rem; margin: 1.5rem 0 2rem;
  padding-bottom: 1.5rem; border-bottom: 1px solid var(--filet);
}
.alphabet a {
  display: grid; place-items: center; width: 2rem; height: 2rem;
  border: 1px solid var(--filet); border-radius: 5px;
  font-family: var(--sans); font-size: .8125rem; text-decoration: none;
}
.alphabet a:hover { background: var(--accent-fond); border-color: var(--accent); }

.groupe-index h2 { font-size: 1.75rem; color: var(--accent); }
.entrees { list-style: none; padding: 0; column-width: 15rem; column-gap: 2rem; }
.entrees li { break-inside: avoid; margin-bottom: .5rem; font-size: .9375rem; }
.entrees .mot { font-weight: 600; }
.entrees a { font-family: var(--sans); font-size: .8125rem; }

/* --------------------------------------------------------------------- pied */

.pied {
  border-top: 1px solid var(--filet); padding: 2rem 1.5rem;
  text-align: center; font-size: .8125rem; color: var(--encre-douce);
}
.pied p { margin: 0; }

/* ------------------------------------------------------------ adaptatif */

@media (max-width: 68rem) {
  .page { grid-template-columns: 14rem minmax(0, 1fr); gap: 2rem; }
  .aside { display: none; }
}

@media (max-width: 52rem) {
  .page { grid-template-columns: minmax(0, 1fr); padding: 1.5rem 1.25rem 3rem; }
  .basculer-nav { display: flex; }
  .bandeau { gap: .5rem; padding: 0 .75rem; }
  .marque { min-width: 0; }
  .marque-sous { display: none; }
  .marque-titre { display: none; }
  .marque-court { display: block; font-size: .9375rem; white-space: nowrap; }
  .nav-site {
    position: fixed; inset: var(--bandeau-h) auto 0 0; z-index: 25;
    width: min(19rem, 84vw); max-height: none; overflow-y: auto;
    padding: 1.25rem; background: var(--papier);
    border-right: 1px solid var(--filet);
    transform: translateX(-102%); transition: transform .22s ease;
  }
  .nav-site.ouverte { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .voile {
    position: fixed; inset: var(--bandeau-h) 0 0; z-index: 24;
    background: rgba(0,0,0,.35);
  }
  .couverture { grid-template-columns: 1fr; gap: 1.5rem; }
  .couverture img { max-width: 15rem; }
  .recherche { flex: 1 1 auto; }
  .pagination { flex-direction: column; }
}

/* ----------------------------------------------------------------- impression */

@media print {
  .bandeau, .nav-site, .aside, .pagination, .pied, .saut, .lien-ancre,
  .alphabet { display: none !important; }
  .page { display: block; max-width: none; padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main { max-width: none; }
  .regle { break-inside: avoid; border: none; border-left: 2px solid #999;
    padding: .2cm .4cm; margin: .3cm 0; background: none; }
  h2 { break-after: avoid; }
  a { color: #000; text-decoration: none; }
  .couverture img { box-shadow: none; }
}
