:root {
  --bg: #0a0a0b;
  --surface: #121214;
  --text: #ededef;
  --muted: #8d9099;
  --line: #222226;
  --accent: #a9bcff;
  --accent-soft: #171b2b;
  --measure: 42rem;
  --wide: 68rem;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

::selection { background: #ededef; color: #0a0a0b; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 0.2em; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 1.5rem; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 0; font-size: 0.9375rem;
}
.top .mark { font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 1.5rem; align-items: center; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--text); }
.top .lang { font-family: var(--mono); font-size: 0.8125rem; border: 1px solid var(--line); padding: 0.15rem 0.5rem; border-radius: 999px; }

/* hero */
.hero { padding: 4.5rem 0 4rem; border-bottom: 1px solid var(--line); }
.hero h1 {
  font-size: clamp(1.625rem, 3.4vw, 2.375rem); line-height: 1.2; letter-spacing: -0.022em;
  font-weight: 600; margin: 0 0 1.25rem; max-width: 30ch;
}
.hero .role { font-family: var(--mono); font-size: 0.875rem; color: var(--muted); margin: 0 0 2rem; }
.hero .lead { font-size: clamp(1.125rem, 2vw, 1.3125rem); line-height: 1.55; max-width: var(--measure); margin: 0 0 2.25rem; color: var(--text); }
.links { display: flex; flex-wrap: wrap; gap: 0.75rem; padding: 0; margin: 0; list-style: none; }
.links a {
  display: inline-block; text-decoration: none; font-size: 0.9375rem;
  padding: 0.55rem 1rem; border: 1px solid var(--line); border-radius: 999px;
}
.links a.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.links a.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.links a:not(.primary):hover { border-color: var(--text); color: var(--text); }

/* sections */
section { padding: 4.5rem 0; border-bottom: 1px solid var(--line); }
.grid { display: grid; grid-template-columns: 13rem 1fr; gap: 2.5rem; }
.label { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 0.35rem 0 0; }
h2 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.02em; font-weight: 600; margin: 0 0 1.25rem; }
h3 { font-size: 1.0625rem; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
p { margin: 0 0 1rem; max-width: var(--measure); }
.muted { color: var(--muted); }

/* now */
.now { display: grid; gap: 1.5rem; }
.now p { margin: 0; }

/* gate feature */
.feature {
  background: var(--surface); border: 1px solid var(--line); border-radius: 1rem;
  padding: 2.25rem; display: grid; gap: 1.25rem;
}
.feature .kicker { font-family: var(--mono); font-size: 0.8125rem; color: var(--accent); margin: 0; }
.feature h2 { margin: 0; font-size: clamp(1.75rem, 3.5vw, 2.25rem); letter-spacing: -0.025em; }
.feature p { margin: 0; }
.feature .links { margin-top: 0.5rem; }
pre, code { font-family: var(--mono); font-size: 0.875rem; }
code { background: var(--surface); border: 1px solid var(--line); border-radius: 0.35rem; padding: 0.05rem 0.35rem; }
pre {
  background: var(--surface); border: 1px solid var(--line); border-radius: 0.75rem;
  padding: 1rem 1.25rem; overflow-x: auto; line-height: 1.6; margin: 0 0 1.25rem; max-width: var(--measure);
}
pre code { background: none; border: 0; padding: 0; }

/* experience */
.jobs { list-style: none; margin: 0; padding: 0; }
.jobs li { display: grid; grid-template-columns: 9.5rem 1fr; gap: 1.5rem; padding: 1.25rem 0; border-top: 1px solid var(--line); }
.jobs li:first-child { border-top: 0; padding-top: 0; }
.jobs .when { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); padding-top: 0.2rem; }
.jobs .org { color: var(--muted); font-weight: 400; }
.jobs p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.9875rem; }

/* skills */
.skills { margin: 0; display: grid; gap: 1rem; }
.skills div { display: grid; grid-template-columns: 11rem 1fr; gap: 1.5rem; }
.skills dt { font-weight: 600; font-size: 0.9875rem; }
.skills dd { margin: 0; color: var(--muted); font-size: 0.9875rem; }

/* contact */
.contact { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.contact li { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; }
.contact span { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); padding-top: 0.15rem; }

footer { padding: 2.5rem 0 3.5rem; font-size: 0.875rem; color: var(--muted); }

/* article */
.article { padding: 4rem 0 5rem; }
.article header { margin-bottom: 3rem; }
.article h1 { font-size: clamp(2.125rem, 5vw, 3.25rem); line-height: 1.08; letter-spacing: -0.03em; font-weight: 600; margin: 0 0 1.25rem; max-width: 22ch; }
.article .meta { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }
.article .body { max-width: var(--measure); }
.article .body h2 { font-size: 1.375rem; margin: 2.75rem 0 0.85rem; }
.article .body ol, .article .body ul { padding-left: 1.25rem; margin: 0 0 1rem; }
.article .body li { margin-bottom: 0.45rem; }
.article .back { display: inline-block; margin-top: 2.5rem; }

@media (max-width: 760px) {
  .wrap { padding: 0 1rem; }
  .top { gap: 1rem; font-size: 0.875rem; }
  .top .mark { white-space: nowrap; }
  .top nav { gap: 0.875rem; }
  .top nav .hide-sm { display: none; }
  /* the hero already links to the experience, so the nav gives up that slot first */
  .top nav a[href$="#experiencia"], .top nav a[href$="#experience"] { display: none; }
  .hero { padding: 3.5rem 0 3rem; }
  section { padding: 3.25rem 0; }
  .grid { grid-template-columns: 1fr; gap: 1rem; }
  .jobs li, .skills div, .contact li { grid-template-columns: 1fr; gap: 0.25rem; }
  .feature { padding: 1.5rem; }
}

@media (max-width: 380px) {
  .top nav a[href$="#contacto"], .top nav a[href$="#contact"] { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  a, .links a { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
}

.article .lead { font-size: 1.1875rem; margin: 0; }

.posts h3 a { text-decoration: none; }
.posts h3 a:hover { text-decoration: underline; }
.now h3 a { text-decoration: none; }
.now h3 a:hover { text-decoration: underline; }
.projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem; }
.projects .kind { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); margin: 0 0 0.35rem; }

/* ── motion ─────────────────────────────────────────────── */

@view-transition { navigation: auto; }
/* the page that leaves rises and blurs away; the next one settles in after it, never on top */
::view-transition-old(root) { animation: vt-out 0.24s cubic-bezier(.4,0,1,1) both; }
::view-transition-new(root) { animation: vt-in 0.5s cubic-bezier(.2,.7,.2,1) 0.12s both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-14px); filter: blur(6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(18px); filter: blur(8px); } }
/* the header and the smoke stay put across pages; the clicked title morphs into the headline */
.top { view-transition-name: top; }
.smoke { view-transition-name: smoke; }
::view-transition-group(top), ::view-transition-group(smoke) { animation: none; }
::view-transition-old(smoke) { display: none; }
::view-transition-new(smoke) { animation: none; }
.article header h1 { view-transition-name: headline; }
::view-transition-group(headline) { animation-duration: 0.6s; animation-timing-function: cubic-bezier(.2,.8,.2,1); }
::view-transition-old(headline), ::view-transition-new(headline) { height: 100%; object-fit: none; object-position: left top; }

.top {
  position: sticky; top: 0; z-index: 10; margin: 0 -1.5rem; padding-left: 1.5rem; padding-right: 1.5rem;
  transition: padding 0.3s ease, background-color 0.3s ease, transform 0.35s ease, border-color 0.3s ease;
  border-bottom: 1px solid transparent;
}
.top.is-scrolled {
  padding-top: 0.9rem; padding-bottom: 0.9rem;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px);
  border-bottom-color: var(--line);
}
.top.is-hidden { transform: translateY(-100%); }
.top nav { position: relative; }
.top nav a.is-active { color: var(--text); }
.nav-bar {
  position: absolute; left: 0; bottom: -0.45rem; height: 1px; width: 0; opacity: 0;
  background: var(--text); pointer-events: none;
  transition: transform 0.35s cubic-bezier(.2,.7,.2,1), width 0.35s cubic-bezier(.2,.7,.2,1), opacity 0.2s ease;
}

/* links: underline that draws in */
.body a:not(.primary):not(.back), .now a, .posts a, .contact a, .muted a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size 0.3s ease, color 0.2s ease;
}
.body a:not(.primary):not(.back):hover, .now a:hover, .posts a:hover, .contact a:hover, .muted a:hover {
  background-size: 0% 1px; background-position: 100% 100%;
}

/* hero background: drifting glow and faint grid, parallax from site.js */
.hero { position: relative; overflow: clip; isolation: isolate; margin: 0 -1.5rem; padding-left: 1.5rem; padding-right: 1.5rem; }
.hero > :not(.hero-bg) { position: relative; will-change: transform, opacity; }
.hero-bg {
  position: absolute; inset: 0 0 -15% 0; z-index: -1; pointer-events: none; will-change: transform;
  -webkit-mask-image: radial-gradient(ellipse 50% 46% at 64% 48%, #000 20%, transparent 72%);
  mask-image: radial-gradient(ellipse 50% 46% at 64% 48%, #000 20%, transparent 72%);
}
.hero-bg .glow {
  position: absolute; inset: 0; --x: 70%; --y: 30%;
  background: radial-gradient(38rem 28rem at var(--x) var(--y), rgba(169,188,255,0.13), transparent 70%),
              radial-gradient(30rem 22rem at 15% 85%, rgba(255,255,255,0.05), transparent 70%);
  transition: background 0.6s ease;
}
.hero-bg .grid-lines {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px; opacity: 0.35;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 60% 35%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 60% 35%, #000 20%, transparent 75%);
}

/* smoke: fixed WebGL layer behind the whole page, from site.js; it fades in */
.smoke {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: -1;
  pointer-events: none; opacity: 0; animation: smoke-in 2.4s ease 0.3s forwards;
}
.has-smoke .hero-bg .glow { opacity: 0.4; }
@keyframes smoke-in { to { opacity: var(--smoke, 1); } }
@media (max-width: 760px) { .smoke { --smoke: 0.6; } }


/* first paint of the hero */
.js .hero .role, .js .hero h1, .js .hero .lead, .js .hero .links { animation: rise 0.8s cubic-bezier(.2,.7,.2,1) both; }
.js .hero h1 { animation-delay: 0.08s; }
.js .hero .lead { animation-delay: 0.16s; }
.js .hero .links { animation-delay: 0.24s; }
.js .article header > * { animation: rise 0.7s cubic-bezier(.2,.7,.2,1) both; }
/* headlines reveal word by word instead; on a morph the headline arrives already in place */
.js .hero h1.words, .js .article header h1.words, .vt .article header h1 { animation: none; }
.words .w { display: inline-block; animation: word 0.9s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i) * 38ms + 60ms); }
@keyframes word { from { opacity: 0; filter: blur(12px); transform: translateY(0.3em); } }
/* after the first page the smoke is already there */
.seen .smoke { animation: none; opacity: var(--smoke, 1); }
.js .article header > :nth-child(2) { animation-delay: 0.08s; }
.js .article header > :nth-child(3) { animation-delay: 0.16s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(.2,.7,.2,1); }
.reveal.is-in { opacity: 1; transform: none; }

.links a { transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease; }
.links a:hover { transform: translateY(-1px); }

@media (max-width: 760px) {
  .top, .hero { margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; }
  .hero-bg .grid-lines { background-size: 44px 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  @view-transition { navigation: none; }
}

/* diagrams */
.diagram { margin: 2rem 0 2.25rem; max-width: 34rem; }
.diagram svg { width: 100%; height: auto; display: block; overflow: visible; }
.diagram figcaption { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); margin-top: 0.85rem; line-height: 1.5; }
.dg-box { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.dg-box.dg-accent { stroke: var(--accent); }
.dg-num { font: 500 13px var(--mono); fill: var(--accent); }
.dg-title { font: 600 15px var(--sans); fill: var(--text); }
.dg-text { font: 400 13.5px var(--sans); fill: var(--muted); }
.dg-tag { font: 500 13px var(--mono); fill: var(--text); letter-spacing: 0.02em; }
.dg-center { font: 600 17px var(--sans); fill: var(--text); text-anchor: middle; }
.dg-line { stroke: var(--muted); stroke-width: 1.25; fill: none; opacity: 0.7; }
.dg-arrowhead { fill: var(--muted); }
.dg-arc { stroke: var(--text); stroke-width: 1.5; opacity: 0.55; }
.dg-rail { stroke: var(--line); stroke-width: 1.5; }
.dg-dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.js .diagram.reveal .dg-line { stroke-dasharray: 600; stroke-dashoffset: 600; transition: stroke-dashoffset 1.4s ease 0.2s; }
.js .diagram.reveal.is-in .dg-line { stroke-dashoffset: 0; }

/* raw log next to its translation */
.log-pair { margin: 2rem 0 2.25rem; display: grid; gap: 0.75rem; max-width: var(--measure); }
.log-pair > div { border: 1px solid var(--line); border-radius: 0.85rem; padding: 1rem 1.15rem; background: var(--surface); }
.log-pair pre { margin: 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: 0.8125rem; white-space: pre-wrap; }
.log-pair .log-read { border-color: var(--accent); }
.log-pair p { margin: 0 0 0.4rem; font-size: 0.9375rem; color: var(--muted); }
.log-pair .log-label { font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.log-pair .log-title { color: var(--text); font-weight: 600; font-size: 1rem; }
.log-pair .log-do span { color: var(--accent); font-weight: 500; margin-right: 0.35rem; }
.log-pair figcaption { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }

/* tags: on each post, in the blog index and on each topic page */
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tags a {
  display: inline-block; font-family: var(--mono); font-size: 0.75rem; color: var(--muted);
  text-decoration: none; background: none; padding: 0.15rem 0.6rem;
  border: 1px solid var(--line); border-radius: 999px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.tags a:hover, .tags a[aria-current="page"] { color: var(--text); border-color: var(--text); }
.article header .tags { margin-top: 1.25rem; }
.body > .tags { margin-bottom: 2rem; }
.posts .tags { margin-top: 0.6rem; }
/* the tag list sits inside post lists and article bodies; it keeps none of their list styles */
.article .body .tags, .jobs .tags { padding-left: 0; }
.article .body .tags li, .jobs .tags li { display: block; margin: 0; padding: 0; border: 0; }
.article .body .tags li a, .posts .tags li a, .article header .tags li a { background-image: none; }

/* reveal from the side the element comes in */
.reveal[data-from="top"] { transform: translateY(-28px); }
.reveal { transform: translateY(28px); }
.reveal.is-in { transform: none; }
