:root {
  --bg: #000;
  --fg: #ededed;
  --muted: #8a8a8a;
  --line: #3a3a3a;
  --hover: #111;
  --gold: #f5c542;
  --purple: #a855f7;
  --c0: #3a3a3a;
  --c1: #6a3fc4;
  --c2: #a066f5;
  --c3: #d49a35;
  --c4: #ffd45c;
  --font: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --fg: #111;
  --muted: #6b6b6b;
  --line: #c8c8c8;
  --hover: #f0f0f0;
  --gold: #c9971c;
  --purple: #8b3fe0;
  --c0: #cfcfcf;
  --c1: #c9a8f5;
  --c2: #9a5ce8;
  --c3: #7a3fd0;
  --c4: #6b4500;
}

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

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

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

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(64px, 18vh, 220px) 24px 80px;
  animation: fade .8s ease both;
}

/* Header */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 56px;
}

.identity { display: flex; align-items: center; gap: 20px; min-width: 0; }
.controls { display: flex; align-items: center; flex: 0 0 auto; }
.control-buttons { display: flex; align-items: center; gap: 20px; }
.portrait {
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  background: transparent;
}
.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 82%;
}

.name {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.cursor { animation: blink 1.1s steps(1) infinite; }

/* Glitch del nombre */
.name { cursor: default; }
.glitch {
  position: relative;
  display: inline-block;
  isolation: isolate;
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  white-space: pre;
  pointer-events: none;
  opacity: 0;
}
.glitch::before { z-index: -1; }
.glitch.glitching { transform: skewX(var(--skew, 0deg)); }
.glitch.glitching::before {
  opacity: 1;
  color: var(--g1, #00e5ff);
  transform: translate(var(--dx1, -3px), var(--dy1, 0));
  clip-path: var(--clip1, none);
}
.glitch.glitching::after {
  opacity: .9;
  color: var(--g2, #ff2a6d);
  transform: translate(var(--dx2, 3px), var(--dy2, 0));
  clip-path: var(--clip2, none);
  mix-blend-mode: screen;
}
:root[data-theme="light"] .glitch.glitching::after { mix-blend-mode: multiply; }

.meta {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  gap: 10px;
}
.dot { opacity: .5; }

.lang-toggle {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px;
  margin: -6px;
  font: inherit;
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .2s;
}
.lang-toggle .on { color: var(--fg); }
.lang-toggle:hover { color: var(--fg); }

.theme-toggle {
  background: none;
  border: 0;
  color: var(--fg);
  cursor: pointer;
  padding: 6px;
  margin: -6px;
  display: grid;
  place-items: center;
  transition: transform .4s ease, opacity .2s;
}
.theme-toggle:hover { transform: rotate(45deg); }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

/* Texto encriptado */
.w { color: var(--line); transition: color .4s ease; }
.w.done { color: inherit; }
h2 .w.done { color: var(--fg); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Sections */
.block { margin-bottom: 48px; }
.block:nth-of-type(n) { animation: rise .7s ease both; }
.block:nth-of-type(1) { animation-delay: .05s; }
.block:nth-of-type(2) { animation-delay: .12s; }
.block:nth-of-type(3) { animation-delay: .19s; }
.block:nth-of-type(4) { animation-delay: .26s; }
.block:nth-of-type(5) { animation-delay: .33s; }

h2 {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

p {
  color: var(--muted);
  max-width: 76ch;
}

a {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(var(--muted), var(--muted));
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 2px;
  transition: color .2s, background-size .3s ease;
}
p a:hover,
p a:focus-visible,
.contrib-meta a:hover,
.contrib-meta a:focus-visible {
  color: var(--fg);
  background-image: linear-gradient(90deg, var(--gold), var(--purple));
  outline: none;
}

/* Glitch de los links (dorado / morado) */
.link-glitch {
  position: relative;
  white-space: nowrap;
  isolation: isolate;
}
.link-glitch::before,
.link-glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.link-glitch::before { z-index: -1; }
.link-glitch.glitching::before {
  opacity: 1;
  color: var(--g1, var(--gold));
  transform: translate(var(--dx1, -3px), var(--dy1, 0));
  clip-path: var(--clip1, none);
}
.link-glitch.glitching::after {
  opacity: .9;
  color: var(--g2, var(--purple));
  transform: translate(var(--dx2, 3px), var(--dy2, 0));
  clip-path: var(--clip2, none);
  mix-blend-mode: screen;
}
:root[data-theme="light"] .link-glitch.glitching::after { mix-blend-mode: multiply; }

/* Contribuciones de GitHub en ASCII */
.contrib { margin-top: 28px; width: fit-content; max-width: 100%; }
.contrib-grid {
  font-family: var(--font);
  font-size: clamp(7px, 1.75vw, 15px);
  line-height: 1.05;
  letter-spacing: .12em;
  text-transform: none;
  overflow: hidden;
  user-select: none;
}
.contrib-grid span { transition: color .2s; }

/* Glitch del gráfico */
.contrib-grid { position: relative; isolation: isolate; }
.contrib-grid::before,
.contrib-grid::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  white-space: pre;
  pointer-events: none;
  opacity: 0;
}
.contrib-grid::before { z-index: -1; }
.contrib-grid.glitching { transform: translateX(var(--shift, 0)); }
.contrib-grid.glitching::before {
  opacity: .9;
  color: var(--g1, var(--gold));
  transform: translate(var(--dx1, -3px), var(--dy1, 0));
  clip-path: var(--clip1, none);
}
.contrib-grid.glitching::after {
  opacity: .8;
  color: var(--g2, var(--purple));
  transform: translate(var(--dx2, 3px), var(--dy2, 0));
  clip-path: var(--clip2, none);
  mix-blend-mode: screen;
}
:root[data-theme="light"] .contrib-grid.glitching::after { mix-blend-mode: multiply; }
.contrib-grid .l0 { color: var(--c0); }
.contrib-grid .l1 { color: var(--c1); }
.contrib-grid .l2 { color: var(--c2); }
.contrib-grid .l3 { color: var(--c3); }
.contrib-grid .l4 { color: var(--c4); }
.contrib-grid span:hover { color: var(--fg); }
.contrib.in .contrib-grid span {
  animation: cell-in .5s ease both;
  animation-delay: calc(var(--x) * 18ms + var(--y) * 30ms);
}
.contrib-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
}
.contrib-legend {
  margin-top: 2px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  font-size: 8px;
  letter-spacing: .08em;
  color: var(--muted);
  opacity: .75;
  user-select: none;
}
.contrib-legend span { font-size: 10px; line-height: 1; }
.contrib-legend span:first-of-type { margin-left: 3px; }
.contrib-legend span:last-of-type { margin-right: 3px; }
.contrib-legend .l0 { color: var(--c0); }
.contrib-legend .l1 { color: var(--c1); }
.contrib-legend .l2 { color: var(--c2); }
.contrib-legend .l3 { color: var(--c3); }
.contrib-legend .l4 { color: var(--c4); }
@keyframes cell-in {
  0% { opacity: 0; }
  40% { opacity: 1; color: var(--fg); }
}

/* Aviso de "copiado" */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  background: var(--fg);
  color: var(--bg);
  font-size: 12px;
  letter-spacing: .08em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Motion */
@keyframes blink { 50% { opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

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

/* Mobile */
@media (max-width: 640px) {
  body { font-size: 13px; }
  .page { padding: 56px 16px 56px; }
  .top { align-items: flex-start; flex-wrap: wrap; row-gap: 16px; }
  .identity { flex: 1 1 100%; gap: 12px; }
  .portrait {
    width: 92px;
    height: 92px;
  }
  .control-buttons { gap: 14px; }
}
