/* Tema oscuro pensado para proyector: alto contraste y letra grande */
:root {
  --fondo: #070a12;
  --fondo-2: #0e1320;
  --fondo-3: #161d2f;
  --borde: #263049;
  --texto: #e8edf7;
  --texto-2: #9aa6bf;
  --laser: #ff3b5c;
  --acento: #38d6ff;
  --verde: #4ee59a;
  --amarillo: #ffd23f;
  --magenta: #ff5fd2;
  --radio: 10px;
  font-size: 17px;
  color-scheme: dark; /* barras de scroll y controles nativos oscuros */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--fondo);
  color: var(--texto);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: 60px 1fr 30px;
  grid-template-columns: minmax(0, 1fr); /* sin esto, el título en nowrap ensancha la página en celulares */
}

button { font: inherit; color: inherit; }

/* ---------- Barra superior ---------- */
.barra {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--fondo-2);
  border-bottom: 1px solid var(--borde);
}
.barra-titulo { display: flex; align-items: baseline; gap: 14px; min-width: 0; flex: 1; }
.barra-num { color: var(--acento); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.barra h1 { margin: 0; font-size: 1.45rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.puntos { display: flex; gap: 8px; }
.punto {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--borde); background: var(--fondo-3);
  color: var(--texto-2); font-size: .8rem; font-weight: 700; cursor: pointer;
}
.punto.visto { color: var(--texto); }
.punto.activo { background: var(--acento); color: #04121a; border-color: var(--acento); }

.barra-flechas { display: flex; gap: 6px; }
.flecha {
  width: 40px; height: 36px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--borde); background: var(--fondo-3); font-size: 1.1rem;
}
.flecha:hover, .punto:hover { border-color: var(--acento); }

/* ---------- Zona principal ---------- */
.principal { display: flex; min-height: 0; }

.simulacion {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #0d1426 0%, var(--fondo) 70%);
}
.simulacion canvas { display: block; }
.simulacion > canvas { position: absolute; inset: 0; }

.panel {
  width: 360px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 18px 18px 24px;
  background: var(--fondo-2);
  border-left: 1px solid var(--borde);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Idea clave */
.idea {
  border-left: 4px solid var(--acento);
  background: var(--fondo-3);
  padding: 12px 14px;
  border-radius: 0 var(--radio) var(--radio) 0;
  font-size: 1.12rem;
  line-height: 1.4;
  font-weight: 600;
}
.idea small { display: block; color: var(--texto-2); font-weight: 400; font-size: .85rem; margin-top: 6px; }

.panel h3 {
  margin: 4px 0 -4px;
  font-size: .92rem;
  font-weight: 600;
  color: var(--texto-2);
}
.panel p { margin: 0; line-height: 1.45; color: var(--texto); }
.panel p.tenue { color: var(--texto-2); font-size: .92rem; }

/* Controles */
.control { display: flex; flex-direction: column; gap: 6px; }
.control-cab { display: flex; justify-content: space-between; gap: 8px; font-size: .95rem; }
.control-cab b { color: var(--acento); font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type=range] { width: 100%; accent-color: var(--acento); height: 22px; cursor: pointer; }

.opciones { display: flex; flex-wrap: wrap; gap: 6px; }
.opcion, .boton {
  border: 1px solid var(--borde);
  background: var(--fondo-3);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .95rem;
}
.opcion:hover, .boton:hover { border-color: var(--acento); }
.opcion.activa { background: var(--acento); color: #04121a; border-color: var(--acento); font-weight: 700; }
.boton.primario { background: var(--laser); border-color: var(--laser); color: #fff; font-weight: 700; padding: 10px 16px; }
.boton.primario:hover { filter: brightness(1.1); }
.boton:disabled { opacity: .5; cursor: default; }

/* Lecturas numéricas */
.lectura {
  background: #05080f;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}
.lectura .et { color: var(--texto-2); font-size: .85rem; }
.lectura .val { font-size: 1.15rem; font-weight: 700; }
.formula { font-family: Consolas, "Cascadia Mono", monospace; font-size: 1rem; }

.leyenda { display: flex; flex-wrap: wrap; gap: 10px; font-size: .88rem; color: var(--texto-2); }
.leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.rampa { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #301040, #4570ee, #1accc8, #66fa66, #d9e633, #fa8c1f, #cc1a1a); }
.rampa-et { display: flex; justify-content: space-between; font-size: .8rem; color: var(--texto-2); }

/* Texto sobre la simulación */
.capa-texto { position: absolute; pointer-events: none; }
.etiqueta3d {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  background: rgba(7, 10, 18, .8);
  border: 1px solid currentColor;
}

/* Pestañas (paso 7) */
.pestanas {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.pestana {
  border: 1px solid var(--borde); background: rgba(14, 19, 32, .92);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: .95rem;
}
.pestana:hover { border-color: var(--acento); }
.pestana.activa { background: var(--acento); color: #04121a; border-color: var(--acento); font-weight: 700; }
.subsim { position: absolute; inset: 0; }

/* Controles de vista sobre una escena 3D (paso 4) */
.vista-sim {
  position: absolute; top: 12px; left: 12px; z-index: 5; max-width: calc(100% - 24px);
  display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 8px 10px;
  background: rgba(14, 19, 32, .88); border: 1px solid var(--borde); border-radius: var(--radio);
  font-size: .9rem;
}
.subsim > canvas { position: absolute; inset: 0; }

/* Tarjetas (pasos 6, 7 y 8) */
.rejilla-scroll { position: absolute; inset: 0; overflow-y: auto; padding: 22px 26px; }
.seccion-tit { margin: 10px 0 10px; font-size: 1.15rem; font-weight: 700; color: var(--acento); }
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tarjeta {
  background: var(--fondo-2); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 14px 16px; line-height: 1.4;
}
/* Solo las tarjetas que se pueden marcar (pasos 6 y 7) reaccionan al ratón */
.tarjeta.elegible { cursor: pointer; transition: border-color .15s; }
.tarjeta.elegible:hover, .tarjeta.activa { border-color: var(--acento); }
.tarjeta h4 { margin: 0 0 6px; font-size: 1.08rem; }
.tarjeta p { margin: 0; color: var(--texto-2); font-size: .93rem; }
.tarjeta .ej { margin-top: 8px; color: var(--texto); font-size: .88rem; }

/* Guion del expositor */
.guion {
  position: fixed; left: 16px; bottom: 42px; width: min(560px, calc(100vw - 32px));
  background: rgba(14, 19, 32, .97); border: 1px solid var(--amarillo); border-radius: var(--radio);
  padding: 12px 16px; z-index: 50; line-height: 1.5; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.guion.oculto { display: none; }
.guion-cab { color: var(--amarillo); font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.guion ul { margin: 0; padding-left: 20px; }

/* Pie */
.pie {
  display: flex; gap: 22px; align-items: center; padding: 0 20px;
  background: var(--fondo-2); border-top: 1px solid var(--borde);
  color: var(--texto-2); font-size: .8rem; white-space: nowrap; overflow: hidden;
}
.tecla {
  display: inline-block; min-width: 20px; padding: 0 5px; text-align: center;
  border: 1px solid var(--borde); border-radius: 4px; background: var(--fondo-3); color: var(--texto);
  font-size: .78rem; line-height: 18px;
}

/* Tablas (paso 8) */
.tabla { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 1rem; }
.tabla th, .tabla td { padding: 10px 12px; border-bottom: 1px solid var(--borde); text-align: left; }
.tabla th { color: var(--texto-2); font-size: .95rem; font-weight: 600; }
.tabla td.c { text-align: center; font-size: 1.25rem; }
.tabla tbody tr { cursor: pointer; }
.tabla tbody tr:hover td, .tabla tbody tr.activa td { background: var(--fondo-3); }
.si { color: var(--verde); } .medio { color: var(--amarillo); } .no { color: var(--laser); }

/* Paso 2: esquema SVG */
.esquema { position: absolute; inset: 0; width: 100%; height: 100%; }
.pieza { cursor: pointer; }
.pieza rect, .pieza circle, .pieza path.cuerpo { transition: stroke .15s, fill .15s; }
.pieza:hover .marco, .pieza.activa .marco { stroke: var(--acento); stroke-width: 3; }
.haz { stroke-dasharray: 14 10; animation: flujo 1s linear infinite; }
.haz.vuelta { animation-duration: 1.2s; }
@keyframes flujo { to { stroke-dashoffset: -24; } }
.giro { animation: gira 3s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes gira { to { transform: rotate(360deg); } }

/* Portada */
.portada {
  position: absolute; left: 40px; bottom: 40px; pointer-events: none; max-width: 640px;
  text-shadow: 0 2px 20px rgba(0,0,0,.9);
}
.portada .grande { font-size: 5rem; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.portada .grande span { color: var(--laser); }
.portada .sub { font-size: 1.4rem; color: var(--texto-2); margin-top: 8px; }
.portada .frase { font-size: 1.7rem; margin-top: 18px; font-weight: 600; }

/* Quien pide menos movimiento: sin animaciones continuas (el giro automático se apaga en visor3d.js) */
@media (prefers-reduced-motion: reduce) {
  .haz, .giro { animation: none; }
  .tarjeta.elegible { transition: none; }
}

/* Proyectores de 720 a 800 px de alto: el panel debe caber sin scroll */
@media (max-height: 820px) {
  .panel { padding: 12px 14px 14px; gap: 10px; }
  .idea { font-size: 1rem; padding: 9px 12px; }
  .idea small { margin-top: 4px; }
  .control { gap: 3px; }
  .opcion, .boton { padding: 5px 10px; }
  .boton.primario { padding: 7px 14px; }
  .lectura { padding: 7px 10px; line-height: 1.4; }
  .panel p { line-height: 1.35; }
  .panel p.tenue { font-size: .86rem; }
}

@media (max-width: 900px) {
  :root { font-size: 15px; }
  .panel { width: 290px; }
  .pie span:nth-child(n+4) { display: none; }
  .puntos { display: none; }
}
@media (max-width: 640px) {
  body { overflow: auto; grid-template-rows: 60px auto 30px; }
  .principal { flex-direction: column; }
  .simulacion { min-height: 60vh; }
  .panel { width: 100%; border-left: 0; border-top: 1px solid var(--borde); }
}
