/* --- Reset base --- */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- Tipografía global --- */
body {
  font-family: 'Georgia', serif;
  background-color: #fff;
  color: #333;
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: #b30000;
}

a:hover {
  text-decoration: underline;
}

/* --- Encabezado y navegación --- */
header, footer {
  background-color: #f8f8f8;
  text-align: center;
  padding: 1.5rem 0;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.3rem;
}

header p {
  font-style: italic;
  font-size: 1.2rem;
  color: #666;
}

nav {
  margin-top: 1rem;
}

nav a {
  margin: 0 1rem;
  font-weight: bold;
  color: #333;
}

nav a:hover {
  color: #b30000;
}

/* --- Main --- */
main {
  padding: 2rem 1rem;
  max-width: 1000px;
  margin: auto;
  overflow-x: hidden; /* Prevenir desbordamiento horizontal */
}

main p {
  text-align: justify;
}

/* --- Noticias --- */
main article.noticia {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #e0e0e0;
}

main article.noticia:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

main article.noticia h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: #333;
}

main article.noticia img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

main article.noticia p {
  margin-bottom: 1rem;
  text-align: justify;
}

/* Imágenes con texto al lado */
main article.noticia .imagen-texto {
  margin: 1.5rem 0;
  overflow: hidden;
}

/* Imágenes optimizadas: 800x600 (horizontal) y 600x800 (vertical) */
main article.noticia .imagen-izquierda,
main article.noticia .imagen-derecha {
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Imagen horizontal (800x600) - flotante izquierda */
main article.noticia .imagen-izquierda.horizontal {
  float: left;
  width: 800px;
  max-width: 100%;
  height: auto;
  margin: 0 1.5rem 1rem 0;
}

/* Imagen vertical (600x800) - flotante izquierda */
main article.noticia .imagen-izquierda.vertical {
  float: left;
  width: 600px;
  max-width: 100%;
  height: auto;
  margin: 0 1.5rem 1rem 0;
}

/* Imagen horizontal (800x600) - flotante derecha */
main article.noticia .imagen-derecha.horizontal {
  float: right;
  width: 800px;
  max-width: 100%;
  height: auto;
  margin: 0 0 1rem 1.5rem;
}

/* Imagen vertical (600x800) - flotante derecha */
main article.noticia .imagen-derecha.vertical {
  float: right;
  width: 600px;
  max-width: 100%;
  height: auto;
  margin: 0 0 1rem 1.5rem;
}

/* Compatibilidad: si no se especifica clase horizontal/vertical, usar tamaño por defecto */
main article.noticia .imagen-izquierda:not(.horizontal):not(.vertical),
main article.noticia .imagen-derecha:not(.horizontal):not(.vertical) {
  float: left;
  max-width: 300px;
  width: 40%;
  margin: 0 1.5rem 1rem 0;
}

main article.noticia .imagen-derecha:not(.horizontal):not(.vertical) {
  float: right;
  margin: 0 0 1rem 1.5rem;
}

/* Limpiar floats */
main article.noticia .imagen-texto::after {
  content: "";
  display: table;
  clear: both;
}

/* Galería de imágenes */
main article.noticia .galeria {
  margin: 2rem 0;
}

/* Contenedor individual para cada imagen con sus párrafos */
main article.noticia .galeria-item {
  margin: 2rem 0;
  text-align: center;
}

/* Párrafos de encabezado y pie de página en galería */
main article.noticia .galeria-item .galeria-encabezado,
main article.noticia .galeria-item .galeria-pie {
  margin: 0.5rem 0;
  text-align: center;
  font-style: italic;
  color: #666;
}

main article.noticia .galeria-item .galeria-encabezado {
  margin-bottom: 1rem;
}

main article.noticia .galeria-item .galeria-pie {
  margin-top: 1rem;
}

/* Imágenes en galería - centradas y a ancho completo */
main article.noticia .galeria-item img {
  width: 100%;
  max-width: 1000px;
  height: auto;
  margin: 0 auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  object-fit: contain;
  object-position: center;
}

/* Imágenes horizontales en galería */
main article.noticia .galeria-item img.galeria-horizontal {
  max-height: 600px;
  width: auto;
  max-width: 100%;
}

/* Imágenes verticales en galería */
main article.noticia .galeria-item img.galeria-vertical {
  max-height: 800px;
  max-width: 600px;
  width: auto;
  height: auto;
}

/* Responsive: en pantallas pequeñas, las imágenes flotantes se vuelven centradas */
@media (max-width: 768px) {
  main article.noticia .imagen-izquierda,
  main article.noticia .imagen-derecha {
    float: none;
    width: 100%;
    max-width: 100%;
    margin: 1rem auto;
  }
  
  /* En móvil, mantener proporción pero adaptar al ancho disponible */
  main article.noticia .imagen-izquierda.horizontal,
  main article.noticia .imagen-derecha.horizontal {
    width: 100%;
    max-width: 800px;
  }
  
  main article.noticia .imagen-izquierda.vertical,
  main article.noticia .imagen-derecha.vertical {
    width: 100%;
    max-width: 600px;
  }
  
  /* En móvil, las imágenes de galería siguen siendo a ancho completo */
  main article.noticia .galeria-item img {
    max-width: 100% !important;
    width: 100%;
    height: auto;
  }
  
  /* Asegurar que las imágenes verticales no se salgan en móvil */
  main article.noticia .galeria-item img.galeria-vertical {
    max-width: 100% !important;
    max-height: none;
    width: 100%;
    height: auto;
  }
  
  /* Asegurar que las imágenes horizontales tampoco se salgan */
  main article.noticia .galeria-item img.galeria-horizontal {
    max-width: 100% !important;
    width: 100%;
    height: auto;
  }
}

/* Contenedores de vídeo */
main article.noticia .video-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 1.5rem auto;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

main article.noticia .video-container iframe,
main article.noticia .video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 4px;
}

/* Vídeo local con controles */
main article.noticia .video-container video {
  object-fit: contain;
  background: #000;
}

/* --- Imágenes generales --- */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
}

/* --- Carrusel --- */
.carousel {
  position: relative;
  width: 90%;
  max-width: 1500px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  aspect-ratio: 3 / 1;
  font-size: 0;
}

.carousel-track {
  display: flex;
  transition: transform 0.5s ease-in-out;
  height: 100%;
}

.carousel-slide {
  flex: 0 0 100%;
  height: 100%;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

/* Botones del carrousel */
.controls {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  transform: translateY(-50%);
  padding: 0 1rem;
  z-index: 2;
  pointer-events: none;
}

.controls button {
  background-color: rgba(0, 0, 0, 0.3);
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 4px;
  pointer-events: auto;
}

.carousel:hover .controls button {
  opacity: 1;
}

.controls button:hover {
  background-color: rgba(0, 0, 0, 0.6);
}

/* --- Visor PDF estilo libro --- */
#book-viewer {
  text-align: center;
  margin: 2rem auto;
}

#pdf-canvas {
  width: 90%;
  max-width: 600px;
  aspect-ratio: 3 / 4;
  box-shadow: 0 0 8px rgba(0,0,0,0.2);
  margin: 1rem auto;
  display: block;
  border-radius: 4px;
}

.pdf-controls {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
}

.pdf-controls button {
  background-color: #333;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s;
}

.pdf-controls button:hover {
  background-color: #b30000;
}

#page-info {
  font-weight: bold;
  font-size: 1rem;
}

/* --- Pie de página --- */
footer {
  font-size: 0.95rem;
  color: #444;
}

footer p {
  margin: 1rem 0;
}

#cookie-banner {
  position: fixed;
  bottom: 0;
  background: #222;
  color: #fff;
  width: 100%;
  padding: 1em;
  text-align: center;
  font-size: 0.9em;
  z-index: 1000;
  display: none; /* Oculto por defecto, se mostrará con JavaScript si es necesario */
}

#cookie-banner a {
  color: #fff;
  text-decoration: underline;
}

#cookie-banner button {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 0.5em 1em;
  margin-left: 1em;
  cursor: pointer;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  nav a {
    display: block;
    margin: 0.5rem 0;
  }

  .pdf-controls {
    flex-direction: column;
    gap: 0.5rem;
  }

  .bio-photo {
    float: none;
    margin: 1rem auto;
    text-align: center;
    display: block;
    width: 100%;
  }
}

nav a i.fab.fa-instagram {
  font-size: 1.4rem;
  color: #b30000;
  transition: color 0.3s;
}

nav a i.fab.fa-instagram:hover {
  color: #000;
}

/* --- Selector de idioma (banderas) --- */
.language-selector {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.5rem;
}

.language-selector a {
  font-size: 1.4rem;
  line-height: 1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 2px;
  transition: all 0.3s ease;
  opacity: 0.7;
}

.language-selector a:hover {
  opacity: 1;
  transform: scale(1.1);
  border-color: #b30000;
  box-shadow: 0 0 4px rgba(179, 0, 0, 0.3);
}

.language-selector a.active {
  opacity: 1;
}

.footer-logo-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.logo-footer {
  height: 1.6em;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
}

/* --- Sección Biografía con imagen flotante --- */
.bio-photo {
  float: left;
  width: 33%;
  margin: 0 2rem 1rem 0;
}

.bio-photo img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 0 8px rgba(0,0,0,0.1);
}

.book-list {
  list-style: none;
  padding-left: 0;
  margin-top: 1rem;
}

.book-list li {
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
}

.book-list li a {
  color: #b30000;
  font-weight: bold;
}

.book-list li a:hover {
  text-decoration: underline;
  color: #000;
}

/* --- Enlaces de compra de libros --- */
.book-title-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.book-title-container h2 {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.book-purchase-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.book-purchase-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background-color: #f0f0f0;
  color: #333;
  text-decoration: none;
  transition: all 0.3s ease;
  border: 2px solid #ddd;
}

.book-purchase-links a:hover {
  background-color: #b30000;
  color: #fff;
  border-color: #b30000;
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.book-purchase-links a i {
  font-size: 1.3rem;
}

.book-purchase-links a[title*="físico"],
.book-purchase-links a[title*="Físico"] {
  background-color: #f5f5f5;
}

.book-purchase-links a[title*="digital"],
.book-purchase-links a[title*="Digital"] {
  background-color: #e8f4f8;
}

/* Responsive para enlaces de compra */
@media (max-width: 600px) {
  .book-title-container {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .book-purchase-links {
    align-self: flex-end;
  }
}
