﻿/* Estilos base del modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.75);
}

.modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  width: 90%;
  max-width: 900px;
  padding: 20px;
}

.modal-description {
  margin-top: 20px;
  color: #f1f1f1;
  text-align: center;
  max-height: 30vh;
  overflow-y: auto;
}

#modalImage {
  width: 100%;
  height: auto;
  max-height: 60vh; /* Reducido de 80vh a 60vh */
  object-fit: contain;
  border-radius: 2px;
  transition: transform 0.3s ease-in-out;
}

.close {
  position: absolute;
  top: 10px;
  right: 15px;
  color: #f1f1f1;
  font-size: 32px;
  font-weight: bold;
  transition: 0.3s;
}

.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

/* Estilos para los elementos de la galería */
.map-item {
  position: relative;
  overflow: hidden; /* Evita que el efecto sobresalga */
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.map-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2);
}

.map-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.map-item img:hover {
  transform: scale(1.05);
}

.map-item img::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent);
  transform: translateY(100%); /* Inicialmente oculto abajo */
  opacity: 0;
  transition: transform 0.6s ease-in-out, opacity 0.6s ease-in-out; /* Velocidad intermedia */
  pointer-events: none;
}

.map-item img:hover::after {
  transform: translateY(0); /* Se mueve hacia arriba */
  opacity: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
}

.map-item figcaption {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 15px 10px 10px;
  transition: transform 0.3s ease-in-out;
}

/* Media queries para responsividad */
@media (min-width: 768px) {
  .modal-content {
    flex-direction: row;
  }
  
  .modal-description {
    margin-left: 20px;
    margin-top: 0;
    text-align: left;
  }
  
  #modalImage {
    max-width: 70%;
    max-height: 70vh;
  }
}

@media (max-height: 600px) {
  #modalImage {
    max-height: 50vh;
  }
  
  .modal-description {
    max-height: 25vh;
  }
  
  .close {
    top: 5px;
    right: 10px;
    font-size: 28px;
  }
  
  .modal-content {
    padding: 10px;
  }
}

/* Control de overflow para el modal */
#imageModal {
  overflow-y: auto;
}

/* Animaciones para las imágenes del modal */
.fade-in {
  animation: fadeIn 0.3s ease-in-out forwards;
}

.fade-out {
  animation: fadeOut 0.3s ease-in-out forwards;
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: scale(0.95); 
  }
  to { 
    opacity: 1; 
    transform: scale(1); 
  }
}

@keyframes fadeOut {
  from { 
    opacity: 1; 
    transform: scale(1); 
  }
  to { 
    opacity: 0; 
    transform: scale(0.95); 
  }
}

/* Mejora para la transición entre imágenes */
#modalImage {
  width: 100%;
  height: auto;
  max-height: 60vh;
  border-radius: 8px;
  object-fit: contain;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Versión mejorada de la descripción con transición */
.modal-description {
  width: 100%;
  transition: opacity 0.3s ease;
  padding: 0 10px;
}

/* Estilos para el texto expandible */
.line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 4.5em;
  transition: max-height 0.3s ease;
}

.line-clamp.expanded {
  -webkit-line-clamp: initial;
  max-height: 40vh;
  overflow-y: auto;
}

/* Botón de "Ver más" */
.toggle-description {
  margin-top: 8px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: background 0.2s ease;
  font-size: 14px;
  cursor: pointer;
}

.toggle-description:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Hacer que el contenedor principal del modal sea responsive */
#imageModal > div {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 1rem;
  box-sizing: border-box;
}

/* Mejoras para los botones de navegación */
#prevButton, #nextButton {
  opacity: 0.7;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#prevButton:hover, #nextButton:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Animación de botones */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.toggle-description:hover {
  animation: pulse 1s infinite;
}

/* Estilo para pantallas muy pequeñas */
@media (max-height: 450px) {
  #modalImage {
    max-height: 45vh;
  }
  
  .modal-description {
    max-height: 20vh;
  }
  
  .toggle-description {
    font-size: 12px;
    padding: 2px 8px;
  }
  
  #prevButton, #nextButton {
    font-size: 24px;
  }
}