/* =========================================================================
   Mode « Construire » pendant la visite (js/play/build.js)
   ========================================================================= */
:root { --bezier: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.56, .64, 1); }

/* barre d'outils : descend du haut de l'écran */
#build-bar { position: fixed; top: 64px; left: 50%; z-index: 11; display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 14px;
  transform: translate(-50%, -14px) scale(.96); opacity: 0; pointer-events: none; transition: transform .32s var(--spring), opacity .2s ease; }
#build-bar.show { transform: translate(-50%, 0) scale(1); opacity: 1; pointer-events: auto; }
#build-bar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 4px 3px; }
#build-bar .btn { background: transparent; border-color: transparent; box-shadow: none; padding: 6px 10px; font-size: .84rem; color: var(--text2); transition: background .15s, color .15s, transform .12s; }
#build-bar .btn.icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
#build-bar .btn:hover:not(:disabled) { background: rgba(22, 26, 37, .06); }
#build-bar .btn:active:not(:disabled) { transform: scale(.94); }
#build-bar .btn.on { background: var(--accent-soft); color: var(--accent); }
#build-bar .btn.primary { background: var(--accent); color: #fff; }
#build-bar .btn.primary:hover { background: var(--accent-h); }
#build-bar .btn.primary kbd { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .25); box-shadow: none; }
.bb-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: rgba(22, 26, 37, .05); }
.bb-title { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px 0 6px; font-size: .74rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.bb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: relative; }
.bb-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: bb-ping 1.6s var(--bezier) infinite; }
@keyframes bb-ping { 0% { transform: scale(.4); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }

/* panneau : glisse depuis la droite quand quelque chose est sélectionné */
#build-panel { position: fixed; top: 64px; right: 14px; bottom: 14px; width: 330px; z-index: 11; display: flex; flex-direction: column;
  background: rgba(255, 255, 255, .94); border: 1px solid var(--glass-line); border-radius: 18px; box-shadow: 0 18px 50px -18px rgba(22, 26, 37, .45);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none; transition: transform .38s var(--bezier), opacity .25s ease; }
#build-panel.open { transform: none; opacity: 1; pointer-events: auto; }
#build-panel #inspector { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 18px; }
#build-panel #inspector.swap > * { animation: bp-in .3s var(--bezier); }
@keyframes bp-in { from { opacity: 0; transform: translateY(8px); } }
#build-panel h3 { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
#build-panel h3 .i { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
#build-panel h3 small { display: block; font-size: .74rem; font-weight: 500; color: var(--faint); letter-spacing: 0; }
.bp-editor { display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-top: 1px solid var(--line); font-size: .8rem; font-weight: 600; text-decoration: none; color: var(--muted); border-radius: 0 0 18px 18px; transition: background .15s, color .15s; }
.bp-editor:hover { background: var(--accent-soft); color: var(--accent); }
.bp-count { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: .9rem; }
.bp-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.bp-actions .btn { justify-content: center; }
.bp-actions .btn.danger { grid-column: 1 / -1; }
.bp-note { font-size: .78rem; color: var(--faint); line-height: 1.5; margin: 14px 0 0; }

/* étiquette au-dessus de l'objet survolé ou sélectionné */
.build-tag { position: fixed; z-index: 9; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 4px 10px; border-radius: 8px; background: #fff; border: 1.5px solid #1d2230; color: #1d2230; box-shadow: 0 3px 0 rgba(29, 34, 48, .18);
  font-size: .68rem; line-height: 1.2; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); opacity: 0; transition: opacity .15s; }
.build-tag::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 8px; height: 8px; margin-left: -4px; background: inherit; border: inherit; border-top: none; border-left: none; transform: rotate(45deg); border-radius: 0 0 2px 0; }
.build-tag b { font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.build-tag span { color: var(--muted); font-variant-numeric: tabular-nums; }
.build-tag.sel { background: var(--accent); border-color: var(--accent-h); color: #fff; }
.build-tag.sel span { color: rgba(255, 255, 255, .8); }
.build-tag.locked { border-color: #c77c02; }
.build-tag.locked span { color: #b26a00; }
.build-tag.show { opacity: 1; }
.build-tag.in { animation: tag-in .28s var(--spring); }
@keyframes tag-in { from { transform: translate(-50%, calc(-100% + 2px)) scale(.7); } }

/* pendant la construction */
body.building #crosshair, body.building #prompt { display: none; }
body.building .stage canvas { cursor: default; }
body.building.hovering .stage canvas { cursor: pointer; }
body.building.dragging .stage canvas { cursor: grabbing; }
body.building #btn-build { background: var(--accent-soft); color: var(--accent); }
body.building .stage::after { content: ''; position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 3px rgba(15, 107, 122, .5), inset 0 0 80px rgba(15, 107, 122, .12); animation: fade-in .4s ease; }
@media (max-width: 900px) { #build-bar .lbl { display: none; } #build-panel { width: min(330px, calc(100vw - 28px)); top: auto; height: 46vh; } }
@media (prefers-reduced-motion: reduce) { #build-bar, #build-panel, .build-tag { transition: none; animation: none; } .bb-dot::after { animation: none; } }
/* panneau ouvert : la barre se recentre dans l'espace restant */
#build-bar { transition: transform .32s var(--spring), opacity .2s ease, left .38s var(--bezier); }
body.build-panel-open #build-bar { left: calc((100% - 344px) / 2); }

/* menu « Ajouter » : s'ouvre sous la barre, les vignettes arrivent l'une après l'autre */
#build-add { position: fixed; top: 116px; left: 50%; z-index: 12; display: grid; grid-template-columns: repeat(4, 86px); gap: 6px; padding: 8px; border-radius: 16px;
  transform: translate(-50%, -10px) scale(.95); transform-origin: 50% 0; opacity: 0; pointer-events: none; transition: transform .3s var(--spring), opacity .18s ease, left .38s var(--bezier); }
#build-add.open { transform: translate(-50%, 0) scale(1); opacity: 1; pointer-events: auto; }
body.build-panel-open #build-add { left: calc((100% - 344px) / 2); }
.ba-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font: 600 .74rem/1.15 inherit; color: var(--text2); cursor: pointer; transition: transform .16s var(--spring), border-color .15s, background .15s, color .15s, box-shadow .15s; }
.ba-item.wide { grid-column: span 2; flex-direction: row; justify-content: center; gap: 10px; background: var(--accent); border-color: var(--accent); color: #fff; }
.ba-item .i { color: var(--accent); transition: transform .25s var(--spring); }
.ba-item.wide .i { color: #fff; }
.ba-item:hover { transform: translateY(-2px); border-color: var(--accent-line); color: var(--accent); box-shadow: 0 8px 18px -10px rgba(15, 107, 122, .6); }
.ba-item.wide:hover { background: var(--accent-h); color: #fff; }
.ba-item:hover .i { transform: scale(1.15) rotate(-6deg); }
.ba-item:active { transform: scale(.95); }
#build-add.open .ba-item { animation: ba-in .34s var(--spring) both; animation-delay: calc(var(--i) * 22ms); }
@keyframes ba-in { from { opacity: 0; transform: translateY(8px) scale(.85); } }

/* indication pendant la pose */
#build-hint { position: fixed; left: 50%; bottom: 54px; z-index: 11; padding: 8px 15px; border-radius: 999px; font-size: .8rem; color: var(--text2); white-space: nowrap; pointer-events: none;
  transform: translate(-50%, 10px); opacity: 0; transition: transform .3s var(--spring), opacity .2s ease; }
#build-hint.show { transform: translate(-50%, 0); opacity: 1; }
#build-hint b { color: var(--accent); font-weight: 700; }
body.placing .stage canvas, body.placing.hovering .stage canvas { cursor: copy; }

/* fichiers glissés sur la vue */
body.drop-over .stage::before { content: 'Lâchez pour ajouter au monde'; position: fixed; inset: 14px; z-index: 30; display: grid; place-items: center; pointer-events: none;
  border: 2px dashed var(--accent); border-radius: 22px; background: rgba(15, 107, 122, .1); color: var(--accent); font-weight: 700; font-size: 1.1rem; animation: fade-in .15s ease; }
.ba-item.wide.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.ba-item.wide.soft .i { color: var(--accent); }
.ba-item.wide.soft:hover { background: var(--accent-soft2); color: var(--accent-h); }

/* =========================================================================
   Caméra libre (Alt) et menu circulaire du clic droit (js/play/pie.js)
   ========================================================================= */
body.alt-cam .stage canvas, body.alt-cam.free-look .stage canvas { cursor: zoom-in; }
#btn-fly.on, #btn-view.on { background: var(--accent-soft); color: var(--accent); }
#build-bar .btn.temp { box-shadow: inset 0 0 0 1.5px var(--accent); }

.pie { position: fixed; z-index: 40; width: 0; height: 0; pointer-events: none; }
/* anneau discret (verre sombre léger) : le décor reste visible derrière les tuiles */
.pie-ring { position: absolute; left: -124px; top: -124px; width: 248px; height: 248px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(20,24,34,.38) 0 44px, rgba(20,24,34,.16) 45px 100%); border: 1px solid rgba(255,255,255,.35);
  box-shadow: 0 0 0 10px rgba(255,255,255,.08), 0 18px 50px -18px rgba(22, 26, 37, .55); backdrop-filter: blur(6px) saturate(1.1); -webkit-backdrop-filter: blur(6px) saturate(1.1);
  transform: scale(.35) rotate(-40deg); opacity: 0; transition: transform .32s var(--spring), opacity .18s ease; }
.pie-center { position: absolute; left: -38px; top: -38px; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; text-align: center; pointer-events: auto; cursor: pointer;
  background: #1d2230; color: #fff; font-size: .64rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; line-height: 1.2; padding: 8px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.85); box-shadow: 0 6px 18px -6px rgba(0,0,0,.6);
  transform: scale(0); transition: transform .28s var(--spring), background .12s; }
.pie-center:hover { background: var(--danger); }
.pie-center span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.pie-item { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 84px; height: 58px; padding: 6px 4px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,.9); background: rgba(255,255,255,.96); color: var(--text); font: 650 .72rem/1.1 inherit; text-align: center; cursor: pointer; box-shadow: 0 8px 20px -10px rgba(22, 26, 37, .65);
  transform: translate(-50%, -50%) scale(.3); opacity: 0;
  transition: transform .34s var(--spring) calc(var(--i) * 18ms), opacity .2s ease calc(var(--i) * 18ms), background .12s, color .12s, border-color .12s, box-shadow .12s; }
.pie-item span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pie-item .i { color: var(--accent); flex: none; }
.pie-item:hover:not(:disabled), .pie-item:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; outline: none; box-shadow: 0 0 0 3px var(--accent-ring), 0 10px 22px -10px rgba(22, 26, 37, .7); }
.pie-item:hover:not(:disabled) .i, .pie-item:focus-visible .i { color: #fff; }
.pie-item.off { background: rgba(255,255,255,.7); color: var(--muted); opacity: .6 !important; cursor: not-allowed; box-shadow: none; }
.pie-item.off .i { color: var(--faint); }
.pie.open .pie-ring { transform: none; opacity: 1; }
.pie.open .pie-center { transform: none; }
.pie.open .pie-item { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))); opacity: 1; }
.pie.open .pie-item:hover:not(:disabled) { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.06); }
.pie.closing { transition: opacity .15s; opacity: 0; }
@media (prefers-reduced-motion: reduce) { .pie-ring, .pie-center, .pie-item { transition: none; } }

/* pastilles de raccourci (Cmd/Ctrl maintenu : Tourner ; + Maj : Taille) */
#build-bar .kb { min-width: 1.5em; margin-left: 6px; padding: 0 4px; font-size: .62rem; line-height: 1.4; opacity: .75; pointer-events: none; }
