/* =========================================================================
   Portafolio — sistema de diseño "editorial técnico"
   Hand-authored. Sin Tialwind. Consciente del tema (claro / oscuro / sistema).
   Prioridades: saturación contenida, neutros con carácter, nada de efectos
   llamativos. Debe verse hecho a mano, no generado.
   ========================================================================= */

:root {
  /* Neutros con una leve calidez (papel), no un gris plano */
  --bg: #f7f6f2;
  --surface: #fdfcfa;
  --surface-2: #efece5;
  --ink: #201f1d;
  --muted: #605e59;
  --faint: #928f87;
  --line: #e4e0d6;
  --line-strong: #d3cec1;

  /* Acento: azul apagado, cercano a la tinta. Se usa con cuentagotas. */
  --accent: #2f4fa0;
  --accent-hover: #26417f;
  --accent-weak: #ecedf4;
  --on-accent: #fbfbf9;

  --shadow: 0 1px 2px rgba(30, 28, 22, .04);

  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: .82rem;
  --step-0: 1.05rem;
  --step-1: 1.2rem;
  --step-2: 1.55rem;
  --step-3: 2rem;
  --hero: clamp(2.6rem, 6.4vw, 4.15rem);

  --wrap: 67rem;
  --radius: 8px;
  --radius-sm: 5px;
  --gutter: clamp(1.15rem, 5vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100f0e;
    --surface: #171615;
    --surface-2: #201e1c;
    --ink: #ecebe8;
    --muted: #a19e97;
    --faint: #706d66;
    --line: #29271f;
    --line-strong: #38352c;
    --accent: #8fa9e0;
    --accent-hover: #a3b6e7;
    --accent-weak: #1b1d2a;
    --on-accent: #100f0e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #100f0e;
  --surface: #171615;
  --surface-2: #201e1c;
  --ink: #ecebe8;
  --muted: #a19e97;
  --faint: #706d66;
  --line: #29271f;
  --line-strong: #38352c;
  --accent: #8fa9e0;
  --accent-hover: #a3b6e7;
  --accent-weak: #1b1d2a;
  --on-accent: #100f0e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
}

:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

/* ---- Reset --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Grano finísimo: da textura de papel/impresión, evita el "flat" de plantilla */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { opacity: .045; } }
:root[data-theme="dark"] body::before { opacity: .045; }

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { color: var(--ink); text-wrap: balance; line-height: 1.15; }
h1 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.015em; }
h2, h3 { font-family: var(--font-body); font-weight: 600; letter-spacing: -.01em; }

/* ---- Layout ------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
main { flex: 1 0 auto; }

.page { padding-block: clamp(2.75rem, 8vw, 5.5rem); }
.page > .wrap > section + section { margin-top: clamp(3rem, 7vw, 5rem); }

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
}
.eyebrow::before { content: "// "; color: var(--accent); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem 1rem;
  flex-wrap: wrap;
  padding-bottom: .85rem;
  margin-bottom: 1.85rem;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: var(--step-2); }
.section-head .eyebrow { align-self: center; }

.lede { font-size: clamp(1.08rem, 2.3vw, 1.3rem); line-height: 1.5; color: var(--muted); }
.prose { max-width: 62ch; }
.prose p + p { margin-top: 1rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: var(--step--1); color: var(--faint); }

/* ---- Header ------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.3) blur(9px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 1.1rem; height: 4rem; }

.brand { font-family: var(--font-mono); font-weight: 500; color: var(--ink); white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 500; }

.nav-links { display: flex; gap: .15rem; margin-left: auto; }
.nav-links a {
  font-size: var(--step--1); color: var(--muted);
  padding: .45rem .68rem; border-radius: var(--radius-sm);
  transition: color .15s, background-color .15s;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a[aria-current="page"]::after {
  content: ""; display: block; height: 2px; margin-top: .28rem;
  background: var(--accent); border-radius: 2px;
}

.nav-tools { display: flex; align-items: center; gap: .4rem; margin-left: .6rem; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--muted);
  font: inherit; font-size: .8rem; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

.lang { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.lang a { font-family: var(--font-mono); font-size: .72rem; padding: .38rem .5rem; color: var(--muted); background: var(--surface); }
.lang a[aria-current="true"] { background: var(--accent); color: var(--on-accent); }

.nav-toggle {
  display: none; width: 2rem; height: 2rem; place-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: .9rem;
}

/* ---- Buttons ---------------------------------------------------- */
.btn, .btn-ghost {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-mono); font-size: var(--step--1); font-weight: 500;
  padding: .72rem 1.15rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .13s ease, background-color .15s, border-color .15s, color .15s;
}
.btn { background: var(--accent); color: var(--on-accent); }
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.actions { display: flex; flex-wrap: wrap; gap: .7rem; }

/* ---- Hero ------------------------------------------------------ */
.hero { position: relative; padding-block: clamp(3rem, 11vw, 6.5rem); overflow: hidden; }
/* Halo ambiental: un solo tono, muy difuso y tenue. Luz, no "gradiente hero". */
.hero::before {
  content: ""; position: absolute; z-index: 0;
  top: -28%; left: -12%;
  width: min(42rem, 85vw); aspect-ratio: 1;
  background: radial-gradient(circle at 50% 50%,
              color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%);
  filter: blur(64px);
  opacity: .38;
  pointer-events: none;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero::before { opacity: .24; } }
:root[data-theme="dark"] .hero::before { opacity: .24; }
.hero > * { position: relative; z-index: 1; }

.hero { padding-block: clamp(3.5rem, 15vw, 8rem); }
.hero h1 { font-size: var(--hero); font-weight: 500; margin-top: 1.5rem; max-width: 20ch; }
.hero .lede { margin-top: 1.6rem; max-width: 46ch; font-size: clamp(1.1rem, 2.5vw, 1.42rem); }
.hero .actions { margin-top: 2.5rem; }

/* ---- Featured module ---------------------------------- */
.featured {
  display: grid;
  gap: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.6rem, 5vw, 3rem);
  box-shadow: var(--shadow);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.featured:hover {
  border-color: var(--line-strong);
  transform: translateY(-3px);
  box-shadow: 0 10px 34px -16px rgba(20, 19, 15, .22), var(--shadow);
}
:root[data-theme="dark"] .featured:hover { box-shadow: 0 12px 40px -18px rgba(0, 0, 0, .75); }
.featured-top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-family: var(--font-mono); font-size: var(--step--1); color: var(--faint);
  padding-bottom: 1rem; border-bottom: 1px solid var(--line);
}
.featured-top .link { color: var(--accent); }
.featured h2 {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(2rem, 5.5vw, 3rem); letter-spacing: -.025em; line-height: 1.05;
}
.featured p { color: var(--muted); max-width: 54ch; }
.featured-tech { font-family: var(--font-mono); font-size: var(--step--1); color: var(--ink); }
.featured-tech span { color: var(--faint); }

/* ---- Cards --------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(1.35rem, 3.5vw, 1.9rem);
  box-shadow: var(--shadow);
}
.card-grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}
a.card { transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--line-strong); transform: translateY(-2px); }

/* ---- Projects ---------------------------------------------- */
.project { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.project-media { aspect-ratio: 16 / 10; background: var(--surface-2); }
.project-media img { width: 100%; height: 100%; object-fit: cover; }
.project-media .noimg { display: grid; place-items: center; height: 100%; color: var(--faint); font-family: var(--font-mono); font-size: var(--step--1); }
.project-body { padding: 1.25rem 1.35rem 1.4rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.project-body h3 { font-size: var(--step-1); }
.project-body p { color: var(--muted); font-size: .95rem; line-height: 1.55; }
.project-foot {
  margin-top: auto; padding-top: .85rem;
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  font-family: var(--font-mono); font-size: .73rem; color: var(--faint);
}
.project-foot .go { color: var(--accent); }

/* ---- Entries ---------------------------------------------- */
.entries { display: grid; gap: 1.7rem; }
.entry { display: grid; gap: .5rem; }
.entry-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; flex-wrap: wrap; }
.entry-role { font-family: var(--font-body); font-weight: 600; font-size: var(--step-1); letter-spacing: -.01em; color: var(--ink); }
.entry-org { color: var(--muted); font-weight: 400; font-size: .95rem; }
.entry-date { font-family: var(--font-mono); font-size: var(--step--1); color: var(--faint); white-space: nowrap; }
.entry ul { display: grid; gap: .4rem; }
.entry li { position: relative; padding-left: 1.1rem; color: var(--muted); }
.entry li::before { content: ""; position: absolute; left: 0; top: .66em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* ---- Definition rows ------------------------------------ */
.defs { display: grid; gap: 1.1rem; }
.def { display: grid; grid-template-columns: 9rem 1fr; gap: .25rem 1.35rem; align-items: baseline; }
.def dt { font-family: var(--font-mono); font-size: var(--step--1); text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.def dd { color: var(--ink); }
@media (max-width: 34rem) { .def { grid-template-columns: 1fr; gap: .1rem; } }

/* ---- Tags ---------------------------------------------- */
.tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag { font-family: var(--font-mono); font-size: .73rem; padding: .3rem .62rem; border: 1px solid var(--line); border-radius: 100px; color: var(--muted); }

/* ---- Contact ------------------------------------------ */
.channels { display: grid; }
.channel {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem .2rem;
  border-bottom: 1px solid var(--line);
  transition: padding-left .15s, color .15s;
}
.channel:first-child { border-top: 1px solid var(--line); }
.channel:hover { padding-left: .85rem; }
.channel .ch-key { font-family: var(--font-mono); font-size: var(--step--1); text-transform: uppercase; letter-spacing: .05em; color: var(--faint); width: 6.5rem; flex-shrink: 0; }
.channel .ch-val { color: var(--ink); }
.channel:hover .ch-key, .channel:hover .ch-val { color: var(--accent); }
.channel .ch-arrow { margin-left: auto; color: var(--faint); font-family: var(--font-mono); }
.channel:hover .ch-arrow { color: var(--accent); }

/* ---- Split (profile) --------------------------------- */
.split { display: grid; gap: 1.6rem; align-items: start; }
@media (min-width: 60rem) {
  .split { grid-template-columns: 18rem 1fr; gap: 2.5rem; }
  .split.sticky-aside > :first-child { position: sticky; top: 5.5rem; }
}
.avatar { display: block; width: 100%; max-width: 14rem; height: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); }

/* ---- Footer ----------------------------------------- */
.site-footer { flex-shrink: 0; border-top: 1px solid var(--line); margin-top: clamp(3rem, 8vw, 5rem); }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1.5rem; padding-block: 1.7rem; font-family: var(--font-mono); font-size: var(--step--1); color: var(--faint); }
.site-footer a:hover { color: var(--accent); }

/* ---- Load motion ----------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .55s cubic-bezier(.2, .7, .3, 1) both; }
.rise-2 { animation-delay: .07s; }
.rise-3 { animation-delay: .14s; }
.rise-4 { animation-delay: .21s; }

/* ---- Scroll reveal -------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .6s cubic-bezier(.2, .7, .3, 1), transform .6s cubic-bezier(.2, .7, .3, 1);
  transition-delay: var(--reveal-delay, 0s);
  will-change: opacity, transform;
}
[data-reveal].is-visible { opacity: 1; transform: none; }

/* Staggered children inside a revealed group */
[data-reveal-stagger].is-visible > * {
  animation: rise .5s cubic-bezier(.2, .7, .3, 1) both;
}
[data-reveal-stagger].is-visible > *:nth-child(1) { animation-delay: .04s; }
[data-reveal-stagger].is-visible > *:nth-child(2) { animation-delay: .09s; }
[data-reveal-stagger].is-visible > *:nth-child(3) { animation-delay: .14s; }
[data-reveal-stagger].is-visible > *:nth-child(4) { animation-delay: .19s; }
[data-reveal-stagger].is-visible > *:nth-child(5) { animation-delay: .24s; }
[data-reveal-stagger].is-visible > *:nth-child(6) { animation-delay: .29s; }
[data-reveal-stagger].is-visible > *:nth-child(n+7) { animation-delay: .33s; }

@media (prefers-reduced-motion: reduce) {
  .rise, [data-reveal], [data-reveal-stagger].is-visible > * { animation: none !important; opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* ---- Hover polish -------------------------------- */
.prose a { color: var(--accent); background-image: linear-gradient(var(--accent), var(--accent)); background-size: 0% 1px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size .25s ease; }
.prose a:hover { background-size: 100% 1px; }

a.card:hover { border-color: var(--line-strong); transform: translateY(-3px); box-shadow: 0 6px 24px -12px rgba(20, 19, 15, .18), var(--shadow); }
:root[data-theme="dark"] a.card:hover { box-shadow: 0 8px 30px -14px rgba(0, 0, 0, .7); }
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.nav-links a[aria-current="page"]::after { transform-origin: left; animation: rule .4s ease both; }
@keyframes rule { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- Responsive nav ------------------------------- */
@media (max-width: 52rem) {
  .nav-links {
    position: fixed; inset: 4rem 0 auto 0; flex-direction: column; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: .4rem var(--gutter) 1rem; margin: 0;
    transform: translateY(-125%); transition: transform .25s ease;
  }
  .nav-links.open { transform: none; }
  .nav-links a { padding: .85rem 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav-links a[aria-current="page"]::after { display: none; }
  .nav-toggle { display: grid; margin-left: auto; }
  .nav-tools { margin-left: .5rem; }
}

/* ---- Print (/resume/) ----------------------------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #333; --faint: #555; --line: #bbb; --accent: #12305e; --shadow: none; }
  body::before, .site-header, .site-footer, .actions, .no-print { display: none !important; }
  .page { padding-block: 0; }
  .hero::before { display: none; }
  a { color: inherit; }
}
