/* ==========================================================================
   Composants réutilisés d'une page à l'autre.
   Nommage : .bloc, .bloc__element, .bloc--variante.
   Aucune couleur en dur : tout passe par tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Boutons (et liens qui ont l'air de boutons)
   -------------------------------------------------------------------------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  border-radius: var(--rayon-cible);
  min-height: var(--cible-min);
  padding: 0 20px;
  font-size: var(--taille-texte);
  background: transparent;
  color: var(--encre);
  text-decoration: none;
}

/* Action principale : une seule par page */
.bouton--principal {
  height: var(--hauteur-cible);
  background: var(--accent-fort);
  color: var(--sur-accent);
  font-size: 19px;
  font-weight: 700;
}
.bouton--principal:disabled { background: var(--inactif); color: var(--texte-discret); }

/* Lien discret : « Je répondrai plus tard », « Fermer » */
.bouton--discret { height: 48px; color: var(--texte-doux); font-size: 16px; }
.bouton--petit { font-size: var(--taille-petit); padding: 0 10px; }

/* Action qui efface (supprimer un traitement) : contour foncé, jamais en plein,
   pour ne pas ressembler à l'action principale. Le texte dit ce qui sera effacé. */
.bouton--danger {
  height: var(--hauteur-cible);
  background: var(--surface);
  border: 2px solid var(--accent-profond);
  color: var(--accent-profond);
  font-size: 17px; font-weight: 700;
  padding: 0 14px;
}

/* Bouton rond (flèches, retour) */
.bouton-rond {
  width: var(--cible-min); height: var(--cible-min);
  border-radius: var(--rayon-cible); border: none; padding: 0;
  background: transparent; color: var(--texte-doux);
  font-size: 30px; line-height: 1;
  display: grid; place-items: center;
  text-decoration: none;
}
.bouton-rond--plein { background: var(--surface-douce); color: var(--encre); font-size: 24px; }
.bouton-rond[aria-disabled="true"] { opacity: .3; pointer-events: none; }

/* --------------------------------------------------------------------------
   Réponse à choix unique : un vrai bouton radio, habillé en grande ligne.
   Le rond natif est masqué ; le cercle à droite (.reponse__rond) le remplace.
   -------------------------------------------------------------------------- */
.reponses { display: flex; flex-direction: column; gap: 10px; border: none; margin: 0; padding: 0; min-width: 0; }

.reponse {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 62px;
  padding: 12px 18px 12px 22px;
  border-radius: var(--rayon-cible);
  border: 2px solid var(--bordure);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.reponse input { position: absolute; opacity: 0; pointer-events: none; }
.reponse__textes { display: flex; flex-direction: column; gap: 2px; }
.reponse__texte { font-size: var(--taille-reponse); }
.reponse__aide { font-size: var(--taille-petit); color: var(--texte-doux); }
.reponse__aide:empty { display: none; }
.reponse__rond { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--rond-vide); }

.reponse:has(input:checked) { background: var(--accent-pale); border-color: var(--accent-fort); }
.reponse:has(input:checked) .reponse__rond { border-color: var(--accent-fort); background: var(--accent-fort); }
.reponse:has(input:focus-visible) { outline: 3px solid var(--accent-fort); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Puce (valeur rapide, raccourci, choix multiple)
   -------------------------------------------------------------------------- */
.puce {
  min-height: 52px;
  padding: 0 20px;
  border-radius: var(--rayon-cible);
  border: 2px solid var(--bordure);
  background: var(--surface);
  font-size: 18px;
  transition: background .15s, border-color .15s;
}
.puce[aria-pressed="true"] { background: var(--accent-pale); border-color: var(--accent-fort); }

/* --------------------------------------------------------------------------
   Échelle de douleur 0–10 : 11 boutons radio.
   La teinte de chaque case est calculée ici à partir de --n (0 à 10),
   posé d'après l'attribut data-n du HTML : plus la douleur est forte, plus l'orange est soutenu.
   (27/11 : data-n remplace l'attribut style="--n: …", interdit par la politique de sécurité, CSP.)
   -------------------------------------------------------------------------- */
.douleur { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.douleur__valeur { font-family: var(--police-titre); font-size: 112px; line-height: 1; text-align: center; }
.douleur__mot { font-size: 19px; color: var(--texte-doux); margin-top: 6px; min-height: 24px; text-align: center; }
/* Deux rangées (0 à 5, puis 6 à 10) : sur une seule, une case faisait 27 px de large sur un
   téléphone, sous le minimum de 44 px (--cible-min). Six colonnes égales : toutes les cases
   ont la même taille, la dernière place de la seconde rangée reste vide. */
.douleur__echelle { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; width: 100%; border: none; margin: 0; padding: 0; min-width: 0; }
.douleur__case {
  --teinte: oklch(calc(var(--douleur-clarte) - var(--n) * var(--douleur-clarte-pas)) calc(var(--douleur-chroma) + var(--n) * var(--douleur-chroma-pas)) var(--douleur-teinte));
  position: relative;
  min-width: 0; height: 56px;
  border-radius: var(--rayon-cible);
  background: var(--surface-douce);
  box-shadow: inset 0 0 0 1.5px var(--bordure);
  color: var(--texte-second);
  font-size: var(--taille-reponse);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .12s;
}
.douleur__case[data-n="0"] { --n: 0; }
.douleur__case[data-n="1"] { --n: 1; }
.douleur__case[data-n="2"] { --n: 2; }
.douleur__case[data-n="3"] { --n: 3; }
.douleur__case[data-n="4"] { --n: 4; }
.douleur__case[data-n="5"] { --n: 5; }
.douleur__case[data-n="6"] { --n: 6; }
.douleur__case[data-n="7"] { --n: 7; }
.douleur__case[data-n="8"] { --n: 8; }
.douleur__case[data-n="9"] { --n: 9; }
.douleur__case[data-n="10"] { --n: 10; }
.douleur__case input { position: absolute; opacity: 0; pointer-events: none; }
.douleur__case.est-allumee { background: var(--teinte); color: var(--encre); }
.douleur__case:has(input:checked) { box-shadow: inset 0 0 0 2px var(--encre); }
.douleur__case:has(input:focus-visible) { outline: 3px solid var(--accent-fort); outline-offset: 2px; }
/* Petit téléphone : le grand chiffre cède de la place aux deux rangées */
@media (max-height: 700px) {
  .douleur { gap: 12px; }
  .douleur__valeur { font-size: 72px; }
}
.douleur__bornes { display: flex; justify-content: space-between; width: 100%; font-size: var(--taille-legende); color: var(--texte-discret); }

/* --------------------------------------------------------------------------
   Compteur − valeur + (heures de sommeil, température, unités d'insuline)
   -------------------------------------------------------------------------- */
.compteur { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.compteur__bouton {
  width: 68px; height: 68px; flex-shrink: 0;
  border-radius: var(--rayon-cible);
  border: 2px solid var(--bordure);
  background: var(--surface);
  font-size: 32px; line-height: 1;
}
.compteur__valeur { flex: 1; font-family: var(--police-titre); font-size: 54px; text-align: center; line-height: 1; white-space: nowrap; }
.rapides { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 22px; }
.rapides .puce { padding: 0 6px; }
.rapides__aide { text-align: center; margin: 10px 0 0; }

/* --------------------------------------------------------------------------
   Onglets de navigation : en bas sur téléphone et tablette, en haut sur ordinateur
   -------------------------------------------------------------------------- */
.onglets {
  /* Place et largeur : le cadre, en tête de css/pages.css */
  display: flex; gap: 4px;
  padding: 6px;
  background: var(--surface-flottante);
  backdrop-filter: blur(12px);
  border-radius: calc(var(--rayon-cible) + 6px);
  box-shadow: var(--ombre-flottante);
  z-index: 30;
}
/* Chaque onglet = largeur de son mot + une même part de la place restante :
   les blancs entre les mots sont égaux (des cases égales donnaient des blancs inégaux). */
.onglet {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  height: var(--cible-min); padding: 0 8px;
  border-radius: var(--rayon-cible);
  color: var(--texte-onglet); text-decoration: none;
  font-size: var(--taille-petit); white-space: nowrap;
}
.onglet[aria-current="page"] { background: var(--accent-pale); color: var(--accent-profond); font-weight: 700; }

/* --------------------------------------------------------------------------
   Message court (« 3 questions gardées pour plus tard »)
   -------------------------------------------------------------------------- */
.message {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 50%; transform: translateX(-50%);
  background: var(--fond-message); color: var(--texte-message);
  padding: 12px 20px; border-radius: 999px;
  font-size: var(--taille-petit);
  z-index: 40; white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Autres boutons
   -------------------------------------------------------------------------- */
/* Action secondaire : contour (« Non, c'est tout ») */
.bouton--secondaire { height: 56px; background: var(--surface); border: 1.5px solid var(--bordure); }
/* Petit bouton plein foncé (« Ajouter ») */
.bouton--sombre { height: 52px; background: var(--encre); color: var(--fond); padding: 0 18px; }

/* --------------------------------------------------------------------------
   Puces à cocher (plusieurs réponses) : une case à cocher habillée en puce
   -------------------------------------------------------------------------- */
.puces { display: flex; flex-wrap: wrap; gap: 10px; border: none; margin: 0; padding: 0; min-width: 0; }
.puce--case { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.puce--case input { position: absolute; opacity: 0; pointer-events: none; }
.puce--case:has(input:checked) { background: var(--accent-pale); border-color: var(--accent-fort); }
.puce--case:has(input:focus-visible) { outline: 3px solid var(--accent-fort); outline-offset: 2px; }
.puce--petite { min-height: 46px; font-size: 16px; border-width: 1.5px; padding: 0 16px; }

/* --------------------------------------------------------------------------
   Sélecteur à onglets (De face / De dos, g/L / mmol/L) : boutons radio
   -------------------------------------------------------------------------- */
.segments { display: inline-flex; background: var(--surface-douce); border-radius: calc(var(--rayon-cible) + 4px); padding: 4px; gap: 4px; border: none; margin: 0; }
.segment {
  position: relative;
  display: inline-flex; align-items: center;
  height: 40px; padding: 0 20px;
  border-radius: var(--rayon-cible);
  color: var(--texte-doux); font-size: var(--taille-petit);
  cursor: pointer;
}
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment:has(input:checked) { background: var(--surface); color: var(--encre); box-shadow: var(--ombre-douce); }
.segment:has(input:focus-visible) { outline: 3px solid var(--accent-fort); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Champs
   -------------------------------------------------------------------------- */
/* Grand chiffre à taper (tension, glycémie) */
.grand-nombre {
  width: 100%; min-width: 0;
  height: 96px;
  border-radius: var(--rayon-cible);
  border: 2px solid var(--bordure);
  background: var(--surface);
  text-align: center;
  font-family: var(--police-titre);
  font-size: 48px;
}
.grand-nombre::placeholder { color: var(--exemple); }
.grand-nombre:focus-visible { outline: none; border-color: var(--accent-fort); }
.grand-nombre--seul { height: 104px; font-size: 56px; }

/* Champ texte d'une ligne */
.champ {
  height: 52px; min-width: 0;
  border-radius: var(--rayon-cible);
  border: 1.5px solid var(--bordure);
  background: var(--surface);
  padding: 0 16px;
  font-size: var(--taille-texte);
}
.champ:focus-visible { outline: none; border-color: var(--accent-fort); }

/* Grande zone de texte (note) */
.zone-texte {
  width: 100%; min-height: 220px; resize: none;
  border-radius: var(--rayon-cible);
  border: 1.5px solid var(--bordure);
  background: var(--surface);
  padding: 18px;
  font-family: var(--police-titre); font-size: 21px; line-height: 1.4;
}
.zone-texte:focus-visible { outline: none; border-color: var(--accent-fort); }

/* Alerte douce (valeur inhabituelle) — à ne pas confondre avec .avertissement (pages.css) */
.alerte-douce { color: var(--accent-texte); font-size: var(--taille-petit); text-align: center; margin: 12px 0 0; }

/* --------------------------------------------------------------------------
   Case à cocher (zones du corps) : une vraie case, redessinée
   -------------------------------------------------------------------------- */
.case-a-cocher {
  appearance: none; -webkit-appearance: none;
  position: relative;
  width: 30px; height: 30px; margin: 0;
  border-radius: var(--rayon-case);
  border: 2px solid var(--rond-vide);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.case-a-cocher:checked { background: var(--accent-fort); border-color: var(--accent-fort); }
/* La coche : deux bords d'un petit rectangle tourné */
.case-a-cocher:checked::before {
  content: ''; position: absolute; left: 8px; top: 3px;
  width: 8px; height: 15px;
  border: solid var(--sur-accent); border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.case-a-cocher:focus-visible { outline: 3px solid var(--accent-fort); outline-offset: 2px; }
