/* ==========================================================================
   CERVOLAND — COMPOSANTS
   Boutons, cartes, en-tête, pied, bandeau démo, jauges, cartes d'usine,
   ressources, formulaire, fenêtre. Lit les tokens sémantiques uniquement.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Boutons (cible ≥ 44 px, texte explicite)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--cible-min);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-bouton);
  border: var(--bordure-epaisse) solid var(--c-bordure-forte);
  background: var(--c-surface);
  color: var(--c-texte);
  font-weight: var(--fw-semibold);
  font-size: 1rem;
  line-height: var(--lh-serre);
  text-decoration: none;
  text-align: center;
  box-shadow: var(--sh-sticker-sm);
  transition: transform var(--dur-rapide) var(--ease-rebond),
              box-shadow var(--dur-rapide) var(--ease-standard),
              background-color var(--dur-rapide) var(--ease-standard);
}
.btn:hover { color: var(--c-texte); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--c-encre); }
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--c-encre); }
.btn--plein { background: var(--c-accent-bouton, var(--c-accent)); color: var(--c-accent-bouton-contraste, var(--c-accent-contraste)); }
.btn--rose  { background: var(--c-rose); color: var(--c-rose-contraste); }
.btn--doux  { box-shadow: none; border-color: var(--c-bordure-champ); }
.btn--doux:hover { box-shadow: none; transform: none; border-color: var(--c-bordure-forte); }
.btn--petit { min-height: var(--cible-min); padding-inline: var(--sp-4); font-size: var(--fs-sm); }
.btn svg { flex: none; width: 1.125em; height: 1.125em; }

/* Espace pro : bouton sans ombre dure, ombre douce */
[data-espace="pro"] .btn { box-shadow: var(--sh-1); border-color: transparent; }
[data-espace="pro"] .btn:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }
[data-espace="pro"] .btn:not(.btn--plein) { border-color: var(--c-bordure-champ); }

.lien-fleche {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-weight: var(--fw-moyen);
}
.lien-fleche svg { width: 1.125em; height: 1.125em; transition: transform var(--dur-rapide) var(--ease-standard); }
.lien-fleche:hover svg { transform: translateX(3px); }

/* --------------------------------------------------------------------------
   Cartes
   -------------------------------------------------------------------------- */
.carte {
  background: var(--c-surface);
  border-radius: var(--r-carte);
  box-shadow: var(--sh-carte);
  border: var(--bordure-fine) solid var(--c-bordure);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
[data-espace="cervoland"] .carte,
.carte--sticker {
  border: var(--bordure-epaisse) solid var(--c-bordure-forte);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sticker);
}
.carte--lien { text-decoration: none; color: inherit; transition: transform var(--dur-rapide) var(--ease-rebond); }
.carte--lien:hover { color: inherit; transform: translate(-2px, -2px); }
.carte > :last-child { margin-top: auto; }
.carte__pied { margin-top: auto; padding-top: var(--sp-2); }

/* --------------------------------------------------------------------------
   Bandeau « texte de démonstration » (brief de lancement)
   -------------------------------------------------------------------------- */
.bandeau-demo {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--c-jaune-pale);
  border: var(--bordure-fine) solid var(--c-jaune-fonce);
  color: var(--c-jaune-fonce);
  font-size: var(--fs-sm);
  line-height: var(--lh-serre);
}
.bandeau-demo svg { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 1px; }

/* --------------------------------------------------------------------------
   En-tête d'espace + passerelle
   -------------------------------------------------------------------------- */
.passerelle {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-2) var(--gouttiere);
  background: var(--c-fond-doux);
  border-bottom: var(--bordure-fine) solid var(--c-bordure);
  font-size: var(--fs-sm);
  color: var(--c-texte-2);
}
.passerelle a { color: var(--c-texte); font-weight: var(--fw-moyen); display: inline-flex; align-items: center; gap: var(--sp-1); }

.entete {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: var(--c-surface);
  border-bottom: var(--bordure-epaisse) solid var(--c-bordure-forte);
}
.entete::before {
  content: "";
  display: block;
  height: 6px;
  background: var(--c-accent);
}
[data-espace="pro"] .entete { border-bottom-width: var(--bordure-fine); border-bottom-color: var(--c-bordure); }
[data-espace="pro"] .entete::before { height: 4px; }
.entete__ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  padding: var(--sp-3) var(--gouttiere);
}
.entete__marque { display: flex; align-items: center; flex: none; }
.entete__marque img { height: 32px; width: auto; }
.entete__nav { flex: 1; }
.entete__nav ul { display: flex; gap: var(--sp-4); align-items: center; }
.entete__nav a {
  display: inline-block;
  padding: var(--sp-2) 0;
  color: var(--c-texte);
  text-decoration: none;
  font-weight: var(--fw-moyen);
  font-size: var(--fs-sm);
  border-bottom: 3px solid transparent;
}
.entete__nav a:hover { border-bottom-color: var(--c-bordure-champ); }
.entete__nav a[aria-current="page"],
.entete__nav a.courant { border-bottom-color: var(--c-accent); }
.entete__action { flex: none; }
.entete__menu { display: none; }

/* Menu mobile : <details> natif, fonctionne sans JavaScript */
@media (max-width: 74.99em) {
  .entete__ligne { flex-wrap: wrap; }
  .entete__nav { order: 3; flex-basis: 100%; }
  .entete__menu {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: var(--cible-min);
    padding: var(--sp-2) var(--sp-3);
    border: var(--bordure-epaisse) solid var(--c-bordure-forte);
    border-radius: var(--r-sm);
    background: var(--c-surface);
    cursor: pointer;
    list-style: none;
    font-weight: var(--fw-semibold);
  }
  .entete__menu::-webkit-details-marker { display: none; }
  .entete__nav ul { flex-direction: column; align-items: stretch; gap: 0; padding-block: var(--sp-2); }
  .entete__nav a { display: block; padding: var(--sp-3) var(--sp-2); border-bottom: 0; border-left: 3px solid transparent; }
  .entete__nav a[aria-current="page"], .entete__nav a.courant { border-left-color: var(--c-accent); }
  .entete__action { order: 2; }
  .entete__action .btn { padding-inline: var(--sp-4); font-size: var(--fs-sm); }
}
@media (max-width: 40em) {
  .entete__action { display: none; }
  .entete__nav .entete__action-mobile { display: block; padding: var(--sp-3) var(--sp-2); }
}
@media (min-width: 75em) {
  .entete__nav details > summary { display: none; }
  .entete__nav .entete__action-mobile { display: none; }
}

.ariane {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  padding-block: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--c-texte-2);
}
.ariane a { color: var(--c-texte-2); }
.ariane svg { width: 1em; height: 1em; }

/* --------------------------------------------------------------------------
   Pied de page
   -------------------------------------------------------------------------- */
.pied {
  margin-top: auto;
  border-top: var(--bordure-epaisse) solid var(--c-bordure-forte);
  background: var(--c-fond-doux);
  font-size: var(--fs-sm);
  color: var(--c-texte-2);
}
[data-espace="pro"] .pied { border-top-width: var(--bordure-fine); border-top-color: var(--c-bordure); }
.pied__grille {
  display: grid;
  gap: var(--sp-6);
  padding-block: var(--sp-7);
}
@media (min-width: 48em) { .pied__grille { grid-template-columns: 1.2fr 1fr 1fr; } }
.pied a { color: var(--c-texte-2); }
.pied h2 { font-size: var(--fs-base); color: var(--c-texte); }
.pied ul { display: flex; flex-direction: column; gap: var(--sp-2); }
.pied__bas {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
  padding-block: var(--sp-4);
  border-top: var(--bordure-fine) solid var(--c-bordure);
}

/* --------------------------------------------------------------------------
   Formulaires (jamais de données cliniques — brief §12)
   -------------------------------------------------------------------------- */
.champ { display: flex; flex-direction: column; gap: var(--sp-1); }
.champ label { font-weight: var(--fw-moyen); }
.champ input, .champ textarea, .champ select {
  min-height: var(--cible-min);
  padding: var(--sp-2) var(--sp-3);
  border: var(--bordure-fine) solid var(--c-bordure-champ);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  width: 100%;
}
.champ textarea { min-height: 8rem; resize: vertical; }
.champ .aide { font-size: var(--fs-sm); color: var(--c-texte-2); }
.champ .erreur { font-size: var(--fs-sm); color: var(--c-erreur); font-weight: var(--fw-moyen); display: none; }
.champ[data-etat="erreur"] .erreur { display: block; }
.champ[data-etat="erreur"] input { border-color: var(--c-erreur); border-width: var(--bordure-epaisse); }
.newsletter { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.newsletter input { flex: 1 1 10rem; min-width: 0; } /* min-width:0 : sinon la largeur intrinsèque du champ pousse le bouton à la ligne avec Poppins */

/* --------------------------------------------------------------------------
   Fenêtre (« Pourquoi deux portes ? ») — <dialog> natif
   -------------------------------------------------------------------------- */
.fenetre {
  width: min(100% - 2 * var(--gouttiere), 40rem);
  padding: 0;
  border: var(--bordure-epaisse) solid var(--c-bordure-forte);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sticker-lg);
  background: var(--c-surface);
  color: var(--c-texte);
}
.fenetre::backdrop { background: rgb(51 48 51 / 0.45); }
.fenetre__corps { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }
.fenetre__entete { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); }
.fenetre__fermer {
  flex: none;
  width: var(--cible-min); height: var(--cible-min);
  display: grid; place-items: center;
  border: var(--bordure-epaisse) solid var(--c-bordure-forte);
  border-radius: var(--r-rond);
  background: var(--c-surface);
}
.fenetre__fermer svg { width: 1.25rem; height: 1.25rem; }
@media (prefers-reduced-motion: no-preference) {
  .fenetre[open] { animation: apparition var(--dur-base) var(--ease-entree); }
}
@keyframes apparition {
  from { opacity: 0; transform: translateY(var(--decalage-apparition)); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Étapes numérotées (déroulement d'un bilan)
   -------------------------------------------------------------------------- */
.etapes { display: flex; flex-direction: column; gap: var(--sp-4); counter-reset: etape; }
.etapes > li {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: var(--sp-4);
  align-items: start;
  counter-increment: etape;
}
.etapes > li::before {
  content: counter(etape);
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  border-radius: var(--r-rond);
  border: var(--bordure-epaisse) solid var(--c-bordure-forte);
  background: var(--c-accent-clair);
  font-weight: var(--fw-gras);
}
.etapes h3 { font-size: var(--fs-lg); }
/* Frise verticale (Qui suis-je ?, déroulement d'un bilan — Nelly, 11 oct.) :
   un seul numéro par étape, un trait fin relie les cercles, plus d'air. */
.etapes--frise { gap: var(--sp-6); }
.etapes--frise > li { position: relative; }
.etapes--frise > li::before { position: relative; z-index: 1; }
.etapes--frise > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(1.375rem - 1px);
  top: 2.75rem;
  bottom: calc(-1 * var(--sp-6));
  width: 2px;
  background: var(--c-bordure);
}
.etapes--frise > li > div { padding-top: 0.4rem; display: flex; flex-direction: column; gap: var(--sp-2); }
.etapes--frise p { max-width: var(--mesure); }
.etapes--coloree > li:nth-child(5n+1)::before { background: var(--c-bleu); }
.etapes--coloree > li:nth-child(5n+2)::before { background: var(--c-jaune); }
.etapes--coloree > li:nth-child(5n+3)::before { background: var(--c-rose); }
.etapes--coloree > li:nth-child(5n+4)::before { background: var(--c-bleu-pale); }
.etapes--coloree > li:nth-child(5n+5)::before { background: var(--c-jaune-pale); }

/* Liste à puces colorées (motifs de consultation, forces, besoins) */
.puces { display: flex; flex-direction: column; gap: var(--sp-2); }
.puces > li { display: flex; gap: var(--sp-3); align-items: baseline; }
.puces > li::before {
  content: "";
  flex: none;
  width: 0.625rem; height: 0.625rem;
  border-radius: var(--r-rond);
  background: var(--c-accent);
  border: 1.5px solid var(--c-bordure-forte);
  transform: translateY(-1px);
}

/* Tableau (tarifs, accompagnements) */
.tableau { width: 100%; border-collapse: collapse; }
.tableau th, .tableau td { text-align: left; padding: var(--sp-3) var(--sp-3); border-bottom: var(--bordure-fine) solid var(--c-bordure); vertical-align: top; }
.tableau th { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--c-texte-2); text-transform: uppercase; letter-spacing: var(--ls-caps); }
.tableau td:first-child { font-weight: var(--fw-moyen); }
.a-valider {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: var(--r-xs);
  background: var(--c-jaune-pale);
  border: 1px solid var(--c-jaune-fonce);
  color: var(--c-jaune-fonce);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px var(--sp-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border: 1.5px solid var(--c-bordure-forte);
  background: var(--c-surface);
}
.badge--gratuit { background: var(--c-accent-clair); }
.badge--payant { background: var(--c-jaune); }
.badge--bientot { background: var(--c-gris-pale); }

/* --------------------------------------------------------------------------
   Jauge circulaire (tokens §9). Le contour encre est obligatoire : c'est lui
   qui rend le niveau lisible, pas la couleur. Niveau via --niveau (0 à 1).
   Retour de Nelly : pas de chiffre affiché ; le mot reste (brief §17).
   -------------------------------------------------------------------------- */
.jauge {
  --niveau: 0;
  --circ: 301.6;
  position: relative;
  width: var(--jauge-taille);
  height: var(--jauge-taille);
  flex: none;
}
.jauge svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.jauge__piste { fill: none; stroke: var(--jauge-piste); stroke-width: 12; }
.jauge__niveau {
  fill: none;
  stroke: var(--jauge-remplissage);
  stroke-width: 12;
  stroke-dasharray: var(--circ);
  stroke-dashoffset: calc(var(--circ) * (1 - var(--niveau)));
  transition: stroke-dashoffset var(--dur-jauge) var(--ease-jauge);
}
.jauge__contour { fill: none; stroke: var(--jauge-contour); stroke-width: 1.5; }
.jauge__mot { display: none; /* plus de libellé (Nelly, 27 sept.) */
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1.1;
  padding: 22%;
}
.jauge--attente .jauge__niveau { stroke-dashoffset: var(--circ); }
.jauge--grande { --jauge-taille: clamp(7rem, 6rem + 5vw, 11rem); }
.jauge--grande .jauge__mot { display: none; /* plus de libellé (Nelly, 27 sept.) */ font-size: var(--fs-base); }
/* Les jauges d'une usine se remplissent l'une après l'autre à l'arrivée. */
.particularites__cartes .carte-jauge:nth-child(2) .jauge__niveau { transition-delay: 0.12s; }
.particularites__cartes .carte-jauge:nth-child(3) .jauge__niveau { transition-delay: 0.24s; }
.particularites__cartes .carte-jauge:nth-child(4) .jauge__niveau { transition-delay: 0.36s; }
.particularites__cartes .carte-jauge:nth-child(5) .jauge__niveau { transition-delay: 0.48s; }
.particularites__cartes .carte-jauge:nth-child(6) .jauge__niveau { transition-delay: 0.6s; }
/* Jauge « variable selon les situations » (sensorialité, attention) : plus de
   pointillés (Nelly, 11 oct.), le remplissage respire entre ses deux bornes. */
.jauge--variable:not(.jauge--attente) .jauge__niveau {
  animation: jauge-respire 7s var(--ease-standard) 0.8s infinite alternate;
}
@keyframes jauge-respire {
  from { stroke-dashoffset: calc(var(--circ) * (1 - var(--niveau-bas, var(--niveau)))); }
  to   { stroke-dashoffset: calc(var(--circ) * (1 - var(--niveau-haut, var(--niveau)))); }
}
@media (prefers-reduced-motion: reduce) {
  .jauge__niveau { transition: none; }
  .jauge--attente .jauge__niveau { stroke-dashoffset: calc(var(--circ) * (1 - var(--niveau))); }
  .jauge--variable .jauge__niveau { animation: none; }
}

/* Carte de jauge (page d'usine) */
.carte-jauge {
  display: flex;
  flex-direction: row;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  text-decoration: none;
  color: var(--c-texte);
}
.carte-jauge:hover { color: var(--c-texte); }
.carte-jauge__nom { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: 1.2; }
.carte-jauge__lieu { font-size: var(--fs-sm); color: var(--c-texte-2); }
.carte-jauge .lien-fleche { font-size: var(--fs-sm); color: var(--c-accent-fonce); margin-top: var(--sp-1); }

/* --------------------------------------------------------------------------
   Cartes d'usine / de personnage (entrée Cervoland)
   -------------------------------------------------------------------------- */
.carte-usine { padding: 0; overflow: hidden; gap: 0; }
.carte-usine__ruban { height: 8px; background: var(--c-accent); }
.carte-usine__visuel {
  display: flex; justify-content: center; align-items: flex-end;
  height: 13rem; padding: var(--sp-4);
  background: var(--c-accent-pale);
}
.carte-usine__visuel img { max-height: 100%; width: auto; }
.carte-usine__corps { padding: var(--sp-5) var(--sp-6) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); }
.carte-usine__corps .btn { align-self: flex-start; margin-top: var(--sp-3); }

/* Sticker personnage (tant que les PNG ne sont pas détourés — plus utilisé
   pour Tisto, Bizz-Bizz, Aoutch ; conservé pour Lilirone/Astrolo à venir) */
.attente-visuel {
  display: grid; place-items: center;
  border: var(--bordure-epaisse) dashed var(--c-bordure-champ);
  border-radius: var(--r-rond);
  color: var(--c-texte-2);
  font-size: var(--fs-xs);
  text-align: center;
  padding: var(--sp-3);
  aspect-ratio: 1;
}

/* --------------------------------------------------------------------------
   Ressources
   -------------------------------------------------------------------------- */
.carte-ressource__apercu {
  aspect-ratio: 4 / 3;
  max-height: 11rem;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  border: var(--bordure-fine) dashed var(--c-bordure-champ);
  display: grid; place-items: center;
  color: var(--c-texte-2);
  font-size: var(--fs-sm);
}
.carte-ressource__meta { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--c-texte-2); }
.carte-ressource h3 { font-size: var(--fs-lg); hyphens: manual; overflow-wrap: anywhere; }
.carte-ressource__titre a { text-decoration: none; color: inherit; }
.carte-ressource__titre a:hover { text-decoration: underline; text-underline-offset: 0.15em; }

/* Ancres de page (usine) */
.ancres { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ancres a {
  display: inline-flex; align-items: center;
  min-height: var(--cible-min);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-pill);
  border: var(--bordure-epaisse) solid var(--c-bordure-forte);
  background: var(--c-surface);
  color: var(--c-texte);
  text-decoration: none;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
}
.ancres a:hover, .ancres a.courant { background: var(--c-accent); color: var(--c-accent-contraste); }

/* Citation du personnage */
.bulle {
  display: flex; gap: var(--sp-4); align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  background: var(--c-accent-pale);
}
.bulle img { width: 5rem; flex: none; }
.bulle p { font-weight: var(--fw-leger); font-size: var(--fs-md); }

/* Apparition au défilement (progressive : visible sans JS) */
.js .apparition { opacity: 0; transform: translateY(var(--decalage-apparition)); transition: opacity var(--dur-lente) var(--ease-entree), transform var(--dur-lente) var(--ease-entree); }
.js .apparition.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js .apparition { opacity: 1; transform: none; transition: none; } }
