/* Les COULEURS sont nommées une fois ici (celles de la maquette) : pour changer l'allure du
   site, on change ces lignes. Ailleurs dans le CSS, on écrit var(--nom), jamais un code couleur. */
:root {
  --fond: #f4f1ea;
  --panneau: #ffffff;
  --encre: #1d2320;
  --discret: #6b736e;
  --trait: #d9d5c9;
  --accent: #1f6f4a;
  --accent-clair: #e8f3ec;
  --alerte: #b3261e;
  --sable: #d9c593;            /* le fond de la carrière avant que le dessin n'arrive */
  --fond-action: #16201b;      /* la barre d'outils pendant « En action » */
  --texte-action: #9fb3a8;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--encre);
  display: flex;
  flex-direction: column;
}

/* ── La mise en page : la scène à gauche, le panneau à droite ───────────────── */
.application { flex: 1; display: flex; min-height: 0; }
.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.scene { flex: 1; position: relative; min-height: 560px; background: var(--sable); }
.scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

aside {
  width: 260px;
  background: var(--panneau);
  border-left: 1px solid var(--trait);
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
aside h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--discret);
  margin: 0 0 6px;
}

/* Sur un écran étroit (téléphone), le panneau passe sous la scène. */
@media (max-width: 860px) {
  .application { flex-direction: column; }
  aside { width: 100%; border-left: 0; border-top: 1px solid var(--trait); }
  .scene { min-height: 56vh; }
}

/* ── La barre d'outils ─────────────────────────────────────────────────────── */
.barre-outils {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 8px 12px;
  background: var(--panneau);
  border-bottom: 1px solid var(--trait);
  align-items: center;
}
.groupe { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.titre-groupe {
  font-size: 11px;
  color: var(--discret);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

button {
  font: inherit;
  border: 1px solid var(--trait);
  background: var(--panneau);
  color: var(--encre);
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: var(--accent-clair); }
button:disabled { opacity: 0.4; cursor: default; }
button:disabled:hover { background: var(--panneau); }
button.actif { background: var(--accent); color: var(--panneau); border-color: var(--accent); }
button.danger { color: var(--alerte); }

/* Pendant « En action » : on ne garde que les boutons de lecture, sur fond sombre. */
body.en-action aside,
body.en-action .groupe:not(.groupe-action) { display: none; }
body.en-action .barre-outils { justify-content: center; background: var(--fond-action); padding: 10px; }
body.en-action .barre-outils .titre-groupe { color: var(--texte-action); }
body.en-action .scene { min-height: 0; }

/* ── Sur la scène : l'indice, le compteur et le voile de la vue 3D ─────────── */
.indice {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--trait);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  pointer-events: none;
  max-width: 90%;
}
#compteur {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 28, 24, 0.78);
  color: var(--panneau);
  font: bold 14px system-ui, sans-serif;
  padding: 7px 16px;
  border-radius: 16px;
  pointer-events: none;
  white-space: nowrap;
}
#voile {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, rgba(0, 0, 0, 0) 55%, rgba(10, 12, 8, 0.38) 100%);
}

/* ── Le panneau : champs, chiffres ─────────────────────────────────────────── */
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.rangee { display: flex; gap: 6px; flex-wrap: wrap; }
.espace-haut { margin-top: 8px; }
.en-bas { justify-content: flex-end; }
select { cursor: pointer; }
.barre-outils select { width: auto; }

label { display: flex; flex-direction: column; font-size: 12px; color: var(--discret); gap: 2px; }
input, select {
  font: inherit;
  color: var(--encre);
  border: 1px solid var(--trait);
  border-radius: 6px;
  padding: 4px 6px;
  background: var(--panneau);
  width: 100%;
}

.chiffres { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chiffre { background: var(--accent-clair); border-radius: 8px; padding: 6px 8px; }
.chiffre b { display: block; font-size: 18px; }
.chiffre small { color: var(--discret); }
.note { font-size: 11px; color: var(--discret); margin: 8px 0 0; }
.note.alerte { color: var(--alerte); font-weight: 600; }
