/* --- Variables y Estilos Globales --- */
:root {
  --bg-color: #0d1117; /* Un azul oscuro, como el de GitHub */
  --primary-color: #1f1f1f;
  --secondary-color: #2a2a2a;
  --font-color: #e0e0e0;
  --accent-color: #00aaff;
  --accent-hover: #0088cc;
  --border-color: #333;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color); /* Color de fondo base */
  color: var(--font-color);
  line-height: 1.6;
  overflow-x: hidden; /* Previene el scroll horizontal */
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(0, 170, 255, 0.2), transparent 30%),
    radial-gradient(circle at 85% 30%, rgba(0, 88, 155, 0.2), transparent 35%),
    radial-gradient(circle at 50% 90%, rgba(0, 120, 200, 0.15), transparent 40%);
  background-size: 200% 200%;
  animation: floatBackground 25s ease-in-out infinite;
}

body.no-scroll {
  overflow: hidden;
}

@keyframes floatBackground {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

h1, h2, h3 {
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h2 {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 2rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--accent-color);
  text-decoration: none;
}

.pantalla {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4rem 2rem;
  border-bottom: 1px solid var(--border-color);
}

/* --- Header y Navegación --- */
header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(18, 18, 18, 0.8);
  backdrop-filter: blur(10px);
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
  transition: transform 0.4s ease-in-out;
}

header.header-hidden {
  transform: translateY(-100%);
}

header h1 {
  font-size: 1.8rem;
  margin: 0;
  color: var(--accent-color);
}

.menu-toggle {
  display: none; /* Oculto en escritorio */
  flex-direction: column;
  cursor: pointer;
}

.menu-toggle span {
  height: 3px;
  width: 25px;
  background: var(--font-color);
  margin: 4px 0;
  transition: all 0.3s ease;
}

/* --- Navegación de Escritorio --- */
.desktop-nav {
  display: flex;
  gap: 1rem;
}

.desktop-nav a {
  margin: 0 1rem;
  color: var(--font-color);
  font-weight: 500;
  position: relative;
  padding: 5px 0;
  transition: color 0.3s ease;
}

.desktop-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: width 0.3s ease;
}

.desktop-nav a:hover {
  color: var(--accent-color);
}

.desktop-nav a:hover::after {
  width: 100%;
}

/* --- Navegación Móvil (Panel) --- */
.mobile-nav {
  display: none; /* Oculto en escritorio */
}

.nav-title {
  display: none;
}

/* --- Sección Inicio --- */
#inicio {
  text-align: center;
  position: relative;
}

.avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 4px solid var(--accent-color);
  margin-bottom: 1.5rem;
}

.action-buttons {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  background-color: var(--accent-color);
  color: #fff;
  border-radius: 5px;
  font-weight: bold;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-3px);
}

.btn-secondary {
  background-color: var(--secondary-color);
}
.btn-secondary:hover {
  background-color: #444;
}

.scroll-down {
  position: absolute;
  bottom: 2rem;
  font-size: 2rem;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-15px); }
  60% { transform: translateY(-8px); }
}

/* Efecto de escritura */
#inicio h2.typing::after {
  content: '|';
  display: inline-block;
  vertical-align: baseline;
  animation: blink 0.7s infinite;
  color: var(--accent-color);
  font-weight: bold;
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* --- Sección Sobre Mí --- */
.container-content {
  max-width: 800px;
  text-align: center;
}

/* --- Timeline en "Sobre Mí" --- */
.timeline {
  position: relative;
  max-width: 900px;
  width: 100%;
  margin: 2rem auto;
}

.timeline::after {
  content: '';
  position: absolute;
  width: 4px;
  background-color: var(--border-color);
  top: 0;
  bottom: 0;
  left: 50%;
  margin-left: -2px;
  z-index: 0; /* Asegura que la línea esté por debajo del contenido y los iconos */
}

.timeline-item {
  padding: 10px 40px;
  position: relative;
  width: 50%;
  box-sizing: border-box;
  z-index: 1;
}

.timeline-item:nth-child(odd) {
  left: 0;
}

.timeline-item:nth-child(even) {
  left: 50%;
}

.timeline-icon {
  position: absolute;
  width: 50px;
  height: 50px;
  right: -25px;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--accent-color);
  border: 4px solid var(--primary-color);
  border-radius: 50%;
  z-index: 2; /* Aumentado para asegurar que esté por encima de todo */
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
}

.timeline-item:nth-child(even) .timeline-icon {
  left: -25px;
}

.timeline-content {
  padding: 20px 30px;
  background: var(--primary-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 1; /* Asegura que el contenido esté por encima de la línea */
}

.timeline-content:hover {
  transform: scale(1.03);
  box-shadow: 0 5px 25px rgba(0, 170, 255, 0.1);
}

/* --- Sección Skills (Aeroespacial) --- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  width: 100%;
  max-width: 1000px;
}

.skill-card {
  background: var(--primary-color);
  padding: 2rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.skill-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 10px 20px rgba(0, 170, 255, 0.15);
}

.skill-card i {
  font-size: 3rem;
  color: var(--accent-color);
  margin-bottom: 1rem;
}

.skill-card h3 {
  margin-bottom: 0.5rem;
}

.skills-container {
  width: 100%;
  max-width: 1000px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2.5rem 2rem;
}

.skill-item {
  width: 100%;
}

.skill-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 1.1rem;
}

.skill-info span:first-child {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.skill-info i {
  color: var(--accent-color);
  width: 20px;
  text-align: center;
}

.skill-bar {
  width: 100%;
  height: 10px;
  background-color: var(--secondary-color);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.skill-level {
  height: 100%;
  width: var(--level);
  background-color: var(--accent-color);
  border-radius: 5px;
  transform: translateX(-101%);
  transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Animación para las barras de habilidad con AOS */
.skill-level[data-aos="skill-fill"].aos-animate {
  transform: translateX(0);
}

/* --- Sección Proyectos --- */
.project-display-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 950px; /* Ancho total incluyendo flechas */
}

.proyecto-card-display {
  background: var(--primary-color);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
  max-width: 800px;
  min-height: 600px; /* Altura consistente */
  transition: opacity 0.4s ease-in-out;
}

.proyecto-card-display.project-fading {
  opacity: 0;
}

.project-nav-btn {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--font-color);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0; /* Evita que los botones se encojan */
}

.project-nav-btn:hover:not(:disabled) {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
  transform: scale(1.1);
}

.project-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.proyecto-imagen-container {
  width: 100%;
  height: 300px; /* Altura fija para la imagen */
  background-color: #000; /* Fondo para las barras de 'contain' */
}

.proyecto-imagen-container img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Muestra la imagen completa sin recortar */
}

.proyecto-content {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Permite que esta sección crezca y ocupe el espacio */
}

.proyecto-card .btn {
  margin-top: auto; /* Empuja el botón hacia la parte inferior de la tarjeta */
  align-self: flex-start; /* Asegura que el botón no se estire */
}

.proyecto-card h3 {
  color: var(--accent-color);
  font-size: 1.8rem;
}

/* --- Overlay para el menú móvil --- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1001; /* Por encima del contenido, por debajo del nav */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-in-out;
}

/* --- Sección Contacto (Formulario) --- */
.contact-form {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.form-group {
  display: flex;
  gap: 1rem;
}
.contact-form input, .contact-form textarea {
  width: 100%;
  padding: 1rem;
  background: var(--secondary-color);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: var(--font-color);
  font-size: 1rem;
}
.contact-form input::placeholder, .contact-form textarea::placeholder {
  color: #888;
}
.contact-form button {
  align-self: center;
  border: none;
  cursor: pointer;
}

/* --- Botón Scroll Top --- */
#scrollTop {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: none; /* Oculto por JS */
  transition: background-color 0.3s, transform 0.3s;
  z-index: 999;
}

#scrollTop:hover {
  background-color: var(--accent-hover);
  transform: scale(1.1);
}

/* --- Responsive (Móvil) --- */
@media (max-width: 768px) {
  h2 {
    font-size: 2rem;
  }

  .desktop-nav {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #161b22;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Centrado verticalmente */
    gap: 1.5rem;
    z-index: 1002;
    transform: translateX(-100%);
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
  }

  .mobile-nav a {
    margin: 0;
    padding: 0.75rem 0;
    font-size: 1.2rem;
    width: 90%;
    text-align: center;
    border-radius: 5px;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
  }

  .mobile-nav a:hover, .mobile-nav a:focus {
    background-color: var(--secondary-color);
    color: var(--accent-color);
    outline: none;
  }

  .mobile-nav.nav-active {
    transform: translateX(0);
  }

  .overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .nav-title {
    display: block;
    color: var(--accent-color);
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    position: absolute;
    top: 5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--accent-color);
  }

  .menu-toggle {
    display: flex;
  }

  .form-group {
    flex-direction: column;
  }

  /* --- Timeline en Móvil --- */
  .timeline::after {
    left: 30px;
  }
  .timeline-item {
    width: 100%;
    padding-left: 70px;
    padding-right: 25px;
  }
  .timeline-item:nth-child(odd),
  .timeline-item:nth-child(even) {
    left: 0;
  }
  .timeline-icon {
    left: 5px;
  }
  .timeline-item:nth-child(even) .timeline-icon {
    left: 5px;
  }

  .skills-container {
    grid-template-columns: 1fr;
  }
}
