/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #0a0a09;
  --bg-1: #131311;
  --bg-2: #1c1c19;
  --ink: #f5f4f0;
  --muted: #9c988e;
  --muted-2: #6b675f;

  --surface: #131311;
  --surface-2: #1c1c19;
  --border: #2a2a25;
  --border-soft: #1c1c19;

  --accent: #cdf83e;
  --accent-ink: #0a0a09;
  --accent-dim: #8fae2e;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --container: 1180px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Archivo", var(--sans);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
  scroll-behavior: smooth;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.02; letter-spacing: -0.02em; font-family: var(--display); font-weight: 800; }
::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: 0.6rem 1rem; background: var(--accent); color: var(--accent-ink);
  z-index: 9999; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.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;
}
.kicker {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent);
  padding: 0.35rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.kicker::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
body { counter-reset: section-count; }
.section { counter-increment: section-count; position: relative; padding-block: clamp(2.75rem, 5vw, 4.5rem); }
.section-head .kicker::before {
  content: counter(section-count, decimal-leading-zero);
  width: auto; height: auto; border-radius: 0; background: none;
  font-size: 0.72rem; color: var(--accent);
}
.section-head { margin-bottom: clamp(2rem, 4vw, 3rem); }
.section-head h2 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin-top: 0.8rem; }
.section-head p { color: var(--muted); margin-top: 0.9rem; font-size: 1.05rem; }

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip {
  font-family: var(--mono); font-size: 0.8rem; color: var(--muted);
  padding: 0.4rem 0.8rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}

/* =============================================================
   4. Typography
   ============================================================= */
.text-gradient { color: var(--accent); }
.lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--muted); max-width: 54ch; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.85rem 1.6rem; border-radius: 999px;
  font-family: var(--display); font-weight: 700; font-size: 0.95rem;
  transition: transform 0.4s var(--ease-soft), box-shadow 0.4s var(--ease-soft), background 0.3s, border-color 0.3s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-3px); }
.btn:active { transform: translateY(-1px); transition-duration: 0.12s; }
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 10px 26px -10px rgba(205, 248, 62, 0.45);
}
.btn-primary:hover { box-shadow: 0 18px 34px -12px rgba(205, 248, 62, 0.55); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--ink); }

.has-magnetic { display: inline-flex; position: relative; isolation: isolate; }
.magnetic-inner {
  display: inline-flex; align-items: center; justify-content: center; gap: inherit;
  will-change: transform; transition: transform 0.8s var(--ease-soft);
}

.avatar-mono {
  width: clamp(120px, 20vw, 168px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px;
}
.avatar-mono span {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--bg-2);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2.2rem, 6vw, 3rem); color: var(--accent);
}
.avatar-mono img {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover;
}

.browser-mock {
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.browser-mock__body {
  aspect-ratio: 16 / 11;
  background: var(--bg-2);
  display: grid; place-items: center; padding: 1.5rem; text-align: center;
  position: relative; overflow: hidden;
  cursor: zoom-in;
  transition: filter 0.3s var(--ease-out);
}
.browser-mock__body:hover { filter: brightness(1.1); }
.browser-mock__body img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.browser-mock__body img[data-tab-panel] {
  opacity: 0; transition: opacity 0.4s var(--ease-soft);
}
.browser-mock__body img[data-tab-panel].is-active { opacity: 1; }

.mock-tabs {
  display: flex; gap: 0.4rem; padding: 0.6rem;
  background: var(--surface); border-top: 1px solid var(--border);
}
.mock-tab {
  flex: 1; min-width: 0; padding: 0.5rem 0.5rem; border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 0.7rem; color: var(--muted);
  background: transparent; border: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color 0.25s var(--ease-out), background 0.25s var(--ease-out), border-color 0.25s var(--ease-out);
}
.mock-tab:hover:not(.is-active) { border-color: var(--ink); color: var(--ink); }
.mock-tab.is-active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 700; }

.lightbox {
  position: fixed; inset: 0; margin: auto;
  border: none; padding: 0; background: transparent; color: var(--ink);
  width: fit-content; height: fit-content;
  max-width: min(94vw, 1400px); max-height: 90vh; border-radius: var(--radius);
  overflow: visible;
}
.lightbox::backdrop { background: rgba(4, 4, 3, 0.9); }
.lightbox img {
  display: block; max-width: min(94vw, 1400px); max-height: 90vh;
  width: auto; height: auto;
  object-fit: contain; border-radius: var(--radius);
  background: var(--surface);
}
.lightbox-close {
  position: absolute; top: -14px; right: -14px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  border: 1px solid var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-weight: 700;
}

/* =============================================================
   6. Sections
   ============================================================= */

/* --- Nav --- */
.nav {
  position: fixed; top: 0; inset-inline: 0; z-index: 100;
  transition: background-color 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out);
}
.nav.is-scrolled {
  background: rgba(10, 10, 9, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; padding-block: 1.1rem; }
.nav-logo { font-family: var(--display); font-weight: 800; font-size: 1.2rem; }
.nav-links { display: none; align-items: center; gap: 2rem; }
.nav-link { position: relative; padding: 0.25rem 0; font-size: 0.95rem; color: var(--muted); }
.nav-link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: right; transition: transform 0.45s var(--ease-out);
}
.nav-link:hover { color: var(--ink); }
.nav-link:hover::after { transform: scaleX(1); transform-origin: left; }
.nav-cta { display: none; }
.nav-burger {
  display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
}
.nav-burger span { display: block; width: 18px; height: 2px; background: var(--ink); position: relative; }
.nav-burger span::before, .nav-burger span::after {
  content: ""; position: absolute; left: 0; width: 18px; height: 2px; background: var(--ink); transition: transform 0.3s;
}
.nav-burger span::before { top: -6px; }
.nav-burger span::after { top: 6px; }

.nav-mobile {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg); color: var(--ink);
  display: grid; place-items: center;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.6s var(--ease-soft);
}
.nav-mobile[aria-hidden="false"] { clip-path: inset(0); }
.nav-mobile ul { display: flex; flex-direction: column; gap: 1.6rem; text-align: center; }
.nav-mobile a { font-family: var(--display); font-size: 1.9rem; font-weight: 800; }
.nav-mobile-close { position: absolute; top: 1.3rem; right: var(--gutter); font-size: 1.6rem; }

/* --- Scroll progress --- */
.scroll-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200; pointer-events: none; }
.scroll-progress span {
  display: block; height: 100%; background: var(--accent);
  transform-origin: 0 0; transform: scaleX(0); transition: transform 0.08s linear;
}

/* --- Hero --- */
.hero {
  position: relative; display: flex; align-items: flex-start;
  padding-top: 6.5rem; padding-bottom: 3rem; overflow: clip;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(65% 60% at 50% 30%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(65% 60% at 50% 30%, #000 40%, transparent 100%);
}
.hero-grid {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: clamp(2.5rem, 6vw, 4rem); width: 100%;
  max-width: 780px; margin-inline: auto;
}
.hero-name { font-size: clamp(2.8rem, 8.5vw, 5.6rem); }
.hero-role { margin-top: 1rem; font-family: var(--mono); font-size: clamp(0.95rem, 1.6vw, 1.05rem); color: var(--accent); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.hero-lede { margin-top: 1.3rem; margin-inline: auto; }
.hero-cta-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.9rem; margin-top: 2.2rem; }
.hero-stats {
  margin-top: 0; width: 100%; max-width: 620px; margin-inline: auto;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0;
  border-top: 1px solid var(--border);
}
.hero-stat {
  padding: 1.1rem 1.5rem 0 1.3rem; flex: 1 1 40%;
  border-left: 1px solid var(--border);
  text-align: center;
}
.hero-stat:first-child { border-left: none; padding-left: 0; }
.hero-stat b { display: block; font-family: var(--display); font-size: 1.6rem; font-weight: 800; }
.hero-stat span { font-size: 0.82rem; color: var(--muted); }

.hero-scroll {
  position: absolute; left: 50%; bottom: clamp(1.25rem, 4vh, 2.5rem); transform: translateX(-50%);
  width: 1px; height: 42px; background: var(--border); overflow: hidden;
}
.hero-scroll span {
  position: absolute; top: 0; left: 0; width: 100%; height: 16px;
  background: linear-gradient(var(--accent), transparent);
  animation: heroScrollDrop 2.2s var(--ease-soft) infinite;
}
@keyframes heroScrollDrop {
  0% { transform: translateY(-100%); }
  60%, 100% { transform: translateY(130px); }
}

/* --- Work / Proyectos --- */
.work-carousel { position: relative; }
.work-track {
  display: grid; gap: 1.5rem; grid-template-columns: 1fr;
}
.work-track:focus-visible { outline-offset: 6px; }
.project-card {
  display: grid; gap: 1.6rem; padding: clamp(1.4rem, 3vw, 2rem);
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d; transition: transform 0.55s var(--ease-soft);
}
.project-card:hover { transition-duration: 0.15s; }
.project-card__label {
  display: inline-block; font-family: var(--mono); font-size: 0.74rem; color: var(--accent-ink);
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--accent); padding: 0.25rem 0.6rem; border-radius: var(--radius-sm);
}
.project-card__title { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-top: 0.7rem; }
.project-card__footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-top: 1.4rem; }

.case-facts { margin-top: 1rem; display: grid; gap: 0.8rem; max-width: 60ch; }
.case-facts dt {
  font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent);
}
.case-facts dd { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.98rem; line-height: 1.55; }

.work-more { margin-top: 2rem; text-align: center; color: var(--muted-2); font-size: 0.95rem; }
.work-more a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.work-more a:hover { color: var(--ink); }

.carousel-nav { display: none; }
.carousel-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 46px; height: 46px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  transition: border-color 0.3s, transform 0.3s var(--ease-soft), color 0.3s, opacity 0.3s;
}
.carousel-btn svg { width: 18px; height: 18px; }
.carousel-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.carousel-btn:disabled { opacity: 0.35; cursor: default; }
.carousel-dots { display: flex; align-items: center; gap: 0.55rem; }
.carousel-dot {
  width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--border);
  transition: background 0.3s, transform 0.3s var(--ease-soft);
}
.carousel-dot:hover { background: var(--muted); }
.carousel-dot.is-active { background: var(--accent); transform: scale(1.3); }

/* --- About / Sobre mí --- */
.about-grid {
  display: grid; gap: clamp(2rem, 5vw, 3rem);
  align-items: start;
}
.about-photo { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.about-bio p { text-align: justify; }
.about-bio p + p { margin-top: 1rem; }
.about-list { margin-top: 1.5rem; display: grid; gap: 0.75rem; }
.about-list li {
  display: flex; gap: 0.7rem; align-items: flex-start;
  color: var(--muted); font-size: 0.98rem; line-height: 1.5;
}
.about-list li::before {
  content: ""; width: 6px; height: 6px; margin-top: 0.55em; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.about-stack { margin-top: 1.8rem; }
.about-stack h3 { font-family: var(--mono); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-2); margin-bottom: 0.8rem; font-weight: 500; }

/* --- Contact --- */
.contact-card {
  padding: clamp(2rem, 5vw, 3.5rem); text-align: center;
  display: grid; justify-items: center; gap: 1.4rem;
}
.contact-card h2 { font-size: clamp(1.9rem, 4.5vw, 2.9rem); max-width: 18ch; }
.contact-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.9rem; margin-top: 0.6rem; }
.contact-direct { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.6rem; margin-top: 0.6rem; font-family: var(--mono); font-size: 0.92rem; color: var(--muted); }
.contact-direct button, .contact-direct a { color: var(--muted); }
.contact-direct button:hover, .contact-direct a:hover { color: var(--accent); }
.copy-feedback {
  font-size: 0.78rem; color: var(--accent); opacity: 0; transition: opacity 0.3s;
}
.copy-feedback.is-visible { opacity: 1; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: var(--accent-ink); font-family: var(--mono); font-size: 0.85rem;
  font-weight: 600; padding: 0.75rem 1.3rem; border-radius: 999px;
  opacity: 0; pointer-events: none; z-index: 300; max-width: 92vw; text-align: center;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Footer --- */
.footer { padding-block: 2.5rem; border-top: 1px solid var(--border); }
.footer-inner { display: flex; flex-direction: column; gap: 0.8rem; align-items: center; text-align: center; font-size: 0.85rem; color: var(--muted-2); }
.back-to-top { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.back-to-top:hover { color: var(--accent); }

/* =============================================================
   7. Effects
   ============================================================= */
[data-reveal] {
  opacity: 0; transform: translateY(36px);
  transition: opacity 0.8s var(--ease-soft), transform 0.8s var(--ease-soft);
}
[data-reveal].is-revealed { opacity: 1; transform: none; }

/* =============================================================
   8. Responsive (mobile-first)
   ============================================================= */
@media (max-width: 719px) {
  .hero-name { margin-top: 0.9rem; }
}

@media (min-width: 540px) {
  .hero-stat { flex: 1 1 auto; }
}

@media (min-width: 720px) {
  .hero { min-height: 88svh; align-items: center; padding-top: 6rem; padding-bottom: 0; }
  .about-grid { grid-template-columns: auto 1fr; }
  .about-photo { align-items: flex-start; }
  .about-bio p { text-align: left; }

  .work-carousel {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto;
    align-items: center; column-gap: 1rem;
  }
  .carousel-nav { display: contents; }
  .work-track {
    grid-column: 2; grid-row: 1; min-width: 0;
    display: flex; gap: 1.5rem;
    overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
  }
  .work-track::-webkit-scrollbar { display: none; }
  .project-card { flex: 0 0 380px; scroll-snap-align: start; }
  .carousel-btn { display: inline-flex; }
  [data-carousel-prev] { grid-column: 1; grid-row: 1; }
  [data-carousel-next] { grid-column: 3; grid-row: 1; }
  .carousel-dots { display: flex; align-items: center; justify-content: center; gap: 0.55rem; grid-column: 1 / -1; grid-row: 2; margin-top: 1.4rem; }
}

@media (min-width: 960px) {
  .nav-links { display: flex; }
  .nav-cta { display: inline-flex; }
  .nav-burger { display: none; }
}

@media (min-width: 1280px) {
  .hero-name { font-size: 6rem; }
}

/* =============================================================
   9. Reduced-motion (only intrusive effects)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
