/* ===== Variables y base ===== */
:root {
  --bg: #05070D;
  --surface: #0D1424;
  --surface-2: #131C33;
  --heading: #F3F7FF;
  --ink: #AEBBD6;
  --muted: #7C8AAE;
  --blue: #0176D3;
  --sky: #1B96FF;
  --cyan: #25E0E8;
  --line: rgba(255, 255, 255, .09);
  --whatsapp: #22C35E;
  --whatsapp-dark: #1AA34D;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cyan);
}

h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; color: var(--heading); line-height: 1.1; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
::selection { background: var(--cyan); color: #05070D; }

/* ===== Fondo animado (aurora + grilla + brillo del mouse) ===== */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; animation: float 16s ease-in-out infinite; }
.aurora span:nth-child(1) { width: 520px; height: 520px; background: #0176D3; top: -160px; left: -120px; }
.aurora span:nth-child(2) { width: 460px; height: 460px; background: #25E0E8; top: 280px; right: -140px; animation-delay: -6s; }
.aurora span:nth-child(3) { width: 380px; height: 380px; background: #3B2FD9; bottom: -140px; left: 30%; animation-delay: -11s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) { .aurora span { animation: none; } }

.grid-pattern {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}

.cursor-glow {
  position: fixed; top: 0; left: 0; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 224, 232, .12) 0%, rgba(37, 224, 232, 0) 70%);
  pointer-events: none; z-index: 0; transform: translate(-50%, -50%);
  transition: opacity .3s; opacity: 0;
}

/* ===== Animación de aparición al hacer scroll ===== */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in-view { opacity: 1; transform: translateY(0); }

/* ===== Barra de progreso de scroll ===== */
.progress-bar { position: fixed; top: 0; left: 0; width: 100%; height: 3px; z-index: 100; background: transparent; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--sky)); box-shadow: 0 0 10px rgba(37, 224, 232, .6); transition: width .08s linear; }

/* ===== Header ===== */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(5, 7, 13, .72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
nav.wrap { display: flex; align-items: center; justify-content: space-between; height: 72px; gap: 20px; }
.logo { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 19px; color: var(--heading); display: flex; align-items: center; gap: 8px; }
.logo span { color: var(--cyan); }
.navlinks { display: flex; gap: 32px; font-size: 14px; font-weight: 500; color: var(--ink); margin-left: auto; }
.navlinks a { opacity: .8; transition: opacity .2s; position: relative; }
.navlinks a:after { content: ""; position: absolute; left: 0; bottom: -6px; width: 0; height: 2px; background: var(--cyan); transition: width .25s ease; }
.navlinks a:hover { opacity: 1; }
.navlinks a:hover:after { width: 100%; }
.nav-cta { background: var(--whatsapp); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; transition: background .2s, transform .2s; }
.nav-cta:hover { background: var(--whatsapp-dark); }

/* ===== Menú hamburguesa (solo móvil) ===== */
.hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 40px; height: 40px; background: none; border: none; cursor: pointer; z-index: 110; }
.hamburger span { display: block; width: 24px; height: 2px; background: var(--heading); border-radius: 2px; transition: transform .3s ease, opacity .3s ease; }
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 820px) {
  .navlinks, .nav-cta { display: none; }
  .hamburger { display: flex; }
}

/* ===== Menú móvil a pantalla completa ===== */
.mobile-menu {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 7, 13, .97);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px;
  opacity: 0; visibility: hidden; transform: scale(1.03);
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}
.mobile-menu.open { opacity: 1; visibility: visible; transform: scale(1); transition: opacity .35s ease, transform .35s ease; }
.mobile-menu nav { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.mobile-menu nav a {
  font-family: 'Space Grotesk', sans-serif; font-size: 28px; font-weight: 600; color: var(--heading);
  opacity: 0; transform: translateY(14px); transition: opacity .4s ease, transform .4s ease;
}
.mobile-menu.open nav a { opacity: 1; transform: translateY(0); }
.mobile-menu.open nav a:nth-child(1) { transition-delay: .05s; }
.mobile-menu.open nav a:nth-child(2) { transition-delay: .1s; }
.mobile-menu.open nav a:nth-child(3) { transition-delay: .15s; }
.mobile-menu.open nav a:nth-child(4) { transition-delay: .2s; }
.mobile-menu.open nav a:nth-child(5) { transition-delay: .25s; }

/* ===== Botón flotante de WhatsApp ===== */
.floating-whatsapp {
  position: fixed;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  right: calc(26px + env(safe-area-inset-right, 0px));
  z-index: 80;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--whatsapp); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px -8px rgba(34, 195, 94, .7);
  transition: transform .25s ease, background .25s ease;
}
@media (max-width: 480px) {
  .floating-whatsapp { width: 50px; height: 50px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); right: calc(18px + env(safe-area-inset-right, 0px)); }
  .floating-whatsapp svg { width: 23px; height: 23px; }
}
.floating-whatsapp svg { width: 27px; height: 27px; position: relative; z-index: 1; }
.floating-whatsapp:hover { transform: translateY(-4px) scale(1.05); background: var(--whatsapp-dark); }
.floating-whatsapp .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--whatsapp); animation: ringPulse 2.2s ease-out infinite; }
@keyframes ringPulse {
  0% { transform: scale(1); opacity: .7; }
  100% { transform: scale(1.7); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .floating-whatsapp .ring { animation: none; } }

/* ===== Hero ===== */
.hero { padding: 100px 0 80px; position: relative; z-index: 1; }
.hero-grid { display: grid; grid-template-columns: 1fr .95fr; gap: 56px; align-items: center; }
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { order: -1; }
  .photo-frame { max-width: 190px; margin: 0 auto; }
}
.hero h1 { font-size: clamp(34px, 5vw, 54px); font-weight: 700; margin: 18px 0 22px; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--cyan), var(--sky)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 17px; color: var(--ink); max-width: 520px; line-height: 1.65; margin-bottom: 34px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 10px; padding: 15px 26px; border-radius: 9px; font-weight: 600; font-size: 15px; transition: transform .2s, box-shadow .2s, background .2s; }
.btn-primary { background: var(--whatsapp); color: #fff; box-shadow: 0 10px 26px -8px rgba(34, 195, 94, .6); }
.btn-primary:hover { background: var(--whatsapp-dark); transform: translateY(-2px); }
.btn-ghost { border: 1.5px solid var(--line); color: var(--heading); background: rgba(255, 255, 255, .03); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan); transform: translateY(-2px); }

.stats { display: flex; gap: 36px; margin-top: 44px; flex-wrap: wrap; }
.stat b { display: block; font-family: 'Space Grotesk', sans-serif; font-size: 28px; color: var(--heading); }
.stat span { font-size: 13px; color: var(--muted); }

.hero-visual { display: flex; flex-direction: column; gap: 22px; }
.photo-frame { position: relative; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 30px 60px -30px rgba(37, 224, 232, .25); max-width: 260px; }
.photo-frame img { width: 100%; display: block; transition: transform .5s ease; }
.photo-frame:hover img { transform: scale(1.05); }

/* ===== Diagrama de integraciones animado ===== */
.flowbox { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px 22px 20px; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .6); position: relative; }
.flowbox-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.flowbox-title { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); letter-spacing: .05em; margin-left: 6px; }
svg#flow { width: 100%; height: auto; display: block; }
.flow-line { stroke: var(--cyan); stroke-width: 2; fill: none; stroke-dasharray: 6 7; animation: dash 2.2s linear infinite; filter: drop-shadow(0 0 4px rgba(37, 224, 232, .5)); }
@keyframes dash { to { stroke-dashoffset: -52; } }
.flow-node { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.4; }
.flow-node-main { fill: var(--blue); stroke: var(--cyan); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(37, 224, 232, .5)); }
  50% { filter: drop-shadow(0 0 14px rgba(37, 224, 232, .85)); }
}
.flow-label { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; fill: var(--ink); }
.flow-label-main { fill: #fff; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .flow-line { animation: none; } .flow-node-main { animation: none; } }

/* ===== Secciones genéricas ===== */
section { padding: 88px 0; position: relative; z-index: 1; }
.section-head { max-width: 640px; margin-bottom: 52px; }
.section-head h2 { font-size: clamp(26px, 3.6vw, 36px); margin: 14px 0 14px; }
.section-head p { color: var(--ink); font-size: 15.5px; line-height: 1.6; }
@media (max-width: 480px) {
  .hero { padding: 64px 0 56px; }
  section { padding: 60px 0; }
  .section-head { margin-bottom: 34px; }
  .stats { gap: 24px; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ===== Servicios ===== */
#servicios .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
@media (max-width: 880px) { #servicios .grid { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px;
  transition: transform .25s, box-shadow .25s, border-color .25s;
  position: relative; overflow: hidden;
}
.card:before {
  content: ""; position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .3s ease;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), rgba(37, 224, 232, .14), transparent 65%);
}
.card:hover:before { opacity: 1; }
.card:hover { transform: translateY(-6px); box-shadow: 0 24px 48px -24px rgba(37, 224, 232, .18); border-color: rgba(37, 224, 232, .35); }
.card .icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 10px; background: rgba(37, 224, 232, .1); color: var(--cyan); position: relative; z-index: 1; }
.card .icon svg { width: 22px; height: 22px; }
.card h3 { font-size: 18px; margin: 14px 0 10px; position: relative; z-index: 1; }
.card p { font-size: 14.5px; color: var(--ink); line-height: 1.6; position: relative; z-index: 1; }

/* ===== Stack técnico ===== */
#stack { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--heading); padding: 9px 16px; border-radius: 100px; font-size: 13.5px; font-weight: 500; font-family: 'IBM Plex Mono', monospace; transition: transform .2s, background .2s, color .2s, border-color .2s; }
.chip:hover { background: var(--cyan); color: #05070D; border-color: var(--cyan); transform: translateY(-2px); }
.stack-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
@media (max-width: 760px) { .stack-cols { grid-template-columns: 1fr; } }
.stack-cols h3 { font-size: 14px; color: var(--cyan); margin-bottom: 16px; font-family: 'IBM Plex Mono', monospace; letter-spacing: .04em; }

/* ===== Línea de tiempo de experiencia ===== */
.timeline { position: relative; padding-left: 28px; }
.timeline:before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 38px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item:before { content: ""; position: absolute; left: -28px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 3px solid var(--cyan); transition: box-shadow .3s; }
.tl-item.in-view:before { box-shadow: 0 0 0 5px rgba(37, 224, 232, .18); }
.tl-date { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--cyan); }
.tl-role { font-size: 19px; margin: 6px 0 2px; color: var(--heading); }
.tl-company { font-size: 14px; color: var(--sky); font-weight: 600; margin-bottom: 10px; }
.tl-desc { font-size: 14.5px; color: var(--ink); line-height: 1.65; max-width: 640px; }

/* ===== Proyectos ===== */
#proyectos .proj-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 760px) { #proyectos .proj-grid { grid-template-columns: 1fr; } }
.proj-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  transition: transform .25s, box-shadow .25s; position: relative;
}
.proj-card:before {
  content: ""; position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .3s ease; z-index: 1;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), rgba(37, 224, 232, .16), transparent 65%);
}
.proj-card:hover:before { opacity: 1; }
.proj-card:hover { transform: translateY(-6px); box-shadow: 0 24px 48px -24px rgba(37, 224, 232, .18); }
.proj-thumb { width: 100%; height: 160px; object-fit: cover; display: block; transition: transform .5s ease; }
.proj-card:hover .proj-thumb { transform: scale(1.06); }
.proj-body { padding: 20px 22px 24px; position: relative; z-index: 2; }
.proj-client { display: inline-block; background: var(--surface-2); color: var(--cyan); font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .05em; padding: 5px 11px; border-radius: 6px; margin-bottom: 12px; border: 1px solid var(--line); }
.proj-body p { font-size: 14.5px; color: var(--ink); line-height: 1.6; }

/* ===== Certificaciones ===== */
#certs { background: linear-gradient(180deg, #0A1020, #05070D); }
.cert-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 820px) { .cert-grid { grid-template-columns: repeat(2, 1fr); } }
.cert-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 18px; color: var(--heading);
  transition: transform .25s, border-color .25s; position: relative; overflow: hidden;
}
.cert-card:before {
  content: ""; position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .3s ease;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), rgba(37, 224, 232, .16), transparent 65%);
}
.cert-card:hover:before { opacity: 1; }
.cert-card:hover { transform: translateY(-4px); border-color: rgba(37, 224, 232, .4); }
.cert-card b, .cert-card span { position: relative; z-index: 1; }
.cert-card b { display: block; font-size: 14.5px; margin-bottom: 4px; font-family: 'Space Grotesk', sans-serif; }
.cert-card span { font-size: 12.5px; color: var(--muted); }

/* ===== Contacto ===== */
#contacto { text-align: center; }
#contacto .section-head { margin: 0 auto 34px; text-align: center; }
.contact-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 56px 40px; max-width: 640px; margin: 0 auto; box-shadow: 0 30px 70px -34px rgba(37, 224, 232, .15); }
.contact-meta { display: flex; justify-content: center; gap: 28px; margin-top: 30px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink); }
.contact-meta a { color: var(--cyan); font-weight: 600; }

/* ===== Footer ===== */
footer { border-top: 1px solid var(--line); padding: 30px 0; position: relative; z-index: 1; }
footer .wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); }
footer a { color: var(--heading); font-weight: 600; }