/* ==========================================================================
   Presentación interactiva — Tema 8: Electrónica digital. Circuitos combinacionales
   Escenario fijo 1280×720 que se escala al tamaño de la ventana.
   ========================================================================== */

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --fg: #1b2330;
  --muted: #5b6678;
  --line: #d9dfe8;
  --grid: #e6eaf0;
  --accent: #0e7c86;
  --accent-soft: #d8eef0;
  --electron: #2563eb;
  --hole: #e0364f;
  --p-tint: #fde4e8;
  --n-tint: #dde8fd;
  --ok: #15803d;
  --bad: #dc2626;
  --warn: #c2680a;
  --current: #f59e0b;
  --sig-in: #7b8698;
  --sig-out: #2563eb;
  --sig-3: #9333ea;
  --shade-on: rgba(22, 163, 74, 0.14);
  --uno: #16a34a;
  --cero: #8794a8;
  --g1: #2563eb;
  --g2: #dc2626;
  --g3: #15803d;
  --g4: #d97706;
  --g5: #9333ea;
  --g6: #0891b2;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 8px 24px rgba(20, 30, 50, .08);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --math: "Cambria Math", "Cambria", "STIX Two Math", "Latin Modern Math", "Times New Roman", serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0f15;
  --surface: #141b25;
  --surface-2: #1a2330;
  --fg: #e6ebf2;
  --muted: #97a3b6;
  --line: #2a3545;
  --grid: #222c3a;
  --accent: #36b8c2;
  --accent-soft: #15383d;
  --electron: #60a5fa;
  --hole: #fb7185;
  --p-tint: #3b1f28;
  --n-tint: #1a2946;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --current: #fbbf24;
  --sig-in: #8b97aa;
  --sig-out: #60a5fa;
  --sig-3: #c084fc;
  --shade-on: rgba(74, 222, 128, 0.14);
  --uno: #4ade80;
  --cero: #64748b;
  --g1: #60a5fa;
  --g2: #f87171;
  --g3: #4ade80;
  --g4: #fbbf24;
  --g5: #c084fc;
  --g6: #22d3ee;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
a { color: var(--accent); text-underline-offset: 3px; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
}

/* ---------- Escenario ---------- */
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1280px;
  height: 720px;
  transform-origin: 50% 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-radius: 6px;
}

.slide {
  position: absolute;
  inset: 0;
  padding: 30px 48px 44px;
  display: none;
  flex-direction: column;
}
.slide.active { display: flex; animation: aparecer .35s ease-out; }
.captura .slide.active { animation: none; }
.captura #barra { display: none; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.slide header { flex: 0 0 auto; margin-bottom: 14px; }
.kicker {
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.slide h2 {
  margin: 2px 0 0;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.01em;
}
.slide h3 { margin: 0 0 8px; font-size: 19px; color: var(--accent); }

.cuerpo { flex: 1 1 auto; min-height: 0; display: flex; gap: 26px; }
.cuerpo.cols > .texto { flex: 0 0 370px; overflow: hidden; }
.cuerpo.cols > .demo { flex: 1 1 auto; min-width: 0; }
.cuerpo.full { flex-direction: column; gap: 10px; }
.cuerpo.full > .demo { flex: 1 1 auto; min-height: 0; }
.cuerpo.cols.ancho > .texto { flex-basis: 300px; }

.texto { font-size: 18.5px; line-height: 1.45; }
.texto p { margin: 0 0 10px; }
.texto .peq, .peq { font-size: 15px; color: var(--muted); }

ul.puntos { list-style: none; margin: 0 0 10px; padding: 0; }
ul.puntos > li { position: relative; padding-left: 22px; margin-bottom: 9px; }
ul.puntos > li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: .55em;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}

.caja {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0 12px;
}
.caja.aviso { border-left-color: var(--warn); }
.caja.clave { border-left-color: var(--hole); }
.caja b:first-child { color: var(--accent); }

.formula {
  font-family: var(--math);
  font-size: 22px;
  text-align: center;
  padding: 8px 10px;
  margin: 8px 0 12px;
  background: var(--accent-soft);
  border-radius: 8px;
}
.m { font-family: var(--math); font-style: italic; }
.m sub, .m sup, .formula sub, .formula sup { font-style: normal; }

/* Negación: barra sobre la variable o sobre un grupo (anidable) */
.ol {
  display: inline-block;
  border-top: 1.4px solid currentColor;
  padding-top: 1px;
  margin: 0 1px;
  line-height: 1.08;
}
.uno { color: var(--uno); font-weight: 700; }
.g1 { color: var(--g1); font-weight: 600; } .g2 { color: var(--g2); font-weight: 600; }
.g3 { color: var(--g3); font-weight: 600; } .g4 { color: var(--g4); font-weight: 600; }
.g5 { color: var(--g5); font-weight: 600; } .g6 { color: var(--g6); font-weight: 600; }
.e { color: var(--electron); font-weight: 600; }
.h { color: var(--hole); font-weight: 600; }
.acc { color: var(--accent); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

/* Fragmentos (aparecen paso a paso) */
.frag { transition: opacity .35s ease, transform .35s ease; }
.frag:not(.visible) { opacity: 0; transform: translateY(6px); pointer-events: none; }

/* ---------- Tablas ---------- */
table.tabla { border-collapse: collapse; width: 100%; font-size: 16px; }
table.tabla th, table.tabla td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
table.tabla th { background: var(--accent-soft); color: var(--fg); font-weight: 700; }
table.tabla tr.activa td { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* ---------- Área de demos ---------- */
.demo { position: relative; display: flex; flex-direction: column; gap: 8px; }
.demo canvas { display: block; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); touch-action: none; }
.demo .fila { display: flex; gap: 10px; align-items: flex-start; }

.controles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  font-size: 15px;
  padding: 2px 2px;
}
.ctl { display: flex; align-items: center; gap: 8px; }
.ctl label { color: var(--muted); white-space: nowrap; }
.ctl .val {
  font-variant-numeric: tabular-nums;
  min-width: 74px;
  font-weight: 600;
  color: var(--fg);
}
.ctl input[type=range] { width: 150px; accent-color: var(--accent); }
.ctl.ancho input[type=range] { width: 230px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit;
  font-size: 14.5px;
  border: 0;
  background: var(--surface);
  color: var(--fg);
  padding: 6px 12px;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }

.btn {
  font: inherit;
  font-size: 14.5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primario { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.lecturas {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 14px;
  font-size: 15.5px;
  align-content: start;
}
.lecturas .k { color: var(--muted); }
.lecturas .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.insignia {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.insignia.ok { color: var(--ok); border-color: var(--ok); }
.insignia.bad { color: var(--bad); border-color: var(--bad); }
.insignia.warn { color: var(--warn); border-color: var(--warn); }

/* ---------- Portada ---------- */
.portada { padding: 0; }
.portada canvas.fondo { position: absolute; inset: 0; }
.portada .centro {
  position: relative;
  margin: auto;
  text-align: center;
  padding: 36px 60px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(3px);
}
.portada .tema { font-size: 20px; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.portada h1 { font-size: 64px; margin: 8px 0 6px; letter-spacing: -.02em; }
.portada .sub { font-size: 21px; color: var(--muted); }
.portada .ayuda { margin-top: 26px; font-size: 15px; color: var(--muted); }
kbd {
  font-family: var(--font);
  font-size: .9em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 6px;
  background: var(--surface-2);
}

/* ---------- Índice (diapositiva) ---------- */
.indice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.indice-grid .bloque {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 22px 24px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.indice-grid .bloque:hover { border-color: var(--accent); transform: translateY(-2px); }
.indice-grid .num { font-size: 15px; font-weight: 800; color: var(--accent); letter-spacing: .1em; }
.indice-grid .tit { font-size: 25px; font-weight: 700; margin: 4px 0 8px; }
.indice-grid .desc { font-size: 17px; color: var(--muted); line-height: 1.4; }

/* ---------- Tarjetas ---------- */
.tarjetas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tarjeta {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 15px;
}
.tarjeta.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tarjeta b { display: block; font-size: 16px; }

/* ---------- Quiz ---------- */
.quiz .pregunta { font-size: 27px; font-weight: 600; margin: 6px 0 18px; }
.quiz .opciones { display: grid; gap: 10px; }
.quiz .opcion {
  text-align: left;
  font: inherit;
  font-size: 21px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
}
.quiz .opcion:hover { border-color: var(--accent); }
.quiz .opcion.correcta { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.quiz .opcion.incorrecta { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.quiz .explica { margin-top: 16px; font-size: 19px; line-height: 1.45; min-height: 84px; }
.quiz .nav { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.quiz .puntos-q { display: flex; gap: 6px; }
.quiz .puntos-q span { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.quiz .puntos-q span.act { outline: 2px solid var(--accent); outline-offset: 1px; }
.quiz .puntos-q span.bien { background: var(--ok); }
.quiz .puntos-q span.mal { background: var(--bad); }

/* ---------- Mapa conceptual ---------- */
.mapa { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mapa .col { display: flex; flex-direction: column; gap: 12px; }
.mapa .cab { font-weight: 800; color: var(--accent); font-size: 16px; letter-spacing: .08em; text-transform: uppercase; }
.mapa .nodo {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16.5px;
  line-height: 1.4;
  cursor: pointer;
}
.mapa .nodo:hover { border-color: var(--accent); }
.mapa .nodo b { display: block; font-size: 18px; margin-bottom: 2px; }

/* ---------- Barra inferior e interfaz ---------- */
#progreso {
  position: absolute;
  left: 0; bottom: 0;
  height: 4px;
  background: var(--accent);
  transition: width .3s ease;
  z-index: 5;
}
#pie {
  position: absolute;
  left: 48px; right: 48px; bottom: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
  z-index: 4;
}

#barra {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
  transition: opacity .35s ease;
}
#barra.oculta { opacity: 0; pointer-events: none; }
#barra button {
  font: inherit;
  font-size: 14px;
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
#barra button:hover { background: var(--surface-2); }
#barra .sep { width: 1px; background: var(--line); margin: 4px 2px; }

#notas {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 40vh;
  overflow: auto;
  background: var(--surface);
  border-top: 3px solid var(--accent);
  padding: 14px 28px 64px;
  font-size: 16px;
  line-height: 1.5;
  z-index: 15;
  display: none;
  box-shadow: 0 -8px 24px rgba(0,0,0,.15);
}
#notas.visible { display: block; }
#notas h4 { margin: 0 0 6px; color: var(--accent); font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }

#indice {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(4px);
  z-index: 30;
  display: none;
  overflow: auto;
  padding: 40px 6vw;
}
#indice.visible { display: block; }
#indice h3 { margin: 18px 0 8px; color: var(--accent); font-size: 14px; letter-spacing: .12em; text-transform: uppercase; }
#indice .lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
#indice button {
  font: inherit;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-size: 15px;
}
#indice button:hover, #indice button.actual { border-color: var(--accent); }
#indice button .n { color: var(--accent); font-weight: 700; margin-right: 6px; }

#negro { position: fixed; inset: 0; background: #000; z-index: 40; display: none; }
#negro.visible { display: block; }

.notas { display: none; } /* notas del ponente: se muestran en #notas */

/* ---------- Ecuaciones con fracciones (estilo LaTeX) ---------- */
.ecuaciones {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 18px;
  align-content: start;
  pointer-events: none;
  font-size: 14.5px;
}
.ecuaciones .tit { grid-column: 1 / -1; color: var(--accent); font-weight: 700; }
.ecuaciones .linea { grid-column: 1 / -1; font-weight: 700; transition: opacity .3s; }
.eq {
  font-family: var(--math);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: opacity .3s;
}
.eq i { font-style: italic; }
.eq sub, .eq sup { font-size: 70%; }
.eq .var { white-space: nowrap; }
.eq .ss { display: inline-flex; flex-direction: column; font-size: 70%; line-height: .95; vertical-align: middle; margin-left: 1px; }
.eq .fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; }
.eq .fr > span { display: inline-flex; align-items: center; gap: 3px; padding: 0 3px; }
.eq .fr > span:first-child { border-bottom: 1.2px solid currentColor; padding-bottom: 2px; }
.eq .fr > span:last-child { padding-top: 2px; }
.eq .fr .fr { font-size: 88%; }
.eq .mn { font-weight: 700; font-size: 125%; line-height: .8; }
.eq .val { font-family: var(--font); font-weight: 700; color: var(--sig-3); margin-left: 4px; }
.pend { opacity: .22; }

