* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-blue: #0288d1;
  --light-blue: #4fc3f7;
  --lighter-blue: #81d4fa;
  --pale-blue: #e3f2fd;
  --white: #ffffff;
  --text-dark: #2c3e50;
  --text-light: #546e7a;
  --shadow: rgba(2, 136, 209, 0.1);
  --shadow-hover: rgba(2, 136, 209, 0.2);
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  color: var(--text-dark);
  background-color: var(--white);
  margin: 0;
  padding: 0;
}

p {
  text-align: justify;
  hyphens: none;
}

.footer p, 
.audio-note, 
.buy-note,
.hero-subtitle,
.audio-description,
.author-name,
.section-title {
  text-align: center;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* NAV */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px var(--shadow);
  z-index: 1000;
  transition: all 0.3s ease;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-family: 'Lora', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-blue);
  text-decoration: none;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 2rem;
  align-items: center;
}

.nav-link {
  text-decoration: none;
  color: var(--text-dark);
  font-size: 0.95rem;
  font-weight: 400;
  transition: color 0.3s ease;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--light-blue);
  transition: width 0.3s ease;
}

.nav-link:hover {
  color: var(--primary-blue);
}

.nav-link:hover::after {
  width: 100%;
}

.nav-cta {
  background-color: var(--primary-blue);
  color: var(--white);
  padding: 0.5rem 1.25rem;
  border-radius: 25px;
  font-weight: 500;
}

.nav-cta::after {
  display: none;
}

.nav-cta:hover {
  background-color: var(--light-blue);
  color: var(--white);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.nav-toggle span {
  width: 25px;
  height: 3px;
  background-color: var(--primary-blue);
  margin: 3px 0;
  transition: 0.3s;
  border-radius: 2px;
}

.nav-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dark);
  transition: all 0.3s ease;
  padding: 0.5rem;
  border-radius: 50%;
}

.nav-social-link svg {
  width: 20px;
  height: 20px;
}

.nav-social-link:hover {
  color: var(--primary-blue);
  background-color: var(--pale-blue);
  transform: translateY(-2px);
}

.nav-social-link::after {
  display: none;
}

main {
  margin-top: 70px;
}

.section {
  padding: 5rem 0;
}

.section-alt {
  background-color: var(--pale-blue);
}

.section-title {
  font-family: 'Lora', serif;
  font-size: 2.5rem;
  color: var(--primary-blue);
  text-align: center;
  margin-bottom: 3rem;
  font-weight: 600;
}

.hero {
  background: linear-gradient(135deg, var(--white) 0%, var(--pale-blue) 100%);
  padding: 6rem 0 8rem 0;
  position: relative;
  overflow: hidden;
}

.hero-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  padding-top: 2rem;
}

.hero-text {
  animation: fadeInUp 0.8s ease-out;
}

.hero-title {
  font-family: 'Lora', serif;
  font-size: 3.5rem;
  color: var(--primary-blue);
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.2;
}

.hero-subtitle {
  font-family: 'Lora', serif;
  font-size: 1.8rem;
  color: var(--light-blue);
  margin-bottom: 1.5rem;
  font-style: italic;
}

.hero-description {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-light);
  margin-bottom: 2rem;
}

.hero-image {
  display: flex;
  justify-content: center;
  animation: fadeInRight 0.8s ease-out;
}

.book-cover {
  perspective: 1000px;
}

.cover-placeholder {
  width: 300px;
  height: 450px;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(2, 136, 209, 0.3);
  transition: transform 0.3s ease;
}

.cover-placeholder:hover {
  transform: rotateY(-5deg) rotateX(2deg);
}

.content-card {
  background: var(--white);
  border-radius: 12px;
  padding: 3rem;
  box-shadow: 0 4px 20px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  max-width: 900px;
  margin: 0 auto;
}

.content-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px var(--shadow-hover);
}

.synopsis-text {
  font-size: 1.1rem;
  line-height: 1.9;
  color: var(--text-light);
  margin-bottom: 1.5rem;
  text-align: justify;
}

.dropcap {
  font-family: 'Lora', serif;
  font-size: 4rem;
  line-height: 1;
  float: left;
  margin: 0 0.5rem 0 0;
  color: var(--primary-blue);
  font-weight: 600;
}

/* Audio Card - UPDATED FOR CENTERING */
.audio-card {
  display: flex;
  flex-direction: column;
  align-items: center; /* Horizontally centers all children */
  justify-content: center;
  text-align: center;
  padding: 4rem 3rem;
}

.audio-icon {
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
}

.audio-description {
  font-size: 1.15rem;
  color: var(--text-light);
  margin-bottom: 2rem;
  line-height: 1.8;
  text-align: center;
}

.bio-card { padding: 3rem 4rem; }
.author-card { display: flex; gap: 3rem; align-items: center; padding: 3rem; }
.author-placeholder img { width: 300px; height: 300px; border-radius: 50%; object-fit: cover; }
.author-content { flex: 1; }
.author-name { font-family: 'Lora', serif; font-size: 1.8rem; color: var(--primary-blue); font-weight: 600; }
.author-bio { font-size: 1.05rem; line-height: 1.8; color: var(--text-light); margin-bottom: 1.25rem; }

.buy-section { background: linear-gradient(135deg, var(--pale-blue) 0%, var(--lighter-blue) 100%); padding: 6rem 0; }
.buy-card { background: var(--white); border-radius: 12px; padding: 4rem; box-shadow: 0 8px 40px var(--shadow-hover); text-align: center; max-width: 700px; margin: 0 auto; }
.buy-title { font-family: 'Lora', serif; font-size: 2.5rem; color: var(--primary-blue); font-weight: 600; margin-bottom: 1.5rem; }
.buy-description { font-size: 1.1rem; line-height: 1.8; color: var(--text-light); margin-bottom: 1rem; }
.isbn-buy { font-size: 0.9rem; color: var(--text-light); font-weight: 900; margin-bottom: 1.5rem; }

.btn { display: inline-flex; align-items: center; gap: 0.75rem; padding: 0.875rem 2rem; border-radius: 30px; text-decoration: none; font-weight: 500; font-size: 1rem; transition: all 0.3s ease; border: none; cursor: pointer; }
.btn-primary { background-color: var(--primary-blue); color: var(--white); box-shadow: 0 4px 15px rgba(2, 136, 209, 0.3); }
.btn-primary:hover { background-color: var(--light-blue); box-shadow: 0 6px 25px rgba(79, 195, 247, 0.4); transform: translateY(-2px); }
.btn-large { padding: 1.125rem 2.5rem; font-size: 1.1rem; }

.footer { background-color: var(--primary-blue); color: var(--white); padding: 3rem 0; text-align: center; }
.footer-text { font-family: 'Lora', serif; font-size: 1.1rem; font-weight: 500; }
.footer-copyright { font-size: 0.95rem; opacity: 0.9; }

/* --- CONTROLES DE AUDIO (LÓGICA HIBRIDA) --- */

.audio-icon-wrapper {
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  display: inline-block;
  margin-bottom: 2rem;
}
.audio-icon-wrapper:hover { transform: scale(1.1); filter: drop-shadow(0 4px 10px rgba(79, 195, 247, 0.4)); }
.hidden { display: none !important; }

/* 1. FILA DE TIEMPO (Timeline) */
.timeline-row {
  display: flex;
  align-items: center;
  justify-content: center; /* Centers content horizontally */
  gap: 1rem;
  width: 100%;
  max-width: 600px;
  margin: 0 auto 1.5rem auto;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  color: var(--text-light);
}

/* 2. FILA DE CONTROL ESCRITORIO (Desktop Controls) */
.desktop-controls-row {
  display: flex; 
  align-items: center;
  justify-content: center;
  gap: 2rem;
  width: 100%;
  margin-bottom: 1.5rem;
}

/* Estilos comunes botones */
.control-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-blue);
  padding: 0.4rem;
  border-radius: 8px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.control-btn:hover { background-color: var(--pale-blue); }

.btn-text {
    margin-left: 5px;
    margin-right: 5px;
    font-weight: 500;
}

.mini-btn svg { width: 22px; height: 22px; }

/* Barras */
input[type=range] {
  -webkit-appearance: none;
  border-radius: 5px;
  outline: none;
  cursor: pointer;
  height: 6px;
  background: #e3f2fd;
}
#progressBar { flex-grow: 1; margin: 0 10px; }
#volumeSlider { width: 80px; }

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-blue);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* VOLUMEN Wrapper */
.volume-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- LOGICA DE VISIBILIDAD (ESCRITORIO POR DEFECTO) --- */

/* Por defecto (Escritorio): Ocultar botones mini */
.mobile-only {
    display: none;
}

/* --- MEDIA QUERY MOVIL (MAX 768px) --- */
@media (max-width: 768px) {
    
    /* 1. OCULTAR controles de escritorio (Volumen y botones grandes) */
    .desktop-controls-row {
        display: none !important;
    }

    /* 2. MOSTRAR botones mini dentro de la línea de tiempo */
    .mobile-only {
        display: flex;
    }

    /* Ajustes visuales */
    .timeline-row { 
        gap: 0.5rem; 
        padding: 0; /* Remove side padding to maximize width for bar */
    }
    
    /* Better centering for timeline elements on small screens */
    #progressBar { 
        margin: 0 5px; /* Reduce margin on mobile to prevent squishing */
    }
    
    /* Ajustes generales móvil */
    .nav-menu { position: fixed; left: -100%; top: 75px; flex-direction: column; background-color: var(--white); width: 100%; text-align: center; transition: 0.3s; box-shadow: 0 10px 27px rgba(0, 0, 0, 0.1); padding: 2rem 0; gap: 1.5rem; }
    .nav-menu.active { left: 0; }
    .nav-toggle { display: flex; }
    .nav-toggle.active span:nth-child(1) { transform: rotate(-45deg) translate(-5px, 6px); }
    .nav-toggle.active span:nth-child(2) { opacity: 0; }
    .nav-toggle.active span:nth-child(3) { transform: rotate(45deg) translate(-5px, -6px); }
    .hero-content { grid-template-columns: 1fr; gap: 3rem; }
    .hero { padding: 3rem 0 8rem 0; }
    .author-card { flex-direction: column; text-align: center; padding: 2rem; gap: 1.5rem; }
    .content-card { padding: 2rem; }
    
    /* Ensure audio card is centered nicely on mobile */
    .audio-card { padding: 2rem 1.5rem; }
    
    main { margin-top: 60px; }
}

@media (max-width: 480px) {
  #opening-scene { height: 100dvh; }
  .book-intro { height: auto; width: 70vw; aspect-ratio: 2/3; }
  body { transform-origin: 50% 50vh; }
  .hero-title { font-size: 2rem; }
}

/* --- ANIMACIONES & RESPONSIVE --- */

@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ANIMACIÓN LIBRO (Global) */
#opening-scene {
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  /* USAMOS DVH GLOBALMENTE: Se adapta a las barras de navegación en todos los móviles/tablets */
  height: 100vh; /* Fallback */
  height: 100dvh; 
  z-index: 9999; 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  perspective: 1500px; 
  pointer-events: none;
}

#opening-scene::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--white); z-index: -1; transition: opacity 0.5s ease-out;
}
#opening-scene.bg-fade-out::before { opacity: 0; }

.book-intro {
  /* Usamos vmin/vmax para asegurar que el libro quepa siempre en pantalla sin salirse */
  height: 60vmin; 
  max-height: 600px;
  aspect-ratio: 2 / 3; 
  width: auto; 
  background-color: transparent; border-radius: 4px; transform-style: preserve-3d; transform-origin: left center; box-shadow: 20px 20px 60px rgba(0,0,0,0.25); z-index: 2; position: relative;
}
.book-intro img, .cover-placeholder img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; display: block; box-shadow: 20px 20px 60px rgba(0,0,0,0.25); }

/* --- BODY TRANSITION --- */
body { overflow-x: hidden; transform-origin: 50% 45vh; }

body:not(.animation-complete) nav, body:not(.animation-complete) main, body:not(.animation-complete) footer {
  opacity: 0; transform: scale(0.8) translateY(80vh); filter: blur(10px); pointer-events: none;
}

.book-intro.open { animation: openBookCover 2.2s forwards cubic-bezier(0.645, 0.045, 0.355, 1); }
@keyframes openBookCover { 0% { transform: rotateY(0deg); } 20% { transform: rotateY(0deg); } 100% { transform: rotateY(-140deg) translateX(-15vw); opacity: 0; } }

body.animation-complete nav, body.animation-complete main, body.animation-complete footer {
  opacity: 1; transform: scale(1) translateY(0); filter: blur(0); transition: opacity 1.5s ease-in-out, transform 1.8s cubic-bezier(0.19, 1, 0.22, 1), filter 1.5s ease;
}

/* --- MEDIA QUERIES --- */

/* TABLET & MOBILE (Hasta 768px) */
@media (max-width: 768px) {
    /* Ocultar Desktop Controls */
    .desktop-controls-row { display: none !important; }
    /* Mostrar Mobile Controls */
    .mobile-only { display: flex; }
    /* Ajustes Timeline */
    .timeline-row { gap: 0.5rem; padding: 0; }
    #progressBar { margin: 0 5px; }
    
    /* NAV MÓVIL */
    .nav-menu { position: fixed; left: -100%; top: 75px; flex-direction: column; background-color: var(--white); width: 100%; text-align: center; transition: 0.3s; box-shadow: 0 10px 27px rgba(0, 0, 0, 0.1); padding: 2rem 0; gap: 1.5rem; }
    .nav-menu.active { left: 0; }
    .nav-toggle { display: flex; }
    .nav-toggle.active span:nth-child(1) { transform: rotate(-45deg) translate(-5px, 6px); }
    .nav-toggle.active span:nth-child(2) { opacity: 0; }
    .nav-toggle.active span:nth-child(3) { transform: rotate(45deg) translate(-5px, -6px); }
    
    /* Layout */
    .hero-content { grid-template-columns: 1fr; gap: 3rem; }
    .hero { padding: 3rem 0 8rem 0; }
    .author-card { flex-direction: column; text-align: center; padding: 2rem; gap: 1.5rem; }
    .content-card { padding: 2rem; }
    .audio-card { padding: 2rem 1.5rem; }
    main { margin-top: 60px; }

    /* AJUSTE ANIMACIÓN MÓVIL (CRÍTICO PARA IPHONE) */
    /* Usamos 50dvh para que el centro del zoom coincida con el centro visual real entre las barras */
    body { transform-origin: 50% 50dvh; } 
    
    /* Ajustamos el tamaño del libro para móvil */
    .book-intro { 
        height: auto; 
        width: 60vw; /* Anchura relativa */
        max-width: 280px; /* Tope máximo */
        aspect-ratio: 2 / 3; 
    }
}

/* MÓVILES PEQUEÑOS */
@media (max-width: 480px) {
  .hero-title { font-size: 2rem; }
  .book-intro { width: 65vw; } /* Un poco más grande en pantallas muy estrechas */
}