/* Web del libro «No es ninguna tonterIA».
   Sin fuentes externas: Georgia para el texto y la letra del sistema (Segoe UI en Windows) para los títulos, como en la portada.
   Colores sacados de la portada: violetas del cielo, amarillo #FFD45C del «IA» y crema #FFF4DC. */

:root {
  color-scheme: light dark;

  /* Colores de la portada (no cambian con el modo) */
  --noche: #1B1640;
  --violeta: #3A2259;
  --malva: #8A3A62;
  --amarillo: #FFD45C;
  --crema: #FFF4DC;

  /* Modo claro */
  --fondo: #FFFBF2;
  --fondo-2: #FFF4DC;
  --texto: #1F1A33;
  --texto-suave: #4A4260;
  --enlace: #5A2D8C;
  --enlace-hover: #3A2259;
  --borde: #E3D5B8;
  --foco: #5A2D8C;

  /* Semáforo (con texto que contrasta en los dos modos) */
  --verde: #1E6B34;
  --ambar: #FFB000;
  --rojo: #B3261E;

  --letra-texto: Georgia, "Times New Roman", Times, serif;
  --letra-titulos: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --letra-titulos-negra: "Segoe UI Black", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ancho: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #141029;
    --fondo-2: #1E1838;
    --texto: #F4ECDD;
    --texto-suave: #CFC5DD;
    --enlace: #FFD45C;
    --enlace-hover: #FFE59A;
    --borde: #3B3262;
    --foco: #FFD45C;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--letra-texto);
  font-size: 1.125rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

img { max-width: 100%; height: auto; }

a { color: var(--enlace); text-underline-offset: 0.15em; }
a:hover { color: var(--enlace-hover); }
a:focus-visible, summary:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--letra-titulos); line-height: 1.2; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); font-weight: 800; margin: 0 0 1rem; }
h2 { font-size: 1.45rem; font-weight: 700; margin: 2.2rem 0 0.8rem; }
h3 { font-size: 1.15rem; font-weight: 700; margin: 1.6rem 0 0.6rem; }

.ia { color: var(--amarillo); }
/* En fondo claro, el amarillo no se lee: va como subrayado de rotulador */
.contenido .ia { background: var(--amarillo); color: var(--noche); padding: 0 0.08em; border-radius: 0.12em; }

/* Saltar al contenido */
.saltar {
  position: absolute; left: 0.5rem; top: -4rem;
  background: var(--amarillo); color: var(--noche);
  padding: 0.6rem 1rem; font-family: var(--letra-titulos); font-weight: 700;
  z-index: 10; border-radius: 0 0 6px 6px; text-decoration: none;
}
.saltar:focus { top: 0; }

/* Cabecera del sitio: siempre con el cielo de la portada */
.cabecera {
  background: var(--noche);
  color: var(--crema);
  font-family: var(--letra-titulos);
}
.cabecera-dentro {
  max-width: 64rem; margin: 0 auto; padding: 0.8rem 1rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem;
}
.marca {
  color: var(--crema); text-decoration: none;
  font-family: var(--letra-titulos-negra); font-weight: 900; font-size: 1.15rem; letter-spacing: 0.01em;
}
.marca:hover { color: #FFFFFF; }
.marca:focus-visible, .menu a:focus-visible { outline-color: var(--amarillo); }
.menu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; }
.menu a { color: var(--crema); text-decoration: none; font-size: 0.98rem; padding: 0.2rem 0; display: inline-block; border-bottom: 2px solid transparent; }
.menu a:hover { border-bottom-color: var(--crema); color: #FFFFFF; }
.menu a[aria-current="page"] { border-bottom-color: var(--amarillo); color: #FFFFFF; }

/* Contenido */
.contenido { max-width: var(--ancho); margin: 0 auto; padding: 2rem 1rem 3rem; }
.contenido.ancho { max-width: 60rem; }
.entradilla { font-size: 1.2rem; color: var(--texto-suave); }
.nota-fuente { font-size: 0.95rem; color: var(--texto-suave); border-left: 4px solid var(--amarillo); padding: 0.4rem 0 0.4rem 0.9rem; }
.pendiente {
  border: 2px dashed var(--borde); background: var(--fondo-2);
  padding: 1rem 1.2rem; border-radius: 8px; font-family: var(--letra-titulos);
}
.pendiente strong { display: block; font-size: 1.05rem; }

/* Portada de inicio */
.portada {
  background: linear-gradient(180deg, var(--noche) 0%, var(--violeta) 55%, var(--malva) 100%);
  color: var(--crema);
}
.portada-dentro {
  max-width: 64rem; margin: 0 auto; padding: 2.5rem 1rem 3rem;
  display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: 2.5rem; align-items: center;
}
.portada-imagen img { display: block; width: 100%; border-radius: 4px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); }
.portada-texto { font-family: var(--letra-titulos); }
.titulo-libro { font-family: var(--letra-titulos-negra); font-weight: 900; line-height: 1.02; margin: 0 0 1rem; }
.titulo-libro .linea1 { display: block; font-size: clamp(1.8rem, 5vw, 2.8rem); }
.titulo-libro .linea2 { display: block; font-size: clamp(3rem, 10vw, 5.4rem); letter-spacing: -0.01em; }
.subtitulo { font-size: clamp(1.15rem, 2.6vw, 1.5rem); font-weight: 600; margin: 0 0 1.2rem; }
.autor { font-size: 1.1rem; font-weight: 600; letter-spacing: 0.04em; margin: 0; }

.secciones { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.8rem; }
.secciones a {
  display: block; height: 100%; padding: 0.9rem 1rem; border: 1px solid var(--borde); border-radius: 8px;
  background: var(--fondo-2); text-decoration: none; color: var(--texto);
}
.secciones a:hover { border-color: var(--enlace); }
.secciones strong { display: block; font-family: var(--letra-titulos); color: var(--enlace); font-size: 1.05rem; }
.secciones span { font-size: 0.95rem; color: var(--texto-suave); }

blockquote.cita { margin: 1.5rem 0; padding: 0.2rem 0 0.2rem 1rem; border-left: 4px solid var(--amarillo); font-style: italic; }

/* Notas */
.indice-capitulos { columns: 2 18rem; padding-left: 0; list-style: none; }
.indice-capitulos li { break-inside: avoid; margin-bottom: 0.3rem; }
.notas-capitulo { border-top: 1px solid var(--borde); margin-top: 2rem; }
.notas-capitulo h2 { scroll-margin-top: 1rem; }
.notas-capitulo ul { padding-left: 1.2rem; }
.notas-capitulo li { margin-bottom: 0.8rem; }
.notas-capitulo a, .notas a { overflow-wrap: anywhere; font-size: 0.92em; }
.volver { font-family: var(--letra-titulos); font-size: 0.9rem; }

table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.98rem; }
th, td { border: 1px solid var(--borde); padding: 0.55rem 0.7rem; text-align: left; vertical-align: top; }
thead th { background: var(--fondo-2); font-family: var(--letra-titulos); }
table.notas td:first-child { width: 36%; }

/* Hojas para imprimir */
.hoja-pie { font-size: 0.9rem; color: var(--texto-suave); }
.hoja h1 { font-size: clamp(1.6rem, 4.5vw, 2.2rem); }
.instrucciones { font-style: italic; }

table.preguntas th.grupo { background: var(--fondo-2); font-family: var(--letra-titulos); font-size: 1rem; }
table.preguntas .opcion { width: 5.5rem; text-align: center; font-family: var(--letra-titulos); font-size: 0.85rem; }
table.preguntas td.opcion { vertical-align: middle; }
.casilla { display: inline-block; width: 1.05rem; height: 1.05rem; border: 2px solid var(--texto); border-radius: 2px; vertical-align: middle; }

table.semaforo th[scope="row"] { font-family: var(--letra-titulos); width: 18%; background: var(--fondo-2); }
table.semaforo thead th { text-align: center; font-size: 1.05rem; }
table.semaforo thead th.verde { background: var(--verde); color: #FFFFFF; }
table.semaforo thead th.ambar { background: var(--ambar); color: var(--noche); }
table.semaforo thead th.rojo { background: var(--rojo); color: #FFFFFF; }
.punto { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; background: currentColor; margin-right: 0.35em; vertical-align: -0.05em; border: 2px solid rgba(255, 255, 255, 0.85); }
.dos-preguntas { font-family: var(--letra-titulos); font-weight: 700; font-size: 1.1rem; }
.reglas { padding-left: 1.4rem; }
.reglas li { margin-bottom: 0.25rem; }

.lista-hojas { padding-left: 1.2rem; }
.lista-hojas li { margin-bottom: 0.8rem; }

.cambios { padding-left: 1.2rem; }
.cambios li { margin-bottom: 1rem; }

/* Pie */
.pie { border-top: 1px solid var(--borde); background: var(--fondo-2); font-family: var(--letra-titulos); font-size: 0.92rem; color: var(--texto-suave); }
.pie-dentro { max-width: 64rem; margin: 0 auto; padding: 1.2rem 1rem 1.6rem; }
.pie p { margin: 0.3rem 0; }

/* Móvil */
@media (max-width: 760px) {
  .portada-dentro { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 1.8rem; }
  .portada-imagen { max-width: 15rem; margin: 0 auto; }
  .portada-texto { text-align: center; }
}

@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  /* Las tablas pasan a bloques: sin desplazamiento horizontal */
  table.notas, table.notas tbody, table.notas tr, table.notas td { display: block; width: 100%; }
  table.notas thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.notas tr { border: 1px solid var(--borde); border-radius: 6px; margin-bottom: 0.8rem; }
  table.notas td { border: 0; }
  table.notas td:first-child { width: 100%; font-weight: 700; padding-bottom: 0.1rem; }

  table.preguntas, table.preguntas tbody, table.preguntas tr, table.preguntas th, table.preguntas td { display: block; width: 100%; }
  table.preguntas thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.preguntas tr { border: 0; }
  table.preguntas th.grupo { margin-top: 1rem; }
  table.preguntas td { border-width: 0 1px; }
  table.preguntas td.pregunta { border-top: 1px solid var(--borde); }
  table.preguntas td.opcion { display: inline-block; width: auto; border: 0; padding: 0.2rem 0.8rem 0.6rem 0.7rem; text-align: left; }
  table.preguntas td.opcion::after { content: attr(data-opcion); margin-left: 0.35rem; }

  table.semaforo, table.semaforo tbody, table.semaforo tr, table.semaforo th, table.semaforo td { display: block; width: 100%; }
  table.semaforo thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.semaforo tr { margin-bottom: 1rem; }
  table.semaforo th[scope="row"] { width: 100%; }
  table.semaforo td::before { font-family: var(--letra-titulos); font-weight: 700; display: block; }
  table.semaforo td.verde::before { content: "Verde"; color: var(--verde); }
  table.semaforo td.ambar::before { content: "Ámbar"; }
  table.semaforo td.rojo::before { content: "Rojo"; color: var(--rojo); }
}

@media (max-width: 640px) and (prefers-color-scheme: dark) {
  table.semaforo td.verde::before { color: #7FD68F; }
  table.semaforo td.rojo::before { color: #FF8A80; }
}

/* Impresión: cada hoja en una página A4 limpia, sin menús */
@page { size: A4; margin: 13mm 14mm; }

@media print {
  :root { color-scheme: light; }
  body { background: #FFFFFF; color: #000000; font-size: 10.5pt; line-height: 1.38; }
  .saltar, .cabecera, .pie, .no-imprimir, .volver { display: none !important; }
  .contenido, .contenido.ancho { max-width: none; padding: 0; }
  a { color: #000000; text-decoration: none; }
  h1 { font-size: 17pt; margin-bottom: 0.4rem; }
  h2 { font-size: 13pt; margin: 0.9rem 0 0.4rem; }
  .hoja { break-after: page; }
  .hoja:last-of-type { break-after: auto; }
  .contenido .ia { background: none; color: #000000; padding: 0; text-decoration: underline; text-decoration-color: #E0A800; text-decoration-thickness: 0.18em; }
  table { font-size: 9.5pt; margin: 0.5rem 0; }
  th, td { border: 0.6pt solid #555555; padding: 0.22rem 0.4rem; }
  thead th, table.preguntas th.grupo, table.semaforo th[scope="row"] { background: #EEEEEE; }
  tr, th, td { break-inside: avoid; }
  table.preguntas .opcion { width: 15mm; }
  .casilla { border: 1.2pt solid #000000; width: 3.6mm; height: 3.6mm; }
  table.semaforo thead th.verde, table.semaforo thead th.ambar, table.semaforo thead th.rojo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .instrucciones { font-size: 9.5pt; }
  .hoja-pie { color: #333333; font-size: 8.5pt; margin-top: 0.5rem; }
  .notas-capitulo a::after { content: none; }
}
