:root {
  --bg: #070a10;
  --bg2: #0b1019;
  --panel: #0e1420;
  --panel2: #121b2b;
  --line: #1c2536;
  --fg: #dbe4f0;
  --soft: #b8c4d6;
  --muted: #7f8da3;
  --g: #00ff9c;
  --c: #38bdf8;
  --p: #a78bfa;
  --on-g: #04120b;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Consolas, Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --m: clamp(16px, 2.2vw, 32px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --foot-h: 720px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--sans); font-size: 1.05rem; line-height: 1.65;
  overflow-x: hidden;
}
::selection { background: var(--g); color: var(--on-g); }
img { display: block; max-width: 100%; }
h1, h2, p, dl, dd, figure, address { margin: 0; }
a { color: inherit; text-decoration: none; }
a:focus-visible, summary:focus-visible, input:focus-visible + span, .btn:focus-visible {
  outline: 2px solid var(--g); outline-offset: 3px; border-radius: 4px;
}

.g { color: var(--g); }
.d { color: var(--muted); }
.grad {
  background: linear-gradient(90deg, var(--g), var(--c) 60%, var(--p));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Fondo: rejilla y brillos (fijos, como en la v1) */
main {
  position: relative; z-index: 1;
  background:
    radial-gradient(600px 400px at 85% 6%, rgba(0,255,156,.10), transparent 70%),
    radial-gradient(500px 400px at 4% 28%, rgba(167,139,250,.10), transparent 70%),
    linear-gradient(rgba(28,37,54,.30) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28,37,54,.30) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 48px 48px, 48px 48px, auto;
  background-attachment: fixed;
}

/* ---------- Botones ---------- */
.btn, .go {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  font-family: var(--mono); font-size: .88rem; font-weight: 600; color: var(--fg);
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--g); box-shadow: 0 6px 24px rgba(0,255,156,.15); }
.btn:active { transform: translateY(1px); }
.btn.ghost { color: var(--g); border-color: rgba(0,255,156,.4); background: transparent; }
.btn.ghost:hover { background: rgba(0,255,156,.12); }

/* ---------- Ventana de terminal ---------- */
.term-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: #0a0f18; border-bottom: 1px solid var(--line); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.term-bar i:nth-child(2) { background: #febc2e; }
.term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { margin-left: 10px; font-family: var(--mono); font-size: .78rem; color: var(--muted); }

/* ---------- Portada (como la v1) ---------- */
.hero { position: relative; min-height: 100svh; display: flex; align-items: center; padding: 104px var(--m) 64px; }

.topbar {
  position: absolute; z-index: 3; top: 22px; left: var(--m); right: var(--m);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.logo { font-family: var(--mono); font-size: .95rem; font-weight: 700; white-space: nowrap; }
.topbar nav { display: flex; gap: 6px; justify-content: center; }
.topbar nav a { font-family: var(--mono); font-size: .82rem; color: var(--muted); padding: 6px 12px; border-radius: 6px; transition: color .2s, background .2s; }
.topbar nav a:hover { color: var(--g); background: rgba(0,255,156,.07); }
.top-right { justify-self: end; display: flex; align-items: center; gap: 10px; }
.langsel {
  appearance: none; -webkit-appearance: none; color-scheme: dark; cursor: pointer;
  font-family: var(--mono); font-size: .82rem; font-weight: 700; color: var(--fg);
  background-color: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 28px 11px 13px; line-height: 1.2;
  background-image: linear-gradient(45deg, transparent 50%, var(--g) 50%), linear-gradient(135deg, var(--g) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
  transition: border-color .2s, box-shadow .2s;
}
.langsel:hover { border-color: var(--g); box-shadow: 0 6px 24px rgba(0,255,156,.15); }

.hero-in { width: 100%; max-width: 1040px; margin: 0 auto; display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.hero-text > * { animation: up .8s var(--ease) both; }
.hero-text > :nth-child(2) { animation-delay: .08s; }
.hero-text > :nth-child(3) { animation-delay: .16s; }
.hero-text > :nth-child(4) { animation-delay: .24s; }
.hero-text > :nth-child(5) { animation-delay: .32s; }

.prompt { margin: 0 0 8px; font-family: var(--mono); color: var(--muted); }
h1 { margin: 0; font-size: clamp(2.6rem, 8vw, 4.6rem); line-height: 1.05; letter-spacing: -0.03em; font-weight: 800; }
.typed-line { margin: 14px 0 20px; min-height: 1.8em; font-family: var(--mono); font-size: clamp(1.05rem, 3vw, 1.4rem); color: var(--c); }
.cursor { color: var(--g); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lead { max-width: 54ch; margin: 0 0 28px; color: var(--soft); font-size: 1.08rem; }
.lead strong { color: var(--g); font-weight: 600; }
.btns { display: flex; flex-wrap: wrap; gap: 12px; }
.btn.primary { background: var(--g); color: var(--on-g); border-color: var(--g); }
.btn.primary:hover { box-shadow: 0 6px 28px rgba(0,255,156,.4); }

.hero-photo { position: relative; display: grid; place-items: center; animation: up .9s var(--ease) .2s both; }
.ring {
  position: relative; width: min(300px, 70vw); aspect-ratio: 1; border-radius: 50%; padding: 4px;
  background: conic-gradient(from 0deg, var(--g), var(--c), var(--p), var(--g));
  box-shadow: 0 0 60px rgba(0,255,156,.25), 0 0 120px rgba(167,139,250,.15);
  animation: spin 14s linear infinite;
}
.ring img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 5px solid var(--bg); animation: spin 14s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip {
  position: absolute; padding: 5px 12px; border-radius: 999px;
  font-family: var(--mono); font-size: .78rem; font-weight: 700;
  background: rgba(14,20,32,.9); border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: float 5s ease-in-out infinite;
}
.c1 { top: 6%; left: 2%; color: var(--g); border-color: rgba(0,255,156,.5); }
.c2 { bottom: 14%; left: -2%; color: var(--c); animation-delay: -1.5s; }
.c3 { top: 30%; right: -2%; color: var(--p); animation-delay: -3s; }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes up { from { opacity: 0; transform: translateY(26px); } }
/* ---------- Carta (ventana de terminal) ---------- */
.about { padding: clamp(120px, 14vw, 200px) var(--m); }
.sheet {
  position: relative; width: min(680px, 100%); margin: 0 auto; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.sheet-body { padding: 32px 48px 0; }
.sheet .avatar {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover; object-position: 50% 20%;
  border: 2px solid var(--g); box-shadow: 0 0 18px rgba(0,255,156,.35);
}
.cmd { margin-top: 18px; font-family: var(--mono); font-size: .92rem; color: var(--fg); }
.sheet p { color: var(--soft); line-height: 1.6; margin-top: 16px; }
.sheet p.cmd { color: var(--fg); }
mark { background: rgba(0,255,156,.16); color: var(--g); padding: 0 .25em; border-radius: 3px; }
.sign { display: grid; margin-top: 30px !important; }
.sign em { font-size: 1.4rem; font-weight: 700; color: var(--fg); font-style: normal; }
.sign span { font-family: var(--mono); font-size: .82rem; color: var(--muted); }

.perf { margin: 40px -48px 0; border-top: 6px dotted rgba(0,255,156,.55); }
.tear {
  display: flex; align-items: center; justify-content: center;
  height: 72px; margin: 0 -48px; background: var(--g); color: var(--on-g);
  font-family: var(--mono); font-size: 1.05rem; font-weight: 700; text-align: center;
  transition: filter .2s, letter-spacing .25s var(--ease);
}
.tear:hover { filter: brightness(1.08); letter-spacing: .02em; }
.hang {
  height: 14px; margin: 0 -48px; background: var(--g);
  -webkit-mask: url("assets/scallop-down.svg") repeat-x 0 0 / 28px 14px;
  mask: url("assets/scallop-down.svg") repeat-x 0 0 / 28px 14px;
}

/* ---------- Carpetas ---------- */
.sec {
  display: flex; align-items: baseline; gap: 10px; margin: 0 var(--m) 88px;
  font-family: var(--mono); font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 600; letter-spacing: -.01em;
}
.sec::after { content: ""; flex: 1 1 60px; height: 1px; align-self: center; background: linear-gradient(90deg, var(--line), transparent); }
.folders { padding-top: clamp(40px, 8vw, 120px); }

.band {
  position: sticky; top: calc(var(--k) * 64px);
  padding: 0 var(--m) 72px;
  background: var(--band); border-top: 1px solid var(--line);
}
.b1 { --k: 0; --band: var(--panel);  --tab: var(--g); }
.b2 { --k: 1; --band: var(--panel2); --tab: var(--c); }
.b3 { --k: 2; --band: var(--panel);  --tab: var(--p); }
.b4 { --k: 3; --band: var(--panel2); --tab: var(--g); }

.tabs { position: absolute; left: var(--m); top: -44px; display: flex; gap: 6px; }
.tab {
  display: flex; align-items: center; height: 44px; padding: 0 34px;
  background: var(--tab); color: var(--on-g);
  font-family: var(--mono); font-size: 1.05rem; font-weight: 700; line-height: 1;
  clip-path: polygon(0 100%, 18px 0, calc(100% - 18px) 0, 100% 100%);
  transition: transform .3s var(--ease);
}
.band:hover .tab:first-child { transform: translateY(-4px); }
.strip { height: 64px; display: flex; align-items: center; justify-content: flex-end; font-family: var(--mono); font-size: .82rem; color: var(--muted); }

.open { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--m); padding-top: clamp(16px, 3vw, 40px); }
.wall {
  grid-column: 1 / 8; margin: 0; padding: clamp(20px, 3vw, 40px);
  list-style: none; container-type: inline-size;
  display: flex; flex-direction: column; justify-content: flex-start; gap: .12em;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: inset 0 0 60px rgba(0,255,156,.04);
}
.wall li { font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; font-size: 8cqw; color: var(--tab); overflow-wrap: anywhere; }
/* lista de carpetas: una por línea, en dos columnas, como un ls */
.wall.dense { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: column; grid-template-rows: repeat(8, auto); align-content: start; column-gap: 1.2em; }
.wall.dense li { font-size: 5.4cqw; line-height: 1.22; letter-spacing: -0.02em; }
.wall.dense li::before { content: "./"; color: var(--muted); font-weight: 600; }
.txt { grid-column: 9 / 13; align-self: start; }
.txt p { color: var(--soft); }
.more { display: inline-block; margin-top: 22px; font-family: var(--mono); font-size: .86rem; font-weight: 600; color: var(--g); transition: transform .2s var(--ease); }
.more:hover { transform: translateX(4px); }

/* ---------- Skills ---------- */
.list { background: var(--bg2); padding: clamp(120px, 14vw, 200px) var(--m); border-top: 1px solid var(--line); }
.col { width: min(640px, 100%); margin: 0 auto; container-type: inline-size; }
.list h2 { font-weight: 800; letter-spacing: -0.04em; line-height: .95; font-size: 41cqw; margin-bottom: 26px; white-space: nowrap; }
.bar { margin-bottom: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; transition: border-color .2s; }
.bar:hover, .bar[open] { border-color: rgba(0,255,156,.35); }
.bar summary {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 18px; list-style: none; cursor: pointer;
  font-weight: 600; transition: background .2s;
}
.bar summary::-webkit-details-marker { display: none; }
.bar summary::after { content: "+"; font-family: var(--mono); font-size: 1.6rem; font-weight: 400; line-height: 1; color: var(--g); }
.bar[open] summary::after { content: "\2212"; }
.bar summary:hover { background: rgba(0,255,156,.05); }
.bar ul { margin: 0; padding: 4px 18px 22px; list-style: none; }
.bar li { display: flex; justify-content: space-between; gap: 24px; margin-top: 14px; color: var(--soft); }
.bar li b { flex: none; font-family: var(--mono); font-size: .84rem; font-weight: 500; color: var(--c); text-align: right; font-variant-numeric: tabular-nums; }
.bar li small { display: block; font-size: .85rem; color: var(--muted); }
.bar li.link a { color: var(--g); font-family: var(--mono); font-size: .86rem; font-weight: 600; }

/* ---------- Contacto ---------- */
.visit { padding: clamp(100px, 12vw, 180px) var(--m); }
.visit-in { max-width: 1376px; margin: 0 auto; container-type: inline-size; }
.visit h2 { font-weight: 800; letter-spacing: -0.04em; line-height: .95; font-size: 21cqw; white-space: nowrap; }
.card {
  width: min(460px, 100%); margin: clamp(32px, 5vw, 56px) 0 0 auto; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 60px rgba(0,255,156,.06);
}
.card-body { padding: 24px 28px 4px; }
.where { font-family: var(--mono); font-size: .92rem; }
fieldset { display: flex; flex-wrap: wrap; gap: 6px; border: 0; margin: 20px 0 0; padding: 0; min-width: 0; }
legend { width: 100%; padding: 0; margin-bottom: 8px; font-family: var(--mono); font-size: .8rem; color: var(--muted); }
label { position: relative; }
label input { position: absolute; opacity: 0; inset: 0; }
label span {
  display: inline-block; padding: 8px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  font-family: var(--mono); font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .2s var(--ease);
}
label:hover span { transform: translateY(-2px); border-color: var(--g); }
label input:checked + span { background: var(--g); border-color: var(--g); color: var(--on-g); }
dl { margin-top: 22px; }
dl div { display: flex; justify-content: space-between; gap: 16px; margin-top: 8px; }
dt { font-family: var(--mono); font-size: .82rem; color: var(--muted); }
dd { text-align: right; overflow-wrap: anywhere; }
dd a { color: var(--fg); border-bottom: 1px solid var(--line); transition: color .2s, border-color .2s; }
dd a:hover { color: var(--g); border-color: var(--g); }
.go {
  display: flex; width: 100%; height: 54px; margin-top: 24px; padding: 0; border: 0; border-radius: 0;
  background: var(--g); color: var(--on-g); font-size: .95rem;
}
.go:hover { box-shadow: 0 0 28px rgba(0,255,156,.4); filter: brightness(1.06); }

/* ---------- Reverso (telón) ---------- */
.back { padding: 0 var(--m); background: var(--bg); }
.back-in { width: min(1120px, 83.333%); margin: 0 auto; padding: 80px 0 40px; }
.up {
  height: 50px; background: var(--panel);
  -webkit-mask: url("assets/scallop-up.svg") repeat-x 0 100% / 100px 50px;
  mask: url("assets/scallop-up.svg") repeat-x 0 100% / 100px 50px;
}
.panel {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 24px 48px;
  min-height: 380px; padding: 24px 56px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,255,156,.06);
}
.msg { grid-column: 1; align-self: start; }
.bye { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.035em; line-height: 1; margin-bottom: 14px; }
.msg p:last-child { color: var(--soft); max-width: 34ch; }
.stamp { grid-column: 2; grid-row: 1; justify-self: end; width: 88px; height: auto; aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 15%; border: 2px solid var(--g); box-shadow: 0 0 22px rgba(0,255,156,.3); }
address { grid-column: 2; grid-row: 2; display: grid; gap: 12px; font-style: normal; font-family: var(--mono); font-size: .92rem; }
address a { width: fit-content; color: var(--soft); transition: color .2s, transform .2s var(--ease); }
address a:hover { color: var(--g); transform: translateX(4px); }
.imprint { grid-column: 1 / -1; align-self: end; text-align: center; font-family: var(--mono); font-size: .8rem; color: var(--muted); }

.js .back { position: fixed; z-index: 0; left: 0; right: 0; bottom: 0; }
.js main { margin-bottom: var(--foot-h); }

/* ---------- Movimiento ---------- */
.js [data-r] { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--ease) var(--d, 0ms), transform .7s var(--ease) var(--d, 0ms); }
.js [data-r].in { opacity: 1; transform: none; }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .topbar nav { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
  .hero { padding-top: 84px; }
  .logo { font-size: .78rem; }
  .top-right { gap: 8px; }
  .langsel { padding: 11px 24px 11px 10px; font-size: .78rem; background-position: calc(100% - 13px) 52%, calc(100% - 8px) 52%; }
  .btn.ghost { padding: 11px 12px; font-size: .78rem; }
  .hero-in { grid-template-columns: 1fr; gap: 36px; }
  .hero-photo { order: -1; }

  .sheet-body { padding: 24px 22px 0; }
  .perf, .tear, .hang { margin-left: -22px; margin-right: -22px; }
  .tear { font-size: .9rem; height: 64px; }

  .band { position: relative; top: auto; min-height: 0; padding-bottom: 48px; }
  .tab { height: 40px; padding: 0 24px; font-size: .95rem; }
  .tabs { top: -40px; }
  .open { display: block; }
 .txt { margin-top: 20px; }

  .card { width: 100%; }
  .go { height: 58px; }

  .back-in { width: 100%; padding-top: 56px; }
  .panel { grid-template-columns: 1fr; padding: 24px; }
  .stamp { position: absolute; top: 24px; right: 24px; width: 64px; grid-column: auto; grid-row: auto; }
  address { grid-column: 1; grid-row: auto; }
  .msg { padding-right: 84px; }

  /* Rendimiento en móvil: sin fondo fijo, sin telón y sin efectos pesados */
  main { background-attachment: scroll; }
  .js .back { position: static; }
  .js main { margin-bottom: 0; }
  .ring, .ring img, .chip { animation: none; }
  .chip { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--panel); }
}

@media (max-height: 760px) and (min-width: 761px) {
  .js .back { position: static; }
  .js main { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-text > *, .hero-photo, .ring, .ring img, .chip, .cursor { animation: none; }
  .js [data-r] { opacity: 1; transform: none; transition: none; }
  .btn, .go, label span, .tab, .more, address a, .tear { transition: none; }
}

@media print {
  .back { position: static !important; }
  .js main { margin-bottom: 0; }
}
