/* AiKO : feuille principale. Jetons et regles : DESIGN.md (scene plate, contenu opaque, verre sur la seule barre). */

@font-face { font-family: "Fraunces"; src: url("polices/fraunces-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url("polices/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("polices/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "JBMono"; src: url("polices/jetbrains-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --fond: #F4F2EE; --surface: #FFFFFF; --surface-2: #ECE9E3; --encre: #1A1D23; --encre-2: #5B606A; --trait: #D9D5CD;
  --maitrise: #0E8A70; --lacune: #A86A00; --angle-mort: #C0304A; --frontiere: #7A818C; --accent: #1F5FBF;
  --verre-teinte: rgba(255, 255, 255, .62); --verre-bord: rgba(255, 255, 255, .55); --verre-reflet: rgba(255, 255, 255, .45);
  --e1: 4px; --e2: 8px; --e3: 12px; --e4: 16px; --e6: 24px; --e8: 32px; --e12: 48px;
  --courbe: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0E1116; --surface: #171B22; --surface-2: #1F242D; --encre: #E8E6E1; --encre-2: #A3A7AE; --trait: #2A303A;
    --maitrise: #3CC8A8; --lacune: #F2B04C; --angle-mort: #F2667A; --frontiere: #8E96A3; --accent: #7FB7FF;
    --verre-teinte: rgba(23, 27, 34, .72); --verre-bord: rgba(255, 255, 255, .14); --verre-reflet: rgba(255, 255, 255, .18);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--fond); color: var(--encre); font: 400 1.0625rem/1.5 "Plex", system-ui, sans-serif; overflow-x: hidden; }
main { max-width: 640px; margin: 0 auto; padding: var(--e4) var(--e4) 120px; }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; line-height: 1.2; margin: 0 0 var(--e3); }
h1 { font-size: 1.75rem; } h2 { font-size: 1.375rem; } h3 { font-size: 1.25rem; }
p { margin: 0 0 var(--e3); }
.discret { color: var(--encre-2); font-size: .9375rem; }
.chargement { color: var(--encre-2); padding-top: 30vh; text-align: center; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); }

/* en-tete : avatar + niveau */
.entete { display: flex; align-items: center; gap: var(--e4); margin-bottom: var(--e6); }
.entete .avatar-boite { width: 64px; height: 64px; flex: none; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.entete .titre { min-width: 0; }
.entete .titre h1 { margin: 0; }
.jauge { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: var(--e2); }
.jauge i { display: block; height: 100%; background: var(--maitrise); border-radius: inherit; transition: width .3s var(--courbe); }

/* paliers de temps */
.paliers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--e2); margin: 0 0 var(--e6); }
.palier { min-height: 48px; padding: var(--e2) var(--e3); border-radius: 16px; border: 1px solid var(--trait); background: var(--surface); text-align: left; line-height: 1.25; }
.palier .discret { display: block; font-size: .8125rem; }
.palier[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* plateau (scene plate : aplats, ni degrade ni contour) */
.plateau { background: var(--surface); border-radius: 24px; padding: var(--e3); margin-bottom: var(--e6); }
.plateau svg { display: block; width: 100%; height: auto; }
.plateau .case { cursor: pointer; }
.plateau .case text { font: 600 11px "Plex", sans-serif; fill: var(--encre); }
.legende { display: flex; flex-wrap: wrap; gap: var(--e2) var(--e4); font-size: .8125rem; color: var(--encre-2); margin-top: var(--e2); }
.legende span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c); vertical-align: -1px; }

/* contenu opaque */
.carte { background: var(--surface); border-radius: 20px; padding: var(--e4); margin-bottom: var(--e4); }
.carte h3 { margin-bottom: var(--e2); }
.carte ul { margin: 0; padding-left: 1.2em; }
.carte li + li { margin-top: var(--e2); }
pre, code { font-family: "JBMono", ui-monospace, monospace; }
pre { margin: 0 0 var(--e3); padding: var(--e3); background: var(--surface-2); border-radius: 12px; font-size: .9375rem; line-height: 1.45; overflow-x: auto; white-space: pre; }
.sortie { border-left: 3px solid var(--maitrise); }
.sortie.erreur { border-left-color: var(--angle-mort); }
dl.jargon dt { font-weight: 600; } dl.jargon dd { margin: 0 0 var(--e2); color: var(--encre-2); }

.actions { display: flex; gap: var(--e2); margin-bottom: var(--e2); }
.actions .bouton { flex: 1; }

/* boutons */
.bouton { min-height: 44px; padding: 0 var(--e4); border-radius: 14px; border: 1px solid var(--trait); background: var(--surface); }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--fond); font-weight: 600; }
.choix { display: grid; gap: var(--e2); margin: var(--e3) 0; }
.choix button { text-align: left; min-height: 48px; padding: var(--e3) var(--e4); border-radius: 14px; border: 1px solid var(--trait); background: var(--surface); }
.choix button pre { margin: 0; padding: 0; background: none; }
.choix button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choix button.juste { border-color: var(--maitrise); box-shadow: inset 0 0 0 2px var(--maitrise); }
.choix button.faux { border-color: var(--angle-mort); box-shadow: inset 0 0 0 2px var(--angle-mort); }
.confiance { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--e2); }
.confiance button { min-height: 48px; border-radius: 14px; border: 1px solid var(--trait); background: var(--surface); }
.confiance button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); font-weight: 600; }
button:disabled { cursor: default; }
.choix button:disabled:not([aria-pressed="true"]):not(.juste), .confiance button:disabled:not([aria-pressed="true"]) { opacity: .55; }
.verdict { padding: var(--e3) var(--e4); border-radius: 14px; background: var(--surface-2); margin: var(--e3) 0; }
.verdict.angle-mort { box-shadow: inset 4px 0 0 var(--angle-mort); }
.verdict.juste { box-shadow: inset 4px 0 0 var(--maitrise); }
.verdict.lacune { box-shadow: inset 4px 0 0 var(--lacune); }
.etape { font-size: .8125rem; color: var(--encre-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: var(--e2); }

/* bilan : la cellule qui grandit (seule animation signature) */
.bilan { text-align: center; }
.bilan .avatar-boite { width: 160px; height: 160px; margin: 0 auto var(--e4); border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.cellule-grandit { animation: grandit .6s var(--courbe); transform-origin: center; transform-box: fill-box; }
@keyframes grandit { from { transform: scale(.6); } to { transform: scale(1); } }

/* barre d'actions : la SEULE couche de verre (DESIGN.md section 5) */
#barre { position: fixed; left: 50%; bottom: max(var(--e4), env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(608px, calc(100% - 2 * var(--e4))); display: flex; gap: var(--e2); padding: var(--e2); border-radius: 22px; }
#barre:empty { display: none; }
#barre .bouton { flex: 1; }
#barre .repos { flex: 1; margin: 0; padding: var(--e3) var(--e4); text-align: center; color: var(--encre-2); }
.verre { background: var(--verre-teinte); -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--verre-bord); box-shadow: inset 0 1px 0 var(--verre-reflet), 0 8px 24px -12px rgba(0, 0, 0, .35); }
@media (prefers-reduced-transparency: reduce) { .verre { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); } }
@media (prefers-contrast: more) { .verre { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); border: 2px solid var(--encre); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
