:root {
  /* Oscuro por defecto; el claro se activa con el botón */
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --muted: #8a8a8a;
  --line: #262626;
  --card: #111111;
  --sans: "Inter Tight", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 960px;
}
:root[data-theme="light"] {
  --bg: #fafafa;
  --fg: #0a0a0a;
  --muted: #737373;
  --line: #e5e5e5;
  --card: #ffffff;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

::selection { background: var(--fg); color: var(--bg); }

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

.mono { font-family: var(--mono); font-size: .85em; letter-spacing: -.01em; }
.dim { color: var(--muted); }

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 2rem;
  max-width: var(--max); margin: 0 auto;
  padding: 1.25rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.nav__logo { font-weight: 500; }
.nav__links { display: flex; gap: 1.5rem; margin-left: auto; }
.nav__links a { color: var(--muted); transition: color .2s; }
.nav__links a:hover, .nav__links a.active { color: var(--fg); }
.nav__actions { display: flex; align-items: center; gap: .75rem; }
.lang-toggle {
  display: flex; gap: .3rem; align-items: center;
  background: none; border: 1px solid var(--line); color: var(--muted);
  height: 2rem; padding: 0 .7rem; border-radius: 999px; cursor: pointer;
  font-size: .8rem; transition: border-color .2s;
}
.lang-toggle:hover { border-color: var(--fg); }
.lang-toggle .active { color: var(--fg); }
.theme-toggle {
  background: none; border: 1px solid var(--line); color: var(--fg);
  width: 2rem; height: 2rem; border-radius: 50%; cursor: pointer;
  font-size: 1rem; transition: transform .4s, border-color .2s;
}
.theme-toggle:hover { transform: rotate(180deg); border-color: var(--fg); }

/* ---------- LAYOUT ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; }

/* ---------- HERO ---------- */
.hero {
  min-height: calc(100vh - 80px);
  display: flex; flex-direction: column; justify-content: center;
  padding: 4rem 0 6rem;
}
.hero__prompt { margin-bottom: 1rem; }

.hero__name {
  font-size: clamp(3.2rem, 11vw, 8.5rem);
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  user-select: none;
  min-height: 1.1em;
}
.hero__name::after {
  content: "";
  display: inline-block;
  width: .07em; height: .8em;
  margin-left: .06em;
  background: var(--fg);
  vertical-align: -.02em;
  animation: blink 1.1s steps(1) infinite;
}

/* Cada letra puede colapsar a ancho 0 */
.ch {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  max-width: 1em;
  transition: max-width .55s cubic-bezier(.7, 0, .2, 1), opacity .35s;
}
.ch.add { max-width: 0; opacity: 0; }
.ch.swap { transition: max-width .55s, opacity .2s; }

/* Estado "handle": José Álvarez -> jxlvz */
.hero__name.is-handle .ch.drop { max-width: 0; opacity: 0; }
.hero__name.is-handle .ch.add { max-width: 1em; opacity: 1; }

.hero__alias {
  display: flex; align-items: center; gap: .75rem;
  margin-top: 1.5rem; font-size: 1rem;
}
.alias { transition: color .3s, opacity .3s; }
.alias--handle { border-bottom: 1px solid var(--line); }
.alias--handle:hover { border-color: var(--fg); }
/* Resalta cuál de las dos identidades está "en pantalla" */
.hero__name:not(.is-handle) ~ .hero__alias .alias--handle,
.hero__name.is-handle ~ .hero__alias .alias--name { color: var(--muted); }

.hero__role {
  margin-top: 2.5rem;
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -.02em;
  max-width: 32ch;
}
.hero__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  margin-top: 2rem;
}
.dot {
  display: inline-block; width: .5rem; height: .5rem; border-radius: 50%;
  background: var(--fg); margin-right: .35rem;
  animation: pulse 2s infinite;
}

/* ---------- SECTIONS ---------- */
.section {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  padding: 5rem 0;
  border-top: 1px solid var(--line);
}
.section__title { font-weight: 400; position: sticky; top: 90px; align-self: start; }
.section__title .dim { margin-right: .5rem; }

.prose p + p { margin-top: 1rem; }
.prose p { color: var(--muted); }
.lead { font-size: 1.5rem; line-height: 1.35; letter-spacing: -.02em; color: var(--fg) !important; margin-bottom: 1.5rem; }
.lead strong { font-weight: 600; }

/* Experiencia */
.entry__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.entry h3 { font-size: 1.35rem; font-weight: 600; letter-spacing: -.02em; }
.entry__org { margin: .25rem 0 1.5rem; }
.entry__list li {
  position: relative; padding-left: 1.5rem; color: var(--muted);
}
.entry__list li + li { margin-top: .6rem; }
.entry__list li::before { content: "→"; position: absolute; left: 0; color: var(--fg); }

.entry + .entry { margin-top: 3.5rem; }
.entry__title { font-size: 1.05rem; font-weight: 600; }
.entry__title .dim { font-weight: 400; }
.entry__summary { color: var(--muted); margin: .4rem 0 1.75rem; }
.entry:last-child .entry__summary { margin-bottom: 0; }
.role__project { font-weight: 400; font-size: .8rem; color: var(--fg); margin-bottom: .6rem; }
.entry h3 .dim { font-weight: 400; }
.role { position: relative; padding-left: 1.25rem; border-left: 1px solid var(--line); }
.role + .role { margin-top: 1.75rem; }
.role::before {
  content: ""; position: absolute; left: -4px; top: .55rem;
  width: 7px; height: 7px; border-radius: 50%; background: var(--fg);
}
.role__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.role h4 { font-size: 1.05rem; font-weight: 600; }
.role h4 .dim { font-weight: 400; }
.role__note { color: var(--muted); }

/* Formación / idiomas */
.edu h3 { font-size: 1.2rem; font-weight: 600; letter-spacing: -.01em; }
.langs { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 1.75rem; }

/* Aptitudes */
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2rem 1.5rem; }
.skills__group h3 { font-weight: 400; margin-bottom: .75rem; }
.tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.tags li {
  font-size: .9rem; padding: .3rem .75rem;
  border: 1px solid var(--line); border-radius: 999px;
  transition: background .2s, color .2s, border-color .2s;
}
.tags li:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* Proyectos */
.projects { border-top: 1px solid var(--line); }
.projects > li { border-bottom: 1px solid var(--line); }
.project {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 1.25rem; align-items: start;
  padding: 1.5rem .5rem;
  transition: background .25s, padding .25s;
}
/* Se desplaza sin cambiar el ancho del texto (evita saltos de línea) */
a.project:hover { background: var(--card); padding-left: 1rem; padding-right: 0; }
a.project:hover .project__icon { transform: rotate(-6deg) scale(1.05); }
a.project:hover .project__arrow { transform: translate(3px, -3px); color: var(--fg); }
.project__icon {
  width: 44px; height: 44px; padding: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  fill: none; stroke: var(--fg); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round;
  transition: transform .3s;
}
.project__icon .fill { fill: var(--fg); }
.project--wip .project__icon { border-style: dashed; }
.project__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.project h3 { font-size: 1.15rem; font-weight: 600; letter-spacing: -.02em; }
.project p { color: var(--muted); font-size: .95rem; margin-top: .2rem; }
.project__stack { margin-top: .6rem !important; font-size: .75rem !important; }
.project__arrow { color: var(--muted); padding-top: .2rem; transition: transform .25s, color .25s; }
.progress { display: flex; align-items: center; gap: .75rem; margin-top: .7rem; font-size: .75rem; }
.progress__bar { width: 120px; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress__bar span { display: block; height: 100%; background: var(--fg); }

/* Certificaciones */
.certs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; }
.cert {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 2rem 1.25rem 1.5rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  transition: border-color .25s, transform .25s;
}
a.cert:hover { border-color: var(--fg); transform: translateY(-3px); }
a.cert:hover .card__arrow { transform: translate(3px, -3px); }
.cert .card__arrow { position: absolute; top: 1rem; right: 1.1rem; transition: transform .25s; }
/* Logo en monocromo: gris en reposo, pleno al pasar el ratón; se invierte en modo oscuro */
.cert__logo {
  width: 96px; height: 96px; object-fit: contain; margin-bottom: 1.25rem;
  filter: grayscale(1) contrast(1.2); opacity: .85; transition: opacity .25s;
}
a.cert:hover .cert__logo { opacity: 1; }
:root:not([data-theme="light"]) .cert__logo { filter: grayscale(1) invert(1); }
.cert h3 { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; margin-bottom: .4rem; }
.cert p { font-size: .75rem; }
.cert__meta { margin-top: .15rem; }
.next { margin-top: 1.25rem; }

/* Contacto */
.contact__big { font-size: clamp(2.5rem, 7vw, 4.5rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; margin-bottom: 2rem; }
.contact__links li { border-bottom: 1px solid var(--line); }
.contact__links a {
  display: flex; justify-content: space-between;
  padding: 1rem 0; font-size: 1.05rem; transition: padding .25s;
}
.contact__links a:hover { padding-left: .75rem; }

/* Footer */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  max-width: var(--max); margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  border-top: 1px solid var(--line);
}

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s, transform .7s; }
.reveal.visible { opacity: 1; transform: none; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 760px) {
  .nav__links { display: none; }
  .nav { justify-content: space-between; }
  .section { grid-template-columns: 1fr; gap: 1.5rem; padding: 3.5rem 0; }
  .section__title { position: static; }
  .hero { min-height: auto; padding: 5rem 0 4rem; }
  .project { grid-template-columns: 36px 1fr; gap: 1rem; }
  .project__icon { width: 36px; height: 36px; padding: 4px; }
  .project__arrow { display: none; }
}

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