:root {
  /* Modo por defecto: oscuro */
  --bg: #05070a;
  --paper: transparent;
  --text: #f4f4f4;
  --muted: #a1a1a1;
  --accent: #ffffff;
  --border-soft: rgba(255,255,255,0.14);
}

/* Modo claro */
body.light-mode {
  --bg: #f5f5f5;
  --paper: transparent;
  --text: #222222;
  --muted: #666666;
  --accent: #111111;
  --border-soft: rgba(0,0,0,0.06);
}

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

body {
  margin: 0;
  padding: 0;
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
  padding: 2.5rem 1.8rem;
}

.article-sheet {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0 3rem;
  background: var(--paper);
  color: var(--text);
}

.article-sheet[data-lang="en"] {
  display: none;
}

body.lang-en .article-sheet[data-lang="es"] {
  display: none;
}

body.lang-en .article-sheet[data-lang="en"] {
  display: block;
}

/* HEADER */

.article-header {
  margin-bottom: 1.8rem;
}

.article-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}

.article-heading {
  flex: 1 1 auto;
}

/* Toolbar + idioma + iconos */

.article-toolbar {
  display: flex;
  flex: 0 0 auto;
  gap: 0.8rem;
  align-items: center;
  margin-top: 0.2rem;
}

/* Selector de idioma */

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.8rem;
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.05em;
}

.lang-btn.lang-active {
  color: var(--accent);
  font-weight: 600;
}

.lang-sep {
  color: var(--muted);
}

/* Iconos minimalistas */

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: 30px;
  height: 30px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.1s ease,
    opacity 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

/* Icono modo claro/oscuro: media luna */

.icon-dark::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.4px solid var(--muted);
  box-shadow: 5px 0 0 0 var(--muted);
  transform: translateX(-2px);
}

/* En modo claro, reforzamos el icono */
body.light-mode .icon-dark::before {
  border-color: var(--accent);
  box-shadow: 5px 0 0 0 var(--accent);
}

/* Icono layout: columnas vs filas */

.icon-layout::before {
  content: "";
  width: 2px;
  height: 14px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow:
    4px 0 0 0 var(--muted),
    -4px 0 0 0 var(--muted);
}

body.reading-mode .icon-layout::before {
  width: 14px;
  height: 2px;
  box-shadow:
    0 4px 0 0 var(--muted),
    0 -4px 0 0 var(--muted);
}

/* Icono fullscreen */

.icon-fullscreen::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1.4px solid var(--muted);
}

/* En modo presentación, marcamos más el icono */
body.presentation-mode .icon-fullscreen::before {
  border-color: var(--accent);
}

/* TÍTULO + SUBTÍTULO + AUTOR */

.article-title {
  font-size: clamp(2.1rem, 4vw, 3rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--accent);
}

.article-subtitle {
  font-size: clamp(1.1rem, 2.1vw, 1.4rem);
  font-weight: 700;
  margin: 0 0 0.6rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Autor + avatar */

.author-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-author {
  font-size: 0.85rem;
  font-weight: 500;
  font-style: normal;
  margin: 0;
  color: var(--muted);
}

/* Enlace a versión imprimible */

.print-link {
  margin: 0.35rem 0 0.4rem;
  font-size: 0.78rem;
}

.print-link a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 1px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.print-link a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- BLOQUE COMBINADO: TEXTO (IZQ) + AUTOR (DER) --- */

.intro-combined {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 2rem;
  align-items: center;
  width: 100%;
  margin: 4rem 0;
  padding: 0;
}

/* Lado Izquierdo (Texto): 70% (3 de 4 columnas) */
.intro-right {
  grid-column: span 3;
  border-right: 1px solid var(--border-soft);
  padding-right: 2rem;
  text-align: left;
}

.intro-right p {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

/* Lado Derecho (Autor): 30% (1 de 4 columnas) */
.intro-left {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-left: 3.5rem;
  gap: 1rem;
}

.intro-left .author-avatar {
  width: 50px;
  height: 50px;
}

.author-details {
  display: flex;
  flex-direction: column;
}

.author-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.author-date {
  font-size: 0.85rem;
  margin: 0;
  color: var(--muted);
}

/* HERO COMO SLIDER */

.article-hero {
  margin: 0 0 1.8rem;
  padding: 0 0 0.8rem;
  border-bottom: 1px solid var(--border-soft);
}

.article-hero.hero-slider {
  margin-bottom: 1.8rem;
}

/* --- FIX DEFINITIVO DEL SLIDER --- */

/* --- SECCIÓN HERO SLIDER (COMPLETA Y UNIFICADA) --- */

.article-hero {
  margin: 0 0 1.8rem;
  padding: 0 0 0.8rem;
  border-bottom: 1px solid var(--border-soft);
}

.article-hero.hero-slider {
  margin-bottom: 1.8rem;
}

.hero-slides {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  touch-action: pan-y; /* Permite scroll vertical de la página pero captura el horizontal para el slider */
}



/* 1. LAS IMÁGENES (Lógica de capas) */
.hero-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  z-index: 1;
  transition: opacity 0.8s ease-in-out;
}

.hero-slide.is-active {
  opacity: 1;
  z-index: 2; /* La activa siempre al frente */
}

/* 2. LAS FLECHAS (Diseño Chevron robusto) */
.slider-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 50px;
  height: 50px;
  z-index: 10; /* Por encima de las fotos */
  opacity: 0.3;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slider-arrow:hover {
  opacity: 1;
}

/* Dibujamos la flecha con un borde en lugar de una línea para que no sea un "cuadrado" */
.slider-arrow::before {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
}

/* Rotación para crear el símbolo < y > */
.arrow-prev {
  left: 1.5rem;
}
.arrow-prev::before {
  transform: rotate(-45deg);
}

.arrow-next {
  right: 1.5rem;
}
.arrow-next::before {
  transform: rotate(135deg);
}

/* 3. LA NAVEGACIÓN NUMÉRICA (Los números de abajo) */
.hero-nav {
  position: absolute;
  right: 0.9rem;
  bottom: 0.75rem;
  display: flex;
  gap: 0.6rem;
  z-index: 5; /* Por encima de las fotos, pero por debajo de las flechas */
}

.hero-nav-dot {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--muted);
  opacity: 0.55;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.hero-nav-dot.is-active {
  opacity: 1;
  color: var(--accent);
}

.hero-nav-dot:hover {
  opacity: 0.9;
}

/* 4. EL PIE DEL HERO */
.article-hero figcaption {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

/* CUERPO: 4 COLUMNAS */

.article-body {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 2rem;
  row-gap: 2.4rem;
  font-size: 0.85rem;
  line-height: 1.7;
}

/* Capítulos */

.chapter {
  text-align: left;
}

/* Imagen de capítulo con hover + cursor zoom */

.chapter-image {
  width: 100%;
  height: auto;
  border-radius: 4px;
  object-fit: cover;
  margin-bottom: 0.9rem;
  cursor: zoom-in;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.chapter-image:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
  opacity: 0.97;
}

/* Subtítulo de capítulo */

.chapter-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.9rem;
  color: var(--accent);
}

/* Párrafos */

.chapter p {
  margin: 0 0 0.85rem;
}

.chapter p:last-child {
  margin-bottom: 0;
}

/* NOTAS */

.article-notes {
  border-top: 1px solid var(--border-soft);
  padding-top: 0.8rem;
  margin-top: 2.6rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.6;
}

.notes-title {
  font-weight: 600;
  margin: 0 0 0.45rem;
}

.notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.notes-list li {
  margin-bottom: 0.4rem;
}

.notes-list li:last-child {
  margin-bottom: 0;
}

sup {
  font-size: 0.6em;
  vertical-align: super;
}

/* Nota: enlace (ver enlace ↗) / (see link ↗) */

.note-link {
  margin-left: 0.4rem;
  font-size: 0.7em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.note-link-arrow {
  text-decoration: none;
  padding-left: 0.15rem;
  border-bottom: 1px solid currentColor;
  color: inherit; /* hereda color según modo */
}

/* Hover: subrayamos "ver enlace" entero + flecha */
.note-link:hover {
  text-decoration: underline;
}

.note-link:hover .note-link-arrow {
  opacity: 0.85;
}

/* MODO LECTURA (una sola columna) */

body.reading-mode .article-sheet {
  max-width: 900px;
}

body.reading-mode .article-body {
  grid-template-columns: 1fr;
  font-size: 0.95rem;
  line-height: 1.8;
  row-gap: 2.7rem;
}

body.reading-mode .chapter {
  max-width: 70ch;
  margin: 0 auto;
}

body.reading-mode .article-notes {
  max-width: 70ch;
  margin-left: auto;
  margin-right: auto;
}

/* MODO PRESENTACIÓN (sobre modo lectura) */

body.presentation-mode .article-sheet {
  max-width: 1000px;
}

body.presentation-mode .article-body {
  font-size: 1rem;
  line-height: 1.9;
}

body.presentation-mode .article-title {
  font-size: clamp(2.3rem, 5vw, 3.2rem);
}

/* LIGHTBOX IMÁGENES CAPÍTULO */

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.image-lightbox.is-visible {
  display: flex;
}

.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}

.image-lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  margin: 0;
}

.image-lightbox-content img {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  border-radius: 6px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}

.image-lightbox-close {
  position: absolute;
  top: -2rem;
  right: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 1.6rem;
  cursor: pointer;
}

/* Mobile: botón de cierre más cerca */
@media (max-width: 600px) {
  .image-lightbox {
    padding: 1rem;
  }

  .image-lightbox-close {
    top: -1.6rem;
    font-size: 1.4rem;
  }
}

/* RESPONSIVE */

@media (max-width: 1024px) {
  .page {
    padding: 2rem 1.4rem;
  }

  .article-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .article-toolbar {
    align-self: flex-end;
  }

  .article-body {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 1.6rem;
    row-gap: 2.2rem;
  }
}

/* --- AJUSTES PARA DISPOSITIVOS (Tablets & Mobile) --- */

/* --- VERSION TABLET / IPAD (721px a 1024px) --- */
@media (min-width: 721px) and (max-width: 1024px) {
  .page {
    padding: 2rem 2.5rem;
  }

  .article-sheet {
    max-width: 100%;
  }

  /* Título un poco más contenido */
  .article-title {
    font-size: 2.5rem;
  }

  /* Introducción: En lugar de 4 columnas de desktop, usamos 2 */
  .intro-combined {
    grid-template-columns: 1.5fr 1fr; /* Texto a la izquierda (60%) y Bio a la derecha (40%) */
    column-gap: 3rem;
    align-items: start;
    margin: 3.5rem 0;
  }

  .intro-right {
    grid-column: span 1;
    border-right: 1px solid var(--border-soft);
    padding-right: 2rem;
  }

  .intro-left {
    grid-column: span 1;
    padding-left: 0; /* Ajustamos el padding para que no quede tan lejos */
  }

  /* CUERPO DEL ARTÍCULO: 2 columnas en lugar de 4 */
  .article-body {
    grid-template-columns: repeat(2, 1fr); 
    column-gap: 2.5rem;
    row-gap: 3rem;
  }

  /* Ajustamos el slider para que no ocupe demasiada altura en tablets */
  .hero-slides {
    aspect-ratio: 16 / 9;
  }

  /* Notas en 2 columnas para aprovechar el ancho */
  .notes-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
}

/* --- AJUSTES PARA MOBILE (720px o menos) --- */
@media (max-width: 720px) {
  .page {
    padding: 1.5rem 1rem;
  }

  /* 1. Header: Toolbar arriba, Título y Subtítulo centrados */
  .article-header-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .article-toolbar {
    order: -1; /* Mantiene los botones arriba */
    margin-bottom: 1.5rem;
    align-self: center;
  }

  .article-title {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
  }

  .article-subtitle {
    font-size: 1rem;
    margin-bottom: 2rem;
  }

  /* 2. Reordenar Bloque de Introducción */
  .intro-combined {
    display: flex;
    flex-direction: column; /* Cambiamos grid por flex vertical */
    gap: 1.5rem;
    margin: 0 0 2.5rem 0;
    padding: 0;
  }

  /* Info del Autor (ahora va PRIMERO) */
  .intro-left {
    order: 1; 
    padding-left: 0;
    align-items: center; /* Centramos foto y nombre */
    text-align: center;
  }

  .author-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  /* Texto de Introducción (ahora va SEGUNDO) */
  .intro-right {
    order: 2;
    padding-right: 0;
    border-right: none; /* Quitamos la línea vertical en mobile */
    text-align: left;
  }

  .intro-right p {
    font-size: 0.9rem;
    line-height: 