:root {
  --bg: #000;
  --text: #a6a6a6;                      /* texto corrido */
  --strong: #f2f2f2;                    /* títulos y énfasis */
  --muted: #6e6e6e;                     /* fechas y datos secundarios */
  --line-c: #262626;                    /* líneas y bordes */
  --card: rgba(255, 255, 255, .045);    /* fondo de tarjeta al pasar el ratón */
  --glyph: #fff;                        /* letra ya resuelta */
  --scramble: rgba(255, 255, 255, .45); /* letra que aún cambia */
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", "Menlo", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --logo-size: 1.15rem;                 /* tamaño del texto ya acomodado arriba de la columna */
  --rain-size: 14px;                    /* letra de la lluvia (semicírculo desactivado) */
  --line: 17px;                         /* alto de cada fila de la lluvia (matrix.js lo lee) */
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: #fff; color: #000; }
a { color: var(--strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .2em; }
a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 3px; }
strong { color: var(--strong); font-weight: 500; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: #fff; color: #000; padding: .4rem .8rem; }

/* Luz tenue que sigue al cursor (site.js mueve --x y --y) */
.spotlight {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(520px circle at var(--x, -999px) var(--y, -999px), rgba(255, 255, 255, .06), transparent 70%);
}

/* ---------- Dos columnas: izquierda fija, derecha con scroll ---------- */
.layout {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 64px);
}
@media (min-width: 1024px) {
  .layout { display: flex; gap: 64px; justify-content: space-between; }
  .side {
    position: sticky;
    top: 0;
    width: 46%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 96px 0;
  }
  .content { width: 52%; padding: 96px 0; }
}
.side { padding-top: 64px; }

/* ---------- Columna izquierda ---------- */
.name {
  margin: 1.4rem 0 0;
  color: var(--strong);
  font: 700 clamp(2.4rem, 5vw, 3.2rem)/1.05 var(--sans);
  letter-spacing: -.025em;
}
.role { margin: .6rem 0 0; color: var(--strong); font-size: 1.2rem; font-weight: 500; }
.tagline { margin: 1rem 0 0; max-width: 22rem; }

.nav { display: none; }
@media (min-width: 1024px) {
  .nav { display: block; margin-top: 4rem; }
  .nav ul { list-style: none; margin: 0; padding: 0; }
  .nav a {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    padding: .55rem 0;
    color: var(--muted);
    font: 600 .8rem/1 var(--mono);
    letter-spacing: .04em;
    text-decoration: none;
    transition: color .2s;
  }
  /* La raya crece en la sección activa o al pasar el ratón */
  .nav a::before {
    content: "";
    width: 2rem;
    height: 1px;
    background: currentColor;
    transition: width .25s ease;
  }
  .nav a:hover, .nav a.active { color: var(--strong); }
  .nav a:hover::before, .nav a.active::before { width: 4rem; }
}

.links {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.4rem;
  font: 400 .85rem var(--mono);
}
.links a { color: var(--text); }
.links a:hover { color: var(--strong); }

/* ---------- Columna derecha ---------- */
.content { padding: 64px 0 48px; }
.section { margin-bottom: 6rem; scroll-margin-top: 96px; }
.section p { margin: 0 0 1rem; max-width: 36rem; }

/* El título de sección solo hace falta cuando no hay menú (pantallas pequeñas) */
.section-title {
  margin: 0 0 1.5rem;
  color: var(--strong);
  font: 600 .85rem var(--mono);
  letter-spacing: .04em;
}
@media (min-width: 1024px) {
  .section-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* Tarjetas de experiencia y proyectos: al pasar sobre una, las demás se atenúan */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 2.5rem; }
.card {
  position: relative;
  display: grid;
  gap: .4rem;
  border-radius: 6px;
  transition: opacity .25s ease;
}
@media (min-width: 640px) {
  .card { grid-template-columns: 9.5rem 1fr; gap: 1.5rem; }
  .card:not(:has(.card-when)) { grid-template-columns: 1fr; }
}
@media (min-width: 1024px) and (hover: hover) {
  .card::before {
    content: "";
    position: absolute;
    inset: -1rem -1.25rem;
    border-radius: 8px;
    background: var(--card);
    opacity: 0;
    transition: opacity .25s ease;
    z-index: -1;
  }
  .card:hover::before { opacity: 1; }
  .cards:hover .card:not(:hover) { opacity: .5; }
}
.card-when { margin: .2rem 0 0; color: var(--muted); font: 400 .78rem/1.5 var(--mono); }
.card-body > p { margin: .5rem 0 0; font-size: .95rem; }
.card-title { margin: 0; color: var(--strong); font-size: 1.02rem; font-weight: 600; line-height: 1.35; }
.card-url { color: var(--muted); font: 400 .8rem var(--mono); }

.tags { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.tags li {
  padding: .2rem .65rem;
  border: 1px solid var(--line-c);
  border-radius: 999px;
  color: var(--strong);
  font: 400 .75rem/1.6 var(--mono);
}

.more { margin-top: 2.5rem; }
.more a { font-weight: 600; border-bottom: 1px solid var(--muted); }
.more a:hover { text-decoration: none; border-color: var(--strong); }

.foot { max-width: 30rem; color: var(--muted); font-size: .85rem; }
.foot a { color: var(--text); }

/* ---------- Texto que se descifra ---------- */
/* Acomodado (estado final): arriba de la columna izquierda, tamaño de logo */
.intro {
  display: inline-flex;
  align-items: center;
  color: var(--glyph);
  font: 600 var(--logo-size)/1 var(--mono);
  user-select: none;
}

/* Durante la intro: centrado en la pantalla y grande; el resto de la página está oculto.
   decode.js quita .is-intro del body y anima el traslado (FLIP) hasta su sitio. */
.is-intro { overflow: hidden; }
.is-intro .intro {
  --n: 11;               /* nº de letras (decode.js lo pone en el div) */
  /* Lo más grande posible sin pasar del 88 % del ancho (una letra mono mide ~0,6em) ni de 6,5rem */
  font-size: min(6.5rem, calc(88vw / (var(--n) * .62)));
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}

/* El contenido aparece cuando el texto ya casi llegó a su sitio */
.reveal { transition: opacity .9s ease .9s; }
.is-intro .reveal { opacity: 0; visibility: hidden; transition: none; }
.is-intro .spotlight { opacity: 0; }

/* Cada letra ocupa siempre el mismo ancho: el texto no "baila" mientras cambia */
.ch {
  display: inline-block;
  width: 1ch;
  text-align: center;
}

/* Mientras cambia: más tenue, con un destello en cada cambio (decode.js reinicia .tick) */
.ch.scrambling { color: var(--scramble); }
.ch.tick { animation: tick .12s ease-out; }
@keyframes tick {
  from { color: #fff; text-shadow: 0 0 12px rgba(255, 255, 255, .8); }
}

/* Al resolverse: golpe de brillo que se asienta */
.ch.done { animation: lock .7s ease-out; }
@keyframes lock {
  0%   { color: #fff; text-shadow: 0 0 24px #fff, 0 0 48px rgba(255, 255, 255, .6); transform: scale(1.15); }
  100% { text-shadow: 0 0 0 transparent; transform: none; }
}

/* Cursor al final: su hueco existe desde el principio (y otro igual e invisible a la izquierda),
   así el texto no se desplaza cuando aparece y sigue centrado */
.intro::before,
.intro::after {
  content: "";
  width: .08em;
  height: .9em;
  margin: 0 .12em;
  opacity: 0;
}
.intro::before { margin-left: 0; width: 0; } /* acomodado, el texto queda alineado con el nombre */
.is-intro .intro::before { margin: 0 .12em; width: .08em; }
.intro.solved::after {
  opacity: 1;
  background: var(--glyph);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret {
  50% { opacity: 0; }
}

/* ---------- Lluvia en semicírculo (desactivada: su div está comentado en index.html) ---------- */
/* Semicírculo: alto de su contenedor y ancho de medio alto. Lado recto a la derecha, curva hacia la izquierda.
   overflow: hidden + border-radius recortan la lluvia: ninguna letra sale del semicírculo. */
.matrix {
  position: relative;
  height: 100%;
  aspect-ratio: 1 / 2;
  max-width: 100%;
  border-radius: 100% 0 0 100% / 50% 0 0 50%;
  overflow: hidden;
  contain: layout paint;
  font: 400 var(--rain-size)/1 var(--mono);
  color: #f2f2f2;
  user-select: none;
}
.row {
  position: absolute;
  left: 0;
  top: var(--y);
  height: var(--line);
  line-height: var(--line);
  white-space: pre;
  animation: flow var(--dur) linear var(--delay) infinite;
  transform: translateX(-100%);
}
@keyframes flow {
  from { transform: translateX(-100%); }
  to   { transform: translateX(var(--w, 100vw)); }
}
.trail {
  opacity: .85;
  -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, .18), #000);
          mask-image: linear-gradient(to right, rgba(0, 0, 0, .18), #000);
}
.head { color: #fff; text-shadow: 0 0 6px #fff; animation: flicker .4s steps(2) infinite; }
@keyframes flicker { 50% { opacity: .7; } }

/* Sin animaciones: texto ya acomodado, contenido visible y lluvia quieta */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ch.tick, .ch.done, .intro.solved::after, .head { animation: none; }
  .reveal, .card, .card::before, .nav a, .nav a::before { transition: none; }
  .row { animation: none; transform: translateX(calc(var(--still) * 1%)); }
}
