/* Curso de amplificadores: estilo común (PC y celular) */
:root {
  --papel: #faf8f4;
  --tinta: #1f2328;
  --suave: #5b6370;
  --linea: #e2ddd3;
  --acento: #1f5fa8;
  --acento-suave: #e8f0fa;
  --naranja: #d9731a;
  --naranja-suave: #fdf1e6;
  --verde: #2b7a4b;
  --verde-suave: #e9f5ee;
  --tarjeta: #ffffff;
  --ancho: 46rem;
  font-size: 18px;
}
@media (max-width: 600px) { :root { font-size: 17px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  line-height: 1.65;
}
header.barra {
  position: sticky; top: 0; z-index: 5;
  background: rgba(250, 248, 244, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--linea);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.85rem;
}
header.barra .dentro {
  max-width: var(--ancho); margin: 0 auto; padding: 0.6rem 1.1rem;
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
}
header.barra a { color: var(--acento); text-decoration: none; }
main { max-width: var(--ancho); margin: 0 auto; padding: 1.5rem 1.1rem 4rem; }

h1, h2, h3 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.25; letter-spacing: -0.01em;
}
h1 { font-size: 1.9rem; margin: 0.4rem 0 0.3rem; }
h2 { font-size: 1.35rem; margin: 2.6rem 0 0.6rem; padding-top: 0.4rem; border-top: 1px solid var(--linea); }
h3 { font-size: 1.1rem; margin: 1.8rem 0 0.4rem; }
.antetitulo {
  font-family: system-ui, sans-serif; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--suave);
}
.bajada { font-size: 1.1rem; color: var(--suave); margin-top: 0; }
a { color: var(--acento); }
p, li { hyphens: auto; }

/* Figuras: se agrandan al tocarlas */
figure { margin: 1.6rem 0; }
figure a.ampliar { display: block; background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 10px; padding: 0.8rem; }
figure img { display: block; width: 100%; height: auto; }
figure img.chico { max-width: 26rem; margin: 0 auto; }
figcaption { font-size: 0.88rem; color: var(--suave); margin-top: 0.5rem; line-height: 1.5; }

/* Fórmulas (MathML) */
math[display="block"] {
  display: block; margin: 1rem 0; padding: 0.8rem 0.6rem;
  font-size: 1.15rem; overflow-x: auto; overflow-y: hidden;
  background: var(--tarjeta); border-left: 3px solid var(--acento); border-radius: 0 8px 8px 0;
}
math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", serif; }

/* Cajas */
.caja {
  border-radius: 10px; padding: 0.9rem 1.1rem; margin: 1.4rem 0;
  border: 1px solid var(--linea); background: var(--tarjeta);
}
.caja > :first-child { margin-top: 0; }
.caja > :last-child { margin-bottom: 0; }
.caja .rotulo {
  display: block; font-family: system-ui, sans-serif; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.35rem;
}
.predeci { background: var(--naranja-suave); border-color: #f3d3b4; }
.predeci .rotulo { color: var(--naranja); }
.idea { background: var(--acento-suave); border-color: #c9dbf1; }
.idea .rotulo { color: var(--acento); }
.llevate { background: var(--verde-suave); border-color: #c4e2d0; }
.llevate .rotulo { color: var(--verde); }

details {
  margin-top: 0.7rem; border-top: 1px dashed #d9c3ac; padding-top: 0.6rem;
}
details summary {
  cursor: pointer; font-family: system-ui, sans-serif; font-size: 0.9rem; color: var(--acento);
  list-style: none; padding: 0.3rem 0;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; }
details[open] summary::before { content: "▾ "; }

/* Tablas que se desplazan de costado en el celular */
.tabla { overflow-x: auto; margin: 1.2rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; font-family: system-ui, sans-serif; }
th, td { border-bottom: 1px solid var(--linea); padding: 0.45rem 0.6rem; text-align: left; white-space: nowrap; }
th { color: var(--suave); font-weight: 600; white-space: normal; vertical-align: bottom; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.85em; }
code { background: #efebe3; padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: #1f2328; color: #e8e6e1; padding: 0.9rem 1rem; border-radius: 8px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; }

/* Pie con navegación y "la terminé" */
.pie {
  margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--linea);
  display: flex; flex-wrap: wrap; gap: 0.8rem; justify-content: space-between; align-items: center;
  font-family: system-ui, sans-serif; font-size: 0.9rem;
}
.boton {
  display: inline-block; padding: 0.6rem 1rem; border-radius: 8px; border: 1px solid var(--acento);
  color: var(--acento); background: var(--tarjeta); text-decoration: none; cursor: pointer;
  font: inherit;
}
.boton.hecho { background: var(--verde); border-color: var(--verde); color: #fff; }
.boton.apagado { border-color: var(--linea); color: var(--suave); pointer-events: none; }

/* Índice */
.modulo { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 12px; padding: 1rem 1.1rem; margin: 1rem 0; }
.modulo h3 { margin: 0 0 0.2rem; }
.modulo p { margin: 0.2rem 0 0.6rem; color: var(--suave); font-size: 0.95rem; }
.modulo ol { margin: 0; padding-left: 1.3rem; font-family: system-ui, sans-serif; font-size: 0.95rem; }
.modulo li { margin: 0.3rem 0; }
.modulo li.pronto { color: var(--suave); }
.marca { color: var(--verde); font-weight: 700; margin-left: 0.3rem; }
.avance { font-family: system-ui, sans-serif; font-size: 0.9rem; color: var(--suave); }
.barra-avance { height: 8px; background: var(--linea); border-radius: 99px; overflow: hidden; margin: 0.4rem 0 1.5rem; }
.barra-avance span { display: block; height: 100%; background: var(--verde); width: 0; transition: width 0.4s; }

/* ---------- Modo oscuro (automático o elegido) ---------- */
:root[data-tema="oscuro"] {
  --papel: #17191c; --tinta: #e6e3dc; --suave: #a3a8b0; --linea: #33373d;
  --acento: #7fb2ee; --acento-suave: #1c2a3a; --naranja: #f0a35e; --naranja-suave: #2d2218;
  --verde: #6cc493; --verde-suave: #18291f; --tarjeta: #202327;
}
:root[data-tema="oscuro"] header.barra { background: rgba(23, 25, 28, 0.95); }
:root[data-tema="oscuro"] code { background: #2a2e33; }
:root[data-tema="oscuro"] .predeci { border-color: #4a3520; }
:root[data-tema="oscuro"] .idea { border-color: #2a405a; }
:root[data-tema="oscuro"] .llevate { border-color: #285238; }
:root[data-tema="oscuro"] details { border-top-color: #4a3f33; }
/* las figuras quedan sobre fondo claro para que se lean los esquemas */
:root[data-tema="oscuro"] figure a.ampliar { background: #f4f2ee; border-color: #3a3e44; }
:root[data-tema="oscuro"] .boton.hecho { color: #10301e; }

/* ---------- Controles de lectura en la barra ---------- */
.controles { display: flex; gap: 0.35rem; }
.controles button {
  font: inherit; font-size: 0.85rem; min-width: 2.4rem; min-height: 2.2rem; padding: 0 0.5rem;
  border-radius: 8px; border: 1px solid var(--linea); background: var(--tarjeta); color: var(--tinta); cursor: pointer;
}
:root[data-letra="grande"] { font-size: 20px; }
:root[data-letra="enorme"] { font-size: 22px; }
:root[data-letra="chica"] { font-size: 16px; }

/* ---------- Navegación anterior / siguiente ---------- */
.navegacion { display: flex; gap: 0.6rem; margin-top: 1rem; font-family: system-ui, sans-serif; font-size: 0.9rem; }
.navegacion a, .navegacion span {
  flex: 1; padding: 0.8rem 0.9rem; border-radius: 10px; border: 1px solid var(--linea);
  background: var(--tarjeta); text-decoration: none; min-height: 3rem;
}
.navegacion .sig { text-align: right; }
.navegacion small { display: block; color: var(--suave); font-size: 0.75rem; }
.navegacion span { color: var(--suave); }

/* ---------- Widgets interactivos ---------- */
.widget {
  background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 12px;
  padding: 1rem 1.1rem; margin: 1.6rem 0; font-family: system-ui, sans-serif; font-size: 0.95rem;
}
.widget .rotulo { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--verde); margin-bottom: 0.5rem; }
.widget label { display: block; margin: 0.9rem 0 0.2rem; }
.widget label output { float: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.widget input[type="range"] { width: 100%; height: 2.2rem; accent-color: var(--acento); touch-action: pan-y; }
.widget .resultado {
  margin-top: 0.9rem; padding: 0.7rem 0.8rem; border-radius: 8px; background: var(--acento-suave);
  font-variant-numeric: tabular-nums; line-height: 1.6;
}
.widget .resultado b { font-size: 1.15rem; }
.widget .barra-nivel { height: 12px; border-radius: 99px; background: var(--linea); overflow: hidden; margin-top: 0.4rem; }
.widget .barra-nivel span { display: block; height: 100%; background: var(--acento); transition: width 0.1s; }
.widget svg { width: 100%; height: auto; display: block; margin-top: 0.6rem; }
.widget .nota { color: var(--suave); font-size: 0.85rem; margin-top: 0.6rem; }

/* En pantallas chicas la barra muestra solo "Índice" y los controles */
@media (max-width: 480px) { header.barra .dentro > span { display: none; } }
