/* Inter, self-hosted: variable font covering weights 400–700, latin subset */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/inter-latin.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;
}

:root {
  color-scheme: light;

  --bg: #f6f5f2;
  --text: #1c1917;
  --muted: #6b645e;
  --line: #e2dfd8;
  --accent: #2563eb;
  --accent-soft: #dbe6fd;
  --pill-bg: #ebe9e3;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 48px;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }
strong { font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 680px);
  column-gap: 96px;
  justify-content: center;
  padding: 40px 24px 64px;
}

.hero { grid-column: 2; margin-bottom: 64px; }
.sidebar { grid-column: 1; grid-row: 2; }
main { grid-column: 2; grid-row: 2; }

/* ---------- Header ---------- */
h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.role {
  margin: 2px 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

/* "Frontend Developer": letters turn rainbow and hop in a wave on hover */
.role-title {
  display: inline-block;
  cursor: default;
}

.role-title .ch {
  display: inline-block;
  white-space: pre;
  transition: color 0.35s;
  transition-delay: calc(var(--i) * 18ms);
}

.role-title:hover .ch,
.role-title.is-playing .ch {
  color: hsl(calc(var(--i) * 20deg + 200deg) 85% 52%);
  animation: hop 0.55s var(--ease) both;
  animation-delay: calc(var(--i) * 30ms);
}

.role-title:hover,
.role-title.is-playing {
  animation: hue 2.4s linear infinite 0.6s;
}

@keyframes hop {
  0% { transform: none; }
  35% { transform: translateY(-7px) rotate(-6deg) scale(1.15); }
  70% { transform: translateY(1px); }
  100% { transform: none; }
}

@keyframes hue {
  to { filter: hue-rotate(360deg); }
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 48px;
  align-self: start;
}

.nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav a {
  display: inline-block;
  padding: 4px 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.25s;
}

.nav a:hover,
.nav a.is-active { color: var(--text); }

.nav a.is-active { font-weight: 500; }

/* ---------- Header links: LinkedIn · email [copy] ---------- */
.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  color: var(--muted);
}

.links li + li::before {
  content: "·";
  margin: 0 8px;
}

.email {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.copy {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.25s, background 0.25s, transform 0.3s var(--ease);
}

.copy:hover { color: var(--text); background: var(--pill-bg); }
.copy:active { transform: scale(0.88); }
.copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.copy svg {
  grid-area: 1 / 1;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.25s, transform 0.4s var(--ease);
}

.copy .check-icon { opacity: 0; transform: scale(0.5); }
.copy.is-copied { color: var(--text); }
.copy.is-copied .copy-icon { opacity: 0; transform: scale(0.5); }
.copy.is-copied .check-icon { opacity: 1; transform: none; }

/* Small "Copiado" bubble above the button */
.copy-toast {
  position: absolute;
  right: -6px;
  bottom: calc(100% + 4px);
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s, transform 0.35s var(--ease);
}

.copy-toast.is-visible { opacity: 1; transform: none; }

/* ---------- Text roll (nav links) ---------- */
.roll .roll-inner {
  display: inline-flex;
  overflow: hidden;
  vertical-align: top;
}

.roll .ch {
  display: inline-block;
  white-space: pre;
  text-shadow: 0 1.5em currentColor;
  transition: transform 0.45s var(--ease);
  transition-delay: calc(var(--i) * 14ms);
}

.roll:hover .ch { transform: translateY(-1.5em); }

/* ---------- Highlight link (prose) ---------- */
.mark {
  position: relative;
  padding: 1px 3px;
  margin: 0 -1px;
  border-radius: 4px;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  background: linear-gradient(var(--accent-soft), var(--accent-soft)) no-repeat left / 0% 100%;
  transition: background-size 0.45s var(--ease), color 0.3s, text-decoration-color 0.3s;
}

.mark:hover {
  background-size: 100% 100%;
  color: var(--accent);
  text-decoration-color: transparent;
}

/* ---------- Sections ---------- */
section { margin-bottom: 72px; }

h2 {
  margin: 0 0 20px;
  min-height: 1.4em;
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.intro p + p { margin-top: 18px; }
.intro { color: var(--text); }

/* ---------- Projects ---------- */
.section-lead {
  margin: -8px 0 28px;
  color: var(--muted);
}

/* Track bleeds to the right edge of the viewport; --bleed is set from JS */
.projects {
  display: flex;
  gap: 32px;
  margin-right: calc(-1 * var(--bleed, 0px));
  padding-right: var(--bleed, 0px);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  cursor: grab;
}

.projects::-webkit-scrollbar { display: none; }
.projects:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 14px; }

.projects.is-dragging {
  scroll-snap-type: none;
  scroll-behavior: auto;
  cursor: grabbing;
  user-select: none;
}

.project {
  flex: 0 0 min(520px, 82%);
  scroll-snap-align: start;
}

/* Cards that aren't the active one dim their image (text keeps full contrast) */
.project-media { transition: opacity 0.5s var(--ease); }
.project:not(.is-current) .project-media { opacity: 0.45; }
.project:not(.is-current):hover .project-media { opacity: 0.8; }

.project-media {
  margin: 0 0 16px;
  padding: 14px 14px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--pill-bg);
}

.project-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.06);
  transform-origin: top center;
  transition: transform 0.7s var(--ease);
}

.project:hover .project-media img { transform: translateY(-4px) scale(1.015); }

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-bottom: 4px;
}

.project-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.project-link svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--muted);
  transition: transform 0.4s var(--ease), color 0.25s;
}

.project-link:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.project-link:hover svg { color: var(--text); transform: translate(2px, -2px); }

.project-body > p { color: var(--muted); }

/* Controls pill */
.carousel-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 28px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--pill-bg);
}

.carousel-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.3s var(--ease);
}

.carousel-btn:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.carousel-btn:active:not(:disabled) { transform: scale(0.9); }
.carousel-btn:disabled { opacity: 0.35; cursor: default; }

.carousel-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.carousel-dots {
  display: flex;
  align-items: center;
}

/* 24px hit area; the visible dot is the ::before */
.carousel-dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: width 0.45s var(--ease);
}

.carousel-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.4;
  transition: width 0.45s var(--ease), opacity 0.3s, background 0.3s;
}

.carousel-dot:hover::before { opacity: 0.7; }

.carousel-dot.is-active { width: 30px; }

.carousel-dot.is-active::before {
  width: 18px;
  background: var(--text);
  opacity: 1;
}

/* ---------- Experience accordion ---------- */
.exp {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.exp:first-child { padding-top: 4px; }

.exp-head {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  cursor: pointer;
}

.exp-toggle {
  flex: none;
  display: grid;
  place-items: center;
  padding: 2px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.exp-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.logo {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--logo);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.4s var(--ease);
}

.exp-head:hover .logo { transform: rotate(-6deg) scale(1.06); }

.exp-title {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.exp-role { font-weight: 600; }

/* Company links: quiet underline that darkens on hover */
.co {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.25s, text-decoration-color 0.25s;
}

.co:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

.exp-company { color: var(--muted); text-underline-offset: 4px; }

.pill {
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--pill-bg);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.chevron {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.5s var(--ease), stroke 0.25s;
}

.exp-head:hover .chevron { stroke: var(--text); }
.exp.is-open .chevron { transform: rotate(180deg); }

.exp-summary {
  margin: 6px 0 0 48px;
  color: var(--muted);
}

.exp-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.55s var(--ease);
}

.exp.is-open .exp-panel { grid-template-rows: 1fr; }

.exp-inner {
  min-height: 0;
  overflow: hidden;
  padding-left: 48px;
}

.bullets {
  margin: 0;
  padding: 16px 0 0 18px;
}

.bullets li { margin-bottom: 8px; }
.bullets li::marker { color: var(--muted); }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 4px;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 1px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Panel content appears progressively */
.exp-inner .bullets li,
.exp-inner .tags {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}

.exp.is-open .exp-inner .bullets li,
.exp.is-open .exp-inner .tags {
  opacity: 1;
  transform: none;
  transition: opacity 0.5s var(--ease), transform 0.6s var(--ease);
  transition-delay: calc(120ms + var(--i, 0) * 70ms);
}

/* ---------- Stack ---------- */
.stack { margin: 0; }

.stack > div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 24px;
  padding: 10px 0;
}

.stack dt { font-weight: 600; }
.stack dd { margin: 0; color: var(--muted); }

/* ---------- Rows (education, languages) ---------- */
.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rows li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
}

.rows .muted { margin-left: 6px; }

/* ---------- Footer ---------- */
footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 0.9rem;
}

/* ---------- Motion (only with JS) ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  filter: blur(4px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease), filter 0.6s var(--ease);
  transition-delay: var(--d, 0ms);
}

.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
  filter: none;
}

/* Intro: words appear one by one */
.w {
  display: inline-block;
  opacity: 0;
  transform: translateY(6px);
  filter: blur(3px);
  animation: word-in 0.45s var(--ease) forwards;
  animation-delay: calc(var(--i) * 10ms);
}

/* Jumping away from the intro shows it complete at once */
.intro.is-done .w {
  animation: none;
  opacity: 1;
  transform: none;
  filter: none;
}

@keyframes word-in {
  to { opacity: 1; transform: none; filter: none; }
}

/* Typed headings: letters exist from the start, hidden until typed */
.tl { visibility: hidden; }
.tl.on { visibility: visible; }

.tl.is-caret { position: relative; }

.tl.is-caret::after {
  position: absolute;
  left: 100%;
  top: 0.2em;
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.12em;
  background: var(--accent);
  animation: caret 0.8s steps(1) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

/* ---------- Custom cursor (mouse only; .has-cursor is set from JS) ---------- */
.has-cursor,
.has-cursor * { cursor: none !important; }

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
  will-change: transform;
}

.cursor.is-visible { opacity: 1; }

.cursor-dot {
  display: grid;
  place-items: center;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  transform: translate(-50%, -50%) scale(1);
  transition:
    width 0.35s var(--ease),
    height 0.35s var(--ease),
    background 0.3s,
    transform 0.25s var(--ease);
}

/* Over links and buttons: a soft, larger disc */
.cursor.is-link .cursor-dot {
  width: 34px;
  height: 34px;
  background: rgb(28 25 23 / 0.1);
}

/* Over the carousel: a solid disc with ‹ › replacing the grab hand */
.cursor.is-drag .cursor-dot {
  width: 58px;
  height: 58px;
  background: var(--text);
}

.cursor-arrows {
  display: flex;
  gap: 2px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s, transform 0.35s var(--ease), gap 0.35s var(--ease);
}

.cursor-arrows svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cursor.is-drag .cursor-arrows { opacity: 1; transform: none; }

/* While dragging: the disc tightens and the arrows spread */
.cursor.is-dragging .cursor-dot { width: 46px; height: 46px; }
.cursor.is-dragging .cursor-arrows { gap: 9px; }

/* Press feedback */
.cursor.is-down .cursor-dot { transform: translate(-50%, -50%) scale(0.75); }

/* ---------- Click burst ---------- */
.burst {
  position: fixed;
  z-index: 9999;
  width: 0;
  height: 0;
  pointer-events: none;
}

.burst-ray {
  position: absolute;
  left: -1px;
  top: -4px;
  width: 2px;
  height: 8px;
  border-radius: 2px;
  background: var(--text);
  transform: rotate(var(--a)) translateY(-8px) scaleY(1);
  animation: burst-ray 0.5s var(--ease) forwards;
}

@keyframes burst-ray {
  from { transform: rotate(var(--a)) translateY(-6px) scaleY(1); opacity: 1; }
  to { transform: rotate(var(--a)) translateY(-26px) scaleY(0.2); opacity: 0; }
}

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  html { scroll-padding-top: 64px; }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 32px 16px 48px;
  }

  /* The sidebar dissolves and its nav becomes a sticky top bar */
  .sidebar { display: contents; }

  .hero { order: 0; grid-column: 1; margin-bottom: 20px; }
  .sidebar > nav { order: 1; }
  main { order: 2; grid-column: 1; grid-row: auto; }

  h1 { font-size: 1.15rem; }

  .sidebar > nav {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -16px 32px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

  .nav {
    display: flex;
    gap: 22px;
    margin: 0;
    padding: 0 16px;
    border: 0;
    overflow-x: auto;
    scrollbar-width: none;
    /* Fade the edges so it's clear the bar scrolls */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent);
  }

  .nav::-webkit-scrollbar { display: none; }
  .nav li { flex: none; }
  .nav li:last-child { padding-right: 16px; }

  .nav a {
    position: relative;
    padding: 13px 0;
    font-size: 0.875rem;
  }

  /* Active section gets an underline in the bar */
  .nav a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    transform: scaleX(0);
    transition: transform 0.4s var(--ease);
  }

  .nav a.is-active::after { transform: scaleX(1); }

  section { margin-bottom: 56px; }
  h2 { font-size: 1.2rem; margin-bottom: 16px; }

  .projects { gap: 16px; }
  .project { flex-basis: 86%; }
  .project-media { padding: 10px 10px 0; border-radius: 12px; }
  .project-head .pill { white-space: normal; }

  .carousel-controls { margin-top: 20px; }
  .carousel-btn { width: 36px; height: 36px; }

  .exp { padding: 18px 0; }
  .exp-head { gap: 12px; align-items: flex-start; }
  .logo { width: 30px; height: 30px; margin-top: 1px; }
  .exp-title { gap: 2px 10px; }
  .exp-toggle { margin-top: 2px; }

  .exp-summary,
  .exp-inner { margin-left: 0; padding-left: 0; }

  .stack > div { grid-template-columns: 1fr; gap: 2px; }

  .rows li { flex-direction: column; gap: 2px; }
  .rows .muted { display: block; margin-left: 0; }

  footer { flex-direction: column; gap: 4px; }
}

/* ---------- Touch: no sticky hover states ---------- */
@media (hover: none) {
  .roll:hover .ch { transform: none; }
  .project:not(.is-current):hover .project-media { opacity: 0.45; }
  .project:hover .project-media img { transform: none; }
  .exp-head:hover .logo { transform: none; }
  .copy:hover:not(.is-copied) { color: var(--muted); background: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}

/* ---------- Print ---------- */
@media print {
  .layout { display: block; padding: 0; }
  .sidebar, .sidebar > *, .chevron, .tags, footer, .project-media, .copy, .copy-toast, .cursor, .burst { display: none !important; }
  .projects { display: block; margin: 0; padding: 0; overflow: visible; }
  .project-media { opacity: 1 !important; }
  .carousel-controls { display: none; }
  .project { margin-bottom: 12px; break-inside: avoid; }
  .hero { margin-bottom: 24px; }
  section { margin-bottom: 28px; }
  .exp { break-inside: avoid; }
  .exp-panel { grid-template-rows: 1fr !important; }
  .js [data-reveal], .w, .exp-inner .bullets li { opacity: 1 !important; transform: none !important; filter: none !important; }
  .mark { background: none; text-decoration: none; }
  .tl { visibility: visible !important; }
}
