/* ============ Tokens ============ */
:root {
  --bg: #f6f7f4;
  --bg-alt: #eef0ea;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #526070;
  --line: #dfe3da;
  --accent: #0d7a5f;
  --accent-ink: #ffffff;
  --accent-soft: #d9f0e7;
  --grid: rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', var(--font);
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --bg-alt: #0e1729; --surface: #121c30; --text: #e6edf6; --muted: #93a1b5;
    --line: #22304a; --accent: #34d399; --accent-ink: #062a1f; --accent-soft: rgba(52, 211, 153, .12);
    --grid: rgba(148, 163, 184, 0.06); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --bg-alt: #0e1729; --surface: #121c30; --text: #e6edf6; --muted: #93a1b5;
  --line: #22304a; --accent: #34d399; --accent-ink: #062a1f; --accent-soft: rgba(52, 211, 153, .12);
  --grid: rgba(148, 163, 184, 0.06); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.65 var(--font); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ============ Botones ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: 600 15px var(--font); text-decoration: none; cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.07); }
.btn--ghost { background: transparent; }
.btn[disabled] { opacity: .6; cursor: wait; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }

/* ============ Barra superior ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar__inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.brand__mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--text); color: var(--bg); font: 700 13px var(--display);
}
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 15px; font-weight: 500; }
.nav a:hover, .nav a.is-active { color: var(--text); background: var(--bg-alt); }
.nav a.nav__cta { color: var(--accent); }
.topbar__tools { display: flex; gap: 8px; }
.menu-btn { display: none; }
:root .i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }

/* ============ Hero ============ */
.hero {
  position: relative; padding: 72px 0 48px;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(#000 70%, transparent);
  -webkit-mask-image: linear-gradient(#000 70%, transparent);
}
.hero__grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; margin-bottom: 20px;
}
.pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.hero__name { font-size: clamp(2.3rem, 5.5vw, 4rem); font-weight: 700; }
.hero__headline { margin-top: 14px; color: var(--accent); font-size: clamp(.85rem, 1.6vw, 1rem); }
.hero__tagline { margin-top: 18px; font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--muted); max-width: 40ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.socials { display: flex; gap: 8px; list-style: none; padding: 0; margin: 24px 0 0; }
.socials a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.socials a:hover { color: var(--accent); border-color: var(--accent); }

.hero__media { position: relative; justify-self: center; width: min(340px, 100%); }
.avatar {
  aspect-ratio: 1; border-radius: 28px; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 40%, var(--text)) 100%);
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.avatar span { font: 700 clamp(3.5rem, 9vw, 5.5rem) var(--display); color: var(--accent-ink); letter-spacing: -0.04em; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.ledger {
  position: absolute; left: -28px; bottom: -22px; padding: 12px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 12.5px; line-height: 1.7; color: var(--text);
}
.ledger span { color: var(--accent); font-weight: 500; }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); margin: 64px 0 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.stats > div { padding: 22px 24px; border-left: 1px solid var(--line); }
.stats > div:first-child { border-left: 0; }
.stats dt { font: 700 clamp(1.7rem, 3vw, 2.2rem) var(--display); color: var(--text); }
.stats dd { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ============ Secciones ============ */
.section { padding: 88px 0; }
.section--alt { background: var(--bg-alt); }
.section__head { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: baseline; margin-bottom: 36px; }
.section__num { color: var(--accent); font-size: 14px; }
.section__head h2 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); }
.section__lead { grid-column: 2; margin-top: 8px; color: var(--muted); }
.sub { font-size: 1.15rem; margin-bottom: 16px; }

/* Sobre mí */
.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 48px; }
.about__text p + p { margin-top: 16px; }
.about__text { font-size: 1.08rem; }
.about__facts dl { margin: 0; display: grid; gap: 14px; }
.about__facts div { padding: 16px 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.about__facts dt { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.about__facts dd { margin: 4px 0 0; font-weight: 500; }

/* Proyectos */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.project {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .2s, border-color .2s;
}
.project:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.project--featured { grid-column: span 2; display: grid; grid-template-columns: 1.15fr 1fr; }
.project__media { aspect-ratio: 16 / 10; background: var(--bg-alt); position: relative; overflow: hidden; }
.project--featured .project__media { aspect-ratio: auto; min-height: 280px; }
.project__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.project:hover .project__media img { transform: scale(1.03); }
.project__placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  background:
    radial-gradient(circle at 20% 20%, var(--accent-soft), transparent 60%),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  font: 700 clamp(1.3rem, 3vw, 1.8rem) var(--display); color: var(--accent);
}
.project__body { padding: 24px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.project__badge { align-self: flex-start; font: 500 11.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.project h3 { font-size: 1.3rem; }
.project__summary { color: var(--muted); }
.project ul.points { margin: 0; padding-left: 18px; color: var(--muted); font-size: 15px; }
.project ul.points li + li { margin-top: 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tags li { font: 500 12px var(--mono); padding: 4px 9px; border-radius: 6px; background: var(--bg-alt); border: 1px solid var(--line); color: var(--text); }
.project__links { display: flex; gap: 10px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.project__links .btn { padding: 8px 14px; font-size: 14px; }

/* Experiencia */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.job { position: relative; padding: 0 0 40px 40px; }
.job:last-child { padding-bottom: 0; }
.job::before {
  content: ''; position: absolute; left: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.job__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; align-items: baseline; }
.job__company { font-size: 1.25rem; }
.job__period { font: 500 13px var(--mono); color: var(--muted); }
.job__role { color: var(--accent); font-weight: 500; margin-top: 2px; }
.job ul { margin: 12px 0 0; padding-left: 18px; color: var(--muted); }
.job li + li { margin-top: 6px; }

/* Habilidades */
.skills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.skill { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.skill__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; }
.skill__icon svg { width: 20px; height: 20px; }
.skill h3 { font-size: 1.05rem; margin-bottom: 10px; }
.skill ul { list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: 15px; }
.skill li { padding: 5px 0; border-top: 1px dashed var(--line); }
.skill li:first-child { border-top: 0; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 56px; }
.certs, .edu { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.certs li, .edu li {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.certs strong, .edu strong { font-weight: 600; display: block; }
.certs small, .edu small { color: var(--muted); font-size: 14px; }
.certs .year, .edu .year { font: 500 13px var(--mono); color: var(--accent); white-space: nowrap; }
.certs a { text-decoration: none; }
.certs a:hover strong { color: var(--accent); }

/* Contacto */
.contact { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }
.contact__lead { color: var(--muted); font-size: 1.08rem; max-width: 42ch; }
.contact__links { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.contact__links a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none; overflow-wrap: anywhere;
}
.contact__links a:hover { border-color: var(--accent); }
.contact__links svg { color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form { padding: 24px; display: grid; gap: 16px; }
.form label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.form input, .form textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 400 15px var(--font); resize: vertical;
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form .btn { justify-self: start; }
.form__status { font-size: 14px; min-height: 1.4em; }
.form__status.ok { color: var(--accent); }
.form__status.err { color: #dc2626; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Footer */
.footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 14px; }
.footer__inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* Animación al aparecer */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .pill__dot { animation: none; }
  .project, .project__media img, .btn { transition: none; }
}

/* ============ Responsive ============ */
@media (max-width: 960px) {
  .skills { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats > div:nth-child(3) { border-left: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .project--featured { grid-template-columns: 1fr; }
  .project--featured .project__media { min-height: 0; aspect-ratio: 16 / 9; }
}
@media (max-width: 820px) {
  .menu-btn { display: inline-grid; }
  .nav {
    position: fixed; inset: 64px 0 auto 0; flex-direction: column; gap: 0; padding: 8px 16px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line); display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px; }
  .topbar__tools { margin-left: auto; }
  .hero { padding-top: 40px; }
  .hero__grid, .about, .contact, .split { grid-template-columns: 1fr; gap: 32px; }
  .hero__media { order: -1; width: min(150px, 50%); justify-self: start; }
  .avatar { border-radius: 22px; }
  .avatar span { font-size: 3rem; }
  .ledger { display: none; }
  .projects { grid-template-columns: 1fr; }
  .project--featured { grid-column: auto; }
  .section { padding: 64px 0; }
}
@media (max-width: 520px) {
  .skills { grid-template-columns: 1fr; }
  .stats > div { padding: 16px; }
  .brand__name { display: none; }
  .hero__actions .btn { flex: 1 1 auto; justify-content: center; }
}
