/* ====================================================================
   HOJA DE ESTILO DEFINITIVA PARA LA PREVIEW DEL LIBRO
   (Tipografía de Alto Impacto para Generación de Imagen de Alta Calidad)
   ==================================================================== */

/* --- 1. Fuentes (se mantienen) --- */
@font-face {
  font-family: 'Playfair Display';
  src: url('https://memorytale.es/fonts/PlayfairDisplay-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Playfair Display';
  src: url('https://memorytale.es/fonts/PlayfairDisplay-Bold.ttf') format('truetype');
  font-weight: 700;
}
@font-face {
  font-family: 'Lora';
  src: url('https://memorytale.es/fonts/Lora-Regular.ttf') format('truetype');
  font-weight: 400;
}

/* --- 2. Página base con dimensiones fijas para alta calidad --- */
.page {
  /* Lienzo de tamaño A5 apaisado a 96 DPI, ideal para html2canvas */
  width: 794px;
  height: 562px;
  
  /* Estilos de layout y fondo */
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #f0f0f0; /* Blanco roto, más suave a la vista */
}

/* --- 3. Overlay oscuro para contraste --- */
.page::before {
  content: '';
  position: absolute; 
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1;
}

/* --- 4. Logo MemoryTale - Sutil y centrado --- 
.page::after {
  content: '';
  position: absolute;
  bottom: 25px; 
  left: 50%; 
  transform: translateX(-50%);
  width: 140px; 
  height: 35px;
  background: url('https://memorytale.es/assets/logo-memorytale.png') center/contain no-repeat;
  opacity: 0.5;
  z-index: 2;
}
*/
/* --- 5. Contenedor de texto con espaciado generoso --- */
.page .content-wrapper {
  position: relative;
  z-index: 2;
  padding: 50px 70px; /* Más aire alrededor del texto */
  max-width: 90%;
  box-sizing: border-box;
}

/* =======================================================
   ✅ 6. TIPOGRAFÍA DE ALTO IMPACTO (LA CLAVE DE LA SOLUCIÓN)
   ======================================================= */
.page h2 {
  font-family: 'Playfair Display', serif;
  font-size: 38px; /* TAMAÑO AJUSTADO: Un poco más pequeño */
  font-weight: 700;
  margin: 0 0 24px;
  text-align: center;
  letter-spacing: 0.5px;
  line-height: 1.3;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.page p {
  font-family: 'Lora', serif;
  font-size: 22px; /* TAMAÑO AJUSTADO: Un poco más pequeño */
  line-height: 1.6;
  margin: 0;
  text-align: justify;

  /* ✅ SOLUCIÓN PALABRAS CORTADAS: Desactivamos la separación con guiones */
  hyphens: none;
  -webkit-hyphens: none;
  -ms-hyphens: none;

  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

/* ================================================================
   7. ESTILOS PARA EL CANVAS GENERADO (CÓMO SE VE LA IMAGEN FINAL)
   ================================================================ */
/* Reglas base para canvas y imagen de preview */
.preview-image-container canvas {
  display: block;
  margin: 0 auto;
  max-width: 100% !important;
  height: auto !important;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.preview-image-container img.preview-pagina {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

/* Media query para dispositivos móviles */
@media screen and (max-width: 600px) {
  .page {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 3 / 4;
    padding: 1.5rem 1rem !important;
    background-size: cover;
    background-position: center;
    min-height: 400px;
  }

  .page .content-wrapper {
    padding: 1rem !important;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .page h2 {
    font-size: 1.5rem !important;
    line-height: 1.3 !important;
    margin-bottom: 1rem !important;
  }

  .page p {
    font-size: 1rem !important;
    line-height: 1.5 !important;
    margin-bottom: 0.8rem !important;
  }

  .subtitulo-preview {
    font-size: 1.2rem !important;
    line-height: 1.4 !important;
    text-align: center;
    padding: 0 1rem;
  }

  .preview-quote, #preview-text {
    font-size: 1rem !important;
    line-height: 1.5 !important;
    padding: 1rem !important;
  }

  .preview-image-container canvas,
  .preview-image-container img.preview-pagina {
    max-width: 95% !important;
    height: auto !important;
    width: auto !important;
  }
}

/* Media query para tablets */
@media screen and (min-width: 601px) and (max-width: 1024px) {
  .page {
    width: 90% !important;
    max-width: 500px !important;
    margin: 0 auto;
  }

  .preview-image-container canvas,
  .preview-image-container img.preview-pagina {
    max-width: 85%;
    height: auto;
  }
}

