/* J-COMIT 2026 — feuille de style de l'espace virtuel.
   La scène mesure exactement 1280 x 800 px et est mise à l'échelle d'un bloc
   (canvas + surcouches) afin que la carte reste intégralement visible. */

:root {
  --bleu: #1b2a56;
  --bleu-clair: #2c4a8f;
  --rouge: #c8102e;
  --sable: #f2ede3;
  --encre: #1d2129;
  --gris: #5b6472;
  --bord: rgba(27, 42, 86, .18);
  --ombre: 0 10px 30px rgba(15, 22, 40, .28);
  --largeur-scene: 1280px;
  --hauteur-scene: 800px;
  /* Taille d'une case d'avatar dans la grille de sélection (px). */
  --avatar-zoom: 2;
}

* { box-sizing: border-box; }

/* L'attribut `hidden` doit toujours l'emporter : plusieurs blocs de l'ATH
   déclarent `display: flex`, ce qui masquerait sinon la règle du navigateur. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: #10131a;
  color: var(--encre);
  font-family: "Marianne", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

#scene {
  position: relative;
  width: var(--largeur-scene);
  height: var(--hauteur-scene);
  transform-origin: top left;
  overflow: hidden;
  background: #10131a;
}

#canvas canvas {
  display: block;
  image-rendering: pixelated;
}

.visuellement-cache {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ ATH */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 14px;
}

#hud > * { pointer-events: auto; }

#hud-zone {
  position: absolute;
  top: 12px; left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, .92);
  border-left: 4px solid var(--bleu);
  border-radius: 3px;
  box-shadow: var(--ombre);
  font-weight: 700;
  letter-spacing: .01em;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bleu);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

#hud-etat {
  position: absolute;
  top: 12px; right: 12px;
  padding: 6px 11px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--ombre);
  font-size: 12.5px;
  font-weight: 600;
}
#hud-etat::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}
.etat-en-ligne { color: #16794c; }
.etat-hors-ligne { color: var(--rouge); }

#hud-actions {
  position: absolute;
  right: 12px; bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.action {
  padding: 9px 15px;
  border: 0;
  border-radius: 3px;
  background: var(--bleu);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--ombre);
}
.action:hover { background: var(--bleu-clair); }
.action:focus-visible { outline: 3px solid #f5c518; outline-offset: 2px; }
.action[disabled] { opacity: .45; cursor: not-allowed; }
.action.secondaire { background: rgba(255, 255, 255, .94); color: var(--bleu); }
.action.secondaire:hover { background: #fff; }

#hud-message {
  position: absolute;
  left: 50%; bottom: 16px;
  transform: translateX(-50%);
  max-width: 620px;
  padding: 9px 16px;
  border-radius: 3px;
  background: rgba(29, 33, 41, .88);
  color: #fff;
  text-align: center;
  opacity: 0;
  transition: opacity .18s;
}
#hud-message.visible { opacity: 1; }

#hud-panneau {
  position: absolute;
  left: 50%; top: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 560px;
  padding: 8px 15px;
  background: #fff8e6;
  border: 1px solid #d9b96a;
  border-radius: 3px;
  box-shadow: var(--ombre);
  font-weight: 600;
}
#hud-panneau .pictogramme { color: #a9812c; }

#hud-aide-panneau {
  position: absolute;
  right: 12px; bottom: 62px;
  width: 420px;
  max-height: 560px;
  overflow: auto;
  padding: 16px 20px;
  background: rgba(255, 255, 255, .97);
  border-radius: 4px;
  box-shadow: var(--ombre);
  font-size: 13px;
  line-height: 1.5;
}
#hud-aide-panneau h2 { margin: 12px 0 6px; font-size: 14px; color: var(--bleu); }
#hud-aide-panneau h2:first-child { margin-top: 0; }
#hud-aide-panneau ul { margin: 0; padding-left: 18px; }
#hud-aide-panneau li { margin-bottom: 4px; }
#hud-aide-panneau .note { margin: 10px 0 0; color: var(--gris); }

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid #c3c9d4;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #f4f6fa;
  font: 600 11px/1.5 ui-monospace, "Consolas", monospace;
  text-align: center;
}

/* ---------------------------------------------------------- Surcouches */
.voile {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, rgba(16, 24, 48, .93), rgba(30, 18, 26, .93));
  z-index: 10;
}
.voile[hidden] { display: none; }
#chargement p { color: #fff; font-size: 16px; }

.panneau {
  width: 1100px;
  max-height: 760px;
  display: flex;
  flex-direction: column;
  padding: 20px 26px;
  background: var(--sable);
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.panneau-entete {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bord);
}
.panneau-entete .logo { object-fit: contain; }
.panneau-entete h1 { margin: 0; font-size: 21px; color: var(--bleu); letter-spacing: .01em; }
.sous-titre { margin: 2px 0 0; color: var(--gris); font-size: 13px; }

.etapes {
  display: flex;
  gap: 10px;
  margin: 14px 0 12px;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gris);
}
.etapes li {
  padding: 5px 12px;
  border-radius: 14px;
  background: rgba(27, 42, 86, .08);
}
.etapes li.courante { background: var(--bleu); color: #fff; }

.etape { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.etape[hidden] { display: none; }

/* -------------------------------------------------- Grille des avatars */
.barre-outils {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}
.barre-outils select,
.barre-outils input {
  padding: 7px 10px;
  border: 1px solid var(--bord);
  border-radius: 3px;
  background: #fff;
  font: inherit;
}
.barre-outils input[type="search"] { flex: 1; max-width: 320px; }

.grille {
  flex: 1;
  min-height: 220px;
  max-height: 340px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--bord);
  border-radius: 4px;
}
.grille:focus-visible { outline: 3px solid #f5c518; outline-offset: 2px; }

.case-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: #f7f8fa;
  cursor: pointer;
  text-align: center;
}
.case-avatar:hover { background: #eef2fa; }
.case-avatar[aria-selected="true"] {
  border-color: var(--bleu);
  background: #e6ecf9;
}
.case-avatar .nom {
  font-size: 10px;
  line-height: 1.2;
  color: var(--gris);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Sprite découpé dans la planche unique : 12 frames par avatar,
   colonnes 0..2 = marche vers le bas. */
.sprite {
  width: calc(32px * var(--avatar-zoom));
  height: calc(32px * var(--avatar-zoom));
  background-image: url("../assets/avatars/avatars.png");
  background-size: calc(384px * var(--avatar-zoom)) calc(3200px * var(--avatar-zoom));
  background-position-x: 0;
  background-position-y: calc(var(--i) * -32px * var(--avatar-zoom));
  image-rendering: pixelated;
}
.case-avatar:hover .sprite,
.case-avatar[aria-selected="true"] .sprite,
#apercu-sprite {
  animation: marche .6s steps(3) infinite;
}
@keyframes marche {
  from { background-position-x: 0; }
  to { background-position-x: calc(-96px * var(--avatar-zoom)); }
}

.apercu {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--bord);
  border-radius: 4px;
}
#apercu-sprite { --avatar-zoom: 3; }
.apercu-nom { margin: 0; font-weight: 700; color: var(--bleu); }
.apercu-desc { margin: 2px 0 0; font-size: 13px; color: var(--gris); }

/* ------------------------------------------------------ Formulaire profil */
.champs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 18px;
}
.champ { margin: 0; display: flex; flex-direction: column; gap: 4px; position: relative; }
.champ-large { grid-column: 1 / -1; }
.champ label { font-size: 13px; font-weight: 600; }
.champ abbr { color: var(--rouge); text-decoration: none; }
.champ input,
.champ select,
.champ textarea {
  padding: 9px 11px;
  border: 1px solid #b9c1cf;
  border-radius: 3px;
  background: #fff;
  font: inherit;
  font-size: 14px;
}
.champ input:focus-visible,
.champ select:focus-visible,
.champ textarea:focus-visible { outline: 3px solid #f5c518; outline-offset: 1px; }
.champ textarea { resize: vertical; }
.champ .compteur { align-self: flex-end; font-size: 11px; color: var(--gris); }
.erreur { min-height: 15px; font-size: 12px; color: var(--rouge); font-weight: 600; }
.erreur.globale {
  min-height: 0;
  margin: 10px 0 0;
  padding: 9px 12px;
  background: #fdeaec;
  border-left: 4px solid var(--rouge);
  border-radius: 3px;
}
.champ.invalide input,
.champ.invalide select,
.champ.invalide textarea { border-color: var(--rouge); }

.actions-etape {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--bord);
}

@media (prefers-reduced-motion: reduce) {
  .case-avatar:hover .sprite,
  .case-avatar[aria-selected="true"] .sprite,
  #apercu-sprite { animation: none; }
  #hud-message { transition: none; }
}
