:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #475569;
  --accent: #4f46e5;
  --accent-2: #0ea5e9;
  --label: #0369a1;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Fondo suave */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(700px circle at 10% 0%, rgba(79, 70, 229, 0.10), transparent 60%),
    radial-gradient(600px circle at 95% 15%, rgba(14, 165, 233, 0.12), transparent 60%);
}

/* Cabecera */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem clamp(1rem, 5vw, 3rem);
  background: rgba(248, 250, 252, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 800; font-size: 1.3rem; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
nav { display: flex; align-items: center; gap: 1.5rem; }
nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; font-weight: 500; transition: color 0.2s; }
nav a:hover { color: var(--text); }
.nav-cta {
  color: var(--text);
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.nav-cta:hover { border-color: var(--accent); color: var(--accent); }

main { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; padding: 0 1.5rem; }
section { padding: 5rem 0; }

/* Hero */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3rem;
  align-items: center;
  padding-top: 5rem;
  padding-bottom: 4rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2); }
h1 { font-size: clamp(2.3rem, 6vw, 4rem); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 1.25rem; font-weight: 800; }
.gradient {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { font-size: clamp(1.05rem, 2.2vw, 1.25rem); color: var(--muted); max-width: 36rem; margin: 0; }

.hero-photo { position: relative; }
.hero-photo::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  opacity: 0.9;
}
.hero-photo img {
  position: relative;
  display: block;
  width: clamp(180px, 26vw, 280px);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 6px solid var(--bg);
  box-shadow: var(--shadow);
}

.actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2.25rem; }
.btn {
  display: inline-block;
  padding: 0.85rem 1.6rem;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.3);
}
.btn-ghost { color: var(--text); border: 1px solid var(--border); background: var(--surface); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-light { color: var(--accent); background: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2); }

/* Títulos de sección */
.section-label { color: var(--label); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 0.5rem; }
h2 { font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -0.02em; margin: 0 0 2rem; }

/* Disponibilidad */
.availability {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3.5rem;
  padding: 1.1rem 1.4rem;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius);
  background: rgba(16, 185, 129, 0.08);
}
.availability p { margin: 0; flex: 1; color: var(--muted); }
.availability strong { color: var(--text); }
.availability .link { white-space: nowrap; }

/* Proyectos */
.projects { display: flex; flex-direction: column; gap: 5rem; }
.project { display: grid; grid-template-columns: 1.4fr 1fr; gap: 2.5rem; align-items: center; }
.project.reverse { grid-template-columns: 1fr 1.4fr; }
.project.reverse .browser { order: 2; }

.browser {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--ty, 0px));
  transition: transform 0.2s ease-out, box-shadow 0.35s ease;
}
.browser:hover { --ty: -6px; box-shadow: 0 30px 70px rgba(79, 70, 229, 0.22); }
.browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.65rem 0.9rem;
  background: #eef2f7;
  border-bottom: 1px solid var(--border);
}
.browser-bar i { width: 10px; height: 10px; border-radius: 50%; }
.browser-bar i:nth-child(1) { background: #ff5f57; }
.browser-bar i:nth-child(2) { background: #febc2e; }
.browser-bar i:nth-child(3) { background: #28c840; }
.browser-bar span {
  margin-left: 0.75rem;
  padding: 0.15rem 0.8rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: #fff;
  border-radius: 6px;
}
.browser img { display: block; width: 100%; height: auto; }

.tag { color: var(--label); font-size: 0.85rem; font-weight: 600; margin: 0 0 0.5rem; }
.project-info h3 { font-size: 1.75rem; margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.project-info p { color: var(--muted); margin: 0 0 1.25rem; }

.link { color: var(--accent); font-weight: 600; text-decoration: none; }
.link span { display: inline-block; transition: transform 0.2s; }
.link:hover span { transform: translateX(5px); }

/* Sobre mí */
.about { color: var(--muted); max-width: 40rem; font-size: 1.1rem; margin: 0 0 1.5rem; }
.skills { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.skills li {
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.subtitle { font-size: 1.1rem; margin: 2.5rem 0 1rem; letter-spacing: -0.01em; }
.facts { list-style: none; padding: 0; margin: 0; color: var(--muted); }
.facts li { padding: 0.35rem 0 0.35rem 1.25rem; position: relative; }
.facts li::before { content: ""; position: absolute; left: 0; top: 0.95rem; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.facts strong { color: var(--text); }

/* Línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.75rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding-bottom: 2.25rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-1.75rem - 6px);
  top: 0.45rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px var(--bg);
}
.period { font-size: 0.8rem; font-weight: 700; color: var(--label); letter-spacing: 0.04em; }
.timeline h3 { font-size: 1.15rem; margin: 0.15rem 0 0.1rem; letter-spacing: -0.01em; }
.company { color: var(--text); font-size: 0.95rem; font-weight: 500; margin: 0 0 0.5rem; }
.timeline p:not(.company) { color: var(--muted); margin: 0; max-width: 42rem; }

/* Contacto */
.contact {
  text-align: center;
  margin-bottom: 3rem;
  padding: 4rem 1.5rem;
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 25px 60px rgba(79, 70, 229, 0.3);
}
.contact h2 { margin-bottom: 0.75rem; }
.contact p { color: rgba(255, 255, 255, 0.92); margin: 0 0 2rem; }

.footer { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 2rem 1rem 3rem; }

/* Aviso de cookies */
.link-btn { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
.link-btn:hover { color: var(--accent); }
.cookie-banner {
  position: fixed; inset-inline: 1rem; inset-block-end: 1rem; z-index: 50;
  display: grid; gap: 1rem; align-items: center; max-width: 44rem; margin-inline: auto; padding: 1.1rem 1.25rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 0.9rem; line-height: 1.5;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner h2 { margin: 0 0 0.25rem; font-size: 1rem; }
.cookie-banner p { margin: 0; color: var(--muted); }
.cookie-actions { display: flex; gap: 0.75rem; }
/* Aceptar y rechazar tienen el mismo aspecto: elegir debe ser igual de fácil. */
.cookie-btn {
  flex: 1; min-height: 2.75rem; padding-inline: 1.25rem; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--accent); background: transparent; color: var(--accent); font: inherit; font-weight: 700;
}
.cookie-btn:hover { background: rgba(79, 70, 229, 0.08); }
.cookie-btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
@media (min-width: 40rem) {
  .cookie-banner { grid-template-columns: 1fr auto; }
  .cookie-btn { flex: none; }
}

/* Barra de progreso de lectura */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; pointer-events: none; }
.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(var(--p, 0));
  transform-origin: left;
}

/* Menú: sección activa */
nav a.active { color: var(--accent); }
.nav-cta.active { border-color: var(--accent); }

/* Red neuronal de fondo (portada) */
#neural {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  z-index: 0;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}

/* Dibujos abstractos flotantes */
.decor { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.decor-item { position: absolute; transition: transform 0.25s ease-out; will-change: transform; }
.float { display: block; animation: float 7s ease-in-out infinite; }
.decor-item:nth-child(2) .float { animation-duration: 9s; animation-delay: -2s; }
.decor-item:nth-child(3) .float { animation-duration: 8s; animation-delay: -4s; }
.decor-item:nth-child(4) .float { animation-duration: 10s; animation-delay: -1s; }
.decor-item:nth-child(5) .float { animation-duration: 11s; animation-delay: -5s; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-14px) rotate(3deg); } }
.sym {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-weight: 700;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0.55;
}
.d1 { top: 4%; left: 46%; }
.d2 { top: 6%; right: 1%; }
.d3 { top: 36%; left: 52%; }
.d4 { top: 44%; right: 4%; opacity: 0.9; }
.d5 { top: 8%; left: 60%; opacity: 0.8; }

/* Ventana de código */
.code-window {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  width: min(100%, 760px);
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0f172a;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35);
}
.code-window .browser-bar { background: #1e293b; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.code-window .browser-bar span { background: rgba(255, 255, 255, 0.08); color: #cbd5e1; }
.code-window pre {
  margin: 0;
  padding: 1.1rem 1.25rem 1.3rem;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  color: #e2e8f0;
  tab-size: 4;
}
.code-window .k { color: #c4b5fd; }
.code-window .t { color: #67e8f9; }
.code-window .s { color: #86efac; }
.code-window .c { color: #94a3b8; font-style: italic; }
.code-window .f { color: #fcd34d; }
.caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: #67e8f9;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.code-replay {
  margin-left: auto;
  padding: 0.15rem 0.7rem;
  font: inherit;
  font-size: 0.75rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.code-replay:hover { background: rgba(255, 255, 255, 0.16); }
.code-replay[hidden] { display: none; }

/* Estadísticas */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding: 1rem 0 2rem; }
.stat {
  padding: 1.4rem 1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.stat strong {
  display: block;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat span { color: var(--muted); font-size: 0.9rem; font-weight: 500; }

/* Etiquetas de tecnologías */
.skills li { transition: transform 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s; cursor: default; }
.skills li:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--accent); box-shadow: 0 8px 20px rgba(79, 70, 229, 0.15); }

/* Animación al hacer scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* Móvil */
@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; gap: 2rem; padding-top: 3rem; }
  .hero-photo { order: -1; width: fit-content; }
  .project, .project.reverse { grid-template-columns: 1fr; gap: 1.5rem; }
  .project.reverse .browser { order: 0; }
  .availability { flex-direction: column; align-items: flex-start; }
  section { padding: 3.5rem 0; }
  nav { gap: 0.9rem; }
  nav a { font-size: 0.85rem; }
}

@media (max-width: 800px) {
  .d1, .d3, .d5 { display: none; }
  .d2 { top: 2%; right: 2%; }
  .d4 { top: 8%; right: 4%; }
  .stats { gap: 0.6rem; }
  .stat { padding: 1rem 0.5rem; }
}

@media (max-width: 560px) {
  .code-window pre { font-size: 0.72rem; }
  .header { justify-content: center; padding: 0.75rem 0.75rem; }
  .logo { display: none; }
  nav { gap: 0.25rem; }
  nav a { white-space: nowrap; font-size: 0.82rem; padding: 0.4rem 0.55rem; }
  .nav-cta { padding: 0.4rem 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .browser, .btn, .link span, .skills li, .decor-item { transition: none; }
  .float, .caret { animation: none; }
}
