/* Atelier des visiteurs (src/atelier.js) : barre d'outils et photo de la fresque. */
#atelier-barre {
  position: fixed; right: max(12px, env(safe-area-inset-right)); top: 0; bottom: 0; z-index: 9; pointer-events: none;
  display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center;
}
#atelier-barre > * { pointer-events: auto; }
#atelier-barre[hidden], body.focus #atelier-barre, body:has(#pause.visible) #atelier-barre { display: none; }
body.walking:has(#atelier-barre:not([hidden])) #help-bar { display: none !important; }
#atelier-barre button {
  font: inherit; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 999px;
  min-width: 36px; height: 36px; padding: 0 10px; cursor: pointer; font-size: 0.86rem;
}
#atelier-barre button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #1a120a; }
/* Boutons ronds du côté droit */
#atelier-barre .at-rail {
  position: relative; width: 52px; height: 52px; min-width: 0; padding: 0; display: grid; place-items: center;
  background: var(--panel); border-color: var(--line); font-size: 1.45rem; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
#atelier-barre .at-rail svg { width: 26px; height: 26px; }
#atelier-barre .at-rail[aria-pressed="true"], #atelier-barre .at-rail[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #1a120a; }
#atelier-barre .at-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.85rem; color: var(--ink);
  opacity: 0; transition: opacity 0.25s;
}
#atelier-barre .at-rail.montre .at-bulle { opacity: 1; }
@media (hover: hover) { #atelier-barre .at-murs:hover .at-bulle { opacity: 1; } }
/* gros plan sur un mur à peindre : « Sortir » à la place de 👁️, pas de 🧩 */
#atelier-barre .at-sortir { display: none; }
body.mur-gros-plan #atelier-barre .at-sortir { display: grid; }
body.mur-gros-plan #atelier-barre .at-oeil, body.mur-gros-plan #atelier-barre .at-puzzle { display: none; }
@media (hover: hover) { #atelier-barre .at-sortir:hover .at-bulle { opacity: 1; } }
#atelier-barre .at-pastille {
  position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%; background: var(--panel);
  border: 1px solid var(--line); display: grid; place-items: center;
}
#atelier-barre .at-pastille::after { content: ''; width: var(--t, 6px); height: var(--t, 6px); border-radius: 50%; background: var(--c, #fff); }
#atelier-barre .at-couleur-courante i { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 2px solid rgba(255,255,255,0.7); }
/* Boîtes ouvertes à gauche du bouton */
#atelier-barre .at-groupe { position: relative; }
#atelier-barre .at-boite {
  position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px;
  display: flex; flex-direction: column; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  max-width: calc(100vw - 100px);
}
#atelier-barre .at-boite[hidden] { display: none; }
#atelier-barre .at-outils { display: grid; grid-template-columns: repeat(5, auto); gap: 8px; }
#atelier-barre .at-formes { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
#atelier-barre [data-outil]:not(.at-rail) { width: 46px; height: 46px; min-width: 0; padding: 0; font-size: 1.3rem; display: grid; place-items: center; }
#atelier-barre [data-outil]:not(.at-rail) svg { width: 24px; height: 24px; }
#atelier-barre .at-nom-outil { margin: -2px 0 0; font-size: 0.95rem; color: var(--accent); font-weight: 500; text-align: center; }
#atelier-barre .at-tailles { display: flex; gap: 6px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
#atelier-barre .at-taille { width: 40px; height: 40px; min-width: 0; padding: 0; display: inline-grid; place-items: center; }
#atelier-barre .at-taille i { display: block; width: var(--t); height: var(--t); border-radius: 50%; background: currentColor; }
#atelier-barre .at-bas { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#atelier-barre .at-couleurs { display: grid; grid-template-columns: repeat(6, auto); gap: 8px; }
#atelier-barre [data-couleur] { width: 34px; min-width: 34px; height: 34px; padding: 0; background: var(--c); border-color: rgba(255,255,255,0.25); }
#atelier-barre [data-couleur][aria-pressed="true"] { outline: 2px solid #fff; outline-offset: 2px; background: var(--c); }
#atelier-aide {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); max-height: calc(100vh - 40px); overflow: auto; width: min(480px, calc(100vw - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; font-size: 0.86rem; color: var(--ink-soft); line-height: 1.5;
}
#atelier-aide[hidden] { display: none; }
#atelier-aide .at-aide-fermer {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; min-width: 0; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 0.85rem; cursor: pointer;
}
#atelier-aide h3 { padding-right: 36px; }
#atelier-aide h3 { margin: 0 0 6px; font: 600 1.15rem var(--serif); color: var(--ink); }
#atelier-aide p { margin: 0 0 8px; }
#atelier-aide ul { list-style: none; padding: 0; margin: 4px 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px; }
#atelier-aide kbd { font-size: 0.75rem; }
body.peint #app canvas { cursor: crosshair; }
body.flash::after { content: ''; position: fixed; inset: 0; background: #fff; z-index: 40; animation: flash 0.4s ease-out forwards; pointer-events: none; }
@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }

#atelier-photo { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(8, 6, 4, 0.72); padding: 16px; overflow-y: auto; }
#atelier-photo[hidden] { display: none; }
#atelier-photo .ap-carte { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; max-width: 520px; width: 100%; text-align: center; }
#atelier-photo .ap-polaroid { margin: 0 auto 12px; background: #fbf8f1; padding: 14px 14px 10px; width: min(420px, 100%); box-shadow: 0 10px 30px rgba(0,0,0,0.5); transform: rotate(-1.5deg); }
#atelier-photo .ap-polaroid img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
#atelier-photo .ap-nom { width: 100%; margin-top: 10px; border: 0; border-bottom: 1px dashed #b8ab95; background: transparent; text-align: center; font: 1.6rem "Caveat", "Segoe Print", cursive; color: #3a3128; padding: 2px 0 4px; }
#atelier-photo .ap-nom:focus { outline: none; border-bottom-color: #8a5a1e; }
#atelier-photo .ap-info { font-size: 0.82rem; color: var(--muted); margin: 6px 0; }
#atelier-photo .ap-message { min-height: 1.3em; font-size: 0.9rem; color: var(--accent); margin: 4px 0 10px; }
#atelier-photo .ap-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#atelier-photo .ap-actions > * { font: inherit; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); text-decoration: none; cursor: pointer; }
#atelier-photo .ap-exposer { background: var(--accent) !important; border-color: var(--accent) !important; color: #1a120a !important; font-weight: 500; }
#atelier-photo .ap-exposer:disabled { opacity: 0.6; cursor: wait; }
#atelier-photo .ap-actions > [hidden], #atelier-photo .ap-partage > [hidden] { display: none; }
#atelier-photo .ap-partage { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
#atelier-photo .ap-partage > * { font: inherit; font-size: 0.85rem; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink);
  text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
#atelier-photo .ap-partage > *:hover { border-color: var(--accent); }
#atelier-photo .ap-partager { background: var(--accent) !important; border-color: var(--accent) !important; color: #1a120a !important; font-weight: 500; }
/* fermer : une croix ronde en haut à droite de la carte */
#atelier-photo .ap-carte { position: relative; }
#atelier-photo .ap-polaroid { margin-top: 20px; }
#atelier-photo .ap-annuler { position: absolute; top: 10px; right: 10px; z-index: 1; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 0.95rem; line-height: 1; cursor: pointer; }
#atelier-photo .ap-annuler:hover { border-color: var(--accent); color: var(--accent); }
/* téléphone en paysage : la photo à gauche (à la hauteur de l'écran), le texte et les boutons à droite */
@media (max-height: 520px) and (orientation: landscape) {
  #atelier-photo { padding: 8px; }
  #atelier-photo .ap-carte { max-width: 760px; padding: 12px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; align-items: center; text-align: left; }
  #atelier-photo .ap-polaroid { grid-row: 1 / span 4; margin: 0; padding: 8px 8px 4px; width: min(calc((100dvh - 60px) * 4 / 3), 48vw); }
  #atelier-photo .ap-nom { font-size: 1.2rem; margin-top: 4px; }
  #atelier-photo .ap-info { margin: 0 0 4px; padding-right: 40px; }
  #atelier-photo .ap-message { margin: 0 0 6px; }
  #atelier-photo .ap-actions { justify-content: flex-start; flex-direction: column; align-items: stretch; gap: 6px; }
  #atelier-photo .ap-actions > * { padding: 8px 14px; text-align: center; }
  #atelier-photo .ap-partage { justify-content: flex-start; margin-top: 8px; padding-top: 8px; }
  #atelier-photo .ap-partage > * { padding: 6px 11px; font-size: 0.8rem; }
}


/* Cadrage de la photo : viseur 4:3, l'extérieur assombri ; la scène reste manipulable (pointer-events). */
#atelier-viseur { position: fixed; inset: 0; z-index: 12; pointer-events: none; user-select: none; -webkit-user-select: none; }
#atelier-viseur[hidden] { display: none; }
#atelier-viseur .av-cadre { position: absolute; box-shadow: 0 0 0 200vmax rgba(8, 6, 4, 0.55); border: 1px solid rgba(255, 255, 255, 0.5); }
#atelier-viseur .av-coin { position: absolute; width: 26px; height: 26px; border: 3px solid #fff; }
#atelier-viseur .hg { left: -3px; top: -3px; border-right: 0; border-bottom: 0; }
#atelier-viseur .hd { right: -3px; top: -3px; border-left: 0; border-bottom: 0; }
#atelier-viseur .bg { left: -3px; bottom: -3px; border-right: 0; border-top: 0; }
#atelier-viseur .bd { right: -3px; bottom: -3px; border-left: 0; border-top: 0; }
#atelier-viseur .av-croix { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  background: linear-gradient(#fff, #fff) center / 100% 1px no-repeat, linear-gradient(#fff, #fff) center / 1px 100% no-repeat; opacity: 0.7; }
#atelier-viseur .av-barre { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 10px 8px 18px; }
#atelier-viseur .av-aide { font-size: 0.82rem; color: var(--ink-soft); flex: 1 1 auto; min-width: 0; max-width: 260px; }
#atelier-viseur .av-zoom { width: 44px; height: 44px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
#atelier-viseur .av-zoom svg { width: 24px; height: 24px; }
body:not(.mur-gros-plan) #atelier-viseur .av-zoom { display: none; }
#atelier-viseur .av-annuler { flex: none; font: inherit; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
#atelier-viseur .av-declencher { flex: none; width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff; background: transparent; padding: 4px; cursor: pointer; }
#atelier-viseur .av-declencher span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; }
#atelier-viseur .av-declencher:active span { transform: scale(0.9); }
body.cadrage #atelier-barre, body.cadrage #hover-label, body.cadrage #crosshair { display: none !important; }
@media (max-width: 600px), (max-height: 500px) { #atelier-viseur .av-aide { display: none; } }
@media (max-height: 500px) { #atelier-viseur .av-barre { padding-left: 10px; } }

#atelier-barre .at-annuler:disabled { opacity: 0.35; cursor: default; }
#atelier-barre .at-mes-titre { margin: 4px 0 0; font-size: 0.78rem; color: var(--ink-soft); align-self: flex-start; }
#atelier-barre .at-mes-titre[hidden] { display: none; }
#atelier-barre .at-labo, #atelier-barre .at-marbrure { font-size: 0.82rem; padding: 6px 14px; }
#atelier-barre .at-taille-cm { width: 52px; font-size: 14px; font-weight: 600; line-height: 1; }
#atelier-barre .at-taille-cm small { display: block; font-size: 10px; font-weight: 400; opacity: 0.8; }
#atelier-barre .at-rail[hidden] { display: none; }

/* téléphone en paysage : la colonne d'outils commence sous la rangée des boutons du haut (le menu ☰ reste toujours
   visible, tout à droite) ; si elle est plus haute que l'écran, on la fait glisser au doigt (src/colonneGlissante.js) */
@media (orientation: landscape) and (max-height: 500px) {
  #hud { z-index: 12; }
  #atelier-barre { top: 68px; bottom: 6px; justify-content: flex-start; touch-action: none; }
  #atelier-barre > * { flex: none; translate: 0 var(--glisse, 0px); }
  #atelier-barre > :first-child { margin-top: auto; }
  #atelier-barre > :last-child { margin-bottom: auto; }
}
