/* PlayRobótica · estilos comunes de los paneles de clase (Robilab y Winlab): panel de pasos, perfil, diálogos y
   la ventana del vídeo (cine.js). Lo propio de cada laboratorio va en su CSS (robilab/panel.css, winlab/winlab.css). */
:root {
  --fondo: #f4f8ff; --texto: #1d3557; --suave: #5b6b82; --borde: #d3def0; --acento: #855cd6;
  --hecho: #2a9d55; --tarjeta: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; background: var(--fondo); color: var(--texto);
  font: 19px/1.45 "Nunito", "Trebuchet MS", system-ui, sans-serif; overflow: hidden;
}
#panel {
  width: 360px; flex: none; height: 100%; overflow-y: auto; padding: 14px 16px 18px;
  border-right: 2px solid var(--borde); background: var(--fondo);
}
body.plegado #panel { display: none; }
main { flex: 1; min-width: 0; height: 100%; overflow: hidden; }
.cabecera { display: flex; align-items: center; gap: 10px; }
.cabecera .logo { width: 54px; flex: none; }
.marca { font-weight: 800; color: var(--acento); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
h1 { font-size: 1.3rem; margin: 0; line-height: 1.2; }
#plegar, #desplegar {
  border: 0; background: var(--acento); color: #fff; border-radius: 10px; cursor: pointer; font: inherit;
}
#plegar { width: 36px; height: 36px; flex: none; }
#inicio {
  margin-left: auto; width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border-radius: 10px; background: var(--borde); color: var(--texto); text-decoration: none; font-size: 1.3rem; font-weight: 800;
}
#inicio:hover { background: var(--acento); color: #fff; }
#desplegar { position: fixed; left: 8px; bottom: 60px; z-index: 10; padding: 8px 12px; font-weight: 700; }
.progreso { height: 12px; border-radius: 6px; background: var(--borde); margin: 14px 0 6px; overflow: hidden; }
#barra { height: 100%; width: 0; background: var(--hecho); transition: width .4s; }
#intro { margin: 8px 0 12px; }
#pasos { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.paso {
  background: var(--tarjeta); border: 2px solid var(--borde); border-radius: 16px; padding: 12px 14px;
  transition: border-color .3s, opacity .3s;
}
.paso .cab { display: flex; align-items: center; gap: 10px; }
.paso .num {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; background: var(--borde); color: var(--texto);
}
.paso h2 { font-size: 1.12rem; margin: 0; }
.paso .cuerpo { margin-top: 8px; }
.paso.actual { border-color: var(--acento); box-shadow: 0 4px 14px rgba(133, 92, 214, .18); }
.paso.actual .num { background: var(--acento); color: #fff; }
.paso.futuro { opacity: .6; }
.paso.futuro .cuerpo, .paso.hecho .cuerpo { display: none; }
.paso.hecho { border-color: var(--hecho); }
.paso.hecho .num { background: var(--hecho); color: #fff; }
.paso.hecho .num::before { content: "✓"; }
.paso.hecho .num span { display: none; }
.paso .estado { margin-left: auto; font-size: .85rem; font-weight: 700; color: var(--hecho); }
.chip {
  display: inline; padding: 2px 8px; border-radius: 9px; color: #fff; line-height: 1.9;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  font-weight: 700; font-size: .92em;
}
.comprobaciones { list-style: none; padding: 0; margin: 10px 0 0; font-size: .92rem; }
.comprobaciones li { padding-left: 1.6em; position: relative; color: var(--suave); }
.comprobaciones li::before { content: "○"; position: absolute; left: .2em; }
.comprobaciones li.ok { color: var(--hecho); font-weight: 700; }
.comprobaciones li.ok::before { content: "✓"; }
.ver-pista {
  margin-top: 10px; border: 2px solid var(--acento); color: var(--acento); background: #fff;
  border-radius: 12px; padding: 6px 14px; font: inherit; font-weight: 700; cursor: pointer;
}
.ver-pista:hover { background: var(--acento); color: #fff; }
#enhorabuena {
  margin-top: 14px; padding: 14px; border-radius: 16px; background: #e3f7ea; border: 2px solid var(--hecho);
  font-weight: 700;
}
footer { margin-top: 18px; font-size: .78rem; color: var(--suave); line-height: 1.4; }
footer a { color: var(--acento); }
dialog#pista { border: 0; border-radius: 18px; padding: 14px; width: min(980px, 92vw); background: #fff; color: var(--texto); }
dialog#pista::backdrop { background: rgba(20, 30, 50, .6); }
.pista-cab { display: flex; align-items: center; margin-bottom: 8px; }
.pista-cab h2 { margin: 0; font-size: 1.2rem; }
#pista-cerrar { margin-left: auto; border: 0; background: var(--borde); border-radius: 10px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; }
#pista-video { width: 100%; border-radius: 10px; background: #000; display: block; }
.perfil-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 12px; font-size: 1rem; }
.perfil-barra span { margin-right: auto; }
.boton-suave {
  border: 2px solid var(--borde); background: #fff; color: var(--texto); border-radius: 10px;
  padding: 3px 10px; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.boton-suave:hover { border-color: var(--acento); color: var(--acento); }
#guardado { min-height: 1.2em; font-size: .78rem; color: var(--suave); text-align: right; }
#guardado.error { color: #c0392b; font-weight: 700; }
dialog#perfiles { border: 0; border-radius: 20px; padding: 22px; width: min(440px, 92vw); color: var(--texto); text-align: center; }
dialog#perfiles::backdrop { background: rgba(20, 30, 50, .6); }
dialog#perfiles h2 { margin: 0 0 14px; font-size: 1.4rem; }
#perfiles-lista { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 16px; }
#perfiles-lista button {
  border: 0; background: var(--acento); color: #fff; border-radius: 14px; padding: 12px 20px;
  font: inherit; font-size: 1.2rem; font-weight: 800; cursor: pointer;
}
#perfil-nuevo label { display: block; margin-bottom: 6px; }
#perfil-nuevo .fila { display: flex; gap: 8px; }
#perfil-input { flex: 1; min-width: 0; font: inherit; font-size: 1.1rem; padding: 8px 12px; border: 2px solid var(--borde); border-radius: 12px; }
#perfil-entrar { border: 0; background: var(--hecho); color: #fff; border-radius: 12px; padding: 8px 16px; font: inherit; font-weight: 800; cursor: pointer; }
#perfiles-volver { margin-top: 14px; }
/* ---- vídeo de la clase: grande (modal) o minimizado flotante */
.ver-clase {
  display: block; width: 100%; margin: 4px 0 14px; border: 0; border-radius: 14px; padding: 12px;
  background: #ff7a45; color: #fff; font: inherit; font-size: 1.15rem; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 122, 69, .35);
}
.ver-clase:hover { filter: brightness(1.05); }
.ver-clase[hidden] { display: none; }
.ver-tramo {
  display: block; margin: 10px 0 2px; border: 0; background: #ff7a45; color: #fff; border-radius: 12px;
  padding: 8px 14px; font: inherit; font-weight: 800; cursor: pointer;
}
.ver-tramo:hover { filter: brightness(1.06); }
.sugerencia { margin: 8px 0 0; font-size: .92rem; color: var(--suave); }
/* Vídeo de la clase para niños: «grande», «pequeño» (esquina, se mueve y se estira) u oculto.
   La geometría (left/top/width/height) la pone panel.js según el estado. */
.cine {
  position: fixed; z-index: 901; background: #fff; border-radius: 18px; padding: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35); color: var(--texto); outline: none;
  display: flex; flex-direction: column; box-sizing: border-box;
}
.cine[hidden] { display: none; }
.cine:focus-visible { box-shadow: 0 0 0 4px #ffb08f, 0 12px 40px rgba(0, 0, 0, .35); }
.cine.grande { border-radius: 0; box-shadow: -2px 0 0 var(--borde); }
.cine.grande .cine-pantalla { flex: 1; min-height: 0; }
.cine.grande #cine-video { height: 100%; aspect-ratio: auto; object-fit: contain; }
.cine.pequeno { border: 4px solid #ff7a45; }
.cine-cab { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; user-select: none; min-width: 0; }
.cine.pequeno .cine-cab { cursor: move; touch-action: none; }
.cine-cab h2 { flex: 1; margin: 0 4px; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cine.pequeno .cine-cab h2 { display: none; }
/* agarre para mover: solo con el vídeo pequeño */
.agarre {
  display: none; flex: none; width: 44px; height: 48px; border-radius: 12px; place-items: center;
  background: #ffe6da; color: #c4501f; font-size: 1.7rem; line-height: 1; cursor: move; touch-action: none;
}
.cine.pequeno .agarre { display: grid; margin-right: auto; }
.cine-botones { display: flex; gap: 8px; flex: none; }
.cine-boton {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; justify-content: center;
  border: 0; background: var(--acento); color: #fff; border-radius: 14px; padding: 6px 16px;
  font: inherit; font-size: 1.05rem; font-weight: 800; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
}
.cine-boton[hidden] { display: none; }
.cine-boton .ico { font-size: 1.3rem; line-height: 1; }
.cine-boton:hover { filter: brightness(1.08); }
.cine-boton:active { transform: translateY(2px); box-shadow: none; }
.cine-boton.esconder { background: var(--borde); color: var(--texto); }
.cine-boton.esconder:hover { background: #c4d3ec; }
.cine.pequeno .cine-boton { padding: 6px 10px; font-size: .95rem; gap: 6px; }
.cine.pequeno .cine-botones { gap: 6px; }
.cine.pequeno .cine-boton .largo { display: none; }
/* asa grande para estirar, en la esquina de abajo a la derecha (también con el dedo) */
.estirar {
  display: none; position: absolute; right: -4px; bottom: -4px; width: 40px; height: 40px; z-index: 2;
  cursor: nwse-resize; touch-action: none; border-radius: 0 0 16px 0;
  background:
    linear-gradient(135deg, transparent 46%, #ff7a45 46%, #ff7a45 56%, transparent 56%, transparent 66%, #ff7a45 66%, #ff7a45 76%, transparent 76%),
    #fff3ec;
}
@media (pointer: coarse) { .estirar { width: 48px; height: 48px; } }
.cine.pequeno .estirar { display: block; }
.cine.pequeno .cine-controles { padding-right: 40px; }
/* durante un arrastre, el iframe del editor no se queda con el puntero */
body.arrastrando iframe { pointer-events: none; }
body.arrastrando { user-select: none; cursor: grabbing; }
.cine-pantalla { position: relative; }
#cine-video { width: 100%; display: block; border-radius: 10px; background: #000; aspect-ratio: 16 / 9; }
#cine-falta { margin: 8px; }
#ahora-tu {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; border-radius: 10px; background: rgba(29, 53, 87, .82); color: #fff; text-align: center; padding: 8px;
}
#ahora-tu[hidden] { display: none; }
#ahora-tu p { margin: 0; font-size: 2.8rem; font-weight: 900; line-height: 1.1; text-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
#ahora-tu p.sub { font-size: 1.15rem; font-weight: 700; }
.cine.pequeno #ahora-tu p { font-size: 1.8rem; }
.cine.pequeno #ahora-tu p.sub { font-size: .9rem; }
#ahora-tu .fila { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#ahora-tu button {
  border: 0; border-radius: 14px; padding: 10px 18px; font: inherit; font-weight: 800; cursor: pointer;
  background: #fff; color: var(--texto); min-height: 48px;
}
#ahora-tu #tramo-seguir { background: #ff7a45; color: #fff; }
.cine.pequeno #ahora-tu button { padding: 6px 12px; font-size: .9rem; min-height: 44px; }
.cine-controles { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.cine-play {
  border: 0; border-radius: 16px; background: var(--hecho); color: #fff; font: inherit; font-size: 1.35rem;
  font-weight: 900; padding: 10px 24px; cursor: pointer; min-width: 8em; min-height: 54px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .2); touch-action: manipulation;
}
.cine-play.sonando { background: #ff7a45; }
.cine.pequeno .cine-play { font-size: 1.1rem; padding: 6px 16px; min-width: 6.5em; min-height: 48px; }
#cine-tiempo { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.cine.pequeno #cine-tiempo { font-size: .9rem; }
.cine.pequeno #cine-tramo { display: none; }
#cine-tramo { margin-left: auto; font-size: .95rem; font-weight: 800; color: #c4501f; }
/* vídeo escondido: botón grande con la carita de la clase para volver */
.volver-clase {
  position: fixed; z-index: 902; left: 16px; bottom: 16px; width: 328px; display: flex; align-items: center; gap: 14px;
  border: 4px solid #fff; border-radius: 999px; padding: 6px 22px 6px 6px; background: #ff7a45; color: #fff;
  font: inherit; font-size: 1.3rem; font-weight: 900; cursor: pointer; text-align: left;
  box-shadow: 0 8px 24px rgba(255, 122, 69, .45), 0 2px 8px rgba(0, 0, 0, .2); touch-action: manipulation;
  animation: llama 1.6s ease-in-out 2;
}
.volver-clase[hidden] { display: none; }
.volver-clase img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; object-position: 18% 70%; flex: none; background: #fff; border: 3px solid #fff; }
.volver-clase:hover { filter: brightness(1.06); }
body.plegado .volver-clase { left: auto; right: 16px; width: auto; }
/* que el botón no tape el final de los pasos: el panel deja sitio debajo */
body.video-oculto #panel { padding-bottom: 120px; }
@keyframes llama { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .volver-clase { animation: none; } }
