/* ==========================================================================
   Portfolio — Jesús Pérez Marinetto
   Sin dependencias. Tema claro/oscuro con variables CSS.
   ========================================================================== */

/* ---------- Tipografía (Inter autoalojada, sin Google Fonts) ---------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../assets/fonts/inter-latin-ext-wght-normal.woff2) format('woff2-variations'), url(../assets/fonts/inter-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../assets/fonts/inter-latin-wght-normal.woff2) format('woff2-variations'), url(../assets/fonts/inter-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Variables registradas (permiten animar el cambio de tema) ---------- */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #fafaf9; }
@property --surface { syntax: '<color>'; inherits: true; initial-value: #f1f0ee; }
@property --line { syntax: '<color>'; inherits: true; initial-value: #e2e1de; }
@property --ink { syntax: '<color>'; inherits: true; initial-value: #141414; }
@property --ink-muted { syntax: '<color>'; inherits: true; initial-value: #5c5b58; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #c2410c; }
@property --on-accent { syntax: '<color>'; inherits: true; initial-value: #ffffff; }

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gutter: clamp(16px, 4vw, 32px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --steps: 40;
  --bg: #fafaf9; --surface: #f1f0ee; --line: #e2e1de;
  --ink: #141414; --ink-muted: #5c5b58;
  --accent: #c2410c; --on-accent: #ffffff;
  color-scheme: light;
  transition: --bg .6s ease, --surface .6s ease, --line .6s ease, --ink .6s ease,
              --ink-muted .6s ease, --accent .6s ease, --on-accent .6s ease;
}
:root[data-theme='light'] {
  --bg: #fafaf9; --surface: #f1f0ee; --line: #e2e1de;
  --ink: #141414; --ink-muted: #5c5b58;
  --accent: #c2410c; --on-accent: #ffffff;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0e0e0e; --surface: #181818; --line: #2a2a2a;
  --ink: #ededec; --ink-muted: #a3a29e;
  --accent: #fb923c; --on-accent: #141414;
  color-scheme: dark;
}
/* Sin JavaScript: respetar el tema del sistema */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e0e0e; --surface: #181818; --line: #2a2a2a;
    --ink: #ededec; --ink-muted: #a3a29e;
    --accent: #fb923c; --on-accent: #141414;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 26px;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p { margin: 0; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
section[id] { scroll-margin-top: 96px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.label {
  font-size: 12px; line-height: 16px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted);
}
.link {
  color: var(--accent); font-size: 14px; line-height: 20px;
  text-decoration: underline; text-underline-offset: 4px;
}

/* ---------- Cabecera / navbar ---------- */
.site-header { position: sticky; top: 0; z-index: 10; }
.navbar {
  position: relative; isolation: isolate;
  margin: 0 auto; max-width: 100%;
  padding: 12px var(--gutter);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 16px 32px;
  border: 1px solid transparent; border-radius: 0;
  background-color: transparent; box-shadow: 0 0 0 transparent;
  transform: translateY(0);
  transition: max-width .35s var(--ease), transform .35s var(--ease),
              background-color .35s ease, border-color .35s ease, border-radius .35s ease,
              box-shadow .35s ease, backdrop-filter .35s ease, -webkit-backdrop-filter .35s ease;
}
.navbar::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; pointer-events: none; opacity: 0;
  background: linear-gradient(180deg, color-mix(in srgb, #fff 30%, transparent), transparent 65%);
  transition: opacity .35s ease;
}
.is-scrolled .navbar {
  max-width: min(960px, calc(100% - 32px));
  transform: translateY(16px);
  background-color: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border-color: color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 60%, transparent),
              0 8px 32px color-mix(in srgb, #000 10%, transparent);
}
.is-scrolled .navbar::before { opacity: 1; }
:root[data-theme='dark'] .navbar::before {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 10%, transparent), transparent 65%);
}
:root[data-theme='dark'] .is-scrolled .navbar {
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 16%, transparent),
              0 8px 32px color-mix(in srgb, #000 45%, transparent);
}

/* Marca: solo visible al hacer scroll */
.brand {
  text-decoration: none; font-size: 24px; line-height: 30px;
  font-weight: 600; letter-spacing: -.02em;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .35s ease, transform .35s var(--ease), visibility .35s;
}
.is-scrolled .brand { opacity: 1; visibility: visible; transform: none; }

.nav-desktop {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 32px; font-size: 14px; line-height: 20px;
}
.navlink {
  color: var(--ink-muted); text-decoration: underline;
  text-decoration-color: var(--line); text-underline-offset: 4px;
}
.navlink:hover { color: var(--ink); }

.controls {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .08em;
}
.lang-btn {
  cursor: pointer; border: 0; background: transparent;
  padding: 8px; min-height: 32px; color: var(--ink-muted);
  text-underline-offset: 4px;
}
.lang-btn[aria-pressed='true'] { color: var(--accent); text-decoration: underline; }
.theme-btn {
  cursor: pointer; margin-left: 8px; border: 0; background: transparent;
  color: var(--ink-muted); padding: 0; width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-btn:hover { color: var(--ink); }

/* Icono sol/luna */
.ti .sun, .ti .moon { transform-origin: 12px 12px; transition: transform .6s var(--ease), opacity .4s ease; }
.ti .sun { opacity: 0; transform: rotate(-90deg) scale(.3); }
.ti .moon { opacity: 1; transform: none; }
:root[data-theme='dark'] .ti .sun { opacity: 1; transform: none; }
:root[data-theme='dark'] .ti .moon { opacity: 0; transform: rotate(90deg) scale(.3); }

/* Menú hamburguesa (móvil) */
.nav-toggle {
  display: none; cursor: pointer; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: -8px -12px -8px 0;
  border: 0; background: transparent; color: var(--ink); padding: 0;
}
.nav-panel { display: none; }

@media (max-width: 980px) {
  .nav-desktop { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav-panel {
    display: block; position: absolute; top: calc(100% + 8px);
    left: var(--gutter); right: var(--gutter);
    padding: 0 16px 16px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 8px 32px color-mix(in srgb, #000 12%, transparent);
    visibility: hidden; opacity: 0; pointer-events: none;
    transform-origin: top; transform: translateY(-8px) scale(.98);
    clip-path: inset(0 0 100% 0 round 8px);
    transition: clip-path .45s var(--ease), transform .45s var(--ease), opacity .25s ease, visibility 0s linear .45s;
  }
  .nav-panel.open {
    visibility: visible; opacity: 1; pointer-events: auto; transform: none;
    clip-path: inset(-48px -48px -48px -48px round 8px);
    transition: clip-path .45s var(--ease), transform .45s var(--ease), opacity .25s ease, visibility 0s;
  }
  .pitem { opacity: 0; transform: translateY(-6px); transition: opacity .2s ease, transform .2s ease; }
  .nav-panel.open .pitem {
    opacity: 1; transform: none;
    transition: opacity .35s ease .12s, transform .35s var(--ease) .12s;
  }
  .nav-panel.open .pitem:nth-child(2) { transition-delay: .17s; }
  .nav-panel.open .pitem:nth-child(3) { transition-delay: .22s; }
  .nav-panel.open .pitem:nth-child(4) { transition-delay: .27s; }
  .nav-panel.open .pitem:nth-child(5) { transition-delay: .32s; }
  .nav-panel.open .pitem:nth-child(6) { transition-delay: .37s; }
  .nav-panel.open .pitem:nth-child(7) { transition-delay: .42s; }
}
.panel-link {
  display: flex; align-items: center; min-height: 48px;
  border-bottom: 1px solid var(--line); text-decoration: none;
  font-size: 16px; line-height: 26px;
}
.panel-controls { padding-top: 16px; }
.panel-controls .lang-btn { padding: 8px 16px 8px 0; min-height: 44px; }
.panel-controls .theme-btn { margin-left: auto; width: 44px; height: 44px; }

/* ---------- Layout ---------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 0 var(--gutter) 32px; }

.section {
  margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 32px;
}
.section > h2 {
  flex: 1 1 100%; font-size: 40px; line-height: 44px;
  font-weight: 600; letter-spacing: -.01em;
}
.section-col { flex: 1 1 400px; min-width: 0; display: flex; flex-direction: column; gap: 32px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; margin-top: 32px;
  min-height: clamp(560px, calc(100svh - 112px), 1100px);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.hero-bg {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 100vw;
  transform: translateX(-50%); z-index: 0; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 48% 34% at 50% 50%, transparent 50%, #000 100%);
  mask-image: radial-gradient(ellipse 48% 34% at 50% 50%, transparent 50%, #000 100%);
}
.hero-bg svg { display: block; width: 100%; height: 100%; }
.hero-main {
  position: relative; z-index: 1; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.hero h1 {
  font-size: clamp(40px, 7vw, 64px); line-height: 1.05; font-weight: 600;
  letter-spacing: -.02em; text-wrap: balance;
}
.cursor { color: var(--accent); }
.hero-role { font-size: 24px; line-height: 30px; font-weight: 600; color: var(--ink-muted); }
.hero-hint {
  position: relative; z-index: 1; padding-bottom: 32px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--ink-muted);
}
.route { fill: none; stroke: var(--ink); stroke-opacity: .16; stroke-width: 1; }
.node { fill: var(--bg); stroke: var(--ink); stroke-opacity: .5; stroke-width: 1; }
.pulse {
  fill: none; stroke: var(--ink); stroke-opacity: .85; stroke-width: 1.5;
  stroke-linecap: round; stroke-dasharray: 3 97; stroke-dashoffset: 3;
}

/* ---------- Sobre mí ---------- */
.about-top { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 32px; }
.about-photo {
  flex: 0 0 280px; width: 280px; max-width: 100%; height: 350px;
  object-fit: cover; border-radius: 8px;
}
.about-text { flex: 1 1 260px; min-width: 0; max-width: 520px; }
.about-text p {
  font-size: clamp(22px, 3vw, 28px); line-height: 1.35; font-weight: 500;
  letter-spacing: -.01em; text-wrap: pretty;
}
.facts { border-bottom: 1px solid var(--line); }
.fact {
  display: flex; flex-wrap: wrap; gap: 8px 32px; padding: 16px 0;
  border-top: 1px solid var(--line);
}
.fact-k { flex: 0 0 120px; line-height: 28px; }
.fact-v { flex: 1 1 240px; min-width: 0; font-size: 20px; line-height: 28px; font-weight: 500; }
.langs { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.lang { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.lang-name { flex: 0 0 120px; font-size: 20px; line-height: 28px; font-weight: 500; }
.bars { display: flex; align-items: center; gap: 4px; }
.bar { display: block; width: 28px; height: 6px; border-radius: 9999px; background: var(--line); }
.bar.on { background: var(--accent); }
.lang-level { margin-left: 12px; font-size: 14px; line-height: 20px; color: var(--ink-muted); }

/* ---------- Tecnologías ---------- */
.marquee {
  flex: 1 1 100%; min-width: 0; padding: 8px 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.mtrack { display: flex; width: max-content; }
.mitem {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-right: 48px; color: var(--ink-muted); transition: color .2s ease;
}
.mitem:hover { color: var(--ink); }
.mitem span {
  font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .08em; white-space: nowrap;
}
.stack-groups { flex: 1 1 100%; min-width: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.stack-group {
  display: flex; flex-wrap: wrap; gap: 8px 32px; padding: 24px 0;
  border-top: 1px solid var(--line);
}
.stack-title { flex: 0 0 240px; font-size: 16px; line-height: 26px; font-weight: 500; }
.techs { flex: 1 1 280px; min-width: 0; display: flex; flex-wrap: wrap; }
.tech { font-size: 14px; line-height: 26px; }
.tech::after { content: '/'; margin: 0 12px; color: color-mix(in srgb, var(--ink-muted) 55%, transparent); }
.tech:last-child::after { content: none; }

/* ---------- Experiencia (grafo) ---------- */
.timeline { flex: 1 1 100%; min-width: 0; }
.tl-item { display: flex; gap: 24px; }
.tl-rail { position: relative; flex: 0 0 12px; }
.tl-dot {
  position: relative; z-index: 1; display: block; margin-top: 7px;
  width: 12px; height: 12px; border-radius: 9999px;
  border: 1.5px solid var(--ink-muted); background: var(--bg);
}
.tl-item:not(:last-child) .tl-rail::after {
  content: ''; position: absolute; left: 5.5px; top: 19px; bottom: -7px; width: 1px;
  background: color-mix(in srgb, var(--ink-muted) 45%, transparent);
}
.tl-body {
  flex: 1 1 auto; min-width: 0; padding-bottom: 32px;
  display: flex; flex-direction: column; gap: 2px;
}
.tl-role { font-size: 24px; line-height: 30px; font-weight: 600; }
.tl-org { color: var(--ink-muted); }
.tl-dates { font-size: 14px; line-height: 20px; color: var(--ink-muted); }

/* ---------- Certificaciones ---------- */
.cert { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 32px; }
.cert-badge {
  flex: 0 0 96px; height: 96px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
}
.cert-badge img { width: 96px; height: 96px; object-fit: contain; }
.cert-body { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cert-title { font-size: 24px; line-height: 30px; font-weight: 600; }
.cert-text { max-width: 560px; color: var(--ink-muted); }

/* ---------- Proyectos ---------- */
.projects { border-bottom: 1px solid var(--line); }
.project {
  display: flex; flex-direction: column; gap: 8px; padding: 16px 0;
  border-top: 1px solid var(--line); text-decoration: none;
}
.project-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.project-name {
  font-size: 24px; line-height: 30px; font-weight: 600;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px;
  transition: text-decoration-color .15s ease;
}
.project:hover .project-name { text-decoration-color: var(--accent); }
.project-desc { max-width: 560px; color: var(--ink-muted); }

/* ---------- Contacto ---------- */
.open-status { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.live { position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 9999px; background: #22c55e; flex: 0 0 8px; }
.live::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: #22c55e; opacity: 0; }
.contact-text { max-width: 480px; color: var(--ink-muted); }
.contact-links { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border-radius: 8px; background: var(--accent); color: var(--on-accent);
  text-decoration: none; font-size: 14px; line-height: 20px; font-weight: 500;
}

/* ---------- Pie ---------- */
.site-footer {
  margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 32px;
}

/* ---------- Animaciones ---------- */
@keyframes blink { 50% { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
@keyframes travel { to { stroke-dashoffset: -97; } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes ping { 0% { transform: scale(1); opacity: .6; } 80%, 100% { transform: scale(2.6); opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .cursor { animation: blink 1.1s steps(1) infinite; }
  .a-rise { animation: rise .8s var(--ease) both; }
  .a-fade { animation: fade 1s ease both; }
  .a-reveal { animation: reveal 1.6s steps(var(--steps), end) both; }
  .a-bob { animation: bob 1.8s ease-in-out infinite; }
  .pulse { animation: travel 9s linear infinite; }
  .mtrack { animation: marquee 72s linear infinite; }
  .marquee:hover .mtrack { animation-play-state: paused; }
  .live::after { animation: ping 2s cubic-bezier(0, 0, .2, 1) infinite; }
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .scroll-in { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .pulse { display: none; }
  .marquee { overflow-x: auto; -webkit-mask-image: none; mask-image: none; }
  .mdup { display: none !important; }
}
