/* Couleurs Sofitex — vert #00ED00 en aplat uniquement (texte #161A1E dessus), #007A00 en texte. */
:root {
  --dark: #161A1E;
  --dark-line: #262C32;
  --on-dark-muted: #9AA3AC;
  --bg: #F2F3F4;
  --card: #FFFFFF;
  --text: #161A1E;
  --text-2: #4B5560;
  --muted: #5F6973;
  --line: #E4E6E8;
  --green: #00ED00;
  --green-press: #00CC00;
  --green-text: #007A00;
  --green-bg: #E3FDE3;
  --red: #C0261B;
  --red-bg: #FDECEA;
  --warn: #8A5300;
  --warn-bg: #FFF3DC;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- En-tête ---------- */
.topbar { background: var(--dark); color: #fff; }
.topbar__inner {
  max-width: 720px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
/* Logo officiel (aplat vert #00ED00, texte noir) : jamais déformé, ratio 220 × 90. */
.topbar__logo { width: 110px; height: auto; aspect-ratio: 220 / 90; display: block; border-radius: 4px; }
.topbar__title {
  margin-left: auto; color: var(--on-dark-muted); font-size: 14px;
  border-left: 1px solid var(--dark-line); padding-left: 12px;
}
.brandbar { height: 4px; background: var(--green); }

/* ---------- Mise en page ---------- */
.page { width: 100%; max-width: 720px; margin: 0 auto; padding: 20px 16px 32px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 16px 28px; }
.footer p { margin: 0; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 1px 2px rgba(22, 26, 30, .06); margin-bottom: 16px;
}
h1, h2 { margin: 0; line-height: 1.25; }

/* ---------- Accueil / mission ---------- */
.hello { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.intro { color: var(--text-2); margin: 0 0 18px; }
.mission { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.mission__item { min-width: 0; }
.mission__item--full { grid-column: 1 / -1; }
.mission dt { color: var(--muted); font-size: 13px; }
.mission dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.pill {
  display: inline-block; background: var(--green-bg); color: var(--green-text);
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-bottom: 12px;
}

/* ---------- Formulaire ---------- */
.section__title {
  font-size: 17px; font-weight: 700; margin: 0 0 4px;
  display: flex; align-items: center; gap: 10px;
}
.section__title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--green); }
.section__body { margin-top: 12px; }

.field { border: 0; margin: 0; padding: 14px 0; min-width: 0; }
.field + .field { border-top: 1px solid var(--line); }
.field[hidden] { display: none; }
.field__label { display: block; font-weight: 600; margin-bottom: 10px; padding: 0; }
/* Une legend se loge dans la bordure du fieldset : flottante, elle redevient du contenu ordinaire. */
legend.field__label { float: left; width: 100%; }
legend.field__label + * { clear: both; }
.field__label .req { color: var(--red); margin-left: 2px; }
.field__error { color: var(--red); font-size: 14px; margin-top: 8px; display: none; }
.field.has-error .field__error { display: block; }
.field.has-error .option span, .field.has-error textarea { border-color: #E8A49E; }
.field.has-error .field__label { color: var(--red); }

.options { display: flex; flex-wrap: wrap; gap: 8px; }
.option { position: relative; }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--text);
  font-weight: 600; cursor: pointer; user-select: none;
  transition: background-color .12s, border-color .12s;
}
.option span:hover { border-color: #C9CDD1; }
.option input:checked + span { background: var(--green); border-color: var(--green); color: var(--dark); }
.option input:focus-visible + span { outline: 3px solid var(--dark); outline-offset: 2px; }

.scale .option span { width: 52px; padding: 10px 0; font-size: 18px; }
.scale__legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 8px; max-width: 300px; }

.field__num { margin-right: 6px; }
.required-note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.required-note .req { color: var(--red); margin-right: 2px; }

.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 10px; font: inherit; color: var(--text); background: #fff;
}
.input:focus { outline: none; border-color: var(--green-text); box-shadow: 0 0 0 3px var(--green-bg); }
.input--readonly { background: var(--bg); color: var(--text-2); border-color: var(--bg); }
.field.has-error .input { border-color: #E8A49E; }

/* Note en étoiles : vert texte #007A00 (contraste suffisant sur blanc), piste grise. */
.stars { gap: 2px; flex-wrap: nowrap; }
.stars .option { flex: 0 0 auto; }
.stars .option .star {
  width: 44px; height: 44px; min-height: 0; padding: 4px; border: 0; background: none;
  color: #C9CDD1; border-radius: 8px;
}
.stars .option .star svg { width: 36px; height: 36px; fill: currentColor; display: block; }
.stars .option:hover .star, .stars .option.is-on .star { color: var(--green-text); }
.stars .option input:checked + .star { background: none; color: var(--green-text); }
.stars .option input:focus-visible + .star { outline: 3px solid var(--dark); outline-offset: 0; }
.stars:hover .option .star { color: var(--green-text); }
.stars .option:hover ~ .option .star { color: #C9CDD1; }
.field.has-error .stars .star { border-color: transparent; }

textarea {
  width: 100%; min-height: 96px; resize: vertical; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 10px; font: inherit; color: var(--text); background: #fff;
}
textarea:focus { outline: none; border-color: var(--green-text); box-shadow: 0 0 0 3px var(--green-bg); }
.counter { text-align: right; color: var(--muted); font-size: 12px; margin-top: 4px; }

.consent { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-weight: 600; }
.consent input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--green-text); flex: none; }

.actions { margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 14px 28px; border-radius: 12px; border: 0;
  font: inherit; font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--green); color: var(--dark); width: 100%; }
.btn--primary:hover { background: var(--green-press); }
.btn--primary:focus-visible { outline: 3px solid var(--dark); outline-offset: 2px; }
.btn--primary[disabled] { opacity: .6; cursor: progress; }

.alert { border-radius: 10px; padding: 12px 14px; font-size: 15px; margin-bottom: 16px; }
.alert--error { background: var(--red-bg); color: var(--red); }

/* ---------- États (validé, expiré, invalide) ---------- */
.state { text-align: center; padding: 36px 24px; }
.state__icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
}
.state__icon svg { width: 32px; height: 32px; }
.state__icon--ok { background: var(--green); color: var(--dark); }
.state__icon--warn { background: var(--warn-bg); color: var(--warn); }
.state__icon--error { background: var(--red-bg); color: var(--red); }
.state__title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.state__text { color: var(--text-2); margin: 0 auto 20px; max-width: 460px; }
.state__ref { color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ---------- Chargement ---------- */
.skeleton__line { height: 14px; border-radius: 7px; background: var(--line); margin: 10px 0; animation: pulse 1.2s ease-in-out infinite; }
.skeleton__line--w60 { width: 60%; height: 20px; }
.skeleton__line--w80 { width: 80%; }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .skeleton__line { animation: none; } }

@media (max-width: 480px) {
  .topbar__title { display: none; }
  .mission { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
  .scale .option span { width: 48px; }
  .options .option { flex: 1 1 auto; }
  .options .option span { width: 100%; }
  .scale .options .option { flex: 0 0 auto; }
}
