/* Sabiduria Para Todos - hoja de estilo
   Tipografia y formatos segun APA 7.a edicion:
   - Fuente: Georgia (APA 7, 2.19), con respaldos serif.
   - Niveles de encabezado APA (2.27): 1 centrado negrita; 2 izquierda negrita;
     3 izquierda negrita cursiva; 4 con sangria, negrita, en linea con el texto.
   - Parrafos de texto corrido con sangria de primera linea de 0,5 pulgadas (2.24).
   - Tablas y figuras con numero en negrita y titulo en cursiva (7.10, 7.26).
   - Referencias con sangria francesa de 0,5 pulgadas (2.25). */

:root {
  --fondo: #fbfaf7;
  --fondo-alt: #f2f0ea;
  --superficie: #ffffff;
  --texto: #1a2330;
  --texto-2: #424c59;
  --linea: #d8d4ca;
  --acento: #1b4b82;
  --acento-texto: #ffffff;
  --acento-hover: #143a66;
  --enlace: #1b4b82;
  --ok: #1f6b45;
  --error: #9b2c1f;

  --fuente: Georgia, "Noto Serif", "DejaVu Serif", "Times New Roman", serif;
  --medida: 42rem;
  --ancho: 72rem;
  --sangria: 0.5in;

  --e1: .25rem; --e2: .5rem; --e3: .75rem; --e4: 1rem; --e5: 1.5rem;
  --e6: 2rem; --e7: 3rem; --e8: 4.5rem; --e9: 6rem;

  --r-ext: 14px;
  --r-pad: 6px;
  --r-int: calc(var(--r-ext) - var(--r-pad));
  --r-ctrl: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #12161c; --fondo-alt: #181d25; --superficie: #1c222b;
    --texto: #ebe8e1; --texto-2: #b9bfc8; --linea: #343c48;
    --acento: #8fb6e8; --acento-texto: #0f1722; --acento-hover: #a9c7ef;
    --enlace: #9cc0ec; --ok: #7fcba2; --error: #f0a091;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #12161c; --fondo-alt: #181d25; --superficie: #1c222b;
  --texto: #ebe8e1; --texto-2: #b9bfc8; --linea: #343c48;
  --acento: #8fb6e8; --acento-texto: #0f1722; --acento-hover: #a9c7ef;
  --enlace: #9cc0ec; --ok: #7fcba2; --error: #f0a091;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente);
  font-size: 1.125rem;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--enlace); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--acento); outline-offset: 3px; border-radius: 4px; }

.saltar {
  position: absolute; left: var(--e4); top: -4rem; z-index: 10;
  background: var(--acento); color: var(--acento-texto); padding: var(--e2) var(--e4);
  border-radius: var(--r-ctrl);
}
.saltar:focus { top: var(--e4); }

.envoltura { width: 100%; max-width: var(--ancho); margin: 0 auto; padding: 0 var(--e4); }
@media (min-width: 48rem) { .envoltura { padding: 0 var(--e6); } }
.medida { max-width: var(--medida); }

/* ---------- Encabezados APA ---------- */
h1, h2, h3, h4 { font-weight: 700; color: var(--texto); text-wrap: balance; margin: 0; }
/* Nivel 1: centrado, negrita */
h1, .n1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.9rem); line-height: 1.2; text-align: center; }
/* Nivel 2: alineado a la izquierda, negrita */
h2, .n2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.85rem); line-height: 1.3; text-align: left; }
/* Nivel 3: alineado a la izquierda, negrita cursiva */
h3, .n3 { font-size: 1.2rem; line-height: 1.4; font-style: italic; }
/* Nivel 4: con sangria, negrita, termina en punto y el texto sigue en la misma linea */
.n4 { font-weight: 700; }
p { margin: 0 0 var(--e4); }
.texto-apa p { text-indent: var(--sangria); }
.texto-apa p.sin-sangria, .texto-apa .n4-parrafo { text-indent: var(--sangria); }
.texto-apa h2 { margin: var(--e7) 0 var(--e4); }
.texto-apa h3 { margin: var(--e6) 0 var(--e3); }
.texto-apa ul, .texto-apa ol { margin: 0 0 var(--e4); padding-left: var(--sangria); }
.texto-apa li { margin-bottom: var(--e2); }

.antetitulo { font-size: 1rem; color: var(--texto-2); text-align: center; margin: 0 0 var(--e3); }
.entrada { font-size: 1.2rem; color: var(--texto-2); text-align: center; margin: var(--e4) auto 0; max-width: 38rem; text-wrap: pretty; }

/* ---------- Cabecera ---------- */
.cabecera { border-bottom: 1px solid var(--linea); background: var(--fondo); position: sticky; top: 0; z-index: 5; }
.cabecera .envoltura { display: flex; align-items: center; justify-content: space-between; gap: var(--e4); min-height: 4.25rem; }
.marca { display: flex; align-items: center; gap: var(--e3); color: var(--texto); text-decoration: none; }
.marca svg { width: 34px; height: 34px; flex: none; }
.marca span { white-space: nowrap; font-weight: 700; font-size: 1.1rem; line-height: 1.15; }
.navegacion ul { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--e1); align-items: center; }
.navegacion a { display: block; white-space: nowrap; padding: var(--e2) var(--e3); color: var(--texto); text-decoration: none; border-radius: var(--r-ctrl); font-size: 1rem; }
.navegacion a:hover { background: var(--fondo-alt); }
.navegacion a[aria-current="page"] { text-decoration: underline; text-underline-offset: .35em; }
.navegacion .boton { margin-left: var(--e2); }
.menu-boton { display: none; }
@media (max-width: 72rem) {
  .menu-boton {
    display: inline-flex; align-items: center; gap: var(--e2); background: none; border: 1px solid var(--linea);
    color: var(--texto); font: inherit; font-size: 1rem; padding: var(--e2) var(--e3); border-radius: var(--r-ctrl); cursor: pointer;
  }
  .menu-boton svg { width: 20px; height: 20px; }
  .navegacion { position: absolute; left: 0; right: 0; top: 100%; background: var(--fondo); border-bottom: 1px solid var(--linea); display: none; }
  .navegacion.abierta { display: block; }
  .navegacion ul { flex-direction: column; align-items: stretch; padding: var(--e3) var(--e4) var(--e5); }
  .navegacion a { padding: var(--e3); }
  .navegacion .boton { margin: var(--e3) 0 0; text-align: center; }
}

/* ---------- Botones ---------- */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e2);
  font: inherit; font-size: 1rem; font-weight: 700; line-height: 1.2;
  padding: .85rem 1.35rem; border-radius: var(--r-ctrl); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color .15s ease, transform .15s ease;
}
.boton svg { width: 18px; height: 18px; }
.boton-principal { background: var(--acento); color: var(--acento-texto); }
.navegacion a.boton-principal { color: var(--acento-texto); }
.boton-principal:hover, .navegacion a.boton-principal:hover { background: var(--acento-hover); }
.boton-secundario { background: transparent; color: var(--texto); border-color: var(--linea); }
.boton-secundario:hover { background: var(--fondo-alt); }
.boton-grande { font-size: 1.1rem; padding: 1rem 1.7rem; }
.boton[disabled] { opacity: .7; cursor: progress; }

/* ---------- Secciones ---------- */
.seccion { padding: var(--e8) 0; }
.seccion-alt { background: var(--fondo-alt); }
.seccion-cabeza { margin-bottom: var(--e6); }
.seccion-cabeza p { color: var(--texto-2); max-width: 40rem; margin-top: var(--e3); }
.portada { padding: var(--e8) 0 var(--e7); }
.portada .acciones { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--e3); margin-top: var(--e6); }
.cabeza-pagina { padding: var(--e7) 0 var(--e6); border-bottom: 1px solid var(--linea); }
.migas { font-size: .95rem; color: var(--texto-2); text-align: center; margin-bottom: var(--e3); }
.migas a { color: var(--texto-2); }

/* ---------- Rejillas y tarjetas ---------- */
.rejilla { display: grid; gap: var(--e5); }
@media (min-width: 40rem) { .rejilla-2 { grid-template-columns: repeat(2, 1fr); } .rejilla-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 62rem) { .rejilla-3 { grid-template-columns: repeat(3, 1fr); } .rejilla-4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 40rem) and (max-width: 62rem) { .rejilla-4 { grid-template-columns: repeat(2, 1fr); } }

.pilar svg { width: 32px; height: 32px; color: var(--acento); margin-bottom: var(--e3); }
.pilar h3 { margin-bottom: var(--e2); }
.pilar p { color: var(--texto-2); margin: 0; }

.tarjeta {
  background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--r-ext);
  padding: var(--e5); display: flex; flex-direction: column;
}
.tarjeta h3 { font-style: normal; margin-bottom: var(--e2); font-size: 1.15rem; }
.tarjeta h3 a { color: var(--texto); text-decoration: none; }
.tarjeta h3 a:hover { text-decoration: underline; }
.tarjeta p { color: var(--texto-2); font-size: 1rem; line-height: 1.65; }
.tarjeta .area { font-size: .9rem; color: var(--texto-2); margin: 0 0 var(--e2); font-style: italic; }
.datos { list-style: none; margin: auto 0 0; padding: var(--e3) 0 0; border-top: 1px solid var(--linea); display: flex; flex-wrap: wrap; gap: var(--e2) var(--e4); font-size: .95rem; color: var(--texto-2); }
.datos li { display: flex; align-items: center; gap: var(--e2); }
.datos svg { width: 16px; height: 16px; flex: none; }

/* ---------- Pasos ---------- */
.pasos { list-style: none; margin: 0; padding: 0; counter-reset: paso; display: grid; gap: var(--e5); }
@media (min-width: 48rem) { .pasos { grid-template-columns: repeat(4, 1fr); } }
.pasos li { counter-increment: paso; border-top: 2px solid var(--texto); padding-top: var(--e4); }
.pasos li::before { content: "Paso " counter(paso); display: block; font-size: .95rem; color: var(--texto-2); margin-bottom: var(--e2); }
.pasos h3 { font-size: 1.1rem; margin-bottom: var(--e2); }
.pasos p { color: var(--texto-2); font-size: 1rem; margin: 0; }

/* ---------- Figura y tabla APA ---------- */
.figura, .tabla-apa { margin: var(--e6) 0; }
.etiqueta-apa { font-weight: 700; margin: 0; }
.titulo-apa { font-style: italic; margin: 0 0 var(--e3); }
.nota-apa { font-size: 1rem; color: var(--texto-2); margin-top: var(--e3); }
.nota-apa em { font-style: italic; }
.tabla-desplazable { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; line-height: 1.55; }
.tabla-apa table { border-top: 2px solid var(--texto); border-bottom: 2px solid var(--texto); }
.tabla-apa thead th { border-bottom: 1px solid var(--texto); }
th, td { text-align: left; vertical-align: top; padding: var(--e3) var(--e4) var(--e3) 0; }
th { font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: var(--e4); }

/* ---------- Certificado de muestra ---------- */
.certificado {
  background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--r-ext); padding: var(--r-pad);
  max-width: 44rem;
}
.certificado-interior {
  border: 1px solid var(--linea); border-radius: var(--r-int); padding: var(--e6) var(--e5);
  text-align: center; background: var(--superficie);
}
.certificado-interior svg.sello { width: 56px; height: 56px; margin: 0 auto var(--e3); color: var(--acento); }
.certificado .c-inst { font-size: 1rem; letter-spacing: .04em; color: var(--texto-2); margin: 0; }
.certificado .c-tipo { font-size: clamp(1.35rem, 1rem + 1.5vw, 1.8rem); font-weight: 700; margin: var(--e3) 0; }
.certificado .c-nombre { font-size: 1.3rem; font-style: italic; border-bottom: 1px solid var(--linea); display: inline-block; padding: 0 var(--e5) var(--e1); margin: var(--e2) 0 var(--e4); }
.certificado .c-texto { color: var(--texto-2); font-size: 1rem; max-width: 30rem; margin: 0 auto var(--e5); }
.certificado .c-pie { display: grid; gap: var(--e4); grid-template-columns: 1fr; font-size: .95rem; color: var(--texto-2); border-top: 1px solid var(--linea); padding-top: var(--e4); }
@media (min-width: 36rem) { .certificado .c-pie { grid-template-columns: repeat(3, 1fr); } }
.certificado .c-pie strong { display: block; color: var(--texto); font-variant-numeric: tabular-nums; }

/* ---------- Catalogo ---------- */
.filtros { display: flex; flex-wrap: wrap; gap: var(--e4); align-items: flex-end; margin-bottom: var(--e6); padding: var(--e5); background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--r-ext); }
.filtros .campo { flex: 1 1 14rem; margin: 0; }
.resultado-filtro { color: var(--texto-2); margin: 0 0 var(--e4); font-size: 1rem; }
.vacio { display: none; padding: var(--e6); text-align: center; color: var(--texto-2); border: 1px dashed var(--linea); border-radius: var(--r-ext); }

/* ---------- Ficha de curso ---------- */
.ficha { display: grid; gap: var(--e7); }
@media (min-width: 62rem) { .ficha { grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; } }
.resumen-curso { position: sticky; top: 5.5rem; }
.resumen-curso dl { margin: 0 0 var(--e5); display: grid; gap: var(--e3); }
.resumen-curso dt { font-size: .95rem; color: var(--texto-2); }
.resumen-curso dd { margin: 0; font-weight: 700; }
.resumen-curso .boton { width: 100%; }
.modulos { list-style: none; margin: 0 0 var(--e4); padding: 0; counter-reset: modulo; }
.modulos li { counter-increment: modulo; padding: var(--e3) 0 var(--e3) 3.25rem; position: relative; border-bottom: 1px solid var(--linea); }
.modulos li::before { content: counter(modulo); position: absolute; left: 0; top: var(--e3); width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border: 1px solid var(--linea); border-radius: 50%; font-variant-numeric: tabular-nums; font-size: .95rem; }
.modulos strong { display: block; }
.modulos span { color: var(--texto-2); font-size: 1rem; }

/* ---------- Formularios ---------- */
.formulario { background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--r-ext); padding: var(--e5); }
@media (min-width: 48rem) { .formulario { padding: var(--e6); } }
.campos { display: grid; gap: var(--e4) var(--e5); }
@media (min-width: 40rem) { .campos { grid-template-columns: 1fr 1fr; } .campo-ancho { grid-column: 1 / -1; } }
.campo { display: flex; flex-direction: column; gap: var(--e2); }
.campo label, .campo .leyenda { font-weight: 700; font-size: 1rem; }
.campo .ayuda { font-size: .95rem; color: var(--texto-2); }
.opcional { font-weight: 400; color: var(--texto-2); }
input, select, textarea {
  font: inherit; font-size: 1rem; color: var(--texto); background: var(--fondo);
  border: 1px solid #8a8f98; border-radius: var(--r-ctrl); padding: .75rem .85rem; width: 100%;
}
textarea { min-height: 8rem; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--acento); outline-offset: 1px; border-color: var(--acento); }
.casilla { display: flex; gap: var(--e3); align-items: flex-start; font-size: 1rem; }
.casilla input { width: 1.25rem; height: 1.25rem; margin-top: .3rem; flex: none; accent-color: var(--acento); }
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.enviar { margin-top: var(--e5); display: flex; flex-wrap: wrap; align-items: center; gap: var(--e4); }
.estado { margin: 0; font-size: 1rem; }
.estado.ok { color: var(--ok); }
.estado.error { color: var(--error); }
.respuesta { display: none; border: 1px solid var(--linea); border-left: 4px solid var(--ok); background: var(--superficie); border-radius: var(--r-ctrl); padding: var(--e5); }
.respuesta.visible { display: block; animation: aparecer .35s ease-out; }
.respuesta h2 { font-size: 1.35rem; margin-bottom: var(--e2); }
.respuesta.error { border-left-color: var(--error); }
.girador { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: girar .8s linear infinite; display: none; }
.cargando .girador { display: inline-block; }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Referencias APA ---------- */
.referencias { list-style: none; margin: 0; padding: 0; }
.referencias li { padding-left: var(--sangria); text-indent: calc(var(--sangria) * -1); margin-bottom: var(--e4); overflow-wrap: anywhere; }

/* ---------- Aviso ---------- */
.aviso { border-left: 4px solid var(--acento); background: var(--superficie); padding: var(--e4) var(--e5); border-radius: 0 var(--r-ctrl) var(--r-ctrl) 0; margin: var(--e5) 0; }
.aviso p { margin: 0; text-indent: 0 !important; }

/* ---------- Llamada final ---------- */
.llamada { text-align: center; }
.llamada p { color: var(--texto-2); max-width: 36rem; margin: var(--e4) auto var(--e5); }

/* ---------- Pie ---------- */
.pie { border-top: 1px solid var(--linea); padding: var(--e7) 0 var(--e6); font-size: 1rem; color: var(--texto-2); }
.pie-rejilla { display: grid; gap: var(--e6); }
@media (min-width: 48rem) { .pie-rejilla { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.pie h2 { font-size: 1rem; margin-bottom: var(--e3); }
.pie ul { list-style: none; margin: 0; padding: 0; }
.pie li { margin-bottom: var(--e2); }
.pie a { color: var(--texto-2); }
.pie .marca { margin-bottom: var(--e3); }
.pie-legal { margin-top: var(--e6); padding-top: var(--e4); border-top: 1px solid var(--linea); font-size: .95rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .cabecera, .pie, .saltar, .boton { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; line-height: 2; }
}
