/* ==========================================
   1. VARIABLES Y CONFIGURACIÓN GLOBAL
   ========================================== */
:root {
  --bg-links-container: #000000;
  --icon-color: #9999cc;
  --icon-hover-bg: #ffffff;
  --icon-size: 45px;
  --main-color: #9999cc;
  --bg-dark: #1a1a1a;
  --transition-fast: 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Arial Black', sans-serif;
}

body {
  background-color: #f9f9f9;
  color: #333;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* CORRECCIÓN INTERNA: Si el body no tiene la etiqueta <main> (como pasa en tu index.html), 
   cambiamos el fondo de respaldo al oscuro del footer para fundir cualquier vacío al 75% o en móvil */
body:not(:has(main)) {
  background-color: var(--bg-dark);
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==========================================
   2. ESTRUCTURA: HEADER Y NAVEGACIÓN
   ========================================== */
header {
  background-color: var(--bg-dark);
  color: #fff;
  padding: 15px 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.logo h1 {
  font-size: 1.8rem;
  letter-spacing: 1px;
  color: var(--main-color);
}

.logo-img {
  height: 50px;
  width: auto;
}

.nav-links {
  display: none; /* Móvil por defecto */
  flex-direction: column;
  position: absolute;
  top: 60px; 
  left: -20px; 
  width: calc(100% + 40px);
  background-color: var(--bg-dark);
  padding: 20px 0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  z-index: 999;
  list-style: none;
}

.nav-links.open {
  display: flex;
}

.nav-links li {
  text-align: center;
  width: 100%;
}

.nav-links a {
  display: block;
  font-size: 0.95rem;
  padding: 12px 10px;
  color: #fff;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.nav-links a.active, 
.nav-links a:hover {
  color: var(--main-color);
  border-bottom: 2px solid var(--main-color);
}

/* Botón Hamburguesa */
.hamburger {
  display: flex; /* Visible en móvil por defecto */
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 21px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1010;
}

.hamburger span {
  width: 100%;
  height: 3px;
  background-color: #ffffff;
  border-radius: 3px;
  transition: all var(--transition-fast);
}

/* Animación Hamburguesa */
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ==========================================
   3. SECCIONES PRINCIPALES Y HERO OPTIMIZADO
   ========================================== */
main {
  flex: 1;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  width: 100%;
}

.hero {
  /* Carga de respaldo inmediata mientras se descarga la imagen */
  background-color: var(--bg-dark); 
  background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('../Imagen/Background.webp') no-repeat center center/cover;
  color: #fff;
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  
  /* Alto estable basado en viewport dinámico para evitar saltos de scroll en celular */
  height: 60dvh; 
  min-height: 400px; 
  width: 100%;
  
  /* Aceleración por hardware para suavizar textos en móviles */
  transform: translateZ(0);
  backface-visibility: hidden;
}

.hero h2 {
  font-size: 2rem;
  margin-bottom: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.hero p {
  font-size: 1.1rem;
  margin-bottom: 30px;
  max-width: 500px;
  opacity: 0.9;
}

.btn {
  background-color: var(--main-color);
  color: #ffffff;
  padding: 12px 30px;
  border-radius: 5px;
  font-weight: bold;
  font-size: 1rem;
  transition: background var(--transition-fast), transform 0.2s;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  display: inline-block;
  border: none; /* Asegura consistencia si se usa en etiquetas <button> */
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-2px);
}

/* ==========================================
   4. SECCIÓN ABOUT Y CONTACTO
   ========================================== */
.about-section, 
.contact-section {
  background: #fff;
  padding: 2.5rem;
  border-radius: 8px; /* Unificado para ambas cajas */
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem; /* Separa los cuadros limpiamente en móvil */
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 600px;
  margin-top: 1.5rem;
}

.contact-form input, 
.contact-form textarea {
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

/* ==========================================
   5. GALERÍA DE PROYECTOS (CARRUSEL RESPONSIVO Y EFECTOS CORREGIDOS)
   ========================================== */
.carousels-grid {
  display: grid;
  grid-template-columns: 1fr; 
  gap: 2rem;
  width: 100%;
  margin-top: 2rem;
}

.carousel-container {
  position: relative;
  max-width: 480px; 
  width: 100%;
  margin: 0 auto;
  margin-bottom: 1.5rem;
  
  /* CORRECCIÓN CRUCIAL: Fuerza un recorte perfecto en todos los navegadores móviles y PC */
  overflow: hidden;
  isolation: isolate; 
  border-radius: 10px;
  
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

/* Efecto de elevación al pasar el mouse sobre el carrusel */
.carousel-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.carousel-track {
  display: flex;
  transition: transform 0.5s ease-in-out;
  width: 100%;
  will-change: transform; 
}

.carousel-slide {
  min-width: 100%;
  position: relative;
  background-color: #e5e5e5; 
  /* Evita desbordamiento de las imágenes adyacentes */
  overflow: hidden; 
}

.carousel-slide img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5; 
  object-fit: cover;
  border-radius: 10px; /* Sella milimétricamente las esquinas */
  
  /* Transición suave y optimización de renderizado */
  transition: transform var(--transition-fast);
  will-change: transform;
}

/* Efecto de zoom interno controlado en las fotos */
.carousel-container:hover .carousel-slide img {
  transform: scale(1.04); /* Un zoom sutil del 4% para cuidar nitidez y bordes */
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1rem;
  border-radius: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.carousel-btn:hover {
  background: #ffffff;
  color: var(--bg-dark);
  transform: translateY(-50%) scale(1.05);
}

.prev { left: 12px; }
.next { right: 12px; }

/* ==========================================
   6. FOOTER Y REDES SOCIALES
   ========================================== */
footer {
  background-color: var(--bg-dark);
  color: #fff;
  text-align: center;
  padding: 25px 20px;
  font-size: 0.9rem;
  margin-top: auto;
}

footer p {
  margin-bottom: 15px;
  opacity: 0.7;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background-color: var(--bg-links-container);
  border-radius: 12px;
  max-width: max-content;
  margin: 20px auto;
}

.social-links a {
  display: flex;
  justify-content: center;
  align-items: center;
  width: var(--icon-size); 
  height: var(--icon-size);
  color: var(--icon-color);
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  font-size: 1.2rem;
  transition: all var(--transition-fast);
}

.social-links a:hover {
  background-color: var(--icon-hover-bg);
  transform: translateY(-5px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   7. RESPONSIVE DESIGN (MEDIA QUERIES MEJORADOS)
   ========================================== */

/* --- TABLETAS / IPAD (Min-width: 768px) --- */
@media (min-width: 768px) {
  .hamburger {
    display: none;
  }

  .nav-links {
    display: flex;
    flex-direction: row; 
    gap: 15px;           
    position: static;
    background-color: transparent;
    padding: 0;
    box-shadow: none;
    width: auto;
  }

  .nav-links a {
    padding: 5px 10px;
  }

  .carousels-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .carousel-container {
    margin-bottom: 0; /* Quitamos márgenes manuales en PC ya que la grid usa gap */
  }

  .hero {
    padding: 60px 40px;
    height: auto; /* Restaura comportamiento responsivo estándar en PC */
    min-height: 70vh; 
    min-height: 70dvh;
  }

  .hero h2 {
    font-size: 3.2rem;
  }

  .hero p {
    font-size: 1.4rem;
    max-width: 700px;
  }
}

/* --- ESCRITORIO (Min-width: 1024px) --- */
@media (min-width: 1024px) {
  .carousels-grid {
    grid-template-columns: repeat(3, 1fr); 
  }
  
  .hero {
    min-height: 70vh;
  }
}

/* ==========================================
   8. ANIMACIONES Y TRANSICIONES DE CARGA (MODIFICADO)
   ========================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Se agregaron .logo, .carousel-container y .contact-form para que compartan la animación */
h2, h3, p, li, .btn, .logo, .carousel-container, .contact-form {
  animation: fadeInUp 0.6s ease-out forwards;
}

/* ==========================================
   9. ESTILOS EXCLUSIVOS REQUERIDOS PARA "ABOUT"
   ========================================== */
.about-section h2, 
.about-section h3 {
  margin-top: 2.8rem;    
  margin-bottom: 1.2rem; 
  display: flex;
  align-items: center;
  gap: 12px;             
  color: var(--main-color); 
}

.about-section h2 {
  font-size: 2.2rem;
  margin-top: 0;         
  border-bottom: 2px solid var(--main-color);
  padding-bottom: 10px;
}

.about-section h3 {
  font-size: 1.6rem;
}

.about-block p {
  margin-bottom: 1.5rem;
}

.about-block ul {
  list-style: none;      
  padding-left: 5px;
}

.about-block ul li {
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.about-block ul li::before {
  content: "\f00c"; 
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: var(--main-color);
}

/* ==========================================
   10. AJUSTES COMPLEMENTARIOS DE COLOR
   ========================================== */
h2 i, h3 i,
h2 span, h3 span {
  color: var(--main-color);
}

/* ==========================================
   11. ACTUALIZACIÓN DE ESTILOS: PROYECTOS Y CONTACTO
   ========================================== */
main > h2,
.contact-section h2 {
  font-size: 2.2rem;
  margin-top: 0;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--main-color);
  border-bottom: 2px solid var(--main-color);
  padding-bottom: 10px;
}

main > h2 + p {
  margin-bottom: 2rem;
}

/* ==========================================
   12. FORMULARIO DE CONTACTO REESTILIZADO Y UNIFICADO
   ========================================== */
.contact-section {
  background: #ffffff;
  padding: 2.5rem; /* Igual a la sección about */
  border-radius: 8px; /* Cambiado de 16px a 8px para igualar a about */
  box-shadow: 0 4px 6px rgba(0,0,0,0.1); /* Igual a la sección about */
}

.contact-form {
  gap: 1.8rem; 
  margin-top: 2.5rem;
}

.contact-form input, 
.contact-form textarea {
  border: none;
  border-bottom: 2px solid #e0e0e0;
  background: transparent;
  padding: 0.8rem 0.4rem;
  font-size: 1rem;
  font-family: 'Arial', sans-serif; 
  color: #333;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  border-radius: 0; 
}

.contact-form textarea {
  resize: none;
}

.contact-form input:focus, 
.contact-form textarea:focus {
  outline: none;
  border-bottom-color: var(--main-color);
}

/* El botón ahora hereda las propiedades exactas de .btn (como el del index) */
.contact-form .btn {
  align-self: flex-start; 
  background-color: var(--main-color);
  color: #ffffff;
  padding: 12px 30px; /* Igual al index */
  border: none;
  border-radius: 5px; /* Cambiado de 50px a 5px para ser idéntico al index */
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1); /* Mismo sombreado del index */
  transition: background var(--transition-fast), transform 0.2s;
}

.contact-form .btn:hover {
  transform: translateY(-2px); /* Mismo efecto de elevación del index */
  background-color: var(--main-color); /* Mantiene su color base */
}

/* ==========================================
   13. CORRECCIÓN EXCLUSIVA MÓVIL, TABLETA E IPAD (INDEX Y ANIMACIONES)
   ========================================== */
@media (max-width: 1023px) {
  /* Evita que los rebotes verticales de las animaciones estiren el alto de la pantalla */
  html, body {
    overflow-x: hidden;
    max-width: 100%;
  }

  /* Remueve los márgenes fantasmas generados por el contenedor <main> vacío en el index */
  main:empty {
    display: none;
    margin: 0 !important;
    padding: 0 !important;
  }
}