/* ============================================================
   Profil santé : la fenêtre du questionnaire (étape 5).
   Mêmes jetons que la maquette ; la carte de l'accueil garde ses
   styles de site.css. Plein écran sur téléphone.
   ============================================================ */

html:has(dialog.profil[open]){overflow:hidden}

.profil{
  width:min(780px,calc(100vw - 32px));height:min(880px,calc(100dvh - 48px));max-width:none;max-height:none;
  padding:0;border:0;border-radius:var(--rayon);background:var(--bg);color:var(--fg);
  box-shadow:0 24px 64px rgba(24,33,27,.28);overflow:hidden;
}
.profil[open]{display:grid;grid-template-rows:auto 1fr auto}
.profil::backdrop{background:rgba(24,33,27,.78)}
.profil :focus-visible{outline:2px solid var(--fg);outline-offset:3px}
/* Les règles d'affichage de la maquette (.bouton, grilles) passent sinon devant l'attribut hidden. */
.profil [hidden]{display:none}

/* Entête : titre de l'étape, fermeture, progression */
.profil-entete{
  display:grid;grid-template-columns:1fr auto;gap:18px 16px;align-items:start;
  padding:28px 32px 20px;border-bottom:1px solid var(--border);
}
.profil-entete h2{font-size:var(--t-h2);text-wrap:balance;outline-offset:6px}
.profil-entete h2:focus:not(:focus-visible){outline:0}
.profil-fermer{
  width:44px;height:44px;display:inline-flex;align-items:center;justify-content:center;flex:none;
  background:transparent;color:var(--fg);border:1px solid var(--border);border-radius:999px;cursor:pointer;
  transition:background-color .18s var(--e),color .18s var(--e),border-color .18s var(--e);
}
.profil-fermer:hover{background:var(--fg);color:var(--bg);border-color:var(--fg)}
.profil-fermer svg{width:20px;height:20px}
.profil-progression{grid-column:1/-1;display:flex;align-items:center;gap:14px}
.profil-progression .barre{flex:1;height:4px;border-radius:999px;background:var(--border);overflow:hidden}
.profil-progression .barre span{display:block;height:100%;background:var(--accent);transform:scaleX(.25);transform-origin:left;transition:transform .6s var(--e)}
.profil-progression .compte{font-size:var(--t-petit);color:var(--muted);font-variant-numeric:tabular-nums;white-space:nowrap}

/* Corps : seule partie qui défile */
.profil-corps{overflow-y:auto;overscroll-behavior:contain;padding:28px 32px 40px;scrollbar-color:var(--border) transparent;scrollbar-width:thin}
.profil-intro{color:var(--muted);max-width:60ch;margin-bottom:28px}

/* Questions */
.profil fieldset{border:0;padding:0;margin:0;min-inline-size:0}
.profil .q{margin:0 0 30px}
.profil legend,.profil .q-intro{
  display:block;padding:0;margin-bottom:12px;max-width:62ch;
  font-size:1rem;font-weight:500;line-height:1.45;color:var(--fg);
}
.profil .champ{margin-bottom:22px}
.profil .champ label,.profil .champ > span{
  font-size:1rem;font-weight:500;letter-spacing:0;text-transform:none;color:var(--fg);margin-bottom:8px;line-height:1.45;
}
.profil .champ textarea,.profil .champ select{
  width:100%;min-height:44px;padding:10px 14px;border:1px solid var(--border);border-radius:var(--rayon-controle);
  background:var(--bg);color:var(--fg);font:inherit;font-size:1rem;caret-color:var(--accent);
  transition:border-color .18s var(--e);
}
.profil .champ textarea{resize:vertical;line-height:1.5}
.profil .champ select{appearance:none;padding-right:40px;cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235D6860' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 12px center;background-size:18px}
.profil .champ textarea:hover,.profil .champ select:hover{border-color:var(--muted)}
.profil .champ textarea:focus-visible,.profil .champ select:focus-visible{outline:2px solid var(--fg);outline-offset:2px;border-color:var(--fg)}
.carte-formulaire [aria-invalid="true"]:is(input,textarea,select){border-color:var(--danger)}
.q-erreur{margin-top:8px;font-size:var(--t-petit);line-height:1.45;color:var(--danger)}

/* Pastilles : une réponse (rond) ou plusieurs (case), dans une étiquette cliquable */
.pastilles{display:flex;flex-wrap:wrap;gap:8px}
.pastille{
  display:inline-flex;align-items:center;gap:10px;min-height:44px;padding:9px 16px 9px 14px;
  border:1px solid var(--border);border-radius:var(--rayon-controle);background:var(--bg);
  font-size:.9375rem;line-height:1.35;cursor:pointer;
  transition:border-color .16s var(--e),background-color .16s var(--e);
}
.pastille input{width:18px;height:18px;margin:0;flex:none;accent-color:var(--accent);cursor:pointer}
.pastille:hover{border-color:var(--muted)}
.pastille:has(:checked){border-color:var(--accent);background:var(--lichen)}
.pastille:has(:focus-visible){outline:2px solid var(--fg);outline-offset:2px}
.pastille input:focus-visible{outline:0}
.ouinon .pastille{min-width:96px}

/* Échelle de 1 à 10 : le chiffre seul, le rond reste lisible par les lecteurs d'écran */
.echelle{display:grid;grid-template-columns:repeat(10,1fr);gap:6px}
.echelle .pastille{justify-content:center;padding:0;font-variant-numeric:tabular-nums;font-weight:500;position:relative}
.echelle .pastille input{position:absolute;opacity:0;width:1px;height:1px}
.echelle .pastille:has(:checked){background:var(--accent);border-color:var(--accent);color:#fff}
.bornes{display:flex;justify-content:space-between;margin-top:8px;font-size:var(--t-petit);color:var(--muted)}

/* Précisions qui s'ouvrent sous une réponse */
.si{display:none;margin-top:16px}
.si.ouvert{display:block}
.si .champ{margin-bottom:12px}

/* Profil de santé général : déjà eu / actuel */
.profil .sante-groupe{margin-bottom:32px}
.sante-groupe legend{font-size:var(--t-etiquette);font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin-bottom:4px}
.sante-tete,.sante-ligne{display:grid;grid-template-columns:1fr 84px 84px;align-items:center}
.sante-tete{font-size:var(--t-etiquette);font-weight:600;letter-spacing:.04em;color:var(--muted);text-align:center;padding:6px 0;border-bottom:1px solid var(--border)}
.sante-ligne{border-bottom:1px solid var(--border);transition:background-color .16s var(--e)}
.sante-ligne:has(:checked){background:var(--lichen)}
.sante-nom{padding:10px 8px 10px 0;font-size:.9375rem;line-height:1.35}
.sante-ligne label{display:flex;align-items:center;justify-content:center;min-height:44px;cursor:pointer}
.sante-ligne input{width:20px;height:20px;margin:0;accent-color:var(--accent);cursor:pointer}

/* Habitudes et médicaments */
.habitude{display:grid;grid-template-columns:1fr 120px 1.3fr;gap:12px;align-items:end;padding:12px 0;border-bottom:1px solid var(--border)}
.habitude:first-of-type{border-top:1px solid var(--border)}
.habitude-nom{padding-bottom:11px;font-weight:500}
.habitude .champ,.medicament .champ{margin:0}
.habitude .champ > span,.medicament .champ > span{display:block;font-size:var(--t-petit);font-weight:400;color:var(--muted);margin-bottom:4px}
.medicament{display:grid;grid-template-columns:1.4fr 1fr;gap:12px;margin-bottom:12px}

/* Consentement */
.consentement p{color:var(--muted);max-width:62ch;margin-bottom:14px}
/* Texte de l'Ordre, à lire avant le rendez-vous : encadré qui défile (retour du 5 nov.). */
.consentement-texte{
  max-height:min(22rem,45svh);overflow-y:auto;overscroll-behavior:contain;
  margin:0 0 14px;padding:18px 20px 6px;background:var(--surface);
  border:1px solid var(--border);border-radius:var(--rayon-controle);
  font-size:var(--t-petit);line-height:1.55;color:var(--fg);
}
.consentement-texte:focus-visible{outline:2px solid var(--fg);outline-offset:2px}
.consentement-texte h3{font-family:var(--display);font-size:var(--t-h3);line-height:1.25;margin:0 0 12px}
.consentement-texte h4{font-size:var(--t-petit);font-weight:600;margin:18px 0 6px}
.consentement-texte p{color:var(--fg);max-width:none;margin:0 0 10px}
.consentement-texte ul{margin:0 0 10px;padding-left:1.1em;list-style:disc}
.consentement-texte li{margin-bottom:8px}
.consentement-texte strong{font-weight:600}
.case{display:flex;gap:12px;align-items:flex-start;padding:14px 16px;border:1px solid var(--border);border-radius:var(--rayon-controle);cursor:pointer;font-weight:500;line-height:1.45;transition:border-color .16s var(--e),background-color .16s var(--e)}
.case:has(:checked){border-color:var(--accent);background:var(--lichen)}
.case input{width:20px;height:20px;margin:2px 0 0;flex:none;accent-color:var(--accent)}
.case:has(:focus-visible){outline:2px solid var(--fg);outline-offset:2px}
.case input:focus-visible{outline:0}

/* Anti-robot, aux couleurs du site */
.profil-robot{
  margin-top:4px;min-height:58px;
  --altcha-max-width:100%;--altcha-border-radius:var(--rayon-controle);--altcha-border-color:var(--border);
  --altcha-color-base:var(--bg);--altcha-color-base-content:var(--fg);--altcha-color-primary:var(--accent);
  --altcha-color-primary-content:#fff;--altcha-color-success:var(--succes);--altcha-color-error:var(--danger);
  --altcha-checkbox-border-radius:4px;
}

/* Fin */
.profil-fin{display:grid;justify-items:center;text-align:center;padding:48px 0 24px}
.profil-fin svg{width:34px;height:34px;padding:19px;box-sizing:content-box;border-radius:999px;background:var(--lichen);color:var(--succes);margin-bottom:22px}
.profil-fin p{max-width:46ch;color:var(--muted)}

/* Pied : message, puis les boutons */
.profil-pied{display:flex;align-items:center;gap:12px;padding:16px 32px;border-top:1px solid var(--border);background:var(--bg)}
.profil .profil-pied .bouton{width:auto;margin:0;flex:none}
.profil-alerte{flex:1;font-size:var(--t-petit);line-height:1.45;color:var(--danger)}
.profil-alerte.info{color:var(--muted)}
.bouton-second{background:transparent;color:var(--fg);box-shadow:inset 0 0 0 1px var(--border)}
.bouton-second:hover{background:var(--surface);color:var(--fg)}
.profil .bouton[disabled]{opacity:.6;cursor:progress}

@media (prefers-reduced-motion:no-preference){
  .profil[open]{animation:ouvre .35s var(--e)}
  .profil[open]::backdrop{animation:fondu .35s var(--e)}
  .profil-volet.entre{animation:volet .45s var(--e)}
}
@keyframes volet{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}

@media (max-width:640px){
  .profil{width:100vw;height:100dvh;border-radius:0}
  .profil-entete{padding:16px 20px 16px}
  .profil-corps{padding:22px 20px 32px}
  .profil-pied{padding:12px 20px calc(12px + env(safe-area-inset-bottom));flex-wrap:wrap}
  .profil-alerte{flex-basis:100%;order:-1}
  .profil-alerte:empty{display:none}
  .profil .profil-pied .bouton{flex:1}
  .echelle{grid-template-columns:repeat(5,1fr)}
  .sante-tete,.sante-ligne{grid-template-columns:1fr 64px 64px}
  .habitude{grid-template-columns:1fr 1.4fr}
  .habitude-nom{grid-column:1/-1;padding:0}
  .medicament{grid-template-columns:1fr}
  .medicament{padding-bottom:12px;border-bottom:1px solid var(--border)}
}
