/* Fiches de révision — feuille de style unique */
:root {
  --fond: #faf9f6;
  --surface: #ffffff;
  --texte: #1f2328;
  --texte-doux: #5b6370;
  --bordure: #e3e1dc;
  --accent: #2f5bd3;
  --accent-doux: #e8eefc;
  --definition: #2f5bd3;   --definition-fond: #eef2fd;
  --propriete: #1f8a5b;    --propriete-fond: #e9f6ef;
  --methode: #8a5a00;      --methode-fond: #fdf3e1;
  --attention: #c23b3b;    --attention-fond: #fcecec;
  --exemple: #6b4fbb;      --exemple-fond: #f1edfb;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #15171a; --surface: #1d2024; --texte: #e6e7e9; --texte-doux: #a2a8b3; --bordure: #30343a;
    --accent: #8aa9ff; --accent-doux: #222c45;
    --definition: #8aa9ff; --definition-fond: #1e2538;
    --propriete: #5ccf98;  --propriete-fond: #17291f;
    --methode: #f0b54a;    --methode-fond: #2d2414;
    --attention: #ff8a8a;  --attention-fond: #331b1b;
    --exemple: #b9a2ff;    --exemple-fond: #241e36;
    --ombre: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
main { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.9rem; line-height: 1.25; margin: .2em 0 .5em; }
h2 { font-size: 1.35rem; margin: 1.8em 0 .6em; }
h3 { font-size: 1.1rem; margin: 1.4em 0 .4em; }

/* En-tête */
.entete {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--bordure);
}
.marque { font-weight: 700; text-decoration: none; color: var(--texte); white-space: nowrap; }
.logo { color: var(--accent); }
.recherche { position: relative; flex: 1; max-width: 360px; }
.recherche input {
  width: 100%; padding: 8px 12px; font: inherit; font-size: .95rem; color: var(--texte);
  background: var(--fond); border: 1px solid var(--bordure); border-radius: 999px;
}
.recherche input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#resultats {
  position: absolute; right: 0; left: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); box-shadow: var(--ombre);
  max-height: 60vh; overflow: auto;
}
#resultats a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--texte); }
#resultats a:hover, #resultats a:focus { background: var(--accent-doux); }
#resultats small { display: block; color: var(--texte-doux); }
#resultats .vide { padding: 8px 10px; color: var(--texte-doux); }

/* Fil d'Ariane */
.fil { font-size: .9rem; color: var(--texte-doux); margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.fil a { color: var(--texte-doux); }
.fil .sep { opacity: .6; }

/* Accueil et grilles */
.hero { padding: 16px 0 8px; }
.hero h1 { font-size: 2.1rem; }
.hero p { color: var(--texte-doux); max-width: 60ch; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 20px; }
.carte {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; min-height: 110px; text-decoration: none; color: var(--texte);
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); box-shadow: var(--ombre);
  transition: border-color .15s, transform .15s;
}
a.carte:hover { border-color: var(--accent); transform: translateY(-2px); }
.carte.inactive { opacity: .55; }
.carte-niveau { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-doux); }
.carte-titre { font-size: 1.2rem; font-weight: 650; }
.carte-info { margin-top: auto; font-size: .88rem; color: var(--texte-doux); }

/* Page matière */
.sous-titre { font-weight: 400; color: var(--texte-doux); font-size: 1.1rem; }
.note { color: var(--texte-doux); font-size: .95rem; background: var(--surface); border: 1px solid var(--bordure);
        border-radius: var(--rayon); padding: 12px 14px; }
.theme h2 { font-size: 1.15rem; border-bottom: 1px solid var(--bordure); padding-bottom: 4px; }
.sujets { list-style: none; padding: 0; margin: 0; }
.sujets li { padding: 7px 0; }
.sujets .a-venir { color: var(--texte-doux); }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--bordure); color: var(--texte-doux); margin-left: 6px; }

/* Fiche */
.fiche-entete { border-bottom: 1px solid var(--bordure); padding-bottom: 14px; margin-bottom: 8px; }
.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.etiquettes span { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--accent-doux); color: var(--accent); }
.resume { color: var(--texte-doux); font-size: 1.05rem; margin: 0 0 10px; }
.imprimer { font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--bordure);
            background: var(--surface); color: var(--texte); cursor: pointer; }
.fiche ul, .fiche ol { padding-left: 1.3em; }
.fiche li { margin: .25em 0; }
.fiche table { border-collapse: collapse; margin: 12px 0; width: 100%; display: block; overflow-x: auto; }
.fiche th, .fiche td { border: 1px solid var(--bordure); padding: 6px 10px; text-align: left; }
.fiche th { background: var(--surface); }
.fiche code { background: var(--surface); border: 1px solid var(--bordure); border-radius: 4px; padding: 0 4px; font-size: .92em; }
.fiche pre { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 12px; overflow-x: auto; }
.fiche pre code { border: 0; padding: 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* Encadrés (extension admonition) */
.admonition { border-left: 4px solid var(--c, var(--accent)); background: var(--f, var(--accent-doux));
              border-radius: 0 var(--rayon) var(--rayon) 0; padding: 10px 16px; margin: 16px 0; }
.admonition > :last-child { margin-bottom: 0; }
.admonition-title { font-weight: 700; margin: 0 0 4px; color: var(--c, var(--accent)); }
.admonition.definition { --c: var(--definition); --f: var(--definition-fond); }
.admonition.propriete  { --c: var(--propriete);  --f: var(--propriete-fond); }
.admonition.methode    { --c: var(--methode);    --f: var(--methode-fond); }
.admonition.attention  { --c: var(--attention);  --f: var(--attention-fond); }
.admonition.exemple    { --c: var(--exemple);    --f: var(--exemple-fond); }

/* Quiz */
details.quiz { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); margin: 10px 0; padding: 0 14px; }
details.quiz > summary { cursor: pointer; padding: 10px 0; font-weight: 600; list-style: none; }
details.quiz > summary::-webkit-details-marker { display: none; }
details.quiz > summary::before { content: "▸"; display: inline-block; width: 1.2em; color: var(--accent); transition: transform .15s; }
details.quiz[open] > summary::before { transform: rotate(90deg); }
details.quiz[open] { padding-bottom: 10px; }
details.quiz > :not(summary) { border-top: 1px dashed var(--bordure); padding-top: 8px; }

/* Figures SVG (générées par scripts/figures_*.py) */
.figure { margin: 18px auto; text-align: center; }
.figure svg { width: 100%; max-width: 520px; height: auto; color: var(--texte); }
.figure figcaption { font-size: .88rem; color: var(--texte-doux); margin-top: 4px; }
.fig .fig-trait, .fig .fig-cadre { stroke: currentColor; stroke-width: 1.6; fill: none; }
.fig .fig-cache { stroke: currentColor; stroke-width: 1.2; fill: none; stroke-dasharray: 5 4; opacity: .6; }
.fig .fig-accent { stroke: var(--definition); fill: none; }
.fig .fig-accent2 { stroke: var(--propriete); fill: none; }
.fig .fig-epais { stroke-width: 3; }
.fig .fig-pointille { stroke: currentColor; stroke-width: 1.2; stroke-dasharray: 4 4; opacity: .7; }
.fig .fig-grille { stroke: var(--bordure); stroke-width: 1; }
.fig .fig-cote { stroke: currentColor; stroke-width: 1.2; marker-start: none; opacity: .8; }
.fig .fig-point { fill: currentColor; }
.fig .fig-texte { fill: currentColor; font-size: 15px; font-family: inherit; }
.fig .fig-petit { fill: var(--texte-doux); font-size: 12.5px; font-family: inherit; }
.fig .fig-grand { fill: currentColor; font-size: 18px; font-weight: 600; font-family: inherit; }
.fig .fig-legende { fill: var(--texte-doux); font-size: 14px; font-style: italic; font-family: inherit; }
.fig .fig-gras { font-weight: 700; }
.fig .fig-accent-texte { fill: var(--definition); }
.fig .fig-accent2-texte { fill: var(--propriete); }
.fig .fig-zone1 { fill: var(--definition-fond); } .fig .fig-zone2 { fill: var(--propriete-fond); }
.fig .fig-zone3 { fill: var(--methode-fond); }    .fig .fig-zone4 { fill: var(--exemple-fond); }

/* Frises chronologiques : pleine largeur ; sur petit écran, taille minimale et défilement horizontal */
.figure:has(svg.frise) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.figure svg.frise { max-width: 100%; min-width: 640px; }
.fig .frise-date { fill: currentColor; font-size: 19px; font-weight: 700; font-family: inherit; }
.fig .frise-lib { fill: currentColor; font-size: 17px; font-family: inherit; }
.fig .frise-annee { fill: var(--texte-doux); font-size: 16px; font-family: inherit; }

/* Bloc de vérification */
.verification { margin-top: 24px; font-size: .9rem; color: var(--texte-doux); }
.verification h2 { font-size: 1rem; }
.verif-etat { padding: 8px 12px; border-radius: 8px; }
.verif-etat.ok { background: var(--propriete-fond); color: var(--propriete); }
.verif-etat.ko { background: var(--attention-fond); color: var(--attention); font-weight: 600; }
.type-source { font-size: .75rem; padding: 1px 7px; border-radius: 999px; background: var(--bordure); margin-left: 4px; }

/* Sources et navigation */
.sources { margin-top: 36px; font-size: .9rem; color: var(--texte-doux); border-top: 1px solid var(--bordure); }
.sources h2 { font-size: 1rem; }
.ref-bo { white-space: nowrap; }
.voisins { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; font-size: .95rem; }
.voisins a { text-decoration: none; padding: 10px 12px; border: 1px solid var(--bordure); border-radius: var(--rayon); background: var(--surface); max-width: 48%; }
.voisins .suiv { text-align: right; margin-left: auto; }
.pied { max-width: 860px; margin: 0 auto; padding: 24px 16px 40px; color: var(--texte-doux); font-size: .85rem; border-top: 1px solid var(--bordure); }

@media (max-width: 560px) {
  body { font-size: 16px; }
  h1, .hero h1 { font-size: 1.6rem; }
  .entete { flex-wrap: wrap; }
  .recherche { max-width: none; flex-basis: 100%; }
  .voisins { flex-direction: column; }
  .voisins a { max-width: none; }
}

/* Impression : une fiche propre, réponses du quiz dépliées */
@media print {
  :root { --fond: #fff; --surface: #fff; --texte: #000; --texte-doux: #333; }
  body { font-size: 11.5pt; }
  .entete, .fil, .voisins, .imprimer, .pied { display: none !important; }
  main { padding: 0; max-width: none; }
  .admonition, details.quiz { break-inside: avoid; }
  details.quiz > summary::before { content: ""; }
  a { color: inherit; text-decoration: none; }
}

/* Schémas (EMC…) : pleine largeur, texte lisible ; défilement horizontal sur petit écran */
.figure:has(svg.schema) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.figure svg.schema { max-width: 100%; min-width: 600px; }
.fig .schema-titre { fill: currentColor; font-size: 20px; font-weight: 700; font-family: inherit; }
.fig .schema-texte { fill: currentColor; font-size: 18px; font-weight: 600; font-family: inherit; }
.fig .schema-petit { fill: currentColor; font-size: 16px; font-family: inherit; }

/* Compte (site en ligne) : lien de l'en-tête, connexion, page « Mon compte » */
.lien-compte {
  white-space: nowrap; font-size: .92rem; font-weight: 600; text-decoration: none; color: var(--accent);
  padding: 7px 14px; border: 1px solid var(--accent); border-radius: 999px;
}
.lien-compte:hover { background: var(--accent-doux); }
.badge.libre { background: var(--propriete-fond); color: var(--propriete); }
.cadenas { font-size: .8rem; margin-left: 6px; opacity: .7; }
.connexion, .compte { max-width: 460px; margin: 8px auto 32px; }
.connexion .intro { color: var(--texte-doux); }
.message { padding: 10px 14px; border-radius: var(--rayon); background: var(--propriete-fond); color: var(--texte);
  border-left: 4px solid var(--propriete); }
.message.erreur { background: var(--attention-fond); border-left-color: var(--attention); }
.fournisseurs { display: grid; gap: 10px; margin: 20px 0; }
.bouton-fournisseur {
  display: block; text-align: center; padding: 11px 14px; border-radius: var(--rayon); text-decoration: none;
  color: var(--texte); background: var(--surface); border: 1px solid var(--bordure); font-weight: 600; box-shadow: var(--ombre);
}
.bouton-fournisseur:hover, .bouton-fournisseur:focus { border-color: var(--accent); background: var(--accent-doux); }
.separateur { display: flex; align-items: center; gap: 12px; color: var(--texte-doux); font-size: .9rem; }
.separateur::before, .separateur::after { content: ""; flex: 1; border-top: 1px solid var(--bordure); }
.form-lien label { display: block; font-weight: 600; margin-bottom: 8px; }
.ligne-form { display: flex; gap: 8px; flex-wrap: wrap; }
.ligne-form input[type=email] {
  flex: 1 1 220px; min-width: 0; padding: 10px 12px; font: inherit; color: var(--texte); background: var(--surface);
  border: 1px solid var(--bordure); border-radius: var(--rayon);
}
.connexion button, .compte button {
  font: inherit; font-weight: 600; padding: 10px 16px; border-radius: var(--rayon); border: 1px solid var(--accent);
  background: var(--accent); color: var(--surface); cursor: pointer;
}
.compte button { background: var(--surface); color: var(--accent); }
.compte button.danger { border-color: var(--attention); color: var(--attention); }
.actions-compte { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }
.infos-compte { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.infos-compte dt { color: var(--texte-doux); }
.infos-compte dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.petit { font-size: .85rem; color: var(--texte-doux); }
@media print { .lien-compte { display: none !important; } }

/* L’attribut hidden doit l’emporter sur les display des classes (.fournisseurs, .separateur, .lien-compte…). */
[hidden] { display: none !important; }
