/* =====================================
   MODAL OVERLAY
   Estilo FadCam (Rojo/Oscuro)
===================================== */
:root {
  /* Paleta Roja y Oscura */
  --primary-color: #e53935;     /* Rojo Intenso */
  --secondary-color: #0a0a0a;   /* Fondo Oscuro Principal */
  --accent-color: #b71c1c;      /* Rojo Oscuro */
  --bg-modal: rgba(0, 0, 0, 0.9); /* Fondo muy oscuro para el overlay */
  --transition-speed: 0.3s;
  --shadow-modal: 0 0 30px rgba(0, 0, 0, 0.9);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-modal);
  display: none; /* Oculto por defecto */
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
  backdrop-filter: blur(5px); /* Desenfoque del fondo */
}

.modal.active {
  display: flex;
  opacity: 1;
}

/* Contenedor del Modal */
.modal-content {
  background: var(--card-bg); 
  backdrop-filter: blur(10px); 
  border: 1px solid var(--primary-color);
  
  width: 95%;          
  max-width: 750px;    
  max-height: 85vh;    
  
  overflow-y: auto;    
  /* FIX CRÍTICO: Esto evita que el scroll "se escape" al body */
  overscroll-behavior: contain;
  
  position: relative;  
  padding: 2.5rem;      
  border-radius: 20px;  
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5); 
  
  animation: modalZoomIn 0.3s ease-out forwards;
}

/* Animación para que aparezca suavemente */
@keyframes modalZoomIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Ajuste para el cuerpo del modal (donde va el texto) */
.modal-details {
  margin-top: 1.5rem; /* Un poco más de espacio entre el carrusel y el texto */
  line-height: 1.7;   /* Mejor lectura */
}

/* Botón de Cierre */
.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition-speed), color var(--transition-speed);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--primary-color); /* Rojo al pasar el mouse */
  color: white;
}

/* Ancho del scrollbar */
.modal-content::-webkit-scrollbar {
  width: 10px;
}

/* Fondo del track (carril) */
.modal-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0 20px 20px 0; /* Borde redondeado a la derecha */
}

/* La barra que arrastras (Thumb) */
.modal-content::-webkit-scrollbar-thumb {
  background-color: var(--primary-color); /* Rojo */
  border-radius: 10px;
  border: 2px solid rgba(0, 0, 0, 0.5); /* Espacio para que se vea flotante */
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background-color: #ff5252; /* Rojo más claro al pasar mouse */
}

/* =====================================
   CARRUSEL MODERNO
===================================== */
.carousel {
  position: relative;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1rem;
}

.carousel-container {
  overflow: hidden;
  border-radius: 10px;
}

.carousel-slides {
  display: flex;
  transition: transform 0.4s ease;
  background: #000; /* Fondo negro para imágenes/videos */
}

.carousel-slide video {
  max-width: 100%;
  max-height: 70vh; /* Limita la altura */
  display: block;
  margin: auto;
  object-fit: contain;
}

.carousel-slide {
  min-width: 100%;
  display: none;
  object-fit: contain;
  max-height: 70vh;
}

.carousel-slide.active {
  display: block;
}

/* Flechas del Carrusel */
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.5rem;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%; 
  transition: background var(--transition-speed), border-color var(--transition-speed);
  z-index: 1;
}

.carousel-arrow:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.carousel-prev {
  left: 15px;
}

.carousel-next {
  right: 15px;
}

/* =====================================
   DETALLES DEL PROYECTO EN EL MODAL
===================================== */
.modal-details {
  color: #d1d1d1; /* Texto gris claro */
  text-align: left;
}

.modal-title {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1.8rem;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(229, 57, 53, 0.2);
}

.modal-recomendation {
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    background: rgba(229, 57, 53, 0.2);
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
}

.modal-description {
  margin-bottom: 1rem;
  line-height: 1.6;
  font-size: 1rem;
}

.modal-tech {
  font-size: 0.95rem;
  margin-top: 1rem;
}

.modal-tech span {
  color: var(--primary-color);
  font-weight: 600;
}

/* Botón GitHub en Modal */
.btn-github {
  display: inline-block;
  padding: 0.8rem 1.6rem;
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
  margin-top: 1.5rem; 
}

.btn-github:hover {
  background: var(--primary-color);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(229, 57, 53, 0.3);
}

/* =====================================
   SOPORTE PARA YOUTUBE (modal.css)
===================================== */
.carousel-slide iframe {
  width: 100%;
  aspect-ratio: 16/9; /* Mantiene el formato cine */
  max-height: 70vh;
  border: none;
  border-radius: 8px;
  display: none; /* Oculto por defecto igual que las imgs */
}

.carousel-slide iframe.active {
  display: block;
}

/* =====================================
   AJUSTE VISUAL DEL REPRODUCTOR YOUTUBE
===================================== */
.carousel-slide.youtube-video {
    width: 100%; /* Que ocupe todo el ancho disponible */
    
    /* MAGIA AQUÍ: Mantiene la proporción de cine (16:9) automáticamente.
       El navegador calcula la altura perfecta según el ancho. */
    aspect-ratio: 16 / 9; 
    
    border: none;
    border-radius: 15px; /* Esquinas redondeadas para que coincida con tu diseño */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); /* Sombra para darle profundidad */
    
    /* Aseguramos que no se pase de altura en pantallas ultra-panorámicas */
    max-height: 65vh; 
    object-fit: cover;
}

/* =====================================
   ADAPTATIVIDAD PARA MÓVILES
===================================== */
@media (max-width: 600px) {
  .modal-content {
    padding: 1rem;
    width: 95%;
    max-width: 95%;
  }
  .carousel-arrow {
    width: 35px;
    height: 35px;
    font-size: 1.2rem;
  }
}