/* ===========================
   VARIABLES Y BASE
=========================== */
:root {
  /* Colores principales */
  --primary: #2563eb;
  --primary-600: #1e40af;
  --text: #1f2937;
  --muted: #6b7280;
  --bg: #c7ddfa;
  --bg-soft: #c7ddfa;
  --card: #ffffff;
  --shadow: 0 6px 18px rgba(0,0,0,.08);
  --radius: 14px;

  /* Tipografía y espacios */
  --font-main: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, "Apple Color Emoji","Segoe UI Emoji";
  --font-size: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 2rem;
  --space-xs: 0.4rem;
  --space-sm: 0.8rem;
  --space-md: 1.2rem;
  --space-lg: 2rem;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

/* ===========================
   RESET Y TIPOGRAFÍA
=========================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html:focus-within { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: var(--font-size);
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ===========================
   ACCESIBILIDAD
=========================== */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: static;
  width: auto;
  height: auto;
  padding: var(--space-xs) var(--space-md);
  background: #000;
  color: #fff;
  z-index: 1000;
  display: inline-block;
  border-radius: var(--radius);
}

/* Foco visible en elementos interactivos */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===========================
   CONTENEDOR
=========================== */
.container {
  width: min(92%, 1200px);
  margin-inline: auto;
}

/* ===========================
   HEADER + NAV
=========================== */
.header {
  position: sticky;
  top: 0;
  background: var(--bg);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  z-index: 20;
}
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: .9rem 0;
}
.logo img { display: block; }

/* Toggle (checkbox hack) */
.nav-toggle { display: none; }
.menu-toggle {
  display: none;
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
  border: 0;
  background: none;
}

.nav-links {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}
.nav-links a {
  padding: .5rem .4rem;
  border-radius: 8px;
  font-weight: 600;
  color: var(--text);
  transition: background var(--transition);
}
.nav-links a:hover,
.nav-links a:focus-visible {
  background: var(--bg-soft);
}

/* Mobile first: menú colapsado */
@media (max-width: 768px) {
  .menu-toggle { display: inline-grid; place-items: center; }
  .nav-links {
    position: absolute;
    inset: 64px 1rem auto 1rem;
    background: var(--bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 1rem;
    display: none;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-links a { padding: .85rem 1rem; }
  .nav-toggle:checked ~ .menu-toggle .bi { transform: rotate(90deg); }
  .nav-toggle:checked ~ .nav-links { display: flex; }
}

/* Mejor contraste en menú móvil */
@media (max-width: 768px) {
  .nav-links {
    background: #fff;      /* Fondo blanco */
  }
  .nav-links a {
    color: #222;           /* Letras oscuras */
  }
}

/* Mejor contraste en menú móvil modo oscuro */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  .nav-links {
    background: #111822;
  }
  .nav-links a {
    color: #fff; /* Letras blancas en menú móvil modo oscuro */
  }
}

/* ===========================
   HERO
=========================== */
.hero {
  position: relative;
  isolation: isolate;
  color: #ffffff;
  min-height: 52dvh;
  display: grid;
  place-items: center;
  text-align: center;
}
.hero-media {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(.55);
}
.hero-content { padding-block: var(--space-lg); }
.hero h1 {
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  font-weight: 800;
  letter-spacing: .2px;
}
.subtitle {
  opacity: .95;
  margin-top: .5rem;
  font-size: clamp(1rem, 2.6vw, 1.25rem);
}
.cta-button {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-top: 1rem;
  background: var(--primary);
  color: #fff;
  padding: .85rem 1.2rem;
  border-radius: 12px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(37,99,235,.25);
  transition: transform var(--transition), background var(--transition);
}
.cta-button:hover,
.cta-button:focus-visible {
  background: var(--primary-600);
  transform: translateY(-1px);
}

/* Reduce motion si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ===========================
   SECCIONES
=========================== */
.section { padding-block: var(--space-lg); }
.section-title {
  text-align: center;
  font-size: clamp(1.4rem, 3.2vw, 2rem);
  margin-bottom: 1.6rem;
  font-weight: 800;
}

.grid-2 {
  display: grid;
  gap: var(--space-md);
  align-items: center;
  grid-template-columns: 1fr; /* mobile */
}
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1.1fr .9fr; }
}

.custom-list li {
  margin: .5rem 0;
  display: flex;
  gap: .6rem;
  align-items: flex-start;
}
.custom-list i {
  color: var(--primary);
  transform: translateY(.15rem);
}

.media .img-rounded {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.bg-light { background: var(--bg-soft); }

.grid-3 {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr; /* mobile */
}
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (min-width: 960px) { .grid-3 { grid-template-columns: repeat(3,1fr); } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
  text-align: center;
  transition: transform var(--transition);
}
.card:hover { transform: translateY(-4px); }
.icon-large {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: .6rem;
}

/* ===========================
   DESCARGAS OFFLINE
=========================== */
.download-list {
  margin-top: .6rem;
  display: grid;
  gap: .6rem;
}
.btn-download {
  display: inline-block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: .75rem 1rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), background var(--transition);
}
.btn-download:focus-visible,
.btn-download:hover {
  border-color: var(--primary);
  outline: 0;
  background: var(--bg-soft);
}

/* ===========================
   FOOTER
=========================== */
.footer {
  color: #fff;
  background: linear-gradient(135deg, var(--primary-600), var(--primary));
  padding-block: 2.2rem;
}
.footer-grid {
  display: grid;
  gap: 1.4rem;
  align-items: start;
  grid-template-columns: 1fr; /* mobile */
}
@media (min-width: 820px) {
  .footer-grid { grid-template-columns: 1.2fr .8fr .8fr; }
}
.footer-title { font-weight: 800; margin-bottom: .6rem; }
.footer-links { display: grid; gap: .4rem; }
.footer-links a { opacity: .9; }
.footer-links a:hover,
.footer-links a:focus-visible { opacity: 1; text-decoration: underline; }
.social { display: flex; gap: .7rem; }
.social a {
  font-size: 1.3rem;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,.12);
  transition: background var(--transition);
}
.social a:hover,
.social a:focus-visible { background: rgba(255,255,255,.2); }
.foot-hr { border: 0; border-top: 1px solid rgba(255,255,255,.25); margin: 1.2rem 0; }
.foot-note { opacity: .9; margin-top: .4rem; }
.copyright { font-size: .95rem; opacity: .9; text-align: center; }

/* ===========================
   DARK MODE (opcional auto)
=========================== */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #e5e7eb;
    --bg: #0b0f14;
    --bg-soft: #0f141b;
    --card: #111822;
    --shadow: 0 10px 24px rgba(0,0,0,.4);
  }
  .header { background: var(--bg); }
  .nav-links a:hover { background: rgba(255,255,255,.06); }
  .btn-download { background: #0f141b; border-color: #1f2937; }
}

/* ===========================
   RESPONSIVE TIPOGRAFÍA
=========================== */
html {
  font-size: clamp(15px, 2vw, 18px);
}

/* Tarjetas de subtemas en módulo */
.subtema-list {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}
.subtema-link {
  display: block;
  background: var(--card, #fff);
  color: var(--text, #222);
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius, 14px);
  font-size: 1.08rem;
  font-weight: 600;
  box-shadow: var(--shadow, 0 6px 18px rgba(0,0,0,.08));
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
  border: 1px solid #e5e7eb;
  text-decoration: none;
}
.subtema-link:hover,
.subtema-link:focus-visible {
  background: var(--bg-soft, #f8fafc);
  box-shadow: 0 10px 24px rgba(37,99,235,.12);
  transform: translateY(-2px) scale(1.02);
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
}

/* Estilo para tablas en módulos */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  max-width: 700px;
  margin: 1.5rem auto;
  background: var(--card, #fff);
  box-shadow: 0 2px 12px rgba(37,99,235,0.07);
  border-radius: 12px;
  overflow: hidden;
  font-size: 1rem;
}
thead {
  background: var(--primary, #2563eb);
  color: #fff;
}
th, td {
  padding: 0.85rem 1rem;
  text-align: left;
}
th {
  font-weight: 700;
  letter-spacing: .5px;
}
tbody tr {
  border-bottom: 1px solid #e5e7eb;
}
tbody tr:last-child {
  border-bottom: none;
}
tbody tr:hover {
  background: var(--bg-soft, #f8fafc);
}
figure img {
  background: linear-gradient(135deg, #f3f4f6 60%, #e0e7ff 100%);
  padding: 8px;
}
@media (prefers-color-scheme: dark) {
  figure img {
    background: linear-gradient(135deg, #1e293b 60%, #2563eb 100%);
  }
}
