/* Estilos básicos */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh; /* evita que la barra del navegador móvil tape contenido */
  margin: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  font-family: 'Comic Sans MS', cursive, sans-serif;
  background: linear-gradient(135deg, #ff9a9e, #fad0c4, #fbc2eb, #a1c4fd);
  background-size: 300% 300%;
  animation: backgroundGradient 10s ease infinite;
}

@keyframes backgroundGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#inicio {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #fff;
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.2);
}

button {
  padding: 12px 25px;
  font-size: 1.2em;
  cursor: pointer;
  color: #fff;
  background-color: #ff6b6b;
  border: none;
  border-radius: 10px;
  box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s, box-shadow 0.3s;
  touch-action: manipulation; /* sin retardo de doble toque */
  -webkit-tap-highlight-color: transparent;
}

/* Solo en dispositivos con ratón: evita el efecto hover "pegado" al tocar */
@media (hover: hover) {
  button:hover {
    transform: scale(1.1);
    box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.4);
  }
}


#album {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.oculto {
  display: none;
}

/* Estilos del carrusel */
.carrusel {
  display: flex;
  overflow: hidden;
  width: min(800px, 94vw); /* Ancho del álbum en escritorio (se adapta a pantallas pequeñas) */
  height: 500px; /* Alto del álbum en escritorio */
  position: relative;
  perspective: 1500px; /* Mayor profundidad en la animación */
  touch-action: pan-y; /* permite deslizar horizontalmente para cambiar de página */
}

.pagina {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.8s ease, opacity 0.4s ease;
  flex-shrink: 0;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.3);
  position: absolute;
  opacity: 0;
  transform-origin: left;
}

.pagina.mostrar {
  opacity: 1;
  transform: rotateY(0deg);
}

.pagina.anterior {
  transform: rotateY(-180deg);
}

.pagina.siguiente {
  transform: rotateY(180deg);
}

.lado {
  width: 50%;
  height: 100%;
  padding: 20px;
  box-sizing: border-box;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.lado-izq {
  background: linear-gradient(135deg, #fbc2eb, #a1c4fd);
}

.lado-der {
  background: linear-gradient(135deg, #ffecd2, #fcb69f);
}

.lado img {
  max-width: 90%;
  max-height: 90%;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 15px;
  box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2);
}

.lado p {
  font-size: 1.1em;
  color: #333;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.2);
}

/* Botones de navegación */
.nav-btn {
  padding: 10px 20px;
  font-size: 1em;
  cursor: pointer;
  background-color: #38b6ff;
  color: #fff;
  border: none;
  border-radius: 10px;
  margin: 20px 10px;
  box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s, box-shadow 0.3s;
}

@media (hover: hover) {
  .nav-btn:hover {
    transform: scale(1.1);
    box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.4);
  }
}

/* Pantallas pequeñas o poco altas: botones en una fila bajo el álbum para que todo quepa sin scroll */
@media (max-width: 768px), (max-height: 720px) {
  #album {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .carrusel {
    height: min(500px, calc(100vh - 90px));
    height: min(500px, calc(100dvh - 90px));
  }

  .nav-btn {
    margin: 12px 8px;
  }

  .lado img {
    min-height: 0;
  }

  .lado p {
    flex: none;
  }
}

/* Móviles y tablets pequeñas */
@media (max-width: 768px) {
  .lado {
    padding: 10px;
  }

  .lado p {
    font-size: 1em;
    margin: 8px 0 0;
    padding: 8px;
  }

  .nav-btn {
    padding: 8px 16px;
    font-size: 0.9em;
  }

  #inicio {
    padding: 15px;
  }
}

/* Móvil en vertical: cada página muestra las dos fotos una encima de otra */
@media (max-width: 768px) and (orientation: portrait) {
  .carrusel {
    height: min(640px, calc(100vh - 90px));
    height: min(640px, calc(100dvh - 90px));
  }

  .pagina {
    flex-direction: column;
  }

  .lado {
    width: 100%;
    height: 50%;
  }
}

/* Cuando el espacio es muy justo, la foto se adapta al hueco disponible */
@media (max-width: 768px) and (orientation: portrait), (max-height: 520px) {
  .lado img {
    width: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }

  .pagina {
    transition: opacity 0.2s ease;
  }
}
