/* Portfolio v2 — "plano técnico".
   Layout: texto alineado a la izquierda; cada sistema se muestra como un plano
   de arquitectura. Lo único que se mueve solo es el plano del hero. */
:root {
  --ground: #0E1C2C;     /* papel del plano */
  --ground-2: #13253A;   /* superficies */
  --line: #25425F;       /* grilla y bordes */
  --chalk: #E8EEF4;      /* texto */
  --chalk-2: #A3B6C9;    /* texto secundario */
  --signal: #F3C24F;     /* datos en movimiento, acción principal */
  --signal-ink: #1B1405;

  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: clamp(2rem, 4.5vw, 3rem);
  --step-hero: clamp(3.4rem, 10vw, 7.25rem);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --max-w: 1180px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  background: var(--ground);
  color: var(--chalk);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; }
ul { list-style: none; }
h1, h2, h3, h4 { font-family: var(--display); text-wrap: balance; line-height: 1.05; letter-spacing: -0.02em; font-weight: 700; }
p { text-wrap: pretty; }
::selection { background: var(--signal); color: var(--signal-ink); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 16px; z-index: 100;
  padding: .6rem 1rem; background: var(--chalk); color: var(--ground);
  border-radius: 6px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 16px; }

.wrap {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px), 4vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 4vw);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 1.25rem;
  border-radius: 6px; font-weight: 600; text-decoration: none;
  transition: background .2s, color .2s, border-color .2s, transform .2s var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--signal); color: var(--signal-ink); }
.btn--primary:hover { background: #F7D27A; }
.btn--ghost { border: 1px solid var(--line); color: var(--chalk); }
.btn--ghost:hover { border-color: var(--chalk-2); background: var(--ground-2); }
.btn--small { min-height: 36px; padding: 0 .9rem; font-size: var(--step--1); border: 1px solid var(--line); }
.btn--small:hover { border-color: var(--chalk-2); }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(14, 28, 44, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.is-scrolled { border-bottom-color: var(--line); }
.nav-inner {
  max-width: var(--max-w); margin-inline: auto;
  padding: .85rem max(16px, env(safe-area-inset-right, 0px), 4vw) .85rem max(16px, env(safe-area-inset-left, 0px), 4vw);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.nav-logo { font-family: var(--display); font-weight: 800; font-size: 1.35rem; text-decoration: none; letter-spacing: -0.03em; }
.nav-links { display: flex; align-items: center; gap: 1.75rem; font-size: .95rem; }
.nav-links a { text-decoration: none; color: var(--chalk-2); transition: color .2s; }
.nav-links a:hover { color: var(--chalk); }
.nav-links .nav-cta { color: var(--chalk); border: 1px solid var(--line); padding: .45rem .9rem; border-radius: 6px; }
.nav-links .nav-cta:hover { border-color: var(--chalk-2); }
.nav-burger { display: none; width: 44px; height: 44px; position: relative; }
.nav-burger span { position: absolute; left: 11px; right: 11px; height: 2px; background: var(--chalk); transition: transform .25s var(--ease-out); }
.nav-burger span:first-child { top: 17px; }
.nav-burger span:last-child { top: 25px; }
.nav-burger[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
.nav-mobile { display: none; }

@media (max-width: 720px) {
  .nav-links { display: none; }
  .nav-burger { display: block; }
  .nav-mobile {
    display: block; max-height: 0; overflow: hidden;
    transition: max-height .3s var(--ease-out);
  }
  .nav-mobile.is-open { max-height: 320px; border-top: 1px solid var(--line); }
  .nav-mobile ul { padding: .5rem max(16px, env(safe-area-inset-left, 0px)) 1rem; }
  .nav-mobile a { display: block; padding: .75rem 0; font-family: var(--display); font-size: 1.4rem; font-weight: 600; text-decoration: none; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-block: clamp(2.5rem, 7vw, 6rem) clamp(3rem, 7vw, 6rem);
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}
/* grilla de plano */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: .35;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 70% 45%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse 80% 70% at 70% 45%, #000 20%, transparent 75%);
}
.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.hero-text { min-width: 0; }
.status {
  display: inline-flex; align-items: center; gap: .55rem;
  font-size: var(--step--1); color: var(--chalk-2);
  margin-bottom: 1.5rem;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 4px rgba(243, 194, 79, .18); }
.hero-title {
  font-size: var(--step-hero);
  font-weight: 800;
  line-height: .9;
  letter-spacing: -0.045em;
  font-variation-settings: "opsz" 96;
}
.hero-role { margin-top: 1.25rem; font-size: var(--step-1); font-weight: 500; }
.hero-sub { margin-top: .9rem; max-width: 46ch; color: var(--chalk-2); font-size: 1.05rem; }
.hero-actions { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: .75rem; }

/* entrada única del hero */
@media (prefers-reduced-motion: no-preference) {
  .hero-text > * { animation: rise .8s var(--ease-out) both; }
  .hero-text > :nth-child(2) { animation-delay: .06s; }
  .hero-text > :nth-child(3) { animation-delay: .14s; }
  .hero-text > :nth-child(4) { animation-delay: .2s; }
  .hero-text > :nth-child(5) { animation-delay: .26s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
}

/* ---------- Plano (hero) ---------- */
.blueprint {
  min-width: 0;
  background: rgba(19, 37, 58, .72);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: clamp(1rem, 2.5vw, 1.5rem);
}
.system-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; }
.system-tab {
  padding: .45rem .85rem; border-radius: 6px;
  font-size: .9rem; font-weight: 500; color: var(--chalk-2);
  border: 1px solid transparent;
  transition: color .2s, border-color .2s, background .2s;
}
.system-tab:hover { color: var(--chalk); }
.system-tab[aria-selected="true"] { color: var(--chalk); border-color: var(--line); background: var(--ground); }
.blueprint-caption { margin-top: 1.1rem; font-size: .95rem; color: var(--chalk-2); max-width: 60ch; min-height: 3.2em; }
.legend { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .8rem; color: var(--chalk-2); }
.legend li { display: inline-flex; align-items: center; gap: .45rem; }
.legend-key { width: 14px; height: 10px; border-radius: 2px; border: 1.5px solid var(--chalk-2); }
.legend-key.is-ai { border-color: var(--signal); }
.legend-key.is-data { background: var(--ground-2); border-color: var(--line); }
.legend-key.is-out { background: var(--chalk); border-color: var(--chalk); }

/* ---------- Diagramas ---------- */
.diagram { min-height: 140px; display: flex; justify-content: center; }
.diagram--hero { min-height: 220px; align-items: center; }
.diagram-svg { width: 100%; height: auto; overflow: visible; }
.diagram-node rect { fill: var(--ground); stroke: var(--chalk-2); stroke-width: 1.25; }
.diagram-node.is-ai rect { stroke: var(--signal); stroke-width: 1.5; }
.diagram-node.is-data rect { fill: var(--ground-2); stroke: var(--line); }
.diagram-node.is-out rect { fill: var(--chalk); stroke: var(--chalk); }
.diagram-label { font-family: var(--sans); font-size: 13.5px; font-weight: 600; fill: var(--chalk); }
.diagram-sub { font-family: var(--sans); font-size: 11.5px; fill: var(--chalk-2); }
.diagram-node.is-out .diagram-label { fill: var(--ground); }
.diagram-node.is-out .diagram-sub { fill: #3E536A; }
.diagram-pulse { fill: var(--signal); }
.diagram-node rect { transition: stroke .25s, filter .25s; }
.diagram-node.is-active rect { stroke: var(--signal); stroke-width: 2; filter: drop-shadow(0 0 8px rgba(243, 194, 79, .45)); }
.diagram-node.is-out.is-active rect { stroke: var(--signal); }
.diagram.is-narrow .diagram-label { font-size: 12.5px; }
.diagram.is-narrow .diagram-sub { font-size: 10.5px; }
.diagram-edge { fill: none; stroke: var(--chalk-2); stroke-width: 1.4; }
.diagram-edge.is-fallback { stroke-dasharray: 4 4; stroke: #7F95AB; }
.diagram-arrow { fill: var(--chalk-2); }
.diagram-packet { fill: var(--signal); filter: drop-shadow(0 0 6px rgba(243, 194, 79, .8)); opacity: 0; pointer-events: none; }

/* dibujo del plano: solo cuando lo pide el JS (hero / cambio de pestaña) */
.diagram:not(.is-static) .diagram-node { opacity: 0; transform-box: fill-box; transition: opacity .45s var(--ease-out) var(--d); }
.diagram:not(.is-static) .diagram-edge:not(.is-fallback) { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .6s var(--ease-out) var(--d); }
.diagram:not(.is-static) .diagram-edge.is-fallback { opacity: 0; transition: opacity .5s var(--ease-out) var(--d); }
.diagram:not(.is-static) .diagram-arrow { opacity: 0; }
.diagram.is-drawn .diagram-node, .diagram.is-drawn .diagram-edge.is-fallback { opacity: 1; }
.diagram.is-drawn .diagram-edge:not(.is-fallback) { stroke-dashoffset: 0; }
.diagram.is-drawn .diagram-arrow { opacity: 1; transition: opacity .3s 1s; }

@media (prefers-reduced-motion: no-preference) {
  .diagram-pulse { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .3; } }
}

/* ---------- Secciones ---------- */
.section { padding-block: clamp(4rem, 9vw, 7rem); }
.section--alt { background: var(--ground-2); border-block: 1px solid var(--line); }
.section-head { margin-bottom: clamp(2rem, 5vw, 3.5rem); max-width: 60ch; }
.section-head h2 { font-size: var(--step-3); }
.section-head p { margin-top: .75rem; color: var(--chalk-2); }

/* ---------- Proyectos ---------- */
.projects { border-top: 1px solid var(--line); }
.project {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  padding-block: clamp(2.25rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--line);
}
.project-body { min-width: 0; }
.project-kind { font-size: var(--step--1); color: var(--signal); font-weight: 500; }
.project-title { margin-top: .35rem; font-size: var(--step-2); }
.project-impact { margin-top: .9rem; font-size: 1.06rem; max-width: 58ch; }
.project-desc { margin-top: .75rem; color: var(--chalk-2); max-width: 62ch; font-size: .95rem; }
.tags { margin-top: 1.1rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.tags li { font-size: .8rem; padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 4px; color: var(--chalk-2); }
.project-links { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.project-links a {
  font-weight: 600; text-decoration: underline; text-decoration-color: var(--signal);
  text-decoration-thickness: 2px; text-underline-offset: 5px;
}
.project-links a:hover { color: var(--signal); }
.project-private { margin-top: 1.25rem; font-size: var(--step--1); color: var(--chalk-2); }
.project-plan {
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 10px;
  background-image:
    linear-gradient(rgba(37, 66, 95, .35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 66, 95, .35) 1px, transparent 1px);
  background-size: 24px 24px;
}
.project:nth-child(even) .project-body { order: 2; }

.others { margin-top: clamp(3rem, 6vw, 4.5rem); }
.others-title { font-size: var(--step-1); }
.others-list { margin-top: 1.25rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem 2rem; }
.others-list h4 { font-size: 1.1rem; }
.others-list h4 a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.others-list h4 a:hover { text-decoration-color: var(--signal); }
.others-list p { margin-top: .4rem; font-size: .95rem; color: var(--chalk-2); }
.others-meta { display: block; margin-top: .5rem; font-size: .8rem; color: var(--chalk-2); opacity: .85; }

/* ---------- Sobre mí ---------- */
.about { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(2rem, 6vw, 5rem); }
.about-text h2 { font-size: var(--step-3); margin-bottom: 1.25rem; }
.about-text p + p { margin-top: 1rem; }
.about-text p { color: var(--chalk-2); max-width: 60ch; }
.about-edu { margin-top: 1.75rem !important; padding-top: 1.25rem; border-top: 1px solid var(--line); display: grid; gap: .2rem; }
.about-edu strong { color: var(--chalk); font-weight: 600; }
.stack-title { font-size: var(--step-1); margin-bottom: 1.25rem; }
.stack-grid { display: grid; gap: 1.25rem; }
.stack-grid div { padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.stack-grid dt { font-weight: 600; margin-bottom: .25rem; }
.stack-grid dd { color: var(--chalk-2); }

/* ---------- Formación ---------- */
.certs { border-top: 1px solid var(--line); }
.certs li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 9rem 3.5rem auto;
  gap: 1rem; align-items: center;
  padding-block: .85rem;
  border-bottom: 1px solid var(--line);
}
.cert-title { font-weight: 500; }
.cert-issuer, .cert-year { color: var(--chalk-2); font-size: .95rem; }
.cert-year { font-variant-numeric: tabular-nums; }
.cert-view { font-size: .9rem; font-weight: 600; color: var(--chalk); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.cert-view:hover { text-decoration-color: var(--signal); }

.cert-modal { margin: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--ground-2); color: var(--chalk); padding: 1rem; max-width: min(900px, 92vw); }
.cert-modal::backdrop { background: rgba(6, 12, 20, .8); }
.cert-modal-img { max-height: 80vh; width: auto; margin-inline: auto; border-radius: 4px; }
.cert-modal-close { position: absolute; top: .4rem; right: .6rem; font-size: 1.8rem; line-height: 1; width: 40px; height: 40px; }
.cert-modal-error { padding: 2rem; color: var(--chalk-2); }

/* ---------- Contacto ---------- */
.contact { border-top: 1px solid var(--line); }
.contact-title { font-size: clamp(2.6rem, 8vw, 5.5rem); font-weight: 800; letter-spacing: -0.04em; line-height: .95; }
.contact-sub { margin-top: 1rem; color: var(--chalk-2); max-width: 56ch; }
.email-row { margin-top: 2rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
.email-text { font-family: var(--display); font-size: clamp(1.25rem, 3.5vw, 2rem); font-weight: 600; user-select: all; overflow-wrap: anywhere; }
.contact-actions { margin-top: 1.75rem; display: flex; flex-wrap: wrap; gap: .75rem; }

.footer { border-top: 1px solid var(--line); padding-block: 1.75rem calc(1.75rem + env(safe-area-inset-bottom, 0px)); font-size: .9rem; color: var(--chalk-2); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--chalk); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; }
  .project { grid-template-columns: 1fr; }
  .project:nth-child(even) .project-body { order: 0; }
  .about { grid-template-columns: 1fr; }
  .others-list { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .certs li { grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; }
  .cert-title { grid-column: 1; }
  .cert-issuer { grid-column: 1; grid-row: 2; font-size: .85rem; }
  .cert-year { display: none; }
  .cert-view { grid-column: 2; grid-row: 1 / span 2; }
  .hero-actions .btn { flex: 1 1 auto; }
}
