/* ===== VARIABLES Y TEMAS ===== */
:root {
  /* Modo oscuro (por defecto) */
  --fondo: #0d1321;
  --fondo-gradient-1: #1f2a44;
  --fondo-gradient-2: #0d1321;
  --superficie: #1d2d44;
  --superficie-card: rgba(13, 19, 33, 0.65);
  --resalte: #f4d35e;
  --texto: #fefefe;
  --texto-sec: #cdd7f0;
  --borde: rgba(255, 255, 255, 0.08);
  --borde-hover: rgba(244, 211, 94, 0.4);
  --sombra: rgba(0, 0, 0, 0.35);
  --hero-gradient: linear-gradient(135deg, rgba(244, 211, 94, 0.1), rgba(13, 19, 33, 0.9));
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Modo claro */
[data-theme="light"] {
  --fondo: #f8f9fa;
  --fondo-gradient-1: #e9ecef;
  --fondo-gradient-2: #f8f9fa;
  --superficie: #ffffff;
  --superficie-card: rgba(255, 255, 255, 0.85);
  --resalte: #d4a520;
  --texto: #1a1a2e;
  --texto-sec: #4a4a6a;
  --borde: rgba(0, 0, 0, 0.08);
  --borde-hover: rgba(212, 165, 32, 0.5);
  --sombra: rgba(0, 0, 0, 0.1);
  --hero-gradient: linear-gradient(135deg, rgba(244, 211, 94, 0.2), rgba(248, 249, 250, 0.95));
}

* {
  box-sizing: border-box;
}

/* ===== TRANSICIONES GLOBALES ===== */
body,
.hero,
section,
.badge,
.ref-card,
.contact-card,
footer,
h1, h2, h3, p, span, strong,
.timeline-item {
  transition: background 0.4s ease, 
              color 0.4s ease, 
              border-color 0.4s ease,
              box-shadow 0.4s ease;
}

/* ===== BODY ===== */
body {
  margin: 0;
  background: radial-gradient(circle at top, var(--fondo-gradient-1) 0%, var(--fondo-gradient-2) 50%);
  color: var(--texto);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== TOGGLE DE TEMA ===== */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  background: var(--superficie-card);
  border: 1px solid var(--borde);
  border-radius: 50px;
  padding: 0.5rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--sombra);
}

.theme-toggle:hover {
  transform: scale(1.05);
  border-color: var(--resalte);
  box-shadow: 0 6px 20px var(--sombra);
}

.theme-toggle .icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.5s ease, opacity 0.3s ease;
}

.theme-toggle .sun {
  color: #f4d35e;
}

.theme-toggle .moon {
  color: #a0c4ff;
}

[data-theme="light"] .theme-toggle .moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun,
:root:not([data-theme]) .theme-toggle .sun {
  display: none;
}

/* ===== HERO ===== */
.hero {
  padding: 4rem 1.5rem 3rem;
  background: var(--hero-gradient);
  border-bottom: 1px solid var(--borde);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  text-align: left;
  min-height: 50vh;
}

.hero-text h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 3.2rem);
  letter-spacing: 0.04em;
  animation: slideInRight 0.8s ease-out;
}

.hero-text p {
  margin: 0.8rem auto 0;
  max-width: 540px;
  color: var(--texto-sec);
  animation: fadeInUp 1s ease-out 0.3s both;
}

.hero-photo {
  width: min(220px, 35vw);
  height: min(220px, 35vw);
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(244, 211, 94, 0.35);
  box-shadow: 0 12px 30px var(--sombra);
  animation: scaleIn 0.8s ease-out, float 6s ease-in-out infinite;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.hero-photo:hover {
  transform: scale(1.05);
  box-shadow: 0 20px 40px var(--sombra);
}

[data-theme="light"] .hero-photo {
  border-color: rgba(212, 165, 32, 0.5);
}

/* ===== MAIN ===== */
main {
  padding: 2.5rem 1.5rem 4rem;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
}

/* ===== SECCIONES ===== */
section {
  background: var(--superficie-card);
  border: 1px solid var(--borde);
  border-radius: 18px;
  padding: 1.75rem;
  backdrop-filter: blur(12px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              border-color 0.3s ease,
              box-shadow 0.4s ease,
              background 0.4s ease;
  opacity: 0;
  transform: translateY(30px);
}

section.visible {
  opacity: 1;
  transform: translateY(0);
}

section:hover {
  transform: translateY(-6px);
  border-color: var(--borde-hover);
  box-shadow: 0 15px 35px var(--sombra);
}

/* Animación escalonada para secciones */
section:nth-child(1) { transition-delay: 0.1s; }
section:nth-child(2) { transition-delay: 0.15s; }
section:nth-child(3) { transition-delay: 0.2s; }
section:nth-child(4) { transition-delay: 0.25s; }
section:nth-child(5) { transition-delay: 0.3s; }
section:nth-child(6) { transition-delay: 0.35s; }
section:nth-child(7) { transition-delay: 0.4s; }
section:nth-child(8) { transition-delay: 0.45s; }
section:nth-child(9) { transition-delay: 0.5s; }
section:nth-child(10) { transition-delay: 0.55s; }

h2 {
  margin-top: 0;
  color: var(--resalte);
  letter-spacing: 0.08em;
  font-size: 1rem;
  text-transform: uppercase;
  position: relative;
  display: inline-block;
}

h2::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--resalte);
  transition: width 0.4s ease;
}

section:hover h2::after {
  width: 100%;
}

h3 {
  color: var(--texto);
  margin-bottom: 0.75rem;
}

/* ===== GRIDS ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.list-item {
  margin: 0.25rem 0;
  color: var(--texto);
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  border: 1px solid var(--borde);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  margin: 0.25rem;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: default;
}

[data-theme="light"] .badge {
  background: rgba(0, 0, 0, 0.03);
}

.badge:hover,
.badge.glow {
  box-shadow: 0 0 20px rgba(244, 211, 94, 0.5);
  transform: translateY(-3px) scale(1.02);
  border-color: var(--resalte);
  background: rgba(244, 211, 94, 0.1);
}

/* ===== TIMELINE ===== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-item {
  border-left: 2px solid rgba(244, 211, 94, 0.6);
  padding-left: 1rem;
  position: relative;
  transition: all 0.3s ease;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 0.5rem;
  width: 10px;
  height: 10px;
  background: var(--resalte);
  border-radius: 50%;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.timeline-item:hover {
  padding-left: 1.5rem;
}

.timeline-item:hover::before {
  transform: scale(1.3);
  box-shadow: 0 0 15px rgba(244, 211, 94, 0.6);
}

.timeline-item span {
  display: block;
  color: var(--texto-sec);
  font-size: 0.95rem;
}

.timeline-item ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.2rem;
}

.timeline-item li {
  margin: 0.3rem 0;
  color: var(--texto-sec);
}

/* ===== CONTACTO ===== */
.contact-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.contact-card p {
  transition: transform 0.3s ease;
}

.contact-card p:hover {
  transform: translateX(5px);
}

.contact-card a {
  color: var(--resalte);
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease;
}

.contact-card a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--resalte);
  transition: width 0.3s ease;
}

.contact-card a:hover::after {
  width: 100%;
}

/* ===== REFERENCIAS ===== */
.refs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.ref-card {
  border: 1px dashed var(--borde);
  border-radius: 16px;
  padding: 1rem;
  transition: all 0.3s ease;
}

.ref-card:hover {
  border-style: solid;
  border-color: var(--resalte);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px var(--sombra);
}

.ref-card a {
  color: var(--resalte);
  text-decoration: none;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--texto-sec);
  font-size: 0.9rem;
  border-top: 1px solid var(--borde);
  animation: fadeInUp 1s ease-out;
}

/* ===== ANIMACIONES KEYFRAMES ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(244, 211, 94, 0.4);
  }
  50% {
    box-shadow: 0 0 20px 10px rgba(244, 211, 94, 0);
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .hero {
    text-align: center;
    padding-top: 5rem;
  }

  .hero-text {
    text-align: center;
  }

  .hero-text p {
    margin-left: auto;
    margin-right: auto;
  }

  section {
    padding: 1.25rem;
  }

  .theme-toggle {
    top: 1rem;
    right: 1rem;
    padding: 0.4rem;
  }
}

/* ===== SCROLLBAR PERSONALIZADA ===== */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--fondo);
}

::-webkit-scrollbar-thumb {
  background: var(--superficie);
  border-radius: 5px;
  border: 2px solid var(--fondo);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--resalte);
}

/* ===== SELECCIÓN DE TEXTO ===== */
::selection {
  background: var(--resalte);
  color: var(--fondo);
}

/* ===== SUMMARY SECTION ===== */
.summary p {
  margin-bottom: 1rem;
  text-align: justify;
}

.summary p:last-child {
  margin-bottom: 0;
}

/* ===== SECCIÓN DE PROYECTOS ===== */
.projects-section {
  background: var(--superficie-card);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.project-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--borde);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

[data-theme="light"] .project-card {
  background: rgba(0, 0, 0, 0.02);
}

.project-card:hover {
  transform: translateY(-8px);
  border-color: var(--resalte);
  box-shadow: 0 20px 40px var(--sombra);
}

/* ===== GALERÍA DE IMÁGENES ===== */
.project-gallery {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--fondo);
}

.gallery-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.gallery-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  cursor: zoom-in;
}

.gallery-image.active {
  opacity: 1;
}

.gallery-image:hover {
  transform: scale(1.02);
}

/* Botones de navegación de galería */
.gallery-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 10;
}

.project-gallery:hover .gallery-btn {
  opacity: 1;
}

.gallery-btn:hover {
  background: var(--resalte);
  color: var(--fondo);
  transform: translateY(-50%) scale(1.1);
}

.gallery-btn.prev {
  left: 10px;
}

.gallery-btn.next {
  right: 10px;
}

/* Indicadores de galería (dots) */
.gallery-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.3s ease;
}

.dot.active {
  background: var(--resalte);
  transform: scale(1.2);
}

.dot:hover {
  background: rgba(255, 255, 255, 0.8);
}

/* Información del proyecto */
.project-info {
  padding: 1.25rem;
}

.project-info h3 {
  margin: 0 0 0.75rem 0;
  color: var(--texto);
  font-size: 1.15rem;
}

.project-info p {
  margin: 0 0 1rem 0;
  color: var(--texto-sec);
  font-size: 0.95rem;
  line-height: 1.5;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.project-tags .badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  margin: 0;
}

/* ===== LIGHTBOX (MODAL DE IMAGEN) ===== */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-image {
  max-width: 90%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

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

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  background: none;
  border: none;
  color: white;
  font-size: 3rem;
  cursor: pointer;
  transition: all 0.3s ease;
  line-height: 1;
}

.lightbox-close:hover {
  color: var(--resalte);
  transform: rotate(90deg);
}

.lightbox-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.lightbox-btn:hover {
  background: var(--resalte);
  color: var(--fondo);
}

.lightbox-btn.prev {
  left: 30px;
}

.lightbox-btn.next {
  right: 30px;
}

@media (max-width: 640px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }
  
  .lightbox-btn {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
  }
  
  .lightbox-btn.prev {
    left: 10px;
  }
  
  .lightbox-btn.next {
    right: 10px;
  }
  
  .lightbox-close {
    top: 10px;
    right: 15px;
    font-size: 2.5rem;
  }
}
