/* Enquête 18-30 : feuille de style publique, mobile d'abord.
   Direction (17.11.2026) : inspirée d'une application de sondage mobile sobre. Fond chaud gris-beige,
   « feuille » centrale, réponses en lignes à fin contour, sélection corail, choix multiples en puces,
   barre d'actions avec bouton retour carré et bouton principal noir.
   Le fonctionnement et les questions ne changent pas. Contrastes vérifiés (docs/ux/ACCESSIBILITY.md). */

:root {
  --page: #E0DCD7;
  --sheet: #ECE9E5;
  --ink: #161616;
  --muted: #57534E;
  --line: #2A2A2A;
  --soft: #D8D4CF;
  --track: #CFCAC4;
  --accent: #F07050;
  --accent-ink: #161616;
  --dark: #141414;
  --dark-ink: #FFFFFF;
  --error: #A11B1B;
  --error-soft: #F6E7E4;
  --focus: #1D4ED8;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max: 30rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0E0E0D;
    --sheet: #1D1C1B;
    --ink: #F2F0ED;
    --muted: #B5B0AA;
    --line: #D9D5D0;
    --soft: #2E2C2A;
    --track: #3A3835;
    --accent: #F07A58;
    --accent-ink: #161616;
    --dark: #F2F0ED;
    --dark-ink: #141414;
    --error: #F19A9A;
    --error-soft: #2E1F1C;
    --focus: #8AB4FF;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
/* La barre d'actions collée ne doit jamais masquer l'élément qui a le focus (WCAG 2.4.11). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 4rem; scroll-padding-bottom: 10rem; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
main:focus, h1:focus { outline: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.skip-link { position: absolute; left: .5rem; top: -4rem; background: var(--sheet); color: var(--ink); padding: .75rem 1rem; z-index: 20; border-radius: var(--radius); border: 1px solid var(--line); }
.skip-link:focus { top: .5rem; }

/* Feuille centrale : plein écran sur téléphone, carte arrondie sur grand écran */
.sheet { min-height: 100vh; min-height: 100dvh; background: var(--sheet); display: flex; flex-direction: column; }
@media (min-width: 40rem) {
  body { padding: 2.5rem 1rem; }
  .sheet { max-width: 34rem; margin: 0 auto; min-height: calc(100vh - 5rem); border-radius: 28px; overflow: clip; }
}

/* En-tête : titre de l'enquête + fermer */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--sheet); }
.topbar-inner { max-width: var(--max); margin: 0 auto; padding: .9rem 1.25rem .4rem; min-height: 3.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font-size: .9375rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.close { flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; color: var(--ink); border-radius: 50%; }
.close:hover { background: var(--soft); }

.mode-banner { margin: 0 1.25rem; padding: .4rem .75rem; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: .8125rem; text-align: center; }
@media (min-width: 40rem) { .mode-banner { margin: 0 auto; width: calc(100% - 2.5rem); max-width: calc(var(--max) - 2.5rem); } }

/* Progression : « Étape 5/20 (25 %) » + fine ligne */
.progress-wrap { margin: .25rem 0 1.75rem; }
.progress-text { margin: 0 0 .5rem; font-size: .8125rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-pct { font-weight: 400; color: var(--muted); }
.progress { display: block; width: 100%; height: 2px; border: 0; background: var(--track); appearance: none; -webkit-appearance: none; }
.progress::-webkit-progress-bar { background: var(--track); }
.progress::-webkit-progress-value { background: var(--ink); transition: width .3s ease; }
.progress::-moz-progress-bar { background: var(--ink); }

.page { flex: 1; width: 100%; max-width: var(--max); margin: 0 auto; padding: .75rem 1.25rem 1.5rem; }

/* Typographie */
h1, .q-title { font-size: 1.625rem; line-height: 1.22; font-weight: 700; margin: 0 0 1.25rem; letter-spacing: -.02em; }
h2 { font-size: 1rem; line-height: 1.4; font-weight: 600; margin: 1.5rem 0 .4rem; }
.q-title-sm { display: block; font-size: 1.0625rem; line-height: 1.35; font-weight: 600; margin: 0 0 .75rem; letter-spacing: -.01em; }
.lead { font-size: 1rem; color: var(--muted); }
.intro { color: var(--muted); margin: -.5rem 0 1.25rem; }
.hint { color: var(--muted); font-size: .875rem; margin: -.5rem 0 1rem; }
p { margin: 0 0 1rem; }
.section-chip { margin: 0 0 .5rem; color: var(--muted); font-size: .8125rem; font-weight: 500; }

/* Accueil (écran de départ) */
.hero { padding-top: .75rem; }
.hero h1 { font-size: 2rem; line-height: 1.15; margin-bottom: 1rem; }
.facts { list-style: none; padding: 0; margin: 1.25rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .9375rem; font-weight: 500; }
.facts li { display: inline-flex; align-items: center; gap: .4rem; }
.is-home .page { display: flex; flex-direction: column; }
.is-home .actions-sticky { margin-top: auto; }

/* Consentement */
.summary { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.summary li { padding: .8rem 0; border-bottom: 1px solid var(--track); }
.summary li:first-child { border-top: 1px solid var(--track); }
.summary strong { display: block; font-weight: 600; margin-bottom: .1rem; }
.details { border: 1px solid var(--line); border-radius: var(--radius); padding: 0 1rem; margin-bottom: 1.25rem; }
.details summary { cursor: pointer; font-weight: 600; min-height: 50px; display: flex; align-items: center; }
.details[open] summary { border-bottom: 1px solid var(--track); margin-bottom: .5rem; }
.info-blocks h2 { font-size: .9375rem; margin-top: 1rem; }
.info-blocks p { font-size: .9375rem; color: var(--muted); }
.notice { background: var(--soft); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.25rem; }
.notice p { margin: 0; }
.field-check { display: flex; gap: .75rem; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.field-check input { width: 1.25rem; height: 1.25rem; margin: .1rem 0 0; accent-color: var(--dark); flex: none; }
.field-check label { font-weight: 500; cursor: pointer; }
.field-check.has-error { border-color: var(--error); border-width: 2px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Questions */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; width: 100%; }
.question { margin: 0 0 1.5rem; }

/* Choix unique : lignes pleine largeur à fin contour, rond à gauche */
.options { display: grid; gap: .5rem; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option label {
  display: flex; align-items: center; gap: .7rem;
  min-height: 48px; padding: .7rem .95rem;
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: .9375rem; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color .12s ease;
}
.option label:hover { background: var(--soft); }
.option input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Contour sombre conservé à la sélection : le corail seul n'atteint que 2,4:1 sur la feuille claire (WCAG 1.4.11). */
.option input:checked + label { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-ink); font-weight: 500; }
.mark { flex: none; width: 1rem; height: 1rem; border: 1.5px solid var(--line); border-radius: 50%; display: grid; place-items: center; }
.option input[type="checkbox"] + label .mark { border-radius: 4px; }
.option input:checked + label .mark { border-color: var(--accent-ink); background: var(--accent-ink); }
.option input[type="radio"]:checked + label .mark::after { content: ""; width: .375rem; height: .375rem; border-radius: 50%; background: var(--accent); }
.option input[type="checkbox"]:checked + label .mark::after { content: ""; width: .25rem; height: .5rem; border: solid var(--accent); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.option-text { flex: 1; }
.option-aside label { border-style: dashed; }
.option-aside { margin-top: .25rem; }

/* Choix multiple : puces qui se répartissent sur plusieurs lignes ; la coche reste visible quand c'est choisi */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips .option label { min-height: 44px; padding: .55rem .9rem; border-radius: 14px; gap: .45rem; }
.chips .mark { display: none; }
.chips .option input:checked + label::before { content: "✓"; font-weight: 700; }
.chips .option-exclusive, .chips .option-aside { flex-basis: 100%; }
.chips .option-exclusive label { border-style: dashed; }
.other-wrap { flex-basis: 100%; margin: .1rem 0 .2rem; }
.other-wrap[hidden] { display: none; }
input[type="text"], input[type="email"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; min-height: 48px;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 8rem; }
.counter { margin-top: .4rem; text-align: right; font-size: .8125rem; }

/* Échelle des leviers : une carte par ligne */
.cards { display: grid; gap: 1.5rem; margin-bottom: 1rem; }
.card .question { margin: 0; }
.card-flat { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin: 1.5rem 0; }
.card-flat h2 { margin-top: 0; }
.scale { gap: .4rem; }
.scale .option label { min-height: 44px; padding: .5rem .9rem; }
@media (min-width: 40rem) {
  .scale { grid-template-columns: repeat(5, 1fr); }
  .scale .option label { flex-direction: column; justify-content: center; text-align: center; gap: .3rem; min-height: 72px; padding: .5rem .3rem; font-size: .8125rem; }
  .scale .option-aside { grid-column: 1 / -1; margin-top: .1rem; }
  .scale .option-aside label { flex-direction: row; justify-content: flex-start; text-align: left; min-height: 44px; padding: .5rem .9rem; }
}

/* Erreurs : icône + texte, jamais la couleur seule */
.error-summary { border: 2px solid var(--error); background: var(--error-soft); border-radius: var(--radius); padding: .85rem 1rem; margin: 0 0 1.25rem; }
.error-summary:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.error-summary p, .error-summary ul { margin: 0; }
.error-summary ul { padding-left: 1.25rem; margin-top: .35rem; }
.error-summary a { color: var(--ink); font-weight: 500; }
.error-summary-title { font-weight: 600; }
.field-error { color: var(--error); font-weight: 600; font-size: .875rem; margin: -.4rem 0 .7rem; }
.error-icon { display: inline-grid; place-items: center; width: 1.125rem; height: 1.125rem; border-radius: 50%; background: var(--error); color: var(--sheet); font-size: .75rem; font-weight: 700; margin-right: .2rem; vertical-align: -.1em; }
.has-error .options .option label { border-color: var(--error); border-width: 2px; }

/* Barre d'actions : bouton retour carré + bouton principal */
.actions { display: flex; flex-direction: column; gap: .35rem; margin-top: 1.5rem; }
.actions-row { display: flex; gap: .6rem; align-items: stretch; }
.actions-sticky {
  position: sticky; bottom: 0; z-index: 4;
  margin: 1.5rem -1.25rem -1.5rem; padding: .8rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--sheet);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 52px; padding: .75rem 1.25rem; width: 100%;
  border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 1rem; text-decoration: none;
  cursor: pointer; touch-action: manipulation; transition: filter .12s ease, background-color .12s ease;
}
.btn-primary { background: var(--dark); color: var(--dark-ink); }
.btn-primary:hover { filter: brightness(1.25); }
.btn-start { background: var(--accent); color: var(--accent-ink); }
.btn-start:hover { filter: brightness(1.05); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--soft); }
.btn-quiet { background: transparent; color: var(--muted); min-height: 44px; font-weight: 500; font-size: .875rem; text-decoration: underline; text-underline-offset: .2em; }
.btn-quiet:hover { color: var(--ink); }
.btn-danger { background: var(--error); color: var(--sheet); }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn-back { flex: none; display: grid; place-items: center; width: 52px; min-height: 52px; border-radius: var(--radius); background: var(--soft); color: var(--ink); }
.btn-back:hover { filter: brightness(.96); }

/* Texte long */
.prose h2 { margin-top: 1.75rem; }
.prose ul { padding-left: 1.25rem; }
.prose code { font-size: .9em; background: var(--soft); padding: .05em .3em; border-radius: 4px; }

.footer { width: 100%; max-width: var(--max); margin: 0 auto; padding: 1rem 1.25rem 1.5rem; color: var(--muted); font-size: .75rem; }
.footer p { margin: 0 0 .3rem; }
.footer a { color: var(--muted); }

/* Transition discrète ; translation seule : si l'animation est gelée (onglet en arrière-plan), le contenu reste lisible. */
.enter { animation: enter .2s ease-out both; }
@keyframes enter { from { transform: translateY(6px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Contraste élevé Windows */
@media (forced-colors: active) {
  .option input:checked + label { border: 3px solid Highlight; }
  .mark { border-color: CanvasText; }
  .option input:checked + label .mark { background: Highlight; }
  .progress { border: 1px solid CanvasText; }
}
