/* ==========================================================================
   Configurateur 3D des marches : bloc #marche-3d de marches.html
   (comportement : configurateur-marche.js)
   Ordinateur : réglages à gauche ; la vue 3D, à droite, reste à l'écran
   pendant qu'on fait défiler les réglages.
   Mobile : la vue en haut, qui reste à l'écran, les réglages dessous.
   ========================================================================== */
.cm-section {
  --cm-encre: #1a1a1a;
  --cm-plomb: #666;
  --cm-filet: rgba(0, 0, 0, .12);
  --cm-piste: rgba(0, 0, 0, .2);
  --cm-fond: #fff;
  --cm-sur-scene: #1d2326;
  padding: 80px 60px;
  background: var(--cm-fond);
  color: var(--cm-encre);
}
.cm-section [hidden] { display: none !important; }

.cm-entete { max-width: 1600px; margin: 0 auto 36px; }
.cm-entete h2 { margin: 0 0 14px; font-size: 32px; line-height: 1.2; color: #000; }
.cm-entete p { max-width: 640px; font-size: 15px; line-height: 1.7; color: #555; }

.cm-app {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr);
  gap: 0 48px;
  align-items: start;
}

/* ---------- réglages ---------- */
.cm-panneau { display: grid; gap: 10px; min-width: 0; }
.cm-groupe { min-width: 0; margin: 0 0 12px; padding: 0; border: 0; }
.cm-groupe legend { margin-bottom: 8px; padding: 0; font-size: 15px; font-weight: 700; }

.cm-tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cm-tuiles.cm-deux { grid-template-columns: repeat(2, 1fr); }
.cm-tuile { position: relative; cursor: pointer; }
.cm-tuile input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.cm-tuile span {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 4px;
  height: 100%;
  padding: 9px 4px 7px;
  border: 1px solid var(--cm-piste);
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  color: var(--cm-encre);
  transition: border-color .2s;
}
.cm-tuile svg { display: block; width: 52px; height: auto; }
.cm-tuile path { fill: var(--cm-encre); }
.cm-tuile input:hover + span { border-color: rgba(0, 0, 0, .5); }
.cm-tuile input:checked + span { border-color: var(--cm-encre); box-shadow: inset 0 0 0 1px var(--cm-encre); font-weight: 700; }
.cm-tuile input:focus-visible + span { outline: 2px solid var(--cm-encre); outline-offset: 2px; }

.cm-case { display: flex; align-items: flex-start; gap: 10px; margin-top: 10px; font-size: 14px; line-height: 1.45; cursor: pointer; }
.cm-case input { flex: none; width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--cm-encre); cursor: pointer; }

.cm-coupe { margin: -16px 0 14px; }    /* le haut du dessin est vide tant que la marche est basse */
.cm-coupe svg { display: block; width: 100%; height: auto; max-width: 26rem; }
.cm-coupe figcaption { margin-top: 4px; font-size: 13px; color: var(--cm-plomb); }
.cm-coupe text { font-size: 12.5px; font-weight: 400; fill: var(--cm-plomb); }
.cm-coupe .cm-v { fill: var(--cm-encre); font-weight: 700; }
.cm-coupe .cm-poche { fill: var(--cm-encre); stroke: var(--cm-fond); stroke-width: 1; }
.cm-coupe .cm-plein { fill: var(--cm-encre); }
.cm-coupe .cm-hach line { stroke: var(--cm-plomb); stroke-opacity: .55; stroke-width: 1; }
.cm-coupe .cm-sol { stroke: var(--cm-encre); stroke-width: 1; fill: none; }
.cm-coupe .cm-cote { stroke: var(--cm-plomb); stroke-width: .75; fill: none; }
.cm-coupe .cm-tique { stroke: var(--cm-encre); stroke-width: 1.25; fill: none; }

.cm-champ {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 12px;
  font-size: 15px;
}
.cm-champ output { font-weight: 700; font-variant-numeric: tabular-nums; }
.cm-champ input, .cm-champ select, .cm-champ .cm-note { grid-column: 1 / -1; }
.cm-note { margin: 0; font-size: 13px; color: var(--cm-plomb); }

.cm-section input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
}
.cm-section input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(var(--cm-encre), var(--cm-encre)) 0 0 / var(--p) 100% no-repeat, var(--cm-piste);
}
.cm-section input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 18px;
  margin-top: -8px;
  border: 0;
  border-radius: 1px;
  background: var(--cm-encre);
}
.cm-section input[type="range"]::-moz-range-track { height: 2px; background: var(--cm-piste); }
.cm-section input[type="range"]::-moz-range-progress { height: 2px; background: var(--cm-encre); }
.cm-section input[type="range"]::-moz-range-thumb { width: 10px; height: 18px; border: 0; border-radius: 1px; background: var(--cm-encre); }
.cm-section input[type="range"]:focus-visible { outline: 2px solid var(--cm-encre); outline-offset: 3px; }
@media (pointer: coarse) {
  .cm-section input[type="range"] { height: 32px; }
}

.cm-section select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  border: 1px solid var(--cm-encre);
  border-radius: 0;
  background: var(--cm-fond);
  color: var(--cm-encre);
  font: inherit;
}

.cm-actions { display: grid; gap: 8px; margin-top: 14px; }
.cm-bouton {
  width: 100%;
  padding: 12px 20px;
  border: 1px solid #000;
  border-radius: 30px;
  background: #000;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .3s, color .3s, border-color .3s;
}
.cm-bouton:hover { background: #333; border-color: #333; }
.cm-bouton:focus-visible { outline: 2px solid var(--cm-encre); outline-offset: 3px; }
.cm-etat { min-height: 20px; margin: 0; font-size: 13px; color: var(--cm-plomb); }

/* ---------- vue 3D ---------- */
.cm-scene {
  position: sticky;
  top: 90px;                              /* sous le menu quand il réapparaît */
  z-index: 2;
  height: calc(100vh - 120px);
  min-height: 460px;
  max-height: 860px;
  overflow: hidden;
  background: radial-gradient(115% 85% at 50% 40%, #b4bec2, #8a979d);
  color: var(--cm-sur-scene);
}
#cm-vue {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;                    /* au doigt : glisser vers le haut ou le bas fait défiler la page */
  cursor: grab;
  opacity: 0;
  transition: opacity .6s ease;
}
#cm-vue.cm-prete { opacity: 1; }
#cm-vue.cm-saisie { cursor: grabbing; }
#cm-vue:focus-visible { outline: 2px solid var(--cm-sur-scene); outline-offset: -6px; }

.cm-chargement {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 15px;
  color: var(--cm-sur-scene);
  opacity: .7;
  pointer-events: none;
}
.cm-aide {
  position: absolute;
  left: 24px;
  top: 22px;
  max-width: calc(100% - 210px);
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  pointer-events: none;
  transition: opacity .5s ease;
}
.cm-aide.cm-vu { opacity: 0; }
.cm-aide .cm-tactile { display: none; }
@media (pointer: coarse) {
  .cm-aide .cm-souris { display: none; }
  .cm-aide .cm-tactile { display: inline; }
}
.cm-recentrer {
  position: absolute;
  top: 20px;
  right: 24px;
  padding: 6px 14px;
  border: 1px solid currentColor;
  border-radius: 30px;
  background: transparent;
  color: inherit;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  transition: background .3s, color .3s;
}
.cm-recentrer:hover { background: var(--cm-sur-scene); color: #b4bec2; }
.cm-recentrer:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.cm-erreur {
  position: absolute;
  inset: 0;
  width: min(34rem, 100% - 48px);
  height: fit-content;
  margin: auto;
  font-size: 16px;
  font-weight: 400;
  text-align: center;
}

@media (max-width: 1024px) {
  .cm-section { padding: 60px 40px; }
  .cm-app { gap: 0 32px; }
}

/* ---------- tablette en portrait et mobile : la vue en haut, bord à bord ----------
   (à côté des réglages, elle deviendrait une colonne étroite où la marche paraît petite) */
@media (max-width: 899.98px) {
  .cm-app { display: flex; flex-direction: column; align-items: stretch; }
  .cm-scene {
    order: -1;
    top: 0;
    height: 46vh;
    height: 46svh;
    min-height: 240px;
    max-height: 480px;
    margin: 0 -40px 24px;
  }
  .cm-panneau { grid-template-columns: 1fr 1fr; gap: 8px 24px; }
  .cm-large { grid-column: 1 / -1; }
  .cm-aide { left: 16px; top: 12px; bottom: auto; max-width: calc(100% - 32px); font-size: 12px; }
  .cm-recentrer { top: auto; bottom: 12px; right: 16px; padding: 5px 12px; font-size: 12px; }
}
@media (max-width: 767.98px) {
  .cm-section { padding: 50px 20px 60px; }
  .cm-entete { margin-bottom: 24px; }
  .cm-entete h2 { font-size: 24px; }
  .cm-scene { max-height: 440px; margin: 0 -20px 20px; }
  .cm-panneau { gap: 8px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  #cm-vue, .cm-aide { transition: none; }
}
