/* Reprise en main — styles (DESIGN.md). Mobile d'abord, thèmes clair et sombre. */

:root {
  --fond: #F2EFEC;
  --surface: #FFFFFF;
  --encre: #151515;
  --texte2: #5E5853;
  --bord: #ECE8E4;
  --bord2: #CFC8C2;
  --forme: #2B5BD7;
  --forme-texte: #1F3F99;
  --forme-fond: #E6EDFB;
  --fortune: #D9861C;
  --fortune-texte: #7A4A0C;
  --fortune-fond: #FBEEDC;
  --or: #C9A227;
  --nav: #151515;
  --nav-texte: #FFFFFF;
  --inverse: #FFFFFF;
  --alerte-fond: #FBEEDC;
  --titre: 'Space Grotesk', system-ui, sans-serif;
  --corps: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #151515; --surface: #1F1F1F; --encre: #F2EFEC; --texte2: #B5ADA6;
    --bord: #2C2C2C; --bord2: #4A4643; --forme-texte: #9DB6F5; --forme-fond: #1D2740;
    --fortune-texte: #F2C27E; --fortune-fond: #3A2A14; --nav: #F2EFEC; --nav-texte: #151515;
    --inverse: #151515; --alerte-fond: #3A2A14; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #151515; --surface: #1F1F1F; --encre: #F2EFEC; --texte2: #B5ADA6;
  --bord: #2C2C2C; --bord2: #4A4643; --forme-texte: #9DB6F5; --forme-fond: #1D2740;
  --fortune-texte: #F2C27E; --fortune-fond: #3A2A14; --nav: #F2EFEC; --nav-texte: #151515;
  --inverse: #151515; --alerte-fond: #3A2A14; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 400 15px/1.45 var(--corps);
  padding: env(safe-area-inset-top) 0 0;
}
h1, h2, h3, .chiffre { font-family: var(--titre); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--encre); }
button, input, textarea, select { font: inherit; color: inherit; }
.muet { color: var(--texte2); }
.petit { font-size: 13px; }
.cache { display: none !important; }

/* ---------- Mise en page ---------- */
.app { max-width: 1180px; margin: 0 auto; }
main { padding: 16px 16px calc(110px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.entete { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 8px 2px 4px; }
.entete .date { color: var(--texte2); font-size: 13px; text-transform: capitalize; }
.grille { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pile { display: flex; flex-direction: column; gap: 10px; }
.ligne { display: flex; align-items: center; gap: 10px; }
.entre { justify-content: space-between; }

/* ---------- Cartes ---------- */
.carte { background: var(--surface); border-radius: 28px; padding: 18px; }
.carte.petite { border-radius: 20px; padding: 14px; }
.carte h2 + * { margin-top: 10px; }
.tuile { background: var(--surface); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; min-height: 92px; }
.tuile .label { font-size: 12px; color: var(--texte2); }
.tuile .chiffre { font-size: 22px; }
.bandeau { background: var(--alerte-fond); color: var(--fortune-texte); border-radius: 18px; padding: 12px 14px; font-weight: 600; font-size: 14px; }

/* ---------- Pastilles et jauges ---------- */
.pastille { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; }
.pastille.forme { background: var(--forme-fond); color: var(--forme-texte); }
.pastille.fortune { background: var(--fortune-fond); color: var(--fortune-texte); }
.pastille.neutre { background: var(--fond); color: var(--texte2); }
.jauge { height: 9px; border-radius: 999px; background: var(--bord); overflow: hidden; }
.jauge > span { display: block; height: 100%; border-radius: 999px; background: var(--encre); transition: width .5s ease; }
.jauge.forme > span { background: var(--forme); }
.jauge.fortune > span { background: var(--fortune); }

/* ---------- Carte avatar ---------- */
.carte-avatar { display: flex; gap: 14px; align-items: center; }
.carte-avatar .scene { background: var(--fond); border-radius: 22px; flex: 0 0 auto; display: flex; align-items: flex-end; justify-content: center; padding: 6px 4px 0; }
.carte-avatar .infos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.niveau { font-family: var(--titre); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }

/* ---------- Quêtes ---------- */
.quete {
  width: 100%; min-height: 56px; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--bord); border-radius: 18px; padding: 8px 14px; cursor: pointer;
}
.quete .case {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bord2); flex: 0 0 auto;
  display: grid; place-items: center; transition: background .15s;
}
.quete .case svg { opacity: 0; }
.quete[aria-pressed="true"] .case { background: var(--encre); border-color: var(--encre); }
.quete[aria-pressed="true"] .case svg { opacity: 1; stroke: var(--inverse); }
.quete .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.quete .txt b { font-weight: 600; }
.quete .txt small { color: var(--texte2); font-size: 12px; }
.quete .xp { font-weight: 600; font-size: 13px; }
.quete[aria-pressed="true"] .txt b, .quete[aria-pressed="true"] .xp { color: var(--texte2); }
.quete[aria-pressed="true"] .txt b { text-decoration: line-through; text-decoration-thickness: 1px; }

/* ---------- Formulaires ---------- */
label.champ { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--texte2); }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="password"], textarea, select {
  width: 100%; min-height: 48px; border: 1px solid var(--bord2); border-radius: 14px; padding: 11px 13px;
  background: var(--surface); color: var(--encre); font-size: 16px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--forme); outline-offset: 2px; }
.bouton {
  min-height: 52px; border: 0; border-radius: 999px; padding: 0 22px; background: var(--encre); color: var(--inverse);
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.bouton.secondaire { background: var(--fond); color: var(--encre); border: 1px solid var(--bord2); }
.bouton.plein { width: 100%; }
.bouton:disabled { opacity: .5; cursor: default; }
.lien-bouton { background: none; border: 0; padding: 8px 0; color: var(--texte2); text-decoration: underline; cursor: pointer; font-size: 13px; }
.etat-sauvegarde { font-size: 12px; color: var(--texte2); min-height: 16px; }

/* Onglets (Corps / Sport / Repas) */
.onglets { display: flex; gap: 6px; background: var(--surface); border-radius: 999px; padding: 5px; }
.onglets a { flex: 1; text-align: center; padding: 10px 6px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 14px; color: var(--texte2); }
.onglets a[aria-current="page"] { background: var(--encre); color: var(--inverse); }

/* ---------- Sport ---------- */
.exercice { display: flex; flex-direction: column; gap: 10px; }
.exercice + .exercice { border-top: 1px solid var(--bord); padding-top: 14px; margin-top: 4px; }
.series { display: flex; flex-wrap: wrap; gap: 8px; }
.serie { display: flex; align-items: center; gap: 6px; background: var(--fond); border-radius: 16px; padding: 6px 8px 6px 6px; }
.serie button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--bord2); background: var(--surface); font-weight: 600; cursor: pointer; }
.serie button[aria-pressed="true"] { background: var(--encre); border-color: var(--encre); color: var(--inverse); }
.serie input { width: 74px; min-height: 44px; padding: 8px; text-align: center; }

/* ---------- Listes ---------- */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--bord); }
.liste li:last-child { border-bottom: 0; }
.liste .fin { margin-left: auto; text-align: right; }
.case-ligne { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; width: 100%; }
.case-ligne input { width: 24px; height: 24px; accent-color: var(--encre); flex: 0 0 auto; }
.icone-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--fond); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }

/* ---------- Graphique ---------- */
.graphique svg { width: 100%; height: auto; display: block; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--texte2); }
.legende i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* ---------- Bilans ---------- */
.bilan { white-space: pre-line; }
.bilan-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- Badges ---------- */
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.badge { display: flex; align-items: center; gap: 10px; background: var(--fond); border-radius: 18px; padding: 12px; font-size: 13px; font-weight: 600; }
.badge .rond { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--bord); flex: 0 0 auto; }
.badge.obtenu .rond { background: var(--or); color: #FFFFFF; }
.badge:not(.obtenu) { color: var(--texte2); }

/* ---------- Navigation ---------- */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
  background: var(--nav); border-radius: 26px; padding: 7px; display: flex; gap: 4px; z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.nav a { width: 54px; height: 50px; border-radius: 20px; display: grid; place-items: center; color: var(--nav-texte); text-decoration: none; }
.nav a svg { stroke: currentColor; }
.nav a[aria-current="page"] { background: var(--nav-texte); color: var(--nav); border-radius: 999px; }
.nav .libelle, .nav .marque, .nav .seulement-bureau { display: none; }

/* ---------- Connexion ---------- */
.connexion { max-width: 420px; margin: 12vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--encre); color: var(--inverse); padding: 12px 18px; border-radius: 999px; font-weight: 600; z-index: 20;
  max-width: calc(100% - 32px); text-align: center; animation: apparait .25s ease;
}
@keyframes apparait { from { opacity: 0; transform: translate(-50%, 10px); } }

/* Avatar : petite animation au changement de palier */
.avatar-svg { display: block; }
.avatar-evolue { animation: evolue .9s cubic-bezier(.2, .9, .3, 1.3); transform-origin: 50% 100%; }
@keyframes evolue { 0% { transform: scale(.92); opacity: .5; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Ordinateur : sidebar noire ---------- */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 16px; }
  main { padding: 0 0 40px; }
  .nav {
    position: sticky; top: 16px; left: auto; bottom: auto; transform: none; align-self: start;
    flex-direction: column; padding: 18px 12px; gap: 4px; box-shadow: none;
  }
  .nav .marque { display: block; color: var(--nav-texte); font-family: var(--titre); font-weight: 600; font-size: 18px; padding: 4px 10px 16px; }
  .nav a { width: auto; height: 46px; display: flex; gap: 12px; padding: 0 12px; justify-content: flex-start; }
  .nav a[aria-current="page"] { border-radius: 14px; }
  .nav .libelle, .nav .seulement-bureau { display: flex; }
  .grille.bureau-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
}
