/* =====================================================================
   Questionnaire – CHU Besançon Franche-Comté
   Charte graphique du CHU : Sora, bleu1 / bleu2, aplats à angles droits,
   ni dégradé ni ombre. Accessibilité RGAA 4.1 niveau AA.
   ===================================================================== */

@font-face { font-family: "Sora"; src: url("../fonts/Sora-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Sora"; src: url("../fonts/Sora-SemiBold.otf") format("opentype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Sora"; src: url("../fonts/Sora-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }

:root {
  /* Tokens de la charte */
  --bleu1: #2c3494;
  --bleu2: #30c4ec;
  --noir: #000000;
  --blanc: #ffffff;
  --gris-fonce: #5a5a5a;
  --gris: #aaabaf;
  --rouge: #ee3225;
  --vert1: #006b77;
  --violet5: #121140;
  --fond-doux: #f2f3f9;      /* aplat clair dérivé de bleu1, sous texte noir */
  --font-sora: "Sora", Arial, sans-serif;

  --focus: var(--bleu1);
  --focus-sur-fonce: var(--blanc);
  --largeur: 50rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--blanc);
  color: var(--noir);
  font-family: var(--font-sora);
  font-size: 1rem;
  line-height: 1.6;
}

a { color: var(--bleu1); text-decoration: underline; text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }

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

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.evitement {
  position: absolute; left: 1rem; top: -10rem; z-index: 10;
  background: var(--bleu1); color: var(--blanc); padding: .75rem 1rem; font-weight: 600;
}
.evitement:focus { top: 1rem; outline-color: var(--focus-sur-fonce); }

.conteneur { max-width: var(--largeur); margin: 0 auto; padding: 0 1rem; }

/* ---------- En-tête ---------- */
.entete { border-bottom: 6px solid var(--bleu2); background: var(--blanc); }
.entete__in { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.entete__logo { display: block; width: 12.5rem; height: auto; }

main.conteneur { padding-top: 2.5rem; padding-bottom: 4rem; }
@media (min-width: 48rem) { main.conteneur { padding-top: 3.5rem; } }
main:focus { outline: none; }

.titre {
  color: var(--bleu1);
  font-size: 1.75rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em;
  margin: 0 0 1.5rem;
}
@media (min-width: 40rem) { .titre { font-size: 2.125rem; } }

/* ---------- Introduction ---------- */
.introduction p { margin: 0 0 1rem; }
.introduction__reperes {
  list-style: none; margin: 1.5rem 0; padding: 0;
  display: grid; gap: .5rem;
}
@media (min-width: 40rem) { .introduction__reperes { grid-template-columns: repeat(3, 1fr); } }
.introduction__reperes li {
  background: var(--fond-doux); border-left: 4px solid var(--bleu1);
  padding: .75rem 1rem; font-size: .9375rem;
}
.introduction__reperes strong { display: block; color: var(--bleu1); }

/* ---------- Mentions RGPD ---------- */
.rgpd { border: 1px solid var(--gris-fonce); margin: 0 0 2rem; }
.rgpd summary {
  cursor: pointer; padding: .875rem 1rem; font-weight: 600; color: var(--bleu1);
  list-style-position: inside;
}
.rgpd[open] summary { border-bottom: 1px solid var(--gris); }
.rgpd__contenu { padding: .25rem 1rem 1rem; font-size: .9375rem; }
.rgpd__contenu h3 { font-size: 1rem; color: var(--bleu1); margin: 1.25rem 0 .25rem; }
.rgpd__contenu p, .rgpd__contenu ul { margin: 0 0 .5rem; }

/* ---------- Encarts et alertes ---------- */
.encart { background: var(--fond-doux); border-left: 6px solid var(--bleu1); padding: 1rem 1.25rem; margin: 0 0 1.5rem; }
.encart p { margin: 0 0 .5rem; }
.encart p:last-child { margin: 0; }
.encart--succes { border-left-color: var(--vert1); }
.encart--info { background: var(--blanc); border: 2px solid var(--bleu1); }
.encart--info h2 { font-size: 1.125rem; color: var(--bleu1); margin: 0 0 .5rem; }

.alerte {
  border: 2px solid var(--rouge); border-left-width: 8px;
  padding: 1rem 1.25rem; margin: 0 0 2rem; background: var(--blanc);
}
.alerte:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.alerte__titre { font-size: 1.125rem; font-weight: 700; margin: 0 0 .5rem; }
.alerte ul { margin: 0; padding-left: 1.25rem; }
.alerte p { margin: 0; }

.legende-obligatoire { font-size: .9375rem; color: var(--gris-fonce); margin: 0 0 1rem; }
.obligatoire { color: var(--bleu1); font-weight: 700; }
.facultatif { color: var(--gris-fonce); font-weight: 400; }

/* ---------- Sections ---------- */
.section { margin: 0 0 3rem; }
.section__titre {
  display: flex; align-items: center; gap: .875rem;
  background: var(--bleu1); color: var(--blanc);
  font-size: 1.25rem; font-weight: 700; line-height: 1.3;
  padding: .75rem 1rem; margin: 0 0 1.25rem;
}
.section__num {
  flex: none; display: inline-grid; place-items: center;
  width: 2rem; height: 2rem; background: var(--bleu2); color: var(--noir); font-weight: 700;
}
.section__intro { font-size: .9375rem; color: var(--gris-fonce); margin: 0 0 1.5rem; padding-left: 1rem; }

/* ---------- Questions ---------- */
.question {
  border: 0; border-left: 3px solid transparent;
  margin: 0 0 2.25rem; padding: 0 0 0 calc(1rem - 3px); min-width: 0;
}
.question:last-child { margin-bottom: 0; }
.question--erreur { border-left-color: var(--rouge); }
.question__titre {
  display: block; padding: 0; margin: 0 0 .75rem;
  font-weight: 600; font-size: 1.0625rem; line-height: 1.45; color: var(--noir);
}
.question__aide, .question__condition, .question__compteur {
  font-size: .875rem; color: var(--gris-fonce); margin: -.25rem 0 .5rem;
}
.question__condition { font-style: normal; }
.question__message {
  font-weight: 600; margin: 0 0 .5rem; padding-left: 1.5rem; position: relative;
}
.question__message::before {
  content: "!"; position: absolute; left: 0; top: .1em;
  width: 1.125rem; height: 1.125rem; display: grid; place-items: center;
  background: var(--rouge); color: var(--noir); font-size: .75rem; font-weight: 700;
}
.question[hidden] { display: none; }

/* Choix */
.choix { display: grid; gap: .25rem; }
@media (min-width: 40rem) { .choix--colonnes { grid-template-columns: 1fr 1fr; column-gap: 1.5rem; } }
.choix__item { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .625rem; padding: .25rem 0; }
.choix__item > label { flex: 1; cursor: pointer; }
.choix__autre { flex-basis: 100%; padding-left: 2rem; }
.choix__autre[hidden] { display: none; }
.choix__autre label { display: block; font-size: .875rem; margin-bottom: .25rem; }

input[type="radio"], input[type="checkbox"] {
  flex: none; width: 1.25rem; height: 1.25rem; margin: .2rem 0 0;
  accent-color: var(--bleu1); cursor: pointer;
}

input[type="text"], textarea {
  width: 100%; font: inherit; color: var(--noir); background: var(--blanc);
  border: 1px solid var(--gris-fonce); border-radius: 0; padding: .625rem .75rem;
}
input[type="text"]:focus, textarea:focus { border-color: var(--bleu1); }
textarea { resize: vertical; min-height: 6rem; }
[aria-invalid="true"] { border-color: var(--rouge); }

/* Tableaux de réponses (q17) et échelles (q24) */
.ligne { border: 0; border-bottom: 1px solid var(--gris); margin: 0; padding: .75rem 0; min-width: 0; display: flow-root; }
.ligne:first-of-type { border-top: 1px solid var(--gris); }
.ligne legend { float: left; width: 100%; padding: 0; margin: 0 0 .5rem; font-size: .9375rem; }
.ligne__choix { clear: both; display: flex; flex-wrap: wrap; gap: .375rem 1.25rem; }
.ligne__item { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.ligne__item label { cursor: pointer; }
.ligne--manquante legend::after { content: " — réponse manquante"; font-weight: 600; }
@media (min-width: 48rem) {
  /* Tableau : libellé à gauche, colonnes de réponses alignées à droite */
  .ligne:not(.ligne--echelle) legend { width: 48%; margin: 0; padding-right: 1rem; }
  .ligne:not(.ligne--echelle) .ligne__choix {
    clear: none; margin-left: 48%;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); gap: .5rem;
  }
}

/* Échelle 0–10 : cases carrées cliquables */
.echelle__bornes {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .8125rem; color: var(--gris-fonce); margin: 0 0 .5rem;
}
.ligne--echelle { padding: 1rem 0 1.25rem; }
.ligne--echelle legend { margin-bottom: .75rem; }
.ligne--echelle .ligne__choix { display: grid; grid-template-columns: repeat(11, minmax(0, 3rem)); gap: .25rem; }
@media (min-width: 30rem) { .ligne--echelle .ligne__choix { gap: .5rem; } }
@media (max-width: 29.99rem) { .ligne--echelle .ligne__item label { padding: 0; font-size: .875rem; } }
.ligne--echelle .ligne__item { position: relative; display: block; }
.ligne--echelle .ligne__item input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0;
}
.ligne--echelle .ligne__item label {
  display: grid; place-items: center; height: 3rem; padding: 0 .25rem;
  border: 1px solid var(--gris-fonce); font-weight: 600; background: var(--blanc);
}
.ligne--echelle .ligne__item input:checked + label { background: var(--bleu1); border-color: var(--bleu1); color: var(--blanc); }
.ligne--echelle .ligne__item input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.ligne--echelle .ligne__item input:hover + label { border-color: var(--bleu1); border-width: 2px; }

/* ---------- Envoi ---------- */
.envoi { border-top: 6px solid var(--bleu2); padding-top: 2rem; margin-top: 1rem; }
.envoi p { font-size: .875rem; color: var(--gris-fonce); margin: 1rem 0 0; }
.bouton {
  font: inherit; font-weight: 700; font-size: 1.0625rem;
  background: var(--bleu1); color: var(--blanc);
  border: 2px solid var(--bleu1); border-radius: 0;
  padding: .875rem 1.75rem; cursor: pointer;
}
.bouton:hover { background: var(--violet5); border-color: var(--violet5); }
a.bouton { display: inline-block; text-decoration: none; }
.bouton--secondaire { background: var(--blanc); color: var(--bleu1); }
.bouton--secondaire:hover { background: var(--fond-doux); border-color: var(--bleu1); }

/* Piège à robots */
.piege { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Pied de page ---------- */
.pied { background: var(--bleu1); color: var(--blanc); font-size: .875rem; }
.pied__in { padding-top: 2rem; padding-bottom: 2rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.pied p { margin: 0; }
.pied a { color: var(--bleu2); }
.pied a:focus-visible { outline-color: var(--focus-sur-fonce); }

/* ---------- Espace d'exploitation ---------- */
.admin-barre { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 0 0 2rem; }
.admin-barre form { margin: 0; }
.chiffre-cle { font-size: 2.5rem; font-weight: 700; color: var(--bleu1); line-height: 1; }
.stat { margin: 0 0 2rem; }
.stat h3 { font-size: 1rem; margin: 0 0 .5rem; }
.stat table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.stat th, .stat td { text-align: left; padding: .375rem .5rem; border-bottom: 1px solid var(--gris); vertical-align: middle; }
.stat tbody th { font-weight: 400; }
.stat td.n, .stat th.n { text-align: right; white-space: nowrap; width: 4.5rem; }
.barre { display: block; width: 100%; min-width: 6rem; height: .75rem; background: var(--fond-doux); }
.barre rect { fill: var(--bleu1); }
.champ { margin: 0 0 1rem; }
.champ label { display: block; font-weight: 600; margin-bottom: .25rem; }
.champ input { max-width: 20rem; }
select { font: inherit; border: 1px solid var(--gris-fonce); border-radius: 0; padding: .5rem; background: var(--blanc); color: var(--noir); }

@media print {
  .entete, .pied, .envoi, .rgpd, .evitement { display: none; }
}

/* ---------- Questionnaire en plusieurs parties (si JavaScript actif) ---------- */
.progression {
  position: sticky; top: 0; z-index: 5;
  background: var(--blanc); border-bottom: 1px solid var(--gris);
  padding: .75rem 0; margin: 0 0 1.5rem;
}
.progression__texte { margin: 0 0 .5rem; font-size: .9375rem; }
.progression__texte strong { color: var(--bleu1); }
.progression__jauge { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.progression__jauge li { flex: 1; height: .5rem; background: var(--fond-doux); border: 1px solid var(--gris); }
.progression__jauge li.fait { background: var(--bleu1); border-color: var(--bleu1); }
.progression__jauge li.en-cours { background: var(--bleu2); border-color: var(--bleu1); }

.etape[hidden] { display: none; }
.section__titre:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.navigation-etapes {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  border-top: 6px solid var(--bleu2); padding-top: 2rem; margin-top: 2.5rem;
}
.navigation-etapes .bouton--suivant { margin-left: auto; }
.envoi[hidden] { display: none; }
.js .envoi { border-top: 0; padding-top: 0; margin-top: 0; }
.introduction[hidden] { display: none; }
.envoi__note { font-size: .875rem; color: var(--gris-fonce); text-align: right; margin: .75rem 0 0; }
