/* Les machines de l'atelier d'assemblage (src/machinesUI.js) : comme dans l'atelier des visiteurs, une colonne
   de boutons ronds à droite (certains ouvrent une boîte à leur gauche), et en haut le nom de la machine et l'aide. */
#machine { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
#machine[hidden] { display: none; }
#machine > * { pointer-events: auto; }
#machine button { font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 6px 12px; font-size: 0.84rem; }
#machine button:disabled { opacity: 0.35; cursor: default; }
/* en haut : le nom de la machine, l'aide (tant qu'elle est arrêtée) et les messages du moment */
#machine .mc-haut { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100vw - 150px)); text-align: center; pointer-events: none;
  background: rgba(15, 12, 9, 0.8); border: 1px solid var(--line); border-radius: 16px; padding: 8px 16px; }
#machine h2 { margin: 0; font: 600 1.2rem var(--serif); color: var(--ink); }
#machine .mc-intro { margin: 3px 0 0; font-size: 0.78rem; color: var(--ink-soft); }
#machine[data-marche="true"] .mc-intro { display: none; }
#machine .mc-info { margin: 3px 0 0; font-size: 0.78rem; color: var(--accent); }
#machine .mc-info:empty { display: none; }
/* la colonne */
#machine .mc-colonne { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 0; bottom: 0; display: flex; flex-direction: column; gap: 9px; align-items: center; justify-content: center; pointer-events: none; }
#machine .mc-colonne > * { pointer-events: auto; }
#machine .mc-rail { position: relative; width: 50px; height: 50px; padding: 0; display: grid; place-items: center; background: var(--panel); border-color: var(--line); font-size: 1.3rem; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
#machine .mc-rail.mc-petit { width: 40px; height: 40px; font-size: 1rem; }
#machine .mc-rail svg { width: 24px; height: 24px; }
#machine .mc-rail .mc-outil-courant svg { width: 28px; height: 28px; }
#machine .mc-rail[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #1a120a; }
#machine .mc-g-aide .mc-ic { font-weight: 700; font-size: 1rem; }
#machine .mc-sortie { border-color: var(--accent); }
/* l'interrupteur : voyant rouge ou vert */
#machine .mc-marche { border-width: 2px; }
#machine .mc-voyant { position: absolute; right: 3px; bottom: 3px; width: 12px; height: 12px; border-radius: 50%; background: #c0392b; box-shadow: 0 0 0 2px var(--panel); }
#machine .mc-marche[aria-pressed="true"] { border-color: #6fbf5a; color: #7ee060; }
#machine .mc-marche[aria-pressed="true"] .mc-voyant { background: #7ee060; box-shadow: 0 0 0 2px var(--panel), 0 0 10px #7ee060; }
/* les bulles (au survol) */
#machine .mc-bulle { position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 0.82rem; color: var(--ink); opacity: 0; transition: opacity 0.2s; }
@media (hover: hover) { #machine .mc-rail:hover .mc-bulle { opacity: 1; } #machine .mc-rail[aria-expanded="true"] .mc-bulle { opacity: 0; } }
/* les boîtes, à gauche de leur bouton */
#machine .mc-groupe { position: relative; }
#machine .mc-boite { position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); width: max-content; max-width: min(340px, calc(100vw - 90px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.45); }
#machine .mc-boite[hidden] { display: none; }
#machine .mc-l { margin: 0; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#machine:not([data-machine="tour"]) .mc-g-outil, #machine:not([data-machine="scie"]) .mc-bas, #machine:not([data-machine="scie"]) .mc-g-patrons { display: none; }
#machine .mc-outils { display: grid; grid-template-columns: repeat(4, 52px); gap: 6px; }
#machine .mc-outils button { height: 48px; padding: 0; border-radius: 12px; display: grid; place-items: center; }
#machine .mc-outils svg { width: 28px; height: 28px; }
#machine .mc-outils button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #1a120a; }
/* en bas : tourner et retourner la planche (scie) */
#machine .mc-bas { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center;
  background: rgba(15, 12, 9, 0.85); border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
#machine .mc-bas-planche, #machine .mc-choix { display: flex; align-items: center; gap: 8px; }
#machine .mc-bas-planche[hidden], #machine .mc-choix[hidden] { display: none; }
#machine .mc-choix > span { padding: 0 6px 0 10px; font-size: 0.88rem; color: var(--ink); white-space: nowrap; }
#machine .mc-jeter { height: 40px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#machine .mc-jeter i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
#machine .mc-jeter:hover { border-color: #d9534f; color: #ff8a80; }
#machine .mc-bas .mc-pivot { width: 40px; height: 40px; padding: 0; font-size: 1.2rem; display: grid; place-items: center; }
#machine .mc-bas .mc-angle { width: 210px; }
#machine .mc-bas .mc-retourner { height: 40px; white-space: nowrap; }
#machine .mc-angle { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--ink-soft); }
#machine .mc-angle input { flex: 1; min-width: 0; accent-color: var(--accent); margin: 0; }
#machine .mc-angle output { min-width: 2.8em; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
#machine .mc-modeles { display: grid; grid-template-columns: repeat(4, 64px); gap: 6px; }
#machine .mc-modeles button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 4px; border-radius: 12px; font-size: 0.68rem; color: var(--ink-soft); }
#machine .mc-modeles img { width: 30px; height: 30px; display: block; }
#machine .mc-nom { width: 240px; box-sizing: border-box; font: inherit; font-size: 0.88rem; color: var(--ink); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; }
#machine .mc-garder { padding: 9px 16px; background: var(--accent) !important; border-color: var(--accent) !important; color: #1a120a !important; font-weight: 600; }
#machine .mc-clavier { width: 280px; font-size: 0.76rem; color: var(--ink-soft); }
#machine .mc-clavier p { margin: 0; line-height: 1.8; }
#machine .mc-aide-texte { color: var(--ink); }
#machine:not([data-machine="scie"]) .mc-clavier-scie, #machine:not([data-machine="tour"]) .mc-clavier-tour, body.touch #machine .mc-clavier-tour, body.touch #machine .mc-clavier-scie { display: none; }
#machine kbd { font: inherit; font-size: 0.72rem; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; color: var(--ink-soft); }
body.machine-gros-plan #assemblage-barre, body.machine-gros-plan #chat, body.machine-gros-plan #joystick, body.machine-gros-plan #joystick-regard { display: none !important; }
@media (max-width: 600px) {
  #machine .mc-colonne { gap: 7px; }
  #machine .mc-rail { width: 42px; height: 42px; font-size: 1.1rem; }
  #machine .mc-rail.mc-petit { width: 36px; height: 36px; }
  #machine .mc-haut { top: auto; bottom: 14px; max-width: calc(100vw - 80px); padding: 6px 12px; }
  #machine[data-machine="scie"] .mc-haut { bottom: 70px; }
  #machine .mc-bas { left: 10px; right: 64px; transform: none; padding: 4px 6px; }
  #machine .mc-bas-planche { flex: 1; min-width: 0; gap: 5px; }
  #machine .mc-choix { flex-wrap: wrap; gap: 5px; }
  #machine .mc-bas .mc-angle { width: auto; flex: 1; min-width: 0; }
  #machine .mc-bas .mc-angle > span, #machine .mc-bas .mc-retourner span { display: none; }
  #machine .mc-bas .mc-pivot, #machine .mc-bas .mc-retourner { width: 36px; height: 36px; padding: 0; }
  #machine h2 { font-size: 1rem; }
  #machine .mc-modeles { grid-template-columns: repeat(3, 60px); }
}
#machine .mc-patrons { display: grid; grid-template-columns: repeat(5, 58px); gap: 6px; }
#machine .mc-patrons button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 3px 4px; border-radius: 12px; font-size: 0.64rem; color: var(--ink-soft); line-height: 1.1; }
#machine .mc-patrons img { width: 38px; height: 38px; display: block; border-radius: 4px; }
#machine .mc-patrons .mc-sans { width: 38px; height: 38px; display: grid; place-items: center; font-size: 1.2rem; border-radius: 4px; border: 1px dashed var(--line); }
#machine .mc-aide-patron { margin: 0; font-size: 0.74rem; color: var(--ink-soft); }
@media (max-width: 600px) { #machine .mc-patrons { grid-template-columns: repeat(4, 54px); } }
