/* =========================================================================
   Questionnaire - feuille de style unique.
   Noir & blanc, polices systeme (aucune police telechargee), RTL gere par
   des proprietes logiques (start/end au lieu de left/right).
   Mobile-first : espacements fluides, header/footer fixes, typographie adaptable.
   ========================================================================= */

:root {
  --fg: #000;
  --bg: #fff;
  --line: #000;
  --muted: #555;
  --disabled: #bbb;
  --focus: #000;
  --tap: 52px;
  --maxw: 34rem;
  --gap: 1rem;
  --header-h: 48px;
  --footer-h: 64px;
  --pad-x: clamp(0.75rem, 4vw, 1.25rem);
  --pad-y: clamp(0.75rem, 3vw, 1.5rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
               "Noto Sans Arabic", sans-serif;
  font-size: clamp(1rem, 2.5vw + 0.6rem, 1.125rem);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-block-start: calc(var(--header-h) + var(--pad-y));
  padding-block-end: calc(var(--footer-h) + var(--pad-y));
  padding-inline: var(--pad-x);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ Header fixe */
.site-header {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  height: var(--header-h);
  background: var(--fg);
  color: var(--bg);
  z-index: 200;
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: var(--maxw);
  margin-inline: auto;
  width: 100%;
  padding-inline: var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header-brand {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.font-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-font {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  min-height: 2.4rem;
  padding: 0.2rem 0.5rem;
  border: 2px solid var(--bg);
  background: transparent;
  color: var(--bg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  user-select: none;
}
.btn-font:hover { background: rgba(255,255,255,0.15); }
.btn-font:focus-visible { outline: 2px solid var(--bg); outline-offset: 2px; }

/* ------------------------------------------------------------------ Footer fixe */
.site-footer {
  position: fixed;
  inset-block-end: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  min-height: var(--footer-h);
  background: var(--fg);
  color: var(--bg);
  z-index: 200;
  display: flex;
  align-items: center;
}

.footer-inner {
  max-width: var(--maxw);
  margin-inline: auto;
  width: 100%;
  padding-inline: var(--pad-x);
  padding-block: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-nav {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

/* ------------------------------------------------------------------ Accueil */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(1.25rem, 4vw, 2rem);
}

.lang-switch {
  display: flex;
  gap: 0.75rem;
  position: absolute;
  inset-block-start: calc(var(--header-h) + 0.75rem);
  inset-inline-end: var(--pad-x);
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  border: 2px solid var(--line);
  text-decoration: none;
  color: var(--fg);
  background: var(--bg);
}
.lang-btn.is-active {
  background: var(--fg);
  color: var(--bg);
}

.title {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.thanks-subtitle { font-weight: 700; margin: 0; }
.thanks-text { color: var(--muted); margin: 0; }

.goal-block { display: flex; flex-direction: column; gap: 0.25rem; }
.goal-intro { font-weight: 700; margin: 0; }
.goal-progress { color: var(--muted); margin: 0; }

.feedback-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-block-start: 0.5rem;
}
.feedback-prompt { margin: 0; }
.pseudo-prompt { margin: 0; font-weight: 700; }

/* ------------------------------------------------------------------ Recompense */
.reward-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-block-start: 1rem;
  padding-block: 1.25rem;
  border-block: 2px solid var(--line);
}
.reward-title {
  font-size: clamp(1.05rem, 4vw, 1.3rem);
  font-weight: 700;
  margin: 0;
}
.reward-intro { margin: 0; }
.reward-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-block-start: 0.5rem;
}
.reward-prompt { margin: 0; font-weight: 700; }
.reward-hint { margin: 0; color: var(--muted); font-size: 0.85rem; }

.phone-field { position: relative; display: flex; align-items: center; }
.phone-prefix {
  position: absolute;
  inset-inline-start: 0.9rem;
  font-weight: 700;
  font-size: 1.1rem;
  pointer-events: none;
}
.phone-input {
  inline-size: 100%;
  min-height: var(--tap);
  padding-inline-start: 2.1rem;
  padding-inline-end: 0.9rem;
  padding-block: 0.6rem;
  border: 2px solid var(--line);
  font: inherit;
  font-size: 1.1rem;
  color: var(--fg);
  background: var(--bg);
}

.start-form { width: 100%; }

/* ------------------------------------------------------------------ Question */
.question { flex: 1; display: flex; flex-direction: column; }

.q-count {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

.q-title {
  text-align: center;
  font-size: clamp(1.15rem, 3.5vw + 0.5rem, 1.4rem);
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.q-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 clamp(0.6rem, 2vw, 1rem);
}

/* ---------------------------------------------------------------- Audio */
/* Style commun a TOUS les boutons audio (question ET par reponse) : un
   rond, fond noir, triangle de lecture blanc au centre. Seule la taille
   change (.btn-audio-sm pour les boutons par reponse/ligne). */
.audio-row {
  display: flex;
  justify-content: center;
  margin-block-end: clamp(0.75rem, 3vw, 1.25rem);
}
.btn-audio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  inline-size: var(--tap);
  block-size: var(--tap);
  border: none;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  padding: 0;
  cursor: pointer;
}
.btn-audio .audio-icon {
  inline-size: 38%;
  block-size: 38%;
  fill: currentColor;
}
.btn-audio.is-playing {
  background: var(--bg);
  color: var(--fg);
  box-shadow: inset 0 0 0 2px var(--fg);
}
.btn-audio-sm {
  inline-size: 2rem;
  block-size: 2rem;
}

/* ---------------------------------------------------------------- Erreur */
.error {
  color: #c00;
  text-align: center;
  margin: 0 0 1rem;
  font-weight: 700;
  padding: 0.25rem 0;
}

/* ---------------------------------------------------------------- Choix */
.choices { flex: 1; margin-block-end: 1rem; }

.choices-list { display: flex; flex-direction: column; gap: 0.6rem; }
.choices-list.cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* Regroupe le choix (label pleine largeur, cliquable partout) et son
   bouton audio independant : le bouton n'est PAS imbrique dans le label,
   pour ne jamais declencher la case/le radio en cliquant dessus. */
.choice-row { display: flex; align-items: center; gap: 0.5rem; }
.choice-row .choice { flex: 1; }

.choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--tap);
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--line);
  cursor: pointer;
  background: var(--bg);
}

.choice input { inline-size: 1.4rem; block-size: 1.4rem; accent-color: #000; flex: none; }
.choice-label { flex: 1; text-align: start; }

.choice:has(input:checked) { background: var(--fg); color: var(--bg); }
.choice:has(input:checked) input { accent-color: #fff; }

.choice.is-disabled { opacity: 0.4; cursor: not-allowed; }
.choice.is-disabled input { pointer-events: none; }

/* ---------------------------------------------------------------- Smiley */
.smiley-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(0.6rem, 3vw, 1rem);
  max-inline-size: 22rem;
  margin-inline: auto;
}
/* .smiley-item porte la taille/position ; .smiley (le label) la remplit a
   100% pour laisser le bouton audio se positionner en badge dans le coin
   sans etre imbrique dans le label (qui activerait le radio au clic). */
.smiley-item {
  position: relative;
  aspect-ratio: 1;
  min-block-size: clamp(4.5rem, 20vw, 6.5rem);
}
.smiley {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 100%;
  block-size: 100%;
  border: 2px solid var(--line);
  cursor: pointer;
}
.smiley input { position: absolute; opacity: 0; inline-size: 0; block-size: 0; }
.smiley-face { font-size: clamp(2.4rem, 10vw, 3.4rem); line-height: 1; }
.smiley:has(input:checked) { background: var(--fg); }

.btn-audio-corner {
  position: absolute;
  inset-block-start: -0.5rem;
  inset-inline-end: -0.5rem;
}

/* ---------------------------------------------------------------- Matrice */
.matrix-row {
  border: 2px solid var(--line);
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.9rem;
}
.matrix-row.is-answered { background: #eee; }
.matrix-legend { font-weight: 700; padding-inline: 0.25rem; }
.matrix-legend .btn-audio-sm {
  vertical-align: middle;
  margin-inline-start: 0.4rem;
}

/* Options en ligne, toujours sur une seule rangee : le libelle passe sous
   le bouton radio (colonne) plutot qu'a cote, pour que le texte tienne
   dans la largeur meme sur un petit ecran. */
.matrix-options {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin-block-start: 0.5rem;
}
.choice-inline {
  flex: 1 1 0;
  min-inline-size: 0;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.3rem;
  min-height: 60px;
  text-align: center;
}
.choice-inline input { inline-size: 1.15rem; block-size: 1.15rem; }
.choice-inline .choice-label {
  flex: none;
  white-space: normal;
  line-height: 1.15;
  font-size: clamp(0.68rem, 2.6vw, 0.82rem);
}

/* Matrice "pouces" (q14) : legende au-dessus, pouces centres en dessous */
.matrix-row-thumbs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
}
.matrix-row-thumbs .matrix-legend { padding-inline: 0; }
.thumbs-row { display: flex; justify-content: center; gap: 0.75rem; }
.smiley-sm { inline-size: 2.6rem; block-size: 2.6rem; }
.smiley-sm .smiley-face { font-size: 1.3rem; }

/* ---------------------------------------------------------------- Jauge */
.slider-box { text-align: center; padding-block: clamp(0.5rem, 2vw, 1rem); }
.slider-value {
  display: block;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 700;
  margin-block-end: 0.75rem;
  min-block-size: 2.4rem;
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 100%;
  block-size: var(--tap);
  background: transparent;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
  block-size: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, #c0392b, #2e7d32);
}
.slider::-moz-range-track {
  block-size: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, #c0392b, #2e7d32);
}
[dir="rtl"] .slider::-webkit-slider-runnable-track { background: linear-gradient(to left, #c0392b, #2e7d32); }
[dir="rtl"] .slider::-moz-range-track { background: linear-gradient(to left, #c0392b, #2e7d32); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 1.7rem;
  block-size: 1.7rem;
  border-radius: 50%;
  background: #000;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #000;
  margin-block-start: -0.6rem;
  cursor: pointer;
}
.slider::-moz-range-thumb {
  inline-size: 1.7rem;
  block-size: 1.7rem;
  border-radius: 50%;
  background: #000;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #000;
  cursor: pointer;
}
.slider-ends {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-block-start: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.slider-end { flex: 1; }
.slider-ends .slider-end:first-child { text-align: start; }
.slider-ends .slider-end:last-child { text-align: end; }

/* ---------------------------------------------------------------- Option "Autre" */
.other-wrap { margin-block-start: 0.4rem; margin-block-end: 0.6rem; }
.other-wrap.is-hidden { display: none; }
.other-input {
  inline-size: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--line);
  font: inherit;
  color: var(--fg);
  background: var(--bg);
}

/* ---------------------------------------------------------------- Texte */
.textarea {
  inline-size: 100%;
  min-block-size: clamp(6rem, 20vw, 8rem);
  padding: 0.75rem;
  border: 2px solid var(--line);
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  resize: vertical;
}

/* ---------------------------------------------------------------- Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.7rem clamp(0.6rem, 3vw, 1.2rem);
  border: 2px solid var(--line);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--bg);
  color: var(--fg);
}
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-secondary { background: var(--bg); color: var(--fg); }
.btn-block { inline-size: 100%; font-size: clamp(1rem, 3vw, 1.2rem); }

/* Boutons dans le footer (fond noir) */
.btn-footer {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.3rem clamp(0.4rem, 2vw, 0.7rem);
  font: inherit;
  font-size: clamp(0.8rem, 2.5vw, 0.95rem);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 2px solid var(--bg);
}
.btn-footer-primary {
  background: var(--bg);
  color: var(--fg);
}
.btn-footer-secondary {
  background: transparent;
  color: var(--bg);
}
.btn-footer:focus-visible { outline: 2px solid var(--bg); outline-offset: 2px; }

/* ---------------------------------------------------------------- Focus clavier */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- Mouvement reduit */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- Fallback :has() */
/* Sur les tres vieux navigateurs sans :has(), la case/radio reste visible :
   la selection reste comprehensible meme sans l'inversion N&B. */
