/* Página del laboratorio interactivo. Colores del tema 'laboratorio' (estilo/BIBLIA.md, PALETA_LAB). */
:root {
  --fondo: #fdf8ee;
  --fondo2: #f0e1c5;
  --tinta: #1c2541;
  --acento: #e8452f;
  --panel: #fffaf0;
  --borde: #1c2541;
  --suave: #5b6380;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fondo); color: var(--tinta);
  font-family: 'Archivo', system-ui, sans-serif; }
main { position: fixed; inset: 0; }

/* El escenario del motor nace 9:16; aquí ocupa toda la ventana. */
#escenario.escenario { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }
#escenario canvas { touch-action: none; outline: none; }
#escenario.sobre-pieza canvas { cursor: pointer; }
#escenario.girando-perilla canvas { cursor: ns-resize; }

#titulo { position: absolute; left: 20px; top: 16px; pointer-events: none; }
#titulo h1 { margin: 0; font-family: 'Archivo Black', sans-serif; font-weight: 400; font-size: 30px; letter-spacing: .02em;
  text-transform: uppercase; -webkit-text-stroke: 5px var(--fondo); paint-order: stroke fill; }
#pista { margin: 4px 0 0; font-weight: 700; font-size: 13px; color: var(--suave); }

#cargando, #sin-webgl { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  font-weight: 800; font-size: 18px; background: var(--fondo); z-index: 5; }
#sin-webgl { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
#sin-webgl p { margin: 0; }
#sin-webgl .detalle { font-weight: 700; font-size: 13px; color: var(--suave); max-width: 520px; word-break: break-word; }
#sin-webgl button { margin-top: 8px; border: 2px solid var(--acento); background: var(--acento); color: #fff; border-radius: 10px;
  padding: 8px 18px; cursor: pointer; }
#cargando.fuera { opacity: 0; pointer-events: none; transition: opacity .4s; }
[hidden] { display: none !important; }

#panel { position: absolute; right: 16px; top: 16px; width: 300px; max-height: calc(100% - 32px); overflow: auto;
  background: var(--panel); border: 3px solid var(--borde); border-radius: 16px; box-shadow: 0 6px 0 rgba(28, 37, 65, .18); }
#plegar { width: 100%; text-align: left; font: 800 15px 'Archivo', sans-serif; text-transform: uppercase; letter-spacing: .08em;
  background: none; border: 0; padding: 12px 16px; color: var(--tinta); cursor: pointer; }
#plegar::after { content: '–'; float: right; }
#plegar[aria-expanded='false']::after { content: '+'; }
#cuerpo { padding: 0 16px 14px; }
fieldset { border: 0; border-top: 2px dashed rgba(28, 37, 65, .25); margin: 0; padding: 10px 0 6px; }
legend { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--acento); padding: 0 6px 0 0; }
label { display: block; font-weight: 700; font-size: 14px; margin: 8px 0; }
output { float: right; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--acento); margin-top: 6px; }
.formas { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 4px 0 6px; }
button { font: 700 14px 'Archivo', sans-serif; }
.formas button, .fila button { border: 2px solid var(--borde); background: #fff; color: var(--tinta); border-radius: 10px;
  padding: 7px 6px; cursor: pointer; }
.formas button[aria-pressed='true'] { background: var(--tinta); color: #fff; }
.fila { display: flex; gap: 8px; margin-top: 8px; }
.fila button { flex: 1; }
#encender { background: var(--acento); color: #fff; border-color: var(--acento); }
#encender[aria-pressed='false'] { background: #fff; color: var(--acento); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; }
.nota { font-size: 12px; color: var(--suave); margin: 10px 0 0; }

/* Teléfono: el panel baja como hoja inferior plegable y deja el resto para la escena. */
@media (max-width: 640px) {
  #titulo { left: 16px; top: 12px; }
  #titulo h1 { font-size: 24px; }
  #pista { font-size: 12px; max-width: 70vw; }
  #panel { left: 8px; right: 8px; top: auto; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; max-height: 52%; }
}
@media (prefers-reduced-motion: reduce) { #cargando.fuera { transition: none; } }
