:root {
  /* Paleta Modernizada (Dark Premium) */
  --bg-dark: #0f1014;
  --bg-card: #181a20;
  --primary: #1dd3b0;
  /* Turquoise - Mantenido como identidad */
  --secondary: #9d4edd;
  /* Violeta más vibrante pero elegante */
  --accent: #affc41;
  /* Green Yellow - Para detalles pequeños */
  --text-main: #f0f2f5;
  --text-muted: #a0aec0;
  --gradient-main: linear-gradient(135deg, var(--bg-dark) 0%, #240b2f 100%);
  --nav-bg: rgba(15, 16, 20, 0.7);
  --card-border: 1px solid rgba(255, 255, 255, 0.05);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  line-height: 1.7;
  /* Mejor lectura */
  font-size: 16px;
  margin: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  text-decoration: none;
  color: inherit;
}

/* --- Navigation (Glassmorphism) --- */
.navbar {
  background-color: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: none;
  /* Borde eliminado a pedido del usuario */
  padding: 0.6rem 0;
  /* Altura reducida */
  transition: all 0.3s ease;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  /* Sombra sutil para separar del fondo sin borde duro */
}

.logo-container {
  width: 4rem;
  height: auto;
  transition: transform 0.3s ease;
}

.logo-container img {
  width: 100%;
  height: auto;
}

.navbar-nav .nav-link {
  color: var(--text-muted) !important;
  font-weight: 500;
  margin: 0 15px;
  position: relative;
  transition: color 0.3s ease;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
  color: var(--primary) !important;
}

.navbar-nav .nav-link::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 50%;
  background-color: var(--primary);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after {
  width: 100%;
}

.navbar-toggler {
  border: none;
  color: var(--text-main);
}

.navbar-toggler:focus {
  box-shadow: none;
}

/* --- Hero Section --- */
.hero {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 50%, #2a1b3d 0%, var(--bg-dark) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding-top: 60px;
}

#particles-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.6;
}

.hero-content {
  text-align: center;
  z-index: 10;
  position: relative;
}

.hero h1 {
  font-size: clamp(3rem, 8vw, 5rem);
  /* Responsive typography */
  background: linear-gradient(to right, #fff, var(--primary));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
  animation: fadeUp 0.8s ease-out;
}

.hero p {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  animation: fadeUp 1s ease-out;
}

.hero .btn-lg {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 12px 35px;
  border-radius: 50px;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  animation: fadeUp 1.2s ease-out;
}

.hero .btn-lg:hover {
  background: var(--primary);
  color: var(--bg-dark);
  box-shadow: 0 0 20px rgba(29, 211, 176, 0.4);
  transform: translateY(-2px);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Section Generics --- */
section {
  padding: 100px 0;
  position: relative;
}

.section-title {
  text-align: center;
  margin-bottom: 4rem;
  font-size: 2.5rem;
  position: relative;
  display: inline-block;
  left: 50%;
  transform: translateX(-50%);
}

.section-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  background: var(--primary);
  margin: 10px auto 0;
  border-radius: 2px;
}

/* --- About Section --- */
.about {
  background-color: #13151a;
}

.about h2,
.projects h2,
.contact h2,
.contact-form-section h2 {
  text-align: center;
  margin-bottom: 3rem;
  font-size: 2.5rem;
  color: var(--text-main);
}

.about p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.skills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 2rem;
}

/* Nota: En el HTML original las skills estaban como .skill-item div sueltos */
.skills {
  margin-top: 2rem;
}

.skill-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 20px;
  border-radius: 12px;
  color: var(--text-main);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 5px;
  transition: all 0.3s ease;
}

.skill-item i {
  color: var(--primary);
  margin-right: 5px;
}

.skill-item:hover {
  background: rgba(29, 211, 176, 0.1);
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* --- Projects Section --- */
.projects {
  background-color: var(--bg-dark);
}

.project-card {
  background: var(--bg-card);
  border: var(--card-border);
  border-radius: 20px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.project-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  border-color: rgba(29, 211, 176, 0.3);
}

.project-image {
  height: 180px;
  background: linear-gradient(135deg, rgba(29, 211, 176, 0.05), rgba(157, 78, 221, 0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Fondo extra para el icono si no hay imagen real */
.project-image::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.project-thumb-icon {
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-muted);
  opacity: 0.8;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
}

.project-card:hover .project-thumb-icon {
  color: var(--primary);
  opacity: 1;
  transform: scale(1.1);
  background: rgba(29, 211, 176, 0.1);
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  color: var(--text-main);
  margin-bottom: 0.8rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.card-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.tech-tag {
  font-size: 0.75rem;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  color: var(--secondary);
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: 'Inter', sans-serif;
  border: 1px solid rgba(157, 78, 221, 0.2);
}

.btn-view-more {
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-view-more:hover {
  background: var(--primary);
  color: var(--bg-dark);
}

.btn-outline-primary {
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-outline-primary:hover {
  border-color: var(--text-main);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.disabled-btn {
  opacity: 0.5;
  cursor: not-allowed !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  background: transparent;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* --- Contact Section --- */
.contact {
  background: linear-gradient(180deg, var(--bg-dark) 0%, #17101f 100%);
  padding: 80px 0;
}

.contact-item {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 16px;
  border: var(--card-border);
  text-align: center;
  transition: transform 0.3s ease;
  height: 100%;
  margin-bottom: 30px;
}

.contact-item:hover {
  transform: translateY(-5px);
  border-color: var(--secondary);
}

.contact-item i {
  font-size: 2rem;
  color: var(--secondary);
  margin-bottom: 1rem;
}

.contact-item h5 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: var(--text-main);
}

.contact-item p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

/* Form */
.contact-form-section {
  padding-bottom: 100px;
  background-color: var(--bg-dark);
}

.contact-form-section form {
  background: var(--bg-card);
  padding: 3rem;
  border-radius: 20px;
  border: var(--card-border);
  max-width: 700px;
  margin: 0 auto;
}

.form-control {
  background: rgba(0, 0, 0, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main) !important;
  padding: 12px 15px;
  border-radius: 10px;
}

.form-control:focus {
  background: rgba(0, 0, 0, 0.3) !important;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(29, 211, 176, 0.1);
  color: var(--text-main) !important;
}

.form-label {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--gradient-main);
  border: 1px solid var(--secondary);
  color: white;
  padding: 12px 30px;
  border-radius: 10px;
  transition: 0.3s;
  width: 100%;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--secondary);
  border-color: var(--secondary);
  box-shadow: 0 5px 15px rgba(157, 78, 221, 0.3);
}

/* --- Footer --- */
.footer {
  background: #0a0a0c;
  padding: 3rem 0;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 1.5rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.social-links a {
  display: inline-flex;
  width: 45px;
  height: 45px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.social-links a:hover {
  background: var(--primary);
  color: var(--bg-dark);
  transform: translateY(-3px);
}

.gallery-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  /* CRITICAL: Prevent clicks when hidden */
  transition: opacity 0.3s ease, visibility 0s 0.3s;
  /* Delay hiding visibility until fade completes */
}

.gallery-modal[aria-hidden="false"] {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  /* Re-enable clicks when visible */
  transition: opacity 0.3s ease, visibility 0s 0s;
  /* Show instantly */
}

.gallery-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
}

.gallery-content {
  position: relative;
  z-index: 2100;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-image {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
  display: block;
  /* Importante para evitar comportamientos inline extraños */
}

.gallery-image.visible {
  opacity: 1 !important;
  /* Force visibility */
}

.gallery-close,
.gallery-prev,
.gallery-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2200;
  font-size: 1.2rem;
}

.gallery-close:hover,
.gallery-prev:hover,
.gallery-next:hover {
  background: var(--primary);
  color: black;
}

.gallery-close {
  top: -50px;
  right: 0;
}

.gallery-prev {
  top: 50%;
  left: -60px;
  transform: translateY(-50%);
}

.gallery-next {
  top: 50%;
  right: -60px;
  transform: translateY(-50%);
}

.gallery-empty {
  color: white;
  font-size: 1.2rem;
  z-index: 2200;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.5rem;
  }

  .section-title {
    font-size: 2rem;
  }

  .gallery-prev {
    left: 10px;
    background: rgba(0, 0, 0, 0.5);
  }

  .gallery-next {
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
  }

  .gallery-close {
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
  }

  .gallery-content {
    width: 100%;
  }
}

/* Utils */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}