/* Evitar distorsión de imágenes en la galería de proyectos */
.gallery-grid img {
  width: 100%;
  height: auto;
  aspect-ratio: 3/2;
  object-fit: contain;
  display: block;
  max-width: 300px;
  max-height: 200px;
  margin: 0 auto;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
:root {
  --bg: #fff;
  --text: #1a1a1a;
  --text-light: #666;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #64748b;
  --border: #e5e7eb;
  --surface: #f8fafc;
  --surface-hover: #f1f5f9;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 4px 6px -1px rgb(0 0 0/0.1);
  --transition: 250ms ease;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --primary: #3b82f6;
    --border: #334155;
    --surface: #1e293b;
    --surface-hover: #334155;
  }
}
[data-theme="dark"] {
  --bg: #0f172a;
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --primary: #3b82f6;
  --border: #334155;
  --surface: #1e293b;
  --surface-hover: #334155;
}
[data-theme="light"] {
  --bg: #fff;
  --text: #1a1a1a;
  --text-light: #666;
  --primary: #2563eb;
  --border: #e5e7eb;
  --surface: #f8fafc;
  --surface-hover: #f1f5f9;
}

html {
  font-family: var(--font);
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: clamp(1rem, 3vw, 1.125rem);
  line-height: 1.6;
  transition: all var(--transition);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 5vw, 2rem);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.header {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(8px);
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}
.logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}
.logo:hover,
.logo:focus {
  color: var(--primary);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  color: var(--text);
}
.nav-toggle:hover {
  background: var(--surface-hover);
}
.hamburger {
  display: block;
  width: 24px;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  transition: var(--transition);
}
.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--transition);
}
.hamburger::before {
  top: -8px;
}
.hamburger::after {
  top: 8px;
}
.nav-toggle[aria-expanded="true"] .hamburger {
  background: transparent;
}
.nav-toggle[aria-expanded="true"] .hamburger::before {
  transform: rotate(45deg) translate(6px, 6px);
}
.nav-toggle[aria-expanded="true"] .hamburger::after {
  transform: rotate(-45deg) translate(6px, -6px);
}

.nav-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.5rem;
}
.nav-menu a {
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all var(--transition);
}
.nav-menu a:hover,
.nav-menu a:focus {
  color: var(--primary);
  background: var(--surface-hover);
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }
  .nav-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    flex-direction: column;
    padding: 1rem;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition);
  }
  .nav-menu[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .nav-menu a {
    display: block;
    width: 100%;
  }
}

.section {
  padding: 4rem 0;
}
.section:nth-child(even) {
  background: var(--surface);
}
.hero {
  padding: 4rem 0;
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
}
.hero .container {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3rem;
  align-items: center;
}
.hero-content h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  margin: 0 0 1.5rem 0;
  line-height: 1.2;
}
.hero-tagline {
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  color: var(--text-light);
  margin: 0 0 1rem 0;
  font-style: italic;
}
.hero-subtitle {
  font-size: clamp(1.125rem, 3.5vw, 1.25rem);
  margin: 0 0 2rem 0;
  max-width: 600px;
}
.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.hero-image img {
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  .hero .container {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hero-image {
    order: -1;
  }
  .hero-image img {
    max-width: 250px;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--surface-hover);
}

h2 {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 600;
  margin: 0 0 2rem 0;
  text-align: center;
}
h3 {
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 600;
  margin: 0 0 1rem 0;
}
h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.about-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  font-size: 1.25rem;
  line-height: 1.7;
}

.project-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 1px 3px 0 rgb(0 0 0/0.1);
  transition: box-shadow var(--transition);
  overflow: visible;
}
.project-card:hover {
  box-shadow: var(--shadow);
}
.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.project-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.tag {
  background: var(--surface);
  color: var(--text);
  padding: 0.25rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  border: 1px solid var(--border);
}
.project-summary {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}
.project-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.project-note {
  font-size: 0.875rem;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 1.5rem;
}
.project-details {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: all var(--transition);
}
.project-details[aria-hidden="false"] {
  opacity: 1;
  max-height: 2000px;
  overflow: visible;
}
.features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem 0;
}
.features-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}
.features-list li:last-child {
  border-bottom: none;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.gallery-grid img {
  border-radius: 8px;
  box-shadow: 0 1px 3px 0 rgb(0 0 0/0.1);
  transition: transform var(--transition);
}
.gallery-grid img:hover {
  transform: scale(1.02);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}
.skill-category {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}
.skill-category h3 {
  color: var(--primary);
  margin-bottom: 1rem;
}
.skill-category ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.skill-category li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.skill-category li:last-child {
  border-bottom: none;
}

.experience-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem 0;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
.experience-list li {
  padding: 1rem 0 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.experience-list li:last-child {
  border-bottom: none;
}
.experience-list li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: bold;
}
.cta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  margin-top: 2rem;
}
.cta p {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0;
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 768px) {
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}
.contact-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}
.contact-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text);
  text-decoration: none;
  padding: 1rem;
  border-radius: 8px;
  transition: background var(--transition);
}
.contact-link:hover {
  background: var(--surface-hover);
}
.contact-icon {
  font-size: 1.25rem;
}

.contact-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235/0.1);
}
.form-group textarea {
  resize: vertical;
  min-height: 120px;
}
.privacy-notice {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 1rem;
  margin-bottom: 0;
}

.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
}
.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.footer-links {
  display: flex;
  gap: 1.5rem;
}
.footer-links a {
  color: var(--text-light);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-links a:hover {
  color: var(--text);
}
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover {
  background: var(--surface-hover);
  transform: scale(1.1);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.theme-icon {
  font-size: 1.25rem;
}

@media (max-width: 768px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .project-card,
  .skill-category {
    transition: transform var(--transition);
  }
  .project-card:hover,
  .skill-category:hover {
    transform: translateY(-2px);
  }
  .hero-content {
    animation: fadeInUp 0.8s ease-out;
  }
  .hero-image {
    animation: fadeInUp 0.8s ease-out 0.2s both;
  }
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media print {
  .header,
  .nav,
  .theme-toggle,
  .contact-form {
    display: none;
  }
  .section {
    page-break-inside: avoid;
  }
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
}

/* Estilos para la galería interactiva */
.gallery-image {
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border-radius: 8px;
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.gallery-image:hover,
.gallery-image:focus {
  transform: scale(1.02);
  box-shadow: var(--shadow);
  outline-color: var(--primary);
}

/* Modal Lightbox */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  cursor: pointer;
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1001;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.image-modal.active .modal-content {
  transform: scale(1);
}

.modal-image {
  max-width: 100%;
  max-height: 80vh;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 20px 25px -5px rgb(0 0 0/0.4);
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: -50px;
  right: -10px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  transition: all var(--transition);
  z-index: 1002;
}

.modal-close:hover,
.modal-close:focus {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
  outline: 2px solid var(--primary);
}

.modal-caption {
  margin-top: 20px;
  text-align: center;
  color: white;
}

.modal-image-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-hint {
  font-size: 0.9rem;
  opacity: 0.8;
  margin: 0;
}

/* Responsive para móviles */
@media (max-width: 768px) {
  .modal-content {
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .modal-image {
    max-height: 75vh;
  }
  
  .modal-close {
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  
  .modal-caption {
    margin-top: 15px;
  }
  
  .modal-image-title {
    font-size: 1rem;
  }
  
  .modal-hint {
    font-size: 0.85rem;
  }
}

/* Animación de entrada para la imagen */
@keyframes modalImageIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-image {
  animation: modalImageIn 0.3s ease;
}
