/* App témoin « Mon histoire » (PWA). Feuille externe : la CSP n'autorise aucun style en ligne.
   Accessibilité (cahier des charges §7) : question ≥ 21 px, cibles ≥ 44 px, contrastes AA dans
   les deux thèmes — vérifiés par tests/test_pwa_navigateur.py (axe-core et mesures réelles). */
:root {
  --fond: #FBF6EE;
  --fond-carte: #FFFFFF;
  --texte: #24211D;
  --texte-doux: #5B564C;
  --accent: #A64B34;
  --sur-accent: #FFFFFF;        /* texte posé sur l'accent */
  --accent-doux: #E7CDBF;
  --ecoute: #2F6F5E;
  --sur-ecoute: #FFFFFF;
  --reflechit: #C08A2E;
  --danger: #8E3B33;
  --bord: #8A806C;          /* contour des boutons : ≥ 3:1 sur le fond (WCAG 1.4.11) */
  --bandeau: #F3E7D3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1C1A17;
    --fond-carte: #26231F;
    --texte: #F4EFE6;
    --texte-doux: #C9C2B4;
    --accent: #E08A6F;
    --sur-accent: #1C1A17;
    --accent-doux: #4A342C;
    --ecoute: #6FBFA8;
    --sur-ecoute: #1C1A17;
    --reflechit: #E0AE5C;
    --danger: #F0A39A;
    --bord: #8A8274;
    --bandeau: #332E27;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--fond); color: var(--texte);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body {
  height: 100vh; height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.cache { display: none !important; }

button {
  font: inherit;
  border: none;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled { cursor: default; opacity: 0.45; }
button:focus-visible { outline: 4px solid var(--ecoute); outline-offset: 3px; }

.bouton-fort {
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  font-weight: 700;
  color: var(--sur-accent);
  background: var(--accent);
  padding: 20px 40px;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12);
}
.bouton-doux, .bouton-pointille {
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  font-weight: 600;
  color: var(--texte);
  background: var(--fond-carte);
  border: 2px solid var(--bord);
  padding: 14px 22px;
  border-radius: 16px;
}
.bouton-pointille { border-style: dashed; font-weight: 700; }
.alerte { color: var(--danger); border-color: var(--danger); }
.lien {
  font-size: clamp(1.05rem, 1.8vw, 1.15rem);
  font-weight: 600;
  color: var(--texte-doux);
  background: transparent;
  padding: 8px 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rangee {
  display: flex; justify-content: center; gap: 14px;
  width: 100%; max-width: 560px;
}
.rangee > button { flex: 1 1 0; }

/* ---- écrans pleins (accueil, guide, connexion, autre appareil, fin) ---- */
.ecran.plein {
  height: 100%;
  overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; text-align: center; padding: 32px 24px;
}
.ecran.plein h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; line-height: 1.25; }
.ecran.plein p { font-size: clamp(1.15rem, 2.4vw, 1.4rem); margin: 0; max-width: 46ch; line-height: 1.45; }
.texte-doux { color: var(--texte-doux); }
.message { color: var(--danger); min-height: 1.4em; }
.message:empty { display: none; }
.etape { color: var(--texte-doux); font-weight: 600; }
.illustration { color: var(--accent); }

/* ---- la séance : trois bandes, seule la zone centrale défile ---- */
.ecran.seance {
  display: flex; flex-direction: column;
  height: 100%;
}
header { flex: 0 0 auto; text-align: center; padding: 14px 16px 4px; }
header .titre { font-size: 1.1rem; color: var(--texte-doux); font-weight: 600; letter-spacing: 0.02em; }

#zone-centrale {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
  padding: 12px 24px 20px;
  text-align: center;
}
#panneau-historique {
  width: min(680px, 92vw);
  max-height: 34vh;
  overflow-y: auto;
  background: var(--fond-carte);
  border: 2px solid var(--bord);
  border-radius: 16px;
  padding: 14px 18px;
  text-align: left;
}
#panneau-historique .ligne { margin: 0 0 12px; font-size: clamp(1.05rem, 2vw, 1.15rem); line-height: 1.4; }
#panneau-historique .ligne:last-child { margin-bottom: 0; }
#panneau-historique .qui { font-weight: 700; color: var(--accent); }
#panneau-historique .ligne.temoin .qui { color: var(--ecoute); }

/* La question : jamais sous 21 px, quelle que soit la taille de l'écran (exigence §7). */
#question {
  font-size: clamp(1.6rem, 4.2vw, 3rem);
  line-height: 1.35;
  font-weight: 600;
  max-width: 42ch;
}
#statut { font-size: clamp(1.15rem, 2.4vw, 1.5rem); color: var(--texte-doux); min-height: 1.6em; }
canvas#onde { width: min(680px, 92vw); height: 110px; display: block; }

.bandeau {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  background: var(--bandeau);
  color: var(--texte);
  border-radius: 14px;
  padding: 12px 16px;
  max-width: 560px;
  margin: 0;
}
.bandeau.alerte { border: 2px solid var(--danger); color: var(--texte); }

#bouton-principal {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--sur-accent);
  background: var(--accent);
  padding: 24px 48px;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12);
  transition: transform 0.15s ease, background 0.25s ease;
}
#bouton-principal.ecoute { background: var(--ecoute); color: var(--sur-ecoute); }
#bouton-principal:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.12); }
#bouton-principal.respire { animation: respire 2.2s ease-in-out infinite; }
@keyframes respire {
  0%, 100% { box-shadow: 0 6px 0 rgba(0,0,0,0.12), 0 0 0 0 var(--accent-doux); }
  50% { box-shadow: 0 6px 0 rgba(0,0,0,0.12), 0 0 0 14px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  #bouton-principal.respire { animation: none; }
}

footer {
  flex: 0 0 auto;     /* jamais rogné : la barre de boutons reste toujours visible */
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  background: var(--fond);
  border-top: 2px solid var(--bord);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
#choix-suite button, #actions-attente button { padding: 16px 18px; font-size: clamp(1.05rem, 2.2vw, 1.3rem); font-weight: 700; }

/* ---- confirmation de fin ---- */
.voile {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 20;
}
.voile .carte {
  background: var(--fond-carte);
  border-radius: 20px;
  padding: 30px 26px;
  max-width: 480px;
  display: flex; flex-direction: column; gap: 22px; align-items: center; text-align: center;
}
.voile .carte p { font-size: 1.3rem; margin: 0; }

/* Petits téléphones : les boutons d'une rangée passent l'un sous l'autre plutôt que de rapetisser. */
@media (max-width: 420px) {
  .rangee { flex-direction: column; }
  #bouton-principal { padding: 20px 32px; }
}
