/* Feuille de style de la sortie HTML du livret.
   Couleurs des encarts : celles de preambule.sty, éclaircies à 50 %
   comme dans le PDF (persoYellow!50, etc.). */

:root {
  --texte: #1d1d1b;
  --fond: #ffffff;
  --discret: #5f5f5a;
  --trait: #1d1d1b;
  --lien: #2f6f8f;
  --jaune: #fbdf97;
  --bleu: #aacfdf;
  --rouge: #e59b94;
  --vert: #bed7a7;
  --mesure: 42rem;
  --bandeau: 19rem;
  --barre: 3rem;
  --surface: #f4f3ef;
  --surligne: #fbdf97;
}

@media (prefers-color-scheme: dark) {
  :root {
    --texte: #e8e6e1;
    --fond: #1b1c1e;
    --discret: #a5a39d;
    --trait: #8a8984;
    --lien: #8cc4de;
    /* Fonds d'encarts assombris : même teinte, texte clair lisible */
    --jaune: #4d3f1a;
    --bleu: #1f3c4a;
    --rouge: #4f2420;
    --vert: #2f3f22;
    --surface: #242528;
    --surligne: #6b5620;
  }
}

html { background: var(--fond); }

body {
  margin: 0 auto;
  max-width: var(--mesure);
  padding: 1.5rem 1rem 4rem;
  color: var(--texte);
  background: var(--fond);
  font-family: "Latin Modern Roman", "Iowan Old Style", "Palatino Linotype",
               Palatino, Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.55;
  hyphens: auto;
  text-align: justify;
}

a { color: var(--lien); }
a.renvoi { text-decoration: none; border-bottom: 1px dotted currentColor; }

img { max-width: 100%; height: auto; }

[lang="ja"] { font-family: "Noto Serif CJK JP", "Noto Serif JP", serif; }

/* ---------------------------------------------------------------- titres */

h1, h2, h3 { line-height: 1.25; text-align: left; hyphens: manual; }

h1 {
  margin: 3rem 0 1.5rem;
  padding: 1.2rem 1rem;
  border: 1px solid var(--trait);
  border-radius: 6px;
  text-align: center;
  font-size: 1.9rem;
  position: relative;
}
h1 .numero {
  position: absolute;
  top: .4rem;
  left: .6rem;
  font-size: 1.1rem;
}
h2 { margin-top: 2.5rem; font-size: 1.45rem; }
h3 { margin-top: 2rem; font-size: 1.2rem; }
h2 .numero, h3 .numero { margin-right: .5em; }

/* ---------------------------------------------- titre du document (HTML) */

#title-block-header { text-align: center; font-variant: small-caps; margin: 1.5rem 0 2.5rem; }
#title-block-header h1.title {
  border: 0;
  border-top: 3px double var(--trait);
  border-bottom: 3px double var(--trait);
  border-radius: 0;
  padding: .5rem 0;
  margin: 0;
  font-size: 2.2rem;
}
#title-block-header .subtitle { font-size: 1.25rem; margin-top: .8rem; }
#title-block-header .auteurs {
  max-width: 36rem;
  margin: 1.2rem auto 0;
  font-variant: normal;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--discret);
}
p.logo { text-align: center; margin: 0 0 2.5rem; }
p.logo img { width: 42%; }

/* ---------------------------------------------------------- page de titre */

.page-de-titre {
  text-align: center;
  font-variant: small-caps;
  margin: 2rem 0 3rem;
}
.page-de-titre p:first-child {
  font-size: 2rem;
  border-top: 3px double var(--trait);
  border-bottom: 3px double var(--trait);
  padding: .4rem 0;
}
.page-de-titre p:nth-child(3) { font-size: 1.8rem; }
.page-de-titre img { width: 60%; margin-top: 1rem; }

/* ---------------------------------------------------------------- encarts */

.encart {
  position: relative;
  margin: 2.2rem 0 1.5rem;
  padding: 1.3rem 1rem .6rem;
  border: 1px solid var(--trait);
  border-radius: 5px;
  background: var(--jaune);
}
.encart.definition, .encart.landmark, .encart.inpractice { background: var(--bleu); }
.encart.example { background: var(--vert); }
.encart.important { background: var(--rouge); }

.encart-cartouche {
  position: absolute;
  top: -.85rem;
  left: .7rem;
  padding: 0 .5rem;
  border: 1px solid var(--trait);
  border-radius: 2px;
  background: inherit;
  font-weight: bold;
}
.encart-titre { text-align: center; font-weight: bold; margin-bottom: .6rem; }
.encart-titre p { margin: 0; }
.encart > p:first-of-type { margin-top: 0; }

/* ----------------------------------------------------------------- listes */

/* Listes contenant des éléments « -- » : marqueurs dessinés ici */
.liste-tirets > ol, .liste-tirets > ul {
  list-style: none;
  counter-reset: etape;
  padding-left: 2.2em;
}
.liste-tirets > ol > li, .liste-tirets > ul > li { position: relative; }
.liste-tirets span.num, .liste-tirets span.tiret, .liste-tirets span.puce {
  position: absolute;
  left: -2.2em;
  width: 1.8em;
  text-align: right;
}
.liste-tirets span.num::before { counter-increment: etape; content: counter(etape) "."; }
.liste-tirets span.tiret::before { content: "–"; }
.liste-tirets span.puce::before { content: "•"; }

li { text-align: left; }

/* --------------------------------------------- colonnes, centrage, divers */

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem 2rem;
}
.colonne-titre { text-align: center; }
.colonne-titre p { margin: 0; }

.center { text-align: center; }

.concepteur {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.concepteur img { width: 9rem; flex: none; border-radius: 4px; }
.concepteur-legende { text-align: center; flex: 1; }
@media (max-width: 30rem) {
  .concepteur { flex-direction: column; }
}

/* ----------------------------------------------------------------- vidéos */

.video { margin: 1.5rem 0; }
.video-cadre { aspect-ratio: 16 / 9; }
.video-cadre iframe { width: 100%; height: 100%; border: 0; border-radius: 4px; }
.video-titre { font-weight: bold; margin-top: .4rem; }
.video-titre p { margin: 0; }

/* ------------------------------------------- navigation (chunkedhtml) */

nav#sitenav, nav#TOC { text-align: left; font-size: 1rem; }
nav#TOC ul { padding-left: 1.2em; }
.sitenav { display: flex; flex-wrap: wrap; gap: .3rem 1.5rem; }
.navlink { flex: 1; }

/* ------------------------------------- bandeau latéral (site, chunkedhtml) */

.visuellement-cache {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.evitement { position: absolute; left: -100vw; }
.evitement:focus { left: 1rem; top: .5rem; z-index: 30; background: var(--fond); padding: .3rem .6rem; }

/* Sans JavaScript, le bandeau n'est qu'un sommaire en tête de page. */
.barre, .voile, .recherche, .recherche-resultats { display: none; }
.bandeau { text-align: left; hyphens: manual; font-size: 1rem; }
.sommaire ul { padding-left: 1.2em; }

.js body { padding-top: calc(var(--barre) + 1rem); }

.js .barre {
  display: flex;
  align-items: center;
  gap: .75rem;
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--barre);
  padding: 0 1rem;
  background: var(--fond);
  border-bottom: 1px solid color-mix(in srgb, var(--trait) 25%, transparent);
  text-align: left;
}
.barre-bouton {
  display: grid;
  place-items: center;
  padding: 0;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid color-mix(in srgb, var(--trait) 35%, transparent);
  border-radius: 6px;
  background: var(--fond);
  color: var(--texte);
  cursor: pointer;
}
.barre-bouton:hover, .barre-bouton[aria-expanded="true"] { background: var(--surface); }
.barre-bouton:focus-visible { outline: 2px solid var(--lien); outline-offset: 2px; }

/* Icône : trois traits qui deviennent une croix à l'ouverture. */
.hamburger path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transform-box: view-box;
  transition: transform .2s ease, opacity .2s ease;
}
/* Chaque trait pivote autour de son propre milieu, puis rejoint le centre. */
.hamburger .trait-haut { transform-origin: 12px 7px; }
.hamburger .trait-milieu { transform-origin: 12px 12px; }
.hamburger .trait-bas { transform-origin: 12px 17px; }
[aria-expanded="true"] .trait-haut { transform: translateY(5px) rotate(45deg); }
[aria-expanded="true"] .trait-milieu { opacity: 0; transform: scaleX(0); }
[aria-expanded="true"] .trait-bas { transform: translateY(-5px) rotate(-45deg); }
@media (prefers-reduced-motion: reduce) { .hamburger path { transition: none; } }
/* Lien vers le site qui héberge le livret (make angular). */
.barre-retour {
  margin-left: auto;
  flex: none;
  color: var(--lien);
  font-size: .95rem;
  text-decoration: none;
  white-space: nowrap;
}
.barre-retour::before { content: "← "; }
.barre-retour:hover { text-decoration: underline; }
@media (max-width: 30rem) { .barre-retour::before { content: "←"; } .barre-retour { font-size: 0; } .barre-retour::before { font-size: 1.2rem; } }
.barre-titre {
  color: var(--texte);
  text-decoration: none;
  font-variant: small-caps;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.js .bandeau {
  position: fixed;
  top: var(--barre);
  bottom: 0;
  left: 0;
  z-index: 15;
  width: min(var(--bandeau), 88vw);
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1rem 3rem;
  background: var(--surface);
  border-right: 1px solid color-mix(in srgb, var(--trait) 25%, transparent);
  transform: translateX(-100%);
  isolation: isolate;
  visibility: hidden;
  transition: transform .2s ease, visibility .2s;
}
.bandeau-ouvert .bandeau { transform: none; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .js .bandeau { transition: none; } }

.js .voile {
  display: block;
  position: fixed;
  inset: var(--barre) 0 0 0;
  z-index: 10;
  background: rgb(0 0 0 / .35);
}
.js .voile[hidden] { display: none; }

/* Grand écran : le bandeau ouvert se range à côté du texte. */
@media (min-width: 75rem) {
  .js.bandeau-ouvert body { padding-left: calc(var(--bandeau) + 2rem); }
}

/* Sommaire : seul le chapitre courant est déplié. */
.js .sommaire > ul { padding-left: 0; margin: 0; }
.sommaire li { list-style: none; margin: .15rem 0; }
.sommaire a {
  display: block;
  padding: .2rem .4rem;
  border-radius: 4px;
  color: var(--texte);
  text-decoration: none;
  line-height: 1.3;
}
.sommaire a:hover { background: color-mix(in srgb, var(--lien) 15%, transparent); }
.sommaire .numero { color: var(--discret); margin-right: .3em; }
.js .sommaire > ul > li > ul { display: none; }
.js .sommaire > ul > li.courant > ul { display: block; font-size: .93rem; }
.sommaire li.courant > a { font-weight: bold; }

/* Recherche */
.js .recherche {
  display: block;
  position: sticky;
  top: -1rem;
  z-index: 1;
  margin: -1rem 0 1rem;
  padding: 1rem 0 .5rem;
  background: var(--surface);
}
.recherche input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: .45rem .6rem;
  border: 1px solid color-mix(in srgb, var(--trait) 40%, transparent);
  border-radius: 6px;
  background: var(--fond);
  color: var(--texte);
}
.recherche input:focus { outline: 2px solid var(--lien); outline-offset: 1px; }
.js .recherche-resultats { display: block; }
.recherche-bilan { color: var(--discret); font-size: .9rem; margin: 0 0 .5rem; }
.recherche-resultats ol { list-style: none; padding: 0; margin: 0; }
.recherche-resultats li { margin: 0 0 .4rem; }
.recherche-resultats a {
  display: block;
  padding: .4rem .5rem;
  border-radius: 4px;
  color: var(--texte);
  text-decoration: none;
}
.recherche-resultats a:hover, .recherche-resultats a:focus {
  background: color-mix(in srgb, var(--lien) 15%, transparent);
}
.recherche-fil { display: block; font-size: .8rem; color: var(--discret); }
.recherche-titre { display: block; font-weight: bold; line-height: 1.3; }
.recherche-extrait { display: block; font-size: .88rem; line-height: 1.4; color: var(--discret); }
.recherche-resultats mark { background: var(--surligne); color: inherit; border-radius: 2px; }

/* Les ancres ne doivent pas passer sous la barre fixe. */
.js [id] { scroll-margin-top: calc(var(--barre) + .5rem); }

/* ------------------------------------------- droits d'auteur (pied de page) */

footer.droits {
  margin: 4rem 0 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--trait);
  text-align: center;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--discret);
}
footer.droits p { margin: .2rem 0; }
