/* Estilo moderno, oscuro por defecto, con modo claro. */
:root {
  --bg: #050505;
  --surface: #0e0e10;
  --text: #f2f2f2;
  --muted: #9a9aa2;
  --line: #2a2a2e;
  --accent: #3b8bff;
  --maxw: 1100px;
}
:root[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #111114;
  --muted: #5d5d66;
  --line: #dcdce0;
  --accent: #0a5fd8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Barra superior */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 18px 24px;
  display: flex; align-items: center; gap: 28px;
}
.brand { color: var(--text); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: 24px; margin-left: auto; flex-wrap: wrap; }
nav a { color: var(--text); font-size: 14px; opacity: .8; }
nav a:hover, nav a.on { opacity: 1; text-decoration: none; }
nav a.on { box-shadow: 0 2px 0 var(--accent); }
.tools { display: flex; align-items: center; gap: 14px; }
.lang { font-size: 13px; color: var(--muted); border: 1px solid var(--line); padding: 3px 9px; border-radius: 4px; }
.lang:hover { color: var(--text); text-decoration: none; }
.theme {
  width: 38px; height: 22px; border-radius: 11px; border: 1.5px solid var(--text);
  background: transparent; position: relative; cursor: pointer; padding: 0;
}
.theme::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%; background: var(--text);
  transition: left .2s;
}
:root[data-theme="light"] .theme::after { left: 17px; }

/* Contenido */
main { max-width: var(--maxw); margin: 0 auto; padding: 56px 24px 80px; }
h1 { font-size: 40px; font-weight: 500; letter-spacing: -0.02em; margin: 0 0 8px; }
.subtitle { color: var(--muted); margin: 0 0 40px; font-size: 18px; }
hr, .rule { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
h2 {
  font-size: 14px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 20px;
}

.hero { display: grid; grid-template-columns: 260px 1fr; gap: 48px; align-items: start; }
.hero img { width: 100%; border-radius: 4px; filter: grayscale(15%); }
.hero p { margin: 0 0 16px; }

.areas { list-style: none; margin: 0; padding: 0; }
.areas li { padding: 22px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 260px 1fr; gap: 48px; }
.areas li:last-child { border-bottom: 1px solid var(--line); }
.areas .k { text-transform: uppercase; font-size: 15px; letter-spacing: .02em; }
.areas .v { color: var(--muted); }

.quote { text-align: right; color: var(--muted); font-style: italic; margin-top: 48px; }

footer { border-top: 1px solid var(--line); }
footer div { max-width: var(--maxw); margin: 0 auto; padding: 24px; color: var(--muted); font-size: 13px; }

/* ---------- Movimiento ---------- */

/* Aparición al hacer scroll: los elementos .reveal suben y se aclaran
   cuando entran en pantalla (ver anim.js). Sin JavaScript se ven normales. */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s ease, transform .8s cubic-bezier(.2,.7,.2,1); }
.js .reveal.visible { opacity: 1; transform: none; }

/* Brillo suave detrás del encabezado, que se desplaza lentamente */
main { position: relative; }
.glow {
  position: absolute; top: -120px; left: 50%; width: 900px; height: 500px; margin-left: -450px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 28%, transparent), transparent);
  filter: blur(40px); opacity: .55; pointer-events: none; z-index: -1;
  animation: drift 14s ease-in-out infinite alternate;
}
:root[data-theme="light"] .glow { opacity: .3; }
@keyframes drift { from { transform: translateX(-120px) scale(1); } to { transform: translateX(120px) scale(1.15); } }

/* Menú: subrayado que crece desde el centro */
nav a { position: relative; }
nav a.on { box-shadow: none; }
nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform .25s ease;
}
nav a:hover::after, nav a.on::after { transform: scaleX(1); }

/* Foto: zoom leve y color al pasar el mouse */
.photo { overflow: hidden; border-radius: 4px; }
.hero .photo img { display: block; transition: transform .6s ease, filter .6s ease; filter: grayscale(60%); }
.hero .photo:hover img { transform: scale(1.04); filter: grayscale(0); }

/* Áreas: la fila se ilumina, aparece una barra de acento y el texto se corre */
.areas li { position: relative; transition: background .3s ease, padding-left .3s ease; }
.areas li::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); transform: scaleY(0); transition: transform .3s ease;
}
.js .areas li.reveal { transition: opacity .8s ease, transform .8s cubic-bezier(.2,.7,.2,1), background .3s ease, padding-left .3s ease; }
.areas li:hover { background: var(--surface); padding-left: 18px; }
html { overflow-x: hidden; } /* asi el clip de body recorta de verdad (no se propaga al viewport) */
body { overflow-x: clip; }
.areas li:hover::before { transform: scaleY(1); }
.areas li .k { transition: color .3s ease; }
.areas li:hover .k { color: var(--accent); }
.areas li .v { transition: color .3s ease; }
.areas li:hover .v { color: var(--text); }

/* Links del texto: subrayado animado */
/* Links del texto: al posarse, el texto brilla y aparece una onda que corre debajo */
main p a:not(.button), main .v a { position: relative; isolation: isolate; transition: color .3s ease, text-shadow .3s ease; }
main p a:not(.button)::after, main .v a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 6px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='6' viewBox='0 0 14 6'%3E%3Cpath d='M0 3 Q3.5 0 7 3 T14 3' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x 0 0 / 14px 6px; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='6' viewBox='0 0 14 6'%3E%3Cpath d='M0 3 Q3.5 0 7 3 T14 3' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x 0 0 / 14px 6px;
  opacity: 0; transform: scaleX(.2); transform-origin: left;
  transition: opacity .25s ease, transform .4s cubic-bezier(.2,.7,.2,1);
  pointer-events: none;
}
main p a:not(.button):hover, main .v a:hover {
  text-decoration: none; color: var(--text);
  text-shadow: 0 0 4px color-mix(in srgb, var(--accent) 90%, transparent), 0 0 12px var(--accent), 0 0 28px color-mix(in srgb, var(--accent) 70%, transparent), 0 0 48px color-mix(in srgb, var(--accent) 40%, transparent);
}
main p a:not(.button):hover::after, main .v a:hover::after {
  opacity: 1; transform: scaleX(1); animation: wave-run .7s linear infinite;
}
@keyframes wave-run { to { -webkit-mask-position: 14px 0; mask-position: 14px 0; } }
@media (prefers-reduced-motion: reduce) { main p a::after, main .v a::after { animation: none !important; } }

/* Fondo de curvas animadas (dibujadas por anim.js), se desvanece hacia abajo */
.waves {
  position: absolute; top: -90px; left: 50%; width: calc(100vw - var(--sbw, 0px)); height: 1300px;
  transform: translateX(-50%); z-index: -1; pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 0%, #000 38%, rgba(0,0,0,.28) 52%, rgba(0,0,0,.18) 85%, transparent);
          mask-image: linear-gradient(#000 0%, #000 38%, rgba(0,0,0,.28) 52%, rgba(0,0,0,.18) 85%, transparent);
}

/* Título letra por letra */
.letters .ch {
  display: inline-block; opacity: 0; transform: translateY(.4em); filter: blur(6px);
  animation: ch-in .7s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes ch-in { to { opacity: 1; transform: none; filter: blur(0); } }

/* Foto con inclinación 3D (el ángulo lo pone anim.js) */
.hero .photo { transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .5s ease, box-shadow .5s ease; will-change: transform; }
.hero .photo.tilting { transition: transform .08s linear, box-shadow .5s ease; box-shadow: 0 20px 50px -20px color-mix(in srgb, var(--accent) 45%, transparent); }

/* Quien prefiere menos movimiento (ajuste del sistema) no ve animaciones */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .letters .ch { opacity: 1; transform: none; filter: none; }
  .waves { display: none; }
}

@media (max-width: 760px) {
  .glow { width: 500px; margin-left: -250px; }
  .top-inner { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  nav { order: 3; width: 100%; margin: 0; gap: 18px; }
  .tools { margin-left: auto; }
  main { padding: 36px 16px 60px; }
  h1 { font-size: 30px; }
  .hero, .areas li { grid-template-columns: 1fr; gap: 20px; }
  .hero img { max-width: 220px; }
  .areas li { gap: 6px; }
}

/* ---------- Piezas del VITA ---------- */
.waves.short { height: 700px; }
.lead { color: var(--muted); max-width: 760px; margin: 0 0 24px; }
.areas .k a { color: var(--text); }
.areas li:hover .k a { color: var(--accent); }
.button {
  display: inline-block; padding: 9px 18px; border: 1px solid var(--text); border-radius: 4px;
  color: var(--text); font-size: 14px; letter-spacing: .04em; text-transform: uppercase;
  transition: background .25s ease, color .25s ease, border-color .25s ease;
}
.button:hover { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; }
main p a.button { background-image: none; }
.pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.pills a {
  display: inline-block; padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); font-size: 15px; transition: border-color .25s ease, color .25s ease, transform .25s ease;
}
.pills a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-2px); }
/* Botones de links: brillo y la misma onda, dentro del botón */
.pills a { position: relative; transition: border-color .25s ease, color .25s ease, transform .25s ease, box-shadow .3s ease, text-shadow .3s ease; }
.pills a::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: 2px; height: 6px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='6' viewBox='0 0 14 6'%3E%3Cpath d='M0 3 Q3.5 0 7 3 T14 3' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x 0 0 / 14px 6px; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='6' viewBox='0 0 14 6'%3E%3Cpath d='M0 3 Q3.5 0 7 3 T14 3' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x 0 0 / 14px 6px;
  opacity: 0; transform: scaleX(.2); transform-origin: left;
  transition: opacity .25s ease, transform .4s cubic-bezier(.2,.7,.2,1);
  pointer-events: none;
}
.pills a:hover {
  color: var(--text);
  text-shadow: 0 0 4px color-mix(in srgb, var(--accent) 90%, transparent), 0 0 12px var(--accent), 0 0 28px color-mix(in srgb, var(--accent) 70%, transparent), 0 0 48px color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.pills a:hover::after { opacity: 1; transform: scaleX(1); animation: wave-run .7s linear infinite; }
@media (prefers-reduced-motion: reduce) { .pills a::after { animation: none !important; } }
/* Nombres de repositorios en minúscula, como en GitHub */
.areas .k.repo { text-transform: none; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 15px; }
/* Evitar doble línea: la lista ya cierra con su borde inferior */
.areas + hr { border: 0; margin: 0 0 56px; }
/* Aire entre el título y el contenido cuando no hay subtítulo */
h1 + h2, h1 + ul { margin-top: 40px; }

/* Filas de áreas cliqueables: el link del título cubre toda la fila */
.areas a.stretch { color: inherit; text-decoration: none; }
.areas a.stretch::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.areas a.stretch:focus-visible { outline: none; }
.areas li:has(a.stretch:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.areas li:has(a.stretch) .v a { position: relative; z-index: 2; }
.areas .go { display: inline-block; margin-left: 8px; opacity: 0; transform: translate(-4px, 4px); transition: opacity .3s ease, transform .3s ease; }
.areas li:hover .go { opacity: 1; transform: none; }
@media (hover: none) { .areas .go { opacity: .6; transform: none; } }

/* Botones de links: la onda recorre el contorno (la dibuja anim.js) en lugar de ir debajo */
.pills a::after { display: none; }
.pills a:hover { border-color: transparent; }
.pills .contorno { position: absolute; left: -7px; top: -7px; overflow: visible; pointer-events: none; opacity: 0; transition: opacity .3s ease; }
.pills .contorno.on { opacity: 1; }
.pills .contorno path { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Links del texto: halo azul difuso detrás de la palabra al posarse */
main p a:not(.button)::before, main .v a::before {
  content: ""; position: absolute; left: -10px; right: -10px; top: -6px; bottom: -6px; z-index: -1;
  border-radius: 999px; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 75%, transparent), color-mix(in srgb, var(--accent) 25%, transparent) 70%, transparent);
  filter: blur(7px); opacity: 0; transform: scale(.6); transition: opacity .3s ease, transform .4s cubic-bezier(.2,.7,.2,1);
}
main p a:not(.button):hover::before, main .v a:hover::before { opacity: 1; transform: scale(1); }

/* Vita: boton del CV con los perfiles de publicaciones al lado, en dos filas */
.cvbar { display: flex; align-items: center; flex-wrap: wrap; gap: 20px 32px; margin: 0 0 48px; }
.cvbar .button { padding: 14px 24px; }
.cvbar .pills { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 12px; }
.cvbar .pills a { text-align: center; display: block; }
@media (max-width: 760px) { .cvbar .pills { grid-template-columns: repeat(2, auto); } }
/* Vita: los perfiles en un solo renglón, separados del botón del CV */
.cvbar { gap: 20px 56px; }
.cvbar .pills { display: flex; flex-wrap: wrap; gap: 12px; }
.cvbar .pills a { display: inline-block; }
/* Vita: los perfiles empiezan en la misma columna que el texto de las filas de abajo */
.cvbar { display: grid; grid-template-columns: 260px 1fr; gap: 20px 48px; align-items: center; }
.cvbar .button { justify-self: start; }
@media (max-width: 760px) { .cvbar { grid-template-columns: 1fr; } }

/* Vita: titulo "Publicaciones" sobre los ovalos; el boton del CV alineado con los ovalos */
.cvbar { align-items: end; }
.cvbar .pubs h2 { margin: 0 0 14px; }
/* Vita: publicaciones a la izquierda (titulo alineado con los demas) y el CV a la derecha */
.cvbar { grid-template-columns: auto auto; justify-content: space-between; }
.cvbar .pubs { order: 1; }
.cvbar .button { order: 2; justify-self: end; }
@media (max-width: 760px) { .cvbar { grid-template-columns: 1fr; } .cvbar .button { justify-self: start; } }
h1 + .cvbar { margin-top: 40px; }
