/* Estilos compartidos por las páginas de módulo (moduloN.html) y de quiz (quiz_moduloN.html) */
:root {
  --rojo: #d7191f;
  --rojo-oscuro: #8f0f14;
  --grafito: #2b2b2f;
  --texto: #1a1a1a;
  --texto-2: #3d3d3d;
  --linea: #d5d8dd;
  --fondo: #f4f5f7;
  --nota-fondo: #fff1f0;
  --ok: #1e7d4f;
  --alerta: #9a5b00;
  --radio: 12px;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  font-family: 'Source Sans 3', 'Segoe UI', Arial, sans-serif;
  font-size: 1.0625rem;
  background: var(--fondo);
  margin: 0;
  color: var(--texto);
  line-height: 1.6;
  overflow-x: hidden;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--grafito);
  outline-offset: 2px;
}

/* ===== ENCABEZADO ===== */
header {
  position: relative;
  text-align: center;
  padding: 35px 20px;
  background: linear-gradient(135deg, var(--rojo-oscuro), var(--rojo));
  color: #fff;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}
header h1 {
  margin: 0 auto;
  max-width: 760px;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
.volver {
  position: absolute;
  top: 10px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  color: #fff;
  font-size: 1rem;
  text-decoration: underline;
}
.volver:hover { text-decoration-thickness: 2px; }
header a:focus-visible { outline-color: #fff; }

/* ===== CONTENIDO ===== */
main {
  max-width: 900px;
  margin: 40px auto;
  padding: 20px;
}

section {
  background: #fff;
  padding: 28px 26px;
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  margin-bottom: 28px;
  scroll-margin-top: 20px;
  outline: 3px solid transparent;
  outline-offset: 2px;
}
section.leyendo { outline-color: var(--rojo); }

section h2 {
  color: var(--rojo);
  margin: 0 0 2px;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  border-bottom: 2px solid var(--rojo);
  display: inline-block;
  padding-bottom: 4px;
}
section h3 {
  color: var(--grafito);
  margin: 22px 0 6px;
  font-size: 1.1rem;
  font-weight: 600;
}
section p { text-align: left; }

ul { list-style: none; padding-left: 0; }
ul li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 8px;
}
ul li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.65em;
  width: 7px;
  height: 7px;
  background: var(--rojo);
  border-radius: 1px;
}
ol { padding-left: 26px; }
ol li { margin-bottom: 8px; padding-left: 4px; }
strong { font-weight: 600; }

/* ===== CAJAS DE INFORMACIÓN ===== */
.info-box {
  background: var(--nota-fondo);
  border-left: 4px solid var(--rojo);
  padding: 14px 18px;
  margin-top: 18px;
  border-radius: 4px;
}
.info-box > :first-child { margin-top: 0; }
.info-box > :last-child { margin-bottom: 0; }

.glosario dt { font-weight: 600; color: var(--rojo-oscuro); }
.glosario dd { margin: 0 0 8px; }

.lema {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--grafito);
}

/* ===== TABLAS ===== */
.tabla-scroll { overflow-x: auto; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--linea); padding: 10px 12px; text-align: left; vertical-align: top; }
th:first-child, td:first-child { width: 38%; }
td:last-child { overflow-wrap: anywhere; }
th { background: #eceef1; font-weight: 600; border-bottom: 2px solid var(--grafito); }

/* ===== BOTONES ===== */
.btn-principal,
.btn-quiz,
.btn-descarga {
  display: block;
  width: fit-content;
  max-width: 100%;
  min-height: 48px;
  margin: 25px auto;
  padding: 12px 32px;
  background: var(--rojo);
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-principal { font-size: 1.15rem; }
.btn-principal:hover,
.btn-quiz:hover,
.btn-descarga:hover {
  background: var(--rojo-oscuro);
}
.btn-descarga {
  display: inline-block;
  margin: 6px 0;
  padding: 10px 20px;
  font-size: 1rem;
  background: var(--grafito);
}
.btn-descarga:hover { background: #121214; }
.btn-omitir {
  display: block;
  min-height: 44px;
  margin: -10px auto 20px;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--texto-2);
  font-family: inherit;
  font-size: 1rem;
  text-decoration: underline;
  cursor: pointer;
}

/* ===== AGENTE ===== */
.agente {
  position: fixed;
  bottom: 30px;
  right: 25px;
  width: 170px;
  height: 170px;
  z-index: 9999;
  overflow: hidden;
  pointer-events: none;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--linea);
  animation: flotarSuave 4s ease-in-out infinite alternate;
}
.agente img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.5) translate(-4%, 2%);
}

@keyframes flotarSuave {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

/* ===== QUIZ ===== */
.quiz-container {
  max-width: 900px;
  margin: 40px auto;
  padding: 28px 30px;
  background: #fff;
  border: 1px solid var(--linea);
  border-radius: var(--radio);
}
.quiz-container h1 {
  text-align: center;
  color: var(--rojo);
  margin: 0 0 24px;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
.question {
  padding: 22px 0;
  border-top: 1px solid var(--linea);
}
.question:first-of-type { border-top: none; padding-top: 0; }
.question > p { margin: 0 0 12px; font-weight: 600; cursor: pointer; }
.question.sin-responder {
  border-left: 4px solid var(--alerta);
  padding-left: 14px;
}
.question.sin-responder::before {
  content: "Sin responder";
  display: block;
  margin-bottom: 4px;
  color: var(--alerta);
  font-weight: 600;
  font-size: 0.95rem;
}

.options label { display: block; position: relative; margin: 8px 0; cursor: pointer; user-select: none; }
.options input[type="radio"] { position: absolute; opacity: 0; }
.options span {
  display: block;
  position: relative;
  min-height: 48px;
  padding: 12px 15px 12px 46px;
  border: 1px solid var(--linea);
  border-radius: 4px;
  background: #fff;
  transition: background 0.2s;
}
.options span::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 15px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--texto-2);
  border-radius: 50%;
  background: #fff;
}
.options label:hover input:not(:checked) + span { background: var(--fondo); }
.options input[type="radio"]:checked + span {
  background: var(--rojo);
  border-color: var(--rojo);
  color: #fff;
  font-weight: 600;
}
.options input[type="radio"]:checked + span::before {
  border-color: #fff;
  background: transparent;
}
.options input[type="radio"]:checked + span::after {
  content: "";
  position: absolute;
  left: 19px;
  top: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}
.options input[type="radio"]:focus-visible + span { outline: 3px solid var(--grafito); outline-offset: 2px; }

.quiz-container button[type="submit"] {
  display: block;
  min-height: 48px;
  margin: 25px auto 0;
  padding: 12px 40px;
  background: var(--rojo);
  color: #fff;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.quiz-container button[type="submit"]:hover { background: var(--rojo-oscuro); }

#aviso {
  margin-top: 18px;
  text-align: center;
  color: var(--alerta);
  font-weight: 600;
}

#mensajeFinal {
  max-width: 600px;
  margin: 40px auto;
  padding: 30px;
  text-align: center;
  background: var(--rojo-oscuro);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--radio);
}
#mensajeFinal .btn-quiz { margin: 20px auto 0; background: #fff; color: var(--rojo-oscuro); }
#mensajeFinal .btn-quiz:hover { background: var(--fondo); }
#mensajeFinal a:focus-visible { outline-color: #fff; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .agente { width: 140px; height: 140px; bottom: 25px; right: 20px; }
}
@media (max-width: 768px) {
  header { padding: 14px 16px 26px; }
  header h1 { font-size: 1.4rem; }
  .volver { position: static; display: flex; justify-content: center; margin: 0 auto 2px; }
  main { margin: 20px auto; padding: 10px 12px 120px; }
  section { padding: 20px 18px; }
  th, td { padding: 10px 8px; }
  .quiz-container { margin: 16px 12px; padding: 20px 16px; }
  .quiz-container h1 { font-size: 1.4rem; }
  .agente { width: 100px; height: 100px; bottom: 15px; right: 15px; }
  #mensajeFinal { margin: 24px 12px; padding: 24px 18px; font-size: 1.2rem; }
}
@media (max-width: 480px) {
  .agente { width: 84px; height: 84px; bottom: 12px; right: 12px; }
  .btn-principal, .btn-quiz { padding: 12px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
