/* Schoozon — feuille de style unique.
   Thème clair et sombre (§8), cible de contraste WCAG 2.1 AA,
   mise en page fluide pour un usage confortable sur téléphone. */

:root {
  --fond: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --bordure: #d9d9e0;
  --texte: #17171c;
  --texte-doux: #55555f;
  --accent: #4338ca;
  --accent-contraste: #ffffff;
  --succes: #15803d;
  --alerte: #b45309;
  --erreur: #b91c1c;
  --rayon: 10px;
  --ombre: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 4%);
}

html[data-theme="dark"] {
  --fond: #131316;
  --surface: #1c1c21;
  --surface-2: #26262d;
  --bordure: #38383f;
  --texte: #ececf1;
  --texte-doux: #a0a0ac;
  --accent: #a5b4fc;
  --accent-contraste: #17171c;
  --succes: #4ade80;
  --alerte: #fbbf24;
  --erreur: #f87171;
  --ombre: 0 1px 2px rgb(0 0 0 / 40%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Le contenu principal reçoit le focus via le lien d'évitement, sans montrer
   de contour : le déplacement suffit, l'encadrer serait déroutant. */
main:focus { outline: none; }

/* Réservé aux lecteurs d'écran : présent dans l'ordre de lecture, invisible
   à l'écran. Ne pas utiliser display:none, qui le retirerait de l'arbre. */
.lecteur-ecran {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Lien d'évitement : hors écran jusqu'à ce qu'il reçoive le focus (RGAA 12.7). */
.lien-evitement {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: .7rem 1.1rem; background: var(--accent); color: var(--accent-contraste);
  border-radius: 0 0 var(--rayon) 0; font-weight: 600; text-decoration: none;
}
.lien-evitement:focus { left: 0; }

/* Un lien de navigation qui est la page courante doit se distinguer autrement
   que par la couleur seule (RGAA 3.1). */
.barre nav a[aria-current="page"] {
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
  font-weight: 600;
}

/* Groupes de réponses : le fieldset ne doit pas ajouter de cadre visuel. */
.groupe-reponses { border: 0; padding: 0; margin: 0; min-width: 0; }
.groupe-reponses > legend { padding: 0; }

.option-reponse {
  display: flex; gap: .6rem; align-items: flex-start; padding: .5rem;
  border: 1px solid var(--bordure); border-radius: var(--rayon);
  margin-bottom: .4rem; font-weight: 400; cursor: pointer;
}
.option-reponse:hover { background: var(--surface-2); }
.option-reponse:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.option-reponse input { width: auto; margin-top: .3rem; }

/* Respecte le réglage système « réduire les animations » (RGAA 13.8). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* --- Barre de navigation ------------------------------------------------ */
.barre {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  padding: .75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
  position: sticky; top: 0; z-index: 20;
}
.marque { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--texte); }
.barre nav { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.barre nav a { padding: .4rem .7rem; border-radius: var(--rayon); text-decoration: none; }
.barre nav a:hover { background: var(--surface-2); }
.barre__fin { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.barre__fin form { margin: 0; }

.contenu { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* --- Éléments de base --------------------------------------------------- */
.bouton {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .85rem; border: 1px solid var(--bordure);
  border-radius: var(--rayon); background: var(--surface); color: var(--texte);
  font: inherit; font-size: .92rem; text-decoration: none; cursor: pointer;
}
.bouton:hover { background: var(--surface-2); }
.bouton--primaire { background: var(--accent); color: var(--accent-contraste); border-color: transparent; font-weight: 600; }
.bouton--primaire:hover { filter: brightness(1.08); }
.bouton--discret { background: transparent; border-color: transparent; }
.bouton--danger { color: var(--erreur); }

.carte {
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--rayon); padding: 1.1rem; box-shadow: var(--ombre);
}
.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.pile { display: flex; flex-direction: column; gap: 1rem; }
.rangee { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.entre { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.doux { color: var(--texte-doux); font-size: .88rem; }
.vide { padding: 2.5rem 1rem; text-align: center; color: var(--texte-doux); }

.pastille {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--bordure);
  font-size: .78rem; color: var(--texte-doux); white-space: nowrap;
}
.pastille--matiere { font-weight: 600; color: var(--texte); }
.puce {
  display: inline-block; width: .6rem; height: .6rem; border-radius: 50%;
  margin-right: .15rem; vertical-align: baseline;
}
.pastille--brouillon { border-color: var(--alerte); color: var(--alerte); }
.pastille--complet { border-color: var(--succes); color: var(--succes); }
.pastille--a_revoir { border-color: var(--erreur); color: var(--erreur); }

/* --- Formulaires -------------------------------------------------------- */
form p { margin: 0 0 .9rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type="text"], input[type="date"], input[type="number"], input[type="password"],
input[type="email"], input[type="search"], select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit;
  color: var(--texte); background: var(--surface);
  border: 1px solid var(--bordure); border-radius: var(--rayon);
}
textarea { resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .92rem; }
input[type="color"] { width: 3.5rem; height: 2.2rem; padding: 2px; }
.aide { color: var(--texte-doux); font-size: .82rem; }
.erreurlist { color: var(--erreur); font-size: .85rem; margin: .25rem 0; padding-left: 1rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
.message { padding: .6rem .9rem; border-radius: var(--rayon); border-left: 4px solid var(--accent); background: var(--surface); }
.message--success { border-left-color: var(--succes); }
.message--error { border-left-color: var(--erreur); }
.message--warning { border-left-color: var(--alerte); }

/* --- Filtres et listes -------------------------------------------------- */
.filtres { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.filtres label { font-size: .82rem; }

.liste-cours { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.cours-ligne {
  display: flex; gap: .9rem; align-items: flex-start;
  padding: .85rem 1rem; background: var(--surface);
  border: 1px solid var(--bordure); border-left-width: 4px; border-radius: var(--rayon);
}
.cours-ligne__corps { flex: 1; min-width: 0; }
.cours-ligne__titre { font-weight: 600; text-decoration: none; color: var(--texte); }
.cours-ligne__titre:hover { text-decoration: underline; }
.cours-ligne mark { background: var(--accent); color: var(--accent-contraste); padding: 0 .15rem; border-radius: 3px; }

/* --- Contenu rendu ------------------------------------------------------ */
.rendu { line-height: 1.7; overflow-wrap: break-word; }
.rendu img { max-width: 100%; height: auto; border-radius: var(--rayon); }
.rendu pre {
  background: var(--surface-2); padding: .9rem; border-radius: var(--rayon);
  overflow-x: auto; font-size: .9rem;
}
.rendu code { background: var(--surface-2); padding: .1rem .3rem; border-radius: 4px; font-size: .92em; }
.rendu pre code { background: none; padding: 0; }
.rendu blockquote { margin: 1rem 0; padding: .1rem 1rem; border-left: 3px solid var(--bordure); color: var(--texte-doux); }
.rendu table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.rendu th, .rendu td { border: 1px solid var(--bordure); padding: .45rem .65rem; text-align: left; }
.rendu th { background: var(--surface-2); }

/* --- Barre de formatage ------------------------------------------------- */
.barre-format {
  display: flex; flex-wrap: wrap; gap: .2rem; align-items: center;
  padding: .35rem; margin-bottom: .4rem;
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}
.barre-format button {
  min-width: 2.1rem; height: 2.1rem; padding: 0 .45rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--texte);
  font: inherit; font-size: .9rem; cursor: pointer;
}
.barre-format button:hover { background: var(--surface-2); border-color: var(--bordure); }
.barre-format button:active { background: var(--bordure); }
.barre-format__separateur {
  width: 1px; height: 1.3rem; margin: 0 .25rem; background: var(--bordure);
}

kbd {
  padding: .05rem .3rem; border: 1px solid var(--bordure); border-radius: 4px;
  background: var(--surface-2); font-family: inherit; font-size: .85em;
}

/* --- Éditeur ------------------------------------------------------------ */
.editeur { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; align-items: start; }
.editeur textarea { min-height: 60vh; }
.apercu { min-height: 60vh; overflow-y: auto; max-height: 75vh; }
.etat-sauvegarde { font-size: .82rem; color: var(--texte-doux); min-height: 1.2em; }

/* --- Diff --------------------------------------------------------------- */
.diff {
  font-family: ui-monospace, Menlo, monospace; font-size: .85rem;
  margin: .8rem 0 0; border: 1px solid var(--bordure); border-radius: var(--rayon);
  overflow-x: auto; background: var(--surface-2);
}
/* pre-wrap sur la ligne, pas sur le conteneur : sinon l'indentation du
   gabarit s'ajouterait à celle du contenu. */
.diff__ligne { padding: .05rem .5rem; white-space: pre-wrap; min-height: 1.2em; }
.diff__ligne--ajout { background: color-mix(in srgb, var(--succes) 18%, transparent); }
.diff__ligne--retrait { background: color-mix(in srgb, var(--erreur) 18%, transparent); }
.diff__ligne--entete { color: var(--texte-doux); font-weight: 600; }

/* --- Frise -------------------------------------------------------------- */
.frise__mois { border-left: 2px solid var(--bordure); padding-left: 1.1rem; margin-left: .4rem; }
.frise__titre { font-size: 1rem; margin: 0 0 .6rem; text-transform: capitalize; }

/* --- Tableaux (suivi) --------------------------------------------------- */
.tableau { width: 100%; border-collapse: collapse; }
.tableau th, .tableau td { padding: .55rem .7rem; border-bottom: 1px solid var(--bordure); text-align: left; }
.tableau th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--texte-doux); }
.tableau td.nombre, .tableau th.nombre { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 800px) {
  .editeur { grid-template-columns: 1fr; }
  .editeur textarea, .apercu { min-height: 40vh; }
  .barre { gap: .5rem; }
  .barre__fin { width: 100%; margin-left: 0; justify-content: flex-end; }
}

@media print {
  .barre, .messages, .rangee--actions { display: none; }
}
