/* BTSENPOCHE — style commun : couleurs, typographie et composants.
   Identité « Savane » (choisie le 2026-11-16) : vert profond, terre cuite, fond crème.
   Les couleurs sont définies UNE fois, ici, sous forme de variables ; aucune autre
   feuille n'écrit de couleur en dur. Deux thèmes : clair (par défaut) et sombre.
   Le thème suit le réglage de l'appareil ; le bouton de l'en-tête pose
   data-theme="clair" ou "sombre" sur <html> et l'emporte. */

/* ---------- Couleurs : thème clair ---------- */
:root, [data-theme="clair"] {
  --fond: #fffdf8;            /* arrière-plan de la page (crème) */
  --surface: #f4f1e8;         /* cartes, bandeaux */
  --surface-2: #e9e4d6;       /* survol, en-têtes de tableau */
  --texte: #1c2218;
  --texte-doux: #55604f;      /* texte secondaire */
  --bordure: #d9d4c3;         /* séparations décoratives */
  --bordure-forte: #767c66;   /* contour des champs (contraste 3:1) */
  --accent: #1e6b3a;          /* action principale, liens (vert profond) */
  --sur-accent: #ffffff;      /* texte posé sur --accent */
  --accent-doux: #e1f0e4;     /* fond teinté */
  --second: #a44a12;          /* mise en valeur : progression, nouveauté (terre cuite) */
  --sur-second: #ffffff;
  --succes: #17693a;   --succes-fond: #e4f4ea;
  --attention: #8a5a00; --attention-fond: #fff3d6;
  --danger: #b3261e;   --danger-fond: #fde8e6;
  color-scheme: light;
}

/* ---------- Couleurs : thème sombre ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --fond: #121610; --surface: #1b2118; --surface-2: #252d21;
    --texte: #eceee6; --texte-doux: #aeb8a4;
    --bordure: #333d2d; --bordure-forte: #7f8b74;
    --accent: #7fd49a; --sur-accent: #0b2414; --accent-doux: #183624;
    --second: #f0a868; --sur-second: #2b1403;
    --succes: #7ad79a; --succes-fond: #12301f;
    --attention: #f2c56b; --attention-fond: #3a2c0c;
    --danger: #ffa198; --danger-fond: #401816;
    color-scheme: dark;
  }
}
[data-theme="sombre"] {
  --fond: #121610; --surface: #1b2118; --surface-2: #252d21;
  --texte: #eceee6; --texte-doux: #aeb8a4;
  --bordure: #333d2d; --bordure-forte: #7f8b74;
  --accent: #7fd49a; --sur-accent: #0b2414; --accent-doux: #183624;
  --second: #f0a868; --sur-second: #2b1403;
  --succes: #7ad79a; --succes-fond: #12301f;
  --attention: #f2c56b; --attention-fond: #3a2c0c;
  --danger: #ffa198; --danger-fond: #401816;
  color-scheme: dark;
}

/* ---------- Mesures ---------- */
:root {
  --rayon: .625rem;
  --rayon-petit: .375rem;
  --largeur: 62rem;
  --pas: 1rem;
  --ombre: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .06);
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --police-fixe: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --cible: 2.75rem;           /* taille minimale d'une zone à toucher (44 px) */
  --nav-basse: 0rem;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4rem; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 1rem;
  line-height: 1.55;
  padding-bottom: var(--nav-basse);
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; text-wrap: balance; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2.1rem); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin-top: 2rem; }
h3 { font-size: 1.08rem; margin-top: 1.4rem; }
p { margin: 0 0 1rem; max-width: 68ch; }
/* Texte courant justifié, avec césure française (lang="fr") : sans elle, la justification
   creuse de grands blancs sur téléphone. Titres, tableaux, champs et blocs centrés gardent
   leur alignement ; un mot trop long (adresse, code) passe à la ligne plutôt que de déborder. */
p, li, dd, blockquote, figcaption { text-align: justify; -webkit-hyphens: auto; hyphens: auto; overflow-wrap: break-word; }
.pied p, .vide-bloc p, .erreur-bloc p, .admin-tache p, .connexion-liens p, p.inscription-deja { text-align: inherit; }
.carte-titre, .surtitre { text-align: start; -webkit-hyphens: manual; hyphens: manual; }
a { color: var(--accent); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--rayon-petit); }
::selection { background: var(--accent); color: var(--sur-accent); }
.discret { color: var(--texte-doux); }
.petit { font-size: .875rem; }
.code { font-family: var(--police-fixe); font-size: .9em; }
.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.evitement { position: absolute; left: -999rem; }
.evitement:focus { left: 1rem; top: 1rem; z-index: 50; background: var(--fond); padding: .5rem 1rem; }

/* ---------- Icônes et logo ---------- */
.icone { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.22em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logo { display: inline-flex; align-items: center; gap: .5rem; color: var(--texte); text-decoration: none; font-weight: 800; letter-spacing: .01em; font-size: 1.1rem; }
.logo-signe { width: 1.9rem; height: 1.9rem; flex: none; }
.logo-poche { fill: var(--accent); }
.logo-feuille { fill: var(--second); }
.logo-trait { fill: none; stroke: var(--sur-accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.logo-nom span { font-weight: 500; }

/* Bouton de thème : la lune en thème clair, le soleil en thème sombre. */
.bascule-soleil, .bascule-theme.est-sombre .bascule-lune { display: none; }
.bascule-theme.est-sombre .bascule-soleil { display: inline; }

/* ---------- Structure de page ---------- */
.entete { position: sticky; top: 0; z-index: 20; background: var(--fond); border-bottom: 1px solid var(--bordure); }
.entete-interieur { max-width: var(--largeur); margin-inline: auto; padding: .55rem var(--pas); display: flex; align-items: center; gap: .75rem; }
.entete-nav { display: none; gap: .25rem; margin-left: 1rem; }
.entete-nav a { padding: .55rem .8rem; border-radius: var(--rayon-petit); color: var(--texte); text-decoration: none; font-weight: 600; }
.entete-nav a:hover { background: var(--surface); }
.entete-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-doux); }
.entete-fin { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.contenu { width: 100%; max-width: var(--largeur); margin-inline: auto; padding: 1.4rem var(--pas) 2.5rem; flex: 1; }
.pied { border-top: 1px solid var(--bordure); padding: 1.2rem var(--pas); text-align: center; color: var(--texte-doux); font-size: .9rem; }
.pied p { margin: 0 auto; }
.pied-liens { display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem 1rem; margin-bottom: .6rem; }
.pied-liens a { color: var(--texte-doux); padding: .35rem 0; }
mark { background: var(--attention-fond); color: var(--texte); padding: 0 .1em; border-radius: 2px; font-weight: 600; }
.surtitre { color: var(--texte-doux); font-weight: 600; margin-bottom: .2rem; }
.liste-simple { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.liste-simple li { padding: .55rem 0; border-bottom: 1px solid var(--bordure); }
.pagination { display: flex; justify-content: space-between; gap: 1rem; margin-block: 1.5rem; }
@media (min-width: 48rem) { .entete-nav { display: flex; } }

/* Compte dans l'en-tête : sur téléphone, « Connexion » et « Mon espace » sont dans la barre du bas. */
.entete .entete-compte, .entete .entete-deconnexion, .entete .entete-inscription { display: none; }
.entete-deconnexion { margin: 0; }
.entete-compte[aria-current="page"] { background: var(--accent-doux); }
@media (min-width: 23rem) { .entete .entete-inscription { display: inline-flex; } }
@media (min-width: 48rem) { .entete .entete-compte { display: inline-flex; } .entete .entete-deconnexion { display: block; } }

/* Pages de formulaire (comptes) : colonne étroite, code à 6 chiffres, blocs repliables. */
.etroit { max-width: 34rem; margin-inline: auto; }
input.champ-code { font-size: 1.5rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; max-width: 14rem; }
summary { cursor: pointer; padding-block: .6rem; font-weight: 600; color: var(--accent); }
details[open] > summary { margin-bottom: .5rem; }
.mot-de-passe { display: flex; gap: .4rem; }
.mot-de-passe input { flex: 1; min-width: 0; }
.mot-de-passe .bouton { flex: none; }
input[type="file"] { width: 100%; padding: .5rem 0; font: inherit; color: var(--texte); }

/* Navigation basse (téléphone) : les entrées principales à portée de pouce. */
.nav-basse { position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; background: var(--fond); border-top: 1px solid var(--bordure); padding-bottom: env(safe-area-inset-bottom); }
.nav-basse a { flex: 1; min-height: 3.5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; font-size: .72rem; font-weight: 600; color: var(--texte-doux); text-decoration: none; }
.nav-basse a[aria-current="page"] { color: var(--accent); }
.nav-basse a[aria-current="page"] .icone { stroke-width: 2.5; }
.avec-nav-basse { --nav-basse: 3.5rem; }
@media (min-width: 48rem) { .nav-basse { display: none; } .avec-nav-basse { --nav-basse: 0rem; } }

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: var(--cible); padding: .55rem 1.1rem;
  border: 2px solid var(--accent); border-radius: var(--rayon);
  background: var(--accent); color: var(--sur-accent);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
  transition: filter .12s, background-color .12s;
}
.bouton:hover { filter: brightness(1.1); }
.bouton:active { filter: brightness(.95); }
.bouton-secondaire { background: transparent; color: var(--accent); }
.bouton-secondaire:hover { background: var(--accent-doux); filter: none; }
.bouton-discret { background: transparent; border-color: transparent; color: var(--accent); }
.bouton-discret:hover { background: var(--surface); filter: none; }
.bouton-danger { background: var(--danger); border-color: var(--danger); color: var(--fond); }
.bouton-large { width: 100%; }
.bouton-icone { padding: .55rem; min-width: var(--cible); }
.bouton:disabled, .bouton[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* ---------- Formulaires ---------- */
.champ { display: grid; gap: .3rem; margin-bottom: 1rem; }
.champ > label, .champ > legend { font-weight: 600; }
.champ-aide { color: var(--texte-doux); font-size: .875rem; margin: 0; }
.champ-erreur { color: var(--danger); font-size: .9rem; font-weight: 600; margin: 0; display: flex; gap: .35rem; align-items: flex-start; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: var(--cible); padding: .55rem .75rem;
  border: 1.5px solid var(--bordure-forte); border-radius: var(--rayon);
  background: var(--fond); color: var(--texte); font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.case { display: flex; gap: .6rem; align-items: flex-start; min-height: var(--cible); padding-block: .5rem; }
.case input { width: 1.25rem; height: 1.25rem; margin: .15rem 0 0; accent-color: var(--accent); flex: none; }
.recherche { display: flex; gap: .5rem; }
.recherche input { flex: 1; }

/* ---------- Messages ---------- */
.message { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--bordure); border-left: .3rem solid var(--texte-doux); border-radius: var(--rayon); padding: .7rem .9rem; background: var(--surface); margin: 0 0 1rem; max-width: none; }
.message-succes { border-color: var(--succes); background: var(--succes-fond); }
.message-attention { border-color: var(--attention); background: var(--attention-fond); }
.message-erreur { border-color: var(--danger); background: var(--danger-fond); }
.message-info { border-color: var(--accent); background: var(--accent-doux); }

/* ---------- Étiquettes ---------- */
.etiquette { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 99rem; border: 1px solid var(--bordure-forte); background: var(--fond); color: var(--texte); font-size: .8rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.etiquette .icone { width: 1em; height: 1em; vertical-align: 0; }
.etiquette-accent { border-color: var(--accent); color: var(--accent); background: var(--accent-doux); }
.etiquette-succes { border-color: var(--succes); color: var(--succes); background: var(--succes-fond); }
.etiquette-attention { border-color: var(--attention); color: var(--attention); background: var(--attention-fond); }
.etiquette-danger { border-color: var(--danger); color: var(--danger); background: var(--danger-fond); }
.etiquette-pleine { border-color: var(--second); background: var(--second); color: var(--sur-second); }

/* ---------- Cartes ---------- */
.carte { display: block; background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 1rem; color: inherit; }
a.carte { text-decoration: none; transition: border-color .12s, box-shadow .12s; }
a.carte:hover { border-color: var(--accent); box-shadow: var(--ombre); }
.carte-titre { font-size: 1.05rem; font-weight: 700; margin: 0 0 .25rem; }
.carte-meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; color: var(--texte-doux); font-size: .875rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.carte-meta li { display: inline-flex; align-items: center; gap: .3rem; }
.grille { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); margin: 0 0 1.5rem; padding: 0; list-style: none; }
.chiffres { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); margin: 1.2rem 0; padding: 0; list-style: none; }
.chiffres li { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: .9rem; text-align: center; color: var(--texte-doux); font-size: .9rem; }
.chiffres strong { display: block; font-size: 1.7rem; line-height: 1.2; color: var(--texte); font-variant-numeric: tabular-nums; }

/* Carte de ressource : nature, titre, année, durée, vues, corrigé. */
.ressource { display: grid; gap: .45rem; }
.ressource-entete { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.ressource-verrou { margin-left: auto; color: var(--texte-doux); }
/* Bandeau « prochaine session » (Mon examen, tableau de bord). */
.examen-session { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; margin: 0 0 1.25rem; border-left: .3rem solid var(--second); }
.examen-session p { margin: 0; flex: 1 1 16rem; }
.examen-session .examen-jours { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .4rem; color: var(--second); font-size: 1.35rem; font-variant-numeric: tabular-nums; }

/* ---------- Fil d'Ariane ---------- */
.ariane { font-size: .875rem; margin-bottom: 1rem; }
.ariane ol { display: flex; flex-wrap: wrap; gap: .15rem .35rem; list-style: none; margin: 0; padding: 0; }
.ariane li + li::before { content: "›"; margin-right: .35rem; color: var(--texte-doux); }
.ariane [aria-current="page"] { color: var(--texte-doux); }

/* ---------- Onglets ---------- */
/* Les onglets passent à la ligne plutôt que de défiler : sur téléphone, un onglet caché hors de l'écran passe inaperçu. */
.onglets { display: flex; flex-wrap: wrap; gap: 0 .25rem; border-bottom: 1px solid var(--bordure); margin: 1.2rem 0 1rem; }
.onglets a, .onglets button { flex: 1 1 auto; justify-content: center; text-align: center; min-height: var(--cible); padding: .5rem .9rem; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--texte-doux); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; }
.onglets [aria-selected="true"], .onglets [aria-current="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.onglets a:hover, .onglets button:hover { color: var(--texte); }

/* ---------- Tableaux ---------- */
.tableau { width: 100%; border-collapse: collapse; font-size: .95rem; margin: 0 0 1.5rem; }
.tableau caption { text-align: left; font-weight: 700; padding-bottom: .5rem; }
.tableau th, .tableau td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--bordure); vertical-align: top; }
.tableau thead th { background: var(--surface-2); font-size: .85rem; white-space: nowrap; }
.tableau .nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tableau tfoot td, .tableau tfoot th { font-weight: 700; background: var(--surface); }
.tableau tbody tr:hover { background: var(--surface); }
/* Sur téléphone, chaque ligne devient une carte : le libellé de la colonne (data-libelle) précède la valeur. */
@media (max-width: 40rem) {
  .tableau-repliable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tableau-repliable, .tableau-repliable tbody, .tableau-repliable tfoot, .tableau-repliable tr, .tableau-repliable td, .tableau-repliable th { display: block; }
  .tableau-repliable caption { display: block; }
  .tableau-repliable tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem .75rem; border: 1px solid var(--bordure); border-radius: var(--rayon); margin-bottom: .6rem; padding: .6rem .75rem; background: var(--surface); }
  .tableau-repliable td, .tableau-repliable tbody th, .tableau-repliable tfoot th { border: 0; padding: 0; min-width: 0; overflow-wrap: anywhere; }
  .tableau-repliable td[data-libelle] { display: flex; flex-direction: column; text-align: left; font-weight: 600; }
  .tableau-repliable td[data-libelle]::before { content: attr(data-libelle); color: var(--texte-doux); font-size: .75rem; font-weight: 400; font-family: var(--police); }
  .tableau-repliable .principal { grid-column: 1 / -1; font-weight: 700; }
  .tableau-repliable thead tr { display: block; border: 0; padding: 0; margin: 0; }
  .tableau-repliable td.vide { display: none; }
}

/* ---------- Progression ---------- */
.progression { display: grid; gap: .3rem; margin-bottom: 1rem; }
.progression-libelle { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; font-weight: 600; }
progress { appearance: none; -webkit-appearance: none; width: 100%; height: .7rem; border: 0; border-radius: 99rem; background: var(--surface-2); overflow: hidden; color: var(--second); }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--second); border-radius: 99rem; }
progress::-moz-progress-bar { background: var(--second); border-radius: 99rem; }

/* ---------- États vides et chargement ---------- */
.vide-bloc { text-align: center; border: 1.5px dashed var(--bordure-forte); border-radius: var(--rayon); padding: 1.6rem 1rem; color: var(--texte-doux); margin-bottom: 1.5rem; }
.vide-bloc .icone { width: 2rem; height: 2rem; }
.vide-bloc p { margin-inline: auto; }
.vide-bloc strong { display: block; color: var(--texte); font-size: 1.05rem; margin: .3rem 0; }
.squelette { display: block; height: 1rem; border-radius: var(--rayon-petit); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: squelette 1.4s linear infinite; margin-bottom: .6rem; }
.squelette-court { width: 55%; }
@keyframes squelette { to { background-position: -200% 0; } }

/* ---------- Fenêtre de dialogue ---------- */
dialog { width: min(92vw, 30rem); border: 1px solid var(--bordure); border-radius: var(--rayon); background: var(--fond); color: var(--texte); padding: 1.2rem; box-shadow: var(--ombre); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin-top: 0; }

/* ---------- Descriptif hiérarchique d'une UE ---------- */
.descriptif { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.descriptif li { padding: .3rem 0 .3rem calc(var(--niveau, 1) * 1rem); border-bottom: 1px solid var(--bordure); }
.descriptif .niveau-0 { --niveau: 0; font-weight: 700; background: var(--surface); padding-inline: .6rem; margin-top: .6rem; border-radius: var(--rayon-petit); border: 0; }
.descriptif .niveau-1 { --niveau: 0.6; font-weight: 600; }
.descriptif .niveau-2 { --niveau: 1.6; }
.descriptif .niveau-3 { --niveau: 2.6; color: var(--texte-doux); }

/* ---------- Mouvement réduit, impression ---------- */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .entete, .pied, .nav-basse, .bouton, .evitement, .onglets { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .contenu { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .carte, .tableau thead th { background: none; }
}
