/* Aucune couleur ni police écrite ici : tout vient des variables posées par app.js
   depuis /api/apparence (--fond, --texte, --accent, --police-titres, --police-texte…). */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police-texte), system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---- En-tête et pied ---- */
.entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 16px;
}
.logo { max-height: 2.5rem; width: auto; }
.nom {
  font-family: var(--police-titres), Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--texte_accent);
}
.lien {
  margin-left: auto;
  min-height: 48px;
  padding: 0 0.5rem;
  background: none;
  border: 0;
  font: inherit;
  color: var(--texte_doux);
  text-decoration: underline;
  cursor: pointer;
}
.lien[hidden] { display: none; }

.ecran {
  flex: 1;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.5rem 16px 2rem;
}

.pied {
  padding: 1rem 16px;
  text-align: center;
  color: var(--texte_doux);
  font-size: 1rem;
}

/* ---- Cartes et titres ---- */
.carte {
  background: var(--carte_claire);
  border-radius: 14px;
  padding: 1.5rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--texte) 12%, transparent);
}
.titre {
  font-family: var(--police-titres), Georgia, serif;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.75rem;
  color: var(--texte);
  overflow-wrap: anywhere;
}
.titre:focus { outline: none; }
.aide {
  margin: 0 0 1.25rem;
  color: var(--texte_doux);
  overflow-wrap: anywhere;
}
.aide:empty { display: none; }

/* ---- Progression ---- */
.progression { margin-bottom: 1rem; }
.etape { margin: 0 0 0.4rem; color: var(--texte_doux); }
.barre {
  height: 10px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--texte_doux) 25%, transparent);
  overflow: hidden;
}
.rempli {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 0.25s ease;
}

/* ---- Champs ---- */
input[type=text], input[type=password], input[type=search], select, textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.9rem;
  margin-top: 0.75rem;
  font: inherit;
  color: var(--texte);
  background: var(--carte_claire);
  border: 2px solid var(--texte_doux);
  border-radius: 10px;
}
textarea { resize: vertical; }
input[type=text]:focus-visible, textarea:focus-visible { outline-offset: 2px; }

/* ---- Boutons ---- */
.bouton {
  min-height: 52px;
  padding: 0.6rem 1.4rem;
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid var(--accent);
  cursor: pointer;
}
.bouton.principal { background: var(--accent); color: var(--texte_sur_accent); }
.bouton.secondaire { background: var(--carte_claire); color: var(--texte_accent); }
.bouton.grand { width: 100%; min-height: 60px; font-size: 1.15rem; margin-top: 1rem; }
.bouton:disabled {
  cursor: not-allowed;
  background: color-mix(in srgb, var(--texte_doux) 18%, var(--fond));
  border-color: color-mix(in srgb, var(--texte_doux) 40%, var(--fond));
  color: var(--texte_doux);
}
.navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.navigation .bouton { flex: 1 1 9rem; }

/* ---- Choix ---- */
.choix { display: grid; gap: 0.6rem; }
.option {
  width: 100%;
  min-height: 52px;
  padding: 0.65rem 1rem;
  text-align: left;
  font: inherit;
  color: var(--texte);
  background: var(--carte_claire);
  border: 2px solid var(--texte_doux);
  border-radius: 10px;
  cursor: pointer;
}
.option[aria-checked=true] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--texte_sur_accent);
  font-weight: 600;
}

/* ---- Case à cocher (prompt en anglais) ---- */
.case {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 52px;
  padding: 0.65rem 1rem;
  border: 2px solid var(--texte_doux);
  border-radius: 10px;
  background: var(--carte_claire);
  font-weight: 600;
  cursor: pointer;
}
.case input[type=checkbox] {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.case:has(input:checked) { border-color: var(--accent); }
.conseil { margin: 0 0 1rem; font-weight: 600; color: var(--texte_accent); overflow-wrap: anywhere; }

/* ---- Cartes de type ---- */
.types { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .types { grid-template-columns: 1fr 1fr; } }
.type {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 48px;
  padding: 1rem;
  text-align: left;
  font: inherit;
  color: var(--texte);
  background: var(--carte_claire);
  border: 2px solid var(--accent);
  border-radius: 12px;
  cursor: pointer;
}
.type-titre {
  font-family: var(--police-titres), Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--texte_accent);
}
.type-desc { color: var(--texte_doux); overflow-wrap: anywhere; }
.type:disabled {
  cursor: not-allowed;
  border-color: color-mix(in srgb, var(--texte_doux) 40%, var(--fond));
  background: color-mix(in srgb, var(--texte_doux) 10%, var(--fond));
}
.type:disabled .type-titre { color: var(--texte_doux); }
.etiquette { font-weight: 600; color: var(--texte_doux); }

/* ---- Résultat ---- */
.prompt {
  margin: 0.5rem 0;
  padding: 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--fond);
  border: 2px solid var(--texte_doux);
  border-radius: 10px;
  user-select: text;
}
.prompt-titre { font-weight: 700; color: var(--texte_accent); }

/* Titre contenant une lettre que la police des titres dessine mal (liste dans les réglages,
   polices.titres.lettres_mal_dessinees) : il passe dans la police du texte, un peu plus petit
   pour garder la même présence visuelle. */
.police-texte { font-family: var(--police-texte), system-ui, sans-serif; }
.titre.police-texte { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.01em; }
.nom.police-texte, .type-titre.police-texte { font-size: 1.3rem; font-weight: 700; }

.message { margin: 0.75rem 0; font-weight: 600; }
.message:empty { display: none; }
.message.alerte, .erreur { color: var(--alerte); }
.message.succes { color: var(--succes); }
.erreur { font-weight: 600; margin: 0 0 0.5rem; overflow-wrap: anywhere; }

.bouton.grand ~ .aide { margin-top: 1rem; }
.question { margin: 0 0 0.5rem; font-weight: 600; font-size: 1.15rem; }
.exemple { margin: 0 0 1rem; color: var(--texte_doux); overflow-wrap: anywhere; }
.exemple p, .exemple ul { margin: 0; }
.exemple ul { padding-left: 1.25rem; }
::placeholder { color: var(--texte_doux); opacity: 1; font-style: italic; }

/* ---- Page d'administration (admin.html) ---- */
.entete.large, .ecran.large { max-width: 72rem; }
.sous-titre {
  font-family: var(--police-titres), Georgia, serif;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.75rem;
  color: var(--texte);
}
.sous-titre:focus { outline: none; }
.sous-titre.police-texte { font-size: 1.4rem; font-weight: 700; }
.etiquette-champ { display: block; margin-top: 1rem; font-weight: 600; }
.etiquette-champ + input { margin-top: 0.35rem; }
.connexion { max-width: 34rem; margin-left: auto; margin-right: auto; }
.lien-cree {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: var(--fond);
}
textarea.lien-grand {
  resize: none;
  overflow-wrap: anywhere;
  word-break: break-all;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--texte_accent);
  border-color: var(--accent);
}
/* Recherche et tri de la liste : côte à côte sur ordinateur, l'un sous l'autre sur téléphone. */
.outils-liste { display: flex; flex-wrap: wrap; gap: 0 1.25rem; margin-bottom: 0.5rem; }
.outil-recherche { flex: 2 1 18rem; }
.outil-tri { flex: 1 1 14rem; }
.outils-liste input, .outils-liste select { margin-top: 0.35rem; }
#resultat-recherche:empty { display: none; }
.codes { width: 100%; border-collapse: collapse; }
.codes th, .codes td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 2px solid color-mix(in srgb, var(--texte_doux) 30%, transparent);
  overflow-wrap: anywhere;
}
.codes th { color: var(--texte_doux); font-weight: 700; overflow-wrap: normal; }
.codes .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.codes .actions .bouton { min-height: 48px; padding: 0.4rem 0.9rem; }
.ligne-alerte td { border-bottom: 0; padding-bottom: 0; }
.ligne-alerte td, .ligne-refus td { background: color-mix(in srgb, var(--alerte) 7%, var(--carte_claire)); }
.alerte-refus {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-left: 5px solid var(--alerte);
  color: var(--alerte);
}
.etat-actif { font-weight: 700; color: var(--succes); }
.etat-desactive { font-weight: 700; color: var(--alerte); }
.etat-actif, .etat-desactive { white-space: nowrap; overflow-wrap: normal; }

/* Téléphone : chaque code devient une petite carte, le nom de la colonne devant chaque valeur. */
@media (max-width: 760px) {
  .codes thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .codes, .codes tbody, .codes tr, .codes td { display: block; width: 100%; }
  .codes tr {
    margin-bottom: 1rem;
    padding: 0.5rem 0.9rem;
    border: 2px solid color-mix(in srgb, var(--texte_doux) 40%, transparent);
    border-radius: 12px;
  }
  .codes tr.ligne-refus { background: color-mix(in srgb, var(--alerte) 7%, var(--carte_claire)); }
  .codes tr.ligne-alerte {
    margin-bottom: 0;
    border-color: var(--alerte);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: color-mix(in srgb, var(--alerte) 7%, var(--carte_claire));
  }
  .codes tr.ligne-alerte + tr { border-color: var(--alerte); border-top: 0; border-radius: 0 0 12px 12px; }
  .codes td { padding: 0.3rem 0; border-bottom: 0; background: none; }
  .ligne-alerte td, .ligne-refus td { background: none; }
  .codes td[data-libelle]::before { content: attr(data-libelle); display: block; font-weight: 700; color: var(--texte_doux); }
}
