/* questionnaire.css : page « Démarrer mon projet » du site WebExpresso (lot QST-02).
   Source : Phase 1 _ Formulaire/questionnaire/src/ ; copié tel quel dans webexpresso site/questionnaire/css/ par
   outils/build_questionnaire.py. Couleurs du site WebExpresso converties en OKLCH ; contrastes mesurés (tests/questionnaire.py). */

:root {
    --fond: oklch(0.967 0.021 86);                /* crème du site WebExpresso */
    --surface: oklch(0.992 0.008 88);             /* feuille */
    --surface-choisie: oklch(0.932 0.036 80);     /* café au lait : choix coché, pastille de numéro */
    --texte: oklch(0.245 0.022 58);               /* espresso : écart de clarté 0,72 avec le fond */
    --texte-doux: oklch(0.43 0.026 60);           /* texte secondaire */
    --bleu: oklch(0.40 0.095 250);                /* bleu de l'enseigne : boutons et liens */
    --bleu-survol: oklch(0.35 0.09 251);
    --bleu-fonce: oklch(0.29 0.075 252);
    --ambre-trait: oklch(0.56 0.12 60);           /* caramel : repère d'interface, 3:1 au moins */
    --ambre-pale: oklch(0.62 0.12 62 / 0.4);
    --ligne: oklch(0.245 0.022 58 / 0.16);
    --bordure-champ: oklch(0.55 0.03 60);         /* 3:1 au moins sur le fond et sur la feuille */
    --erreur: oklch(0.50 0.15 27);
    --police-titre: 'Besley', Georgia, 'Times New Roman', serif;
    --police-texte: 'Andika', Verdana, 'Segoe UI', sans-serif;
    --rayon: 10px;
    --rayon-bloc: 14px;
    --rayon-pilule: 9999px;
    --gouttiere: 16px;
    --duree: 180ms;
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 1.5rem;
}

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font-family: var(--police-texte);
    font-size: 1.0625rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--bleu); text-underline-offset: 0.2em; }
a:hover { color: var(--bleu-fonce); }

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

h1, h2, h3 {
    font-family: var(--police-titre);
    color: var(--texte);
    line-height: 1.15;
    margin: 0;
    text-wrap: balance;
}

h1 {
    font-size: clamp(2.125rem, 1.5rem + 2.6vw, 3.25rem);
    font-weight: 700;
    letter-spacing: -0.018em;
}

h2 {
    font-size: clamp(1.5rem, 1.25rem + 1.1vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.015em;
}

/* Les titres de question se lisent comme du texte : police du texte, en gras. */
h3 {
    font-family: var(--police-texte);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0;
}

p { margin: 0; max-width: 65ch; text-wrap: pretty; }

/* ── Bandeau et pied ──────────────────────────────────────────────────────────────────────────────── */

.bandeau {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.75rem var(--gouttiere);
    border-bottom: 1px solid var(--ligne);
}

.marque {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 44px;
    font-family: var(--police-titre);
    font-weight: 700;
    font-size: 1.1875rem;
    letter-spacing: -0.01em;
    color: var(--bleu);
    text-decoration: none;
}

.marque img { display: block; width: auto; height: 26px; }

.langue {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0 1.125rem;
    border: 1px solid var(--bordure-champ);
    border-radius: var(--rayon-pilule);
    background: var(--surface);
    color: var(--bleu);
    font: 700 0.9375rem/1 var(--police-texte);
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--duree) var(--ease-out), background-color var(--duree) var(--ease-out), transform 100ms var(--ease-out);
}

.langue:active { transform: scale(0.97); }

.langue:hover { border-color: var(--bleu); }
.langue-bouton { display: none; }
.js-pret .langue-bouton { display: inline-flex; }
.js-pret .langue-lien { display: none; }

.pied {
    max-width: 72rem;
    margin: 4rem auto 0;
    padding: 1.5rem var(--gouttiere) 2.5rem;
    border-top: 1px solid var(--ligne);
    color: var(--texte-doux);
    font-size: 0.9375rem;
}

/* ── Mise en page ─────────────────────────────────────────────────────────────────────────────────── */

.cadre {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 var(--gouttiere);
}

.contenu { min-width: 0; padding-top: 2.5rem; }
.contenu-merci { max-width: 44rem; margin: 0 auto; padding-left: var(--gouttiere); padding-right: var(--gouttiere); }

.sommaire { padding-top: 2rem; }

.sommaire-titre {
    font-family: var(--police-texte);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--texte-doux);
    margin-bottom: 0.5rem;
}

.sommaire ol {
    list-style: none;
    counter-reset: etape;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--ligne);
}

.sommaire li { counter-increment: etape; border-bottom: 1px solid var(--ligne); }

.sommaire a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    padding: 0.5rem 0.75rem 0.5rem 0;
    color: var(--texte);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: border-color var(--duree) ease, color var(--duree) ease;
}

.sommaire a::before {
    content: counter(etape);
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    margin-left: 0.5rem;
    border: 1px solid var(--bordure-champ);
    border-radius: var(--rayon-pilule);
    color: var(--texte-doux);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    transition: background-color var(--duree) var(--ease-out), border-color var(--duree) var(--ease-out), color var(--duree) var(--ease-out);
}

.sommaire a:hover { color: var(--bleu); }
.sommaire a[aria-current="step"] { border-left-color: var(--ambre-trait); font-weight: 700; color: var(--bleu); }
.sommaire a[aria-current="step"]::before { border-color: var(--bleu); color: var(--bleu); }
.sommaire a.fait::before { background: var(--bleu); border-color: var(--bleu); color: var(--surface); }

@media (max-width: 959.98px) {
    .js-pret .sommaire { display: none; }
}

@media (min-width: 960px) {
    .cadre {
        display: grid;
        grid-template-columns: 16rem minmax(0, 44rem);
        gap: 3.5rem;
        justify-content: center;
        align-items: start;
    }
    .sommaire { position: sticky; top: 0; padding-top: 2.5rem; }
}

/* ── Introduction et brouillon ────────────────────────────────────────────────────────────────────── */

.intro { display: grid; gap: 1rem; }
.intro-texte { font-size: 1.125rem; }
.note { color: var(--texte-doux); font-size: 0.9375rem; }

.brouillon {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 1rem;
    border: 1px solid var(--ligne);
    border-left: 3px solid var(--ambre-trait);
    border-radius: var(--rayon-bloc);
    background: var(--surface);
}

.brouillon p { flex: 1 1 18rem; }

/* ── Étapes et questions ──────────────────────────────────────────────────────────────────────────── */

.formulaire { margin-top: 1rem; }

.etape {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--ligne);
}

.js .etape:not(.est-active) { display: none; }
.js .etape { margin-top: 2rem; }

/* Entrée d'une étape : seulement quand la personne change d'étape (classe posée par le script), jamais au chargement. */
.js .etape.entree { animation: etape-entree 240ms var(--ease-out) both; }

@keyframes etape-entree {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.etape-entete { display: grid; gap: 0.75rem; }
.etape-entete h2:focus { outline: none; }
.etape-entete h2:focus-visible { outline: 2px solid var(--bleu); outline-offset: 4px; }

.etape-numero {
    color: var(--texte-doux);
    font-size: 0.9375rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.etape-barre { display: flex; gap: 6px; max-width: 20rem; }
.etape-barre span { flex: 1; height: 6px; border-radius: var(--rayon-pilule); background: var(--ligne); }
.etape-barre span.faite { background: var(--ambre-pale); }
.etape-barre span.courante { background: var(--ambre-trait); }

.etape-intro { color: var(--texte-doux); }

.question { margin-top: 3rem; }

.question > h3 {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    font-size: 1.3125rem;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.3;
}

.question-numero {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.875rem;
    height: 1.875rem;
    margin-top: -0.0625rem;
    border-radius: var(--rayon-pilule);
    background: var(--surface-choisie);
    color: var(--bleu);
    font-family: var(--police-texte);
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.question-option {
    flex: none;
    align-self: center;
    padding: 0.125rem 0.625rem;
    border: 1px solid var(--bordure-champ);
    border-radius: var(--rayon-pilule);
    color: var(--texte-doux);
    font-family: var(--police-texte);
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0;
    line-height: 1.4;
}

.question > .aide { margin-top: 0.5rem; }

/* ── Champs ───────────────────────────────────────────────────────────────────────────────────────── */

.champ { margin: 1.5rem 0 0; }
fieldset.champ { border: 0; padding: 0; min-width: 0; }

.champ > label,
.champ > legend {
    display: block;
    padding: 0;
    margin-bottom: 0.375rem;
    font-weight: 700;
}

.requis { font-weight: 400; color: var(--texte-doux); font-size: 0.9375rem; }

.aide,
.exemple { color: var(--texte-doux); font-size: 0.9375rem; margin-bottom: 0.5rem; }
.exemple { font-style: italic; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
textarea {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 0.6875rem 0.875rem;
    border: 1px solid var(--bordure-champ);
    border-radius: var(--rayon);
    background: var(--surface);
    color: var(--texte);
    font: inherit;
    transition: border-color var(--duree) var(--ease-out), box-shadow var(--duree) var(--ease-out);
}

textarea { min-height: 7.5rem; resize: vertical; }

input:hover,
textarea:hover { border-color: var(--bleu); }

input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--bleu);
    outline-offset: 1px;
    border-color: var(--bleu);
    box-shadow: 0 0 0 4px oklch(0.40 0.095 250 / 0.16);
}

input[aria-invalid="true"]:not([type="radio"]):not([type="checkbox"]),
textarea[aria-invalid="true"] { border-color: var(--erreur); box-shadow: inset 0 0 0 1px var(--erreur); }
.groupe:has([aria-invalid="true"]) .option,
.champ-case:has([aria-invalid="true"]) .option { border-color: var(--erreur); }

.options { display: grid; gap: 0.5rem; }

/* Choix courts (classe posée par build_questionnaire.py) : côte à côte quand la place le permet */
.options-courtes { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }

.option {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-height: 48px;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--bordure-champ);
    border-radius: var(--rayon);
    background: var(--surface);
    cursor: pointer;
    transition: background-color var(--duree) var(--ease-out), border-color var(--duree) var(--ease-out), box-shadow var(--duree) var(--ease-out);
}

.option:hover { border-color: var(--bleu); }
.option:has(input:checked) {
    background: var(--surface-choisie);
    border-color: var(--bleu);
    box-shadow: inset 4px 0 0 var(--ambre-trait);
}
.option:has(input:focus-visible) { outline: 2px solid var(--bleu); outline-offset: 2px; }

/* Rond et carré dessinés ici : même rendu sur tous les navigateurs, même balisage et même clavier */
.option input {
    flex: none;
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0.125rem 0 0;
    padding: 0;
    border: 2px solid var(--bordure-champ);
    border-radius: var(--rayon-pilule);
    background: var(--surface);
    cursor: pointer;
    transition: background-color var(--duree) var(--ease-out), border-color var(--duree) var(--ease-out);
}

.option input[type="checkbox"] { border-radius: 5px; }

.option input:checked { background: var(--bleu); border-color: var(--bleu); }
.option input[type="radio"]:checked { box-shadow: inset 0 0 0 3px var(--surface); }

.option input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 0.3125rem;
    top: 0.0625rem;
    width: 0.3125rem;
    height: 0.625rem;
    border: solid var(--surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.option input:hover { border-color: var(--bleu); }
.option input:focus-visible { outline: none; }

.exemples { margin: 0.25rem 0 0.75rem; }

.exemples summary {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--bleu);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
}

.exemples ul { margin: 0.25rem 0 0; padding-left: 1.25rem; color: var(--texte-doux); }
.exemples li + li { margin-top: 0.375rem; }

.erreur { color: var(--erreur); font-weight: 700; font-size: 0.9375rem; margin-top: 0.375rem; }
.erreur:empty { display: none; }

.erreurs {
    margin: 1.5rem 0 0;
    padding: 1rem 1.125rem;
    border: 1px solid var(--erreur);
    border-left-width: 4px;
    border-radius: var(--rayon-bloc);
    background: var(--surface);
}

.erreurs:focus { outline: none; }
.erreurs-titre { font-weight: 700; }
.erreurs ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.erreurs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--erreur); font-weight: 700; }

.piege { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ── Actions et envoi ─────────────────────────────────────────────────────────────────────────────── */

.etape-actions { display: none; }

.js-pret .etape-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 2.5rem;
}

.js-pret .etape-actions [data-action="suivant"]:only-child { margin-left: auto; }

/* Même bouton que le site : une touche pleine, avec son ombre, qui s'enfonce quand on appuie. */
.bouton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 0 1.75rem;
    border: 2px solid var(--bleu-fonce);
    border-radius: var(--rayon-bloc);
    background: var(--bleu);
    color: var(--surface);
    box-shadow: 0 4px 0 var(--bleu-fonce);
    font: 700 1.0625rem/1.2 var(--police-texte);
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duree) var(--ease-out), transform 100ms var(--ease-out);
}

.bouton:hover { background: var(--bleu-survol); color: var(--surface); }
.bouton:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--bleu-fonce); }

.bouton-second { background: var(--surface); border-color: var(--texte); color: var(--texte); box-shadow: 0 4px 0 var(--texte); }
.bouton-second:hover { background: var(--surface-choisie); color: var(--texte); }
.bouton-second:active { box-shadow: 0 1px 0 var(--texte); }

.donnees-court {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ligne);
    display: grid;
    gap: 0.5rem;
    font-size: 0.9375rem;
}

.envoi { margin-top: 2rem; }

@media (max-width: 599.98px) {
    .bouton-envoi { width: 100%; }
    .js-pret .etape-actions .bouton { flex: 1 1 auto; }
}

/* ── Vos données ──────────────────────────────────────────────────────────────────────────────────── */

.donnees {
    display: grid;
    gap: 0.875rem;
    margin-top: 4.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--ligne);
    font-size: 0.9375rem;
}

.donnees h2 { font-size: 1.5rem; margin-bottom: 0.25rem; }

.paiement {
    display: grid;
    gap: 1rem;
    justify-items: start;
    margin-top: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--ligne);
    border-left: 3px solid var(--ambre-trait);
    border-radius: var(--rayon-bloc);
    background: var(--surface);
}

.recap-engagement {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--ligne);
    border-radius: var(--rayon);
    background: var(--fond);
    display: grid;
    gap: 0.5rem;
}

.recap-engagement-titre {
    margin: 0;
    font-size: 1.0625rem;
    font-family: var(--police-titre);
    color: var(--bleu);
}

.recap-engagement-choisie {
    margin: 0;
    font-weight: 700;
    color: var(--texte);
}

.recap-engagement ul {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
    display: grid;
    gap: 0.45rem;
    font-size: 0.9375rem;
}

.recap-engagement li.est-retenue {
    padding: 0.35rem 0.6rem;
    border-radius: var(--rayon);
    background: var(--surface-choisie);
    border-left: 3px solid var(--ambre-trait);
}

.recap-engagement-garantie {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    color: var(--texte-doux);
}

.paiement .erreur {
    margin: 0.35rem 0 0;
    color: var(--erreur);
    font-size: 0.9rem;
    font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
    .bouton:active, .langue:active { transform: none; }
    .bouton:active { box-shadow: 0 4px 0 var(--bleu-fonce); }
    .bouton-second:active { box-shadow: 0 4px 0 var(--texte); }
}
