/* Une seule variable pilote toute l'ambiance : --h, la teinte de la catégorie
   en cours. Elle est animable (@property), donc le fond glisse d'une couleur
   à l'autre entre deux questions. */
@property --h { syntax: "<number>"; inherits: true; initial-value: 218; }

:root {
  --h: 218;
  color-scheme: light dark;
  --fond: hsl(var(--h) 50% 96%);
  --halo1: hsl(var(--h) 95% 84%);
  --halo2: hsl(calc(var(--h) + 45) 90% 89%);
  --carte: rgb(255 255 255 / .86);
  --texte: hsl(var(--h) 35% 12%);
  --discret: hsl(var(--h) 14% 38%);
  --bord: hsl(var(--h) 40% 30% / .14);
  --accent: hsl(var(--h) 75% 40%);
  --accent-fort: hsl(var(--h) 72% 44%);
  --accent-doux: hsl(var(--h) 85% 45% / .12);
  --ok: #17803a; --ko: #cf222e;
  --ombre: 0 1px 2px hsl(var(--h) 40% 20% / .06), 0 6px 20px hsl(var(--h) 40% 20% / .07);
  transition: --h .7s ease;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: hsl(var(--h) 38% 7%);
    --halo1: hsl(var(--h) 75% 24%);
    --halo2: hsl(calc(var(--h) + 45) 65% 17%);
    --carte: hsl(var(--h) 28% 15% / .82);
    --texte: hsl(var(--h) 30% 94%);
    --discret: hsl(var(--h) 14% 68%);
    --bord: hsl(var(--h) 40% 85% / .13);
    --accent: hsl(var(--h) 85% 72%);
    --accent-fort: hsl(var(--h) 65% 46%);
    --accent-doux: hsl(var(--h) 85% 65% / .16);
    --ok: #3fb950; --ko: #ff6b61;
    --ombre: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100dvh; color: var(--texte); background: var(--fond);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body::before {  /* halos de couleur, fixes pendant le défilement */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(75% 48% at 92% -6%, var(--halo1), transparent 72%),
    radial-gradient(70% 42% at -8% 104%, var(--halo2), transparent 72%);
}
main { max-width: 560px; margin: 0 auto; padding: 20px 16px 104px; }
section:not([hidden]) { animation: apparait .28s ease both; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 4px 0 16px; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 6px 0 20px; letter-spacing: -.01em; text-wrap: balance; }
h3 { font-size: .8rem; margin: 24px 4px 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--discret); }
.carte h3 { margin: 0 0 8px; }
p { margin: 0 0 8px; }
.discret { color: var(--discret); font-size: .875rem; }
.erreur { color: var(--ko); }

.carte, .tuile {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 18px;
  box-shadow: var(--ombre);
}
.carte { padding: 16px; margin-bottom: 12px; }
.tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.tuile { padding: 14px 6px 12px; text-align: center; }
.tuile b { display: block; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tuile span { color: var(--discret); font-size: .72rem; line-height: 1.3; display: block; margin-top: 2px; }

button, input {
  font: inherit; color: inherit; width: 100%; min-height: 52px; padding: 12px 16px;
  border: 1px solid var(--bord); border-radius: 16px; background: var(--carte);
  margin-bottom: 10px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { cursor: pointer; transition: transform .12s ease, background-color .2s, border-color .2s; }
button:active:not(:disabled) { transform: scale(.975); }
button:disabled { cursor: default; }
button.principal {
  background: var(--accent-fort); border-color: transparent; color: #fff; font-weight: 650;
  box-shadow: 0 6px 18px hsl(var(--h) 72% 44% / .35);
}
button.lien { width: auto; min-height: 0; border: 0; background: none; color: var(--accent); margin: 0; padding: 6px; font-weight: 600; }
label { display: block; margin-bottom: 6px; font-weight: 600; }

/* ---------- accueil ---------- */
.hero { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.hero h1 { margin: 0 0 2px; }
.hero p { margin: 0; }
.flamme {
  flex: none; width: 76px; height: 76px; border-radius: 24px; display: grid; place-content: center;
  text-align: center; background: var(--carte); border: 1px solid var(--bord); box-shadow: var(--ombre);
}
.flamme span { font-size: 1.5rem; line-height: 1; }
.flamme b { font-size: 1.25rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.flamme.eteinte span { filter: grayscale(1); opacity: .5; }
.flamme:not(.eteinte) span { display: block; animation: flamme 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
.bilan { text-align: center; padding: 22px 16px; animation: monte .4s cubic-bezier(.2, .9, .3, 1.2) both; }
.bilan .gros { font-size: 2.4rem; line-height: 1.1; }
.bilan b { font-size: 1.3rem; display: block; margin: 6px 0 2px; }

/* ---------- question ---------- */
.entete { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 9px; border-radius: 99px;
  background: var(--accent-doux); color: var(--accent); font-weight: 650; font-size: .85rem;
  text-transform: capitalize;
}
.score { margin-left: auto; font-size: .85rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.score .ok { color: var(--ok); }
.score .ko { color: var(--ko); margin-left: 8px; }
#q-meta { margin-bottom: 4px; }
#q-corps { animation: monte .32s ease both; }

#q-propositions button {
  display: flex; align-items: center; gap: 12px; text-align: left; box-shadow: var(--ombre);
  animation: monte .34s ease both; animation-delay: calc(var(--i) * 45ms + 60ms);
}
#q-propositions button i {
  flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-content: center;
  font-style: normal; font-size: .8rem; font-weight: 700;
  background: var(--accent-doux); color: var(--accent); transition: background-color .2s, color .2s;
}
#q-propositions button:disabled:not(.ok, .ko) { opacity: .55; }
#q-propositions button.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--carte)); }
#q-propositions button.ko { border-color: var(--ko); background: color-mix(in srgb, var(--ko) 16%, var(--carte)); }
#q-propositions button.ok i { background: var(--ok); color: #fff; }
#q-propositions button.ko i { background: var(--ko); color: #fff; }
#q-propositions button.gagne { animation: gagne .45s cubic-bezier(.3, 1.6, .5, 1) both; }
#q-propositions button.perdu { animation: secoue .42s ease both; }
#q-propositions button.revele { animation: revele .6s ease .15s both; }

#q-resultat { animation: monte .35s ease both; }
#q-verdict { font-weight: 700; font-size: 1.05rem; }
#q-verdict.ok { color: var(--ok); }
#q-verdict.ko { color: var(--ko); }
#btn-suivante { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); animation: monte .35s ease .1s both; }

#confettis { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
#confettis i {
  position: absolute; width: 8px; height: 12px; border-radius: 2px;
  animation: confetti .9s cubic-bezier(.15, .7, .3, 1) both;
}

/* ---------- stats ---------- */
.barres { display: flex; align-items: flex-end; gap: 2px; height: 96px; margin-bottom: 10px; }
.barres .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.barres .seg {
  border-radius: 3px 3px 0 0; background: var(--accent-fort); min-height: 0;
  transform-origin: bottom; animation: pousse .5s cubic-bezier(.2, .8, .3, 1) both;
}
.barres .seg.ok { background: var(--ok); }
.barres .seg.ko { background: var(--ko); border-radius: 0; }
.barres .col.vide::after { content: ""; height: 2px; border-radius: 1px; background: var(--bord); }
.barres.etiquetees { height: 124px; gap: 8px; }
.barres.etiquetees .seg { border-radius: 6px 6px 2px 2px; }
.barres.etiquetees .col span { text-align: center; font-size: .72rem; color: var(--discret); }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 10px; }
.pastille.ok { background: var(--ok); margin-left: 0; }
.pastille.ko { background: var(--ko); }

.ligne { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin-bottom: 12px; font-size: .92rem; }
.ligne:last-child { margin-bottom: 0; }
.jauge { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: var(--bord); overflow: hidden; }
.jauge i {
  display: block; height: 100%; border-radius: 4px; background: hsl(var(--hc, var(--h)) 70% 50%);
  transform-origin: left; animation: etire .6s cubic-bezier(.2, .8, .3, 1) both;
}

/* ---------- navigation ---------- */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--carte); border-top: 1px solid var(--bord);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1; max-width: 180px; border: 0; border-radius: 0; margin: 0; background: none;
  color: var(--discret); min-height: 62px; padding: 8px 6px 6px; font-size: .7rem; font-weight: 600;
}
nav svg {
  display: block; width: 24px; height: 24px; margin: 0 auto 2px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
nav button.actif { color: var(--accent); }
nav button.actif svg { transform: translateY(-2px) scale(1.1); }

/* ---------- animations ---------- */
@keyframes apparait { from { opacity: 0; } }
@keyframes monte { from { opacity: 0; transform: translateY(12px); } }
@keyframes gagne { 40% { transform: scale(1.045); } }
@keyframes secoue {
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); }
}
@keyframes revele { 50% { transform: scale(1.025); } }
@keyframes confetti {
  from { opacity: 1; transform: translate(0, 0) rotate(0); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--r)); }
}
@keyframes pousse { from { transform: scaleY(0); } }
@keyframes etire { from { transform: scaleX(0); } }
@keyframes flamme { 50% { transform: scale(1.12) rotate(-4deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
