/* ---------- Tokens ---------- */
/* Colours follow color-scheme: the system by default, or the one forced with data-theme. */
:root {
  --bg: light-dark(#fbf7f1, #1b1815);
  --bg-soft: light-dark(#f4ece1, #24201c);
  --surface: light-dark(rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.04));
  --ink: light-dark(#2a2420, #f3ece3);
  --ink-soft: light-dark(#5f554c, #cbbfb2);
  --muted: light-dark(#8f8378, #94887c);
  --line: light-dark(rgba(42, 36, 32, 0.1), rgba(243, 236, 227, 0.1));

  --clay: light-dark(#d9653b, #ef8a5f);
  --clay-deep: light-dark(#b84f2a, #f4a07b);
  --sun: #f2c14e;
  --sage: #8fa58a;
  --sky: #9cc3d5;

  --radius: 22px;
  --shadow: 0 1px 2px light-dark(rgba(42, 36, 32, 0.04), rgba(0, 0, 0, 0.2)),
            0 12px 40px -12px light-dark(rgba(42, 36, 32, 0.12), rgba(0, 0, 0, 0.5));

  --serif: "Fraunces", ui-serif, Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --wrap: min(1120px, 100% - 3rem);
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.1; margin: 0; letter-spacing: -0.02em; }
em { font-style: italic; color: var(--clay); }
h1 em, h2 em { font-weight: 300; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
small { font-size: 0.85em; }
::selection { background: var(--sun); color: #2a2420; }

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

/* ---------- Language toggle ---------- */
html[lang="es"] [data-l="en"],
html[lang="en"] [data-l="es"] { display: none !important; }

/* ---------- Ambient blobs ---------- */
.aura { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: drift 26s ease-in-out infinite alternate;
}
.blob--sun  { width: 46vmax; height: 46vmax; background: var(--sun);  top: -18vmax; right: -12vmax; }
.blob--clay { width: 34vmax; height: 34vmax; background: var(--clay); top: 30vh;    left: -18vmax; opacity: 0.28; animation-duration: 32s; }
.blob--sage { width: 38vmax; height: 38vmax; background: var(--sage); bottom: -20vmax; right: 10vw;  opacity: 0.3;  animation-duration: 38s; }

/* Dimmer in dark mode, whether forced or coming from the system. */
:root[data-theme="dark"] .blob { opacity: 0.16; }
:root[data-theme="dark"] :is(.blob--clay, .blob--sage) { opacity: 0.12; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .blob { opacity: 0.16; }
  :root:not([data-theme="light"]) :is(.blob--clay, .blob--sage) { opacity: 0.12; }
}

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(4vw, 3vh) scale(1.06); }
  100% { transform: translate(-3vw, -2vh) scale(0.96); }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2rem;
  width: var(--wrap);
  margin: 0 auto;
  padding: 1.25rem 0;
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0 -50vw;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.topbar.is-scrolled::before { opacity: 1; }

.brand {
  font-family: var(--serif);
  font-size: 1.5rem;
  text-decoration: none;
  letter-spacing: -0.03em;
}
.brand__dot { color: var(--clay); }

.nav { display: flex; gap: 1.75rem; margin-left: auto; font-size: 0.95rem; }
.nav a { text-decoration: none; color: var(--ink-soft); position: relative; transition: color 0.2s; }
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 1.5px;
  background: var(--clay);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after { transform: scaleX(1); }

.lang {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: 500 0.8rem/1 var(--sans);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.2s;
}
.lang:hover { border-color: var(--clay); }
.lang__sep { opacity: 0.4; }
html[lang="es"] .lang__opt[data-for="es"],
html[lang="en"] .lang__opt[data-for="en"] { color: var(--ink); }

.tools { display: flex; align-items: center; gap: 0.5rem; }

.theme {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.theme__opt {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}
.theme__opt svg { width: 0.85rem; height: 0.85rem; }
.theme__opt:hover { color: var(--ink); }
.theme__opt[aria-pressed="true"] { background: var(--bg-soft); color: var(--clay); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.5rem;
  border-radius: 999px;
  font-weight: 500;
  text-decoration: none;
  transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.btn svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.25s ease; }
.btn:hover { transform: translateY(-2px); }
.btn:hover svg { transform: translateX(3px); }
.btn--solid { background: var(--ink); color: var(--bg); box-shadow: var(--shadow); }
.btn--solid:hover { background: var(--clay); color: #fff; }
.btn--ghost { border: 1px solid var(--line); background: var(--surface); }
.btn--ghost:hover { border-color: var(--clay); }
.btn--big { padding: 1.1rem 1.9rem; font-size: 1.05rem; }

/* ---------- Hero ---------- */
main { width: var(--wrap); margin: 0 auto; }

.hero {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
  min-height: min(88vh, 820px);
  padding: 3rem 0 4rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(8px);
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin-bottom: 1.75rem;
}
.pill__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4caf6a;
  box-shadow: 0 0 0 0 rgba(76, 175, 106, 0.5);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(76, 175, 106, 0.45); }
  70%  { box-shadow: 0 0 0 10px rgba(76, 175, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 106, 0); }
}

.hero__title { font-size: clamp(3rem, 8vw, 6.25rem); margin-bottom: 1.5rem; }
.hero__lead { font-size: clamp(1.1rem, 1.6vw, 1.3rem); color: var(--ink-soft); max-width: 34em; margin-bottom: 2.25rem; }
.hero__lead strong { color: var(--ink); font-weight: 600; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 0.9rem; }

.hero__photo { position: relative; margin: 0; justify-self: center; width: min(100%, 400px); }
.arch {
  aspect-ratio: 4 / 5;
  border-radius: 999px 999px var(--radius) var(--radius);
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(170deg, #fde7c4 0%, #f7c9a8 55%, #e9b394 100%);
  box-shadow: var(--shadow);
  animation: float 9s ease-in-out infinite;
}
.arch img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
  /* The portrait has a white background: multiply lets the warm arch gradient show through. */
  mix-blend-mode: multiply;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

.sticker {
  position: absolute;
  left: -1.5rem;
  bottom: 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.1rem;
  border-radius: 18px;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: rotate(-4deg);
}
.sticker__big { font-family: var(--serif); font-size: 2rem; line-height: 1; color: var(--clay); }
.sticker__small { font-size: 0.8rem; line-height: 1.25; color: var(--ink-soft); font-weight: 500; }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 2rem 1.75rem;
  background: var(--bg);
}
.stat__num { font-family: var(--serif); font-size: clamp(2.5rem, 4vw, 3.25rem); line-height: 1; color: var(--clay); letter-spacing: -0.03em; }
.stat__label { font-weight: 500; line-height: 1.4; }
.stat__label small { color: var(--muted); font-weight: 400; }

/* ---------- Sections ---------- */
.section { padding: clamp(5rem, 12vw, 9rem) 0 0; }
.section__title { font-size: clamp(2.4rem, 5vw, 3.75rem); margin-bottom: 2.75rem; }
.section__intro { color: var(--ink-soft); max-width: 38em; margin: -1.25rem 0 2.5rem; font-size: 1.1rem; }

/* About */
.about { display: grid; grid-template-columns: 1.4fr 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.about__body { font-size: 1.15rem; color: var(--ink-soft); }
.about__body strong { color: var(--ink); font-weight: 600; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.chips li {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.925rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.chips li:hover { transform: translateY(-2px) rotate(-1deg); border-color: var(--clay); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: 11.5rem;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 1px;
  background: linear-gradient(var(--clay), var(--line) 30%, var(--line));
}
.step { display: grid; grid-template-columns: 10rem 1fr; gap: 3rem; padding-bottom: 2.25rem; position: relative; }
.step::before {
  content: "";
  position: absolute;
  left: calc(11.5rem - 5px);
  top: 0.65rem;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--muted);
}
.step--now::before { border-color: var(--clay); background: var(--clay); box-shadow: 0 0 0 6px color-mix(in srgb, var(--clay) 20%, transparent); }
.step__meta { display: flex; flex-direction: column; text-align: right; padding-top: 0.25rem; }
.step__when { font-weight: 600; }
.step__where { color: var(--muted); font-size: 0.9rem; }
.step__card {
  padding: 1.75rem 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(6px);
  color: var(--ink-soft);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.step__card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.step__card h3 { font-size: 1.75rem; color: var(--ink); margin-bottom: 0.35rem; }
.step__card h3 small { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); letter-spacing: 0; }
.step__role { color: var(--clay); font-weight: 500; margin-bottom: 0.75rem; }

.roles { list-style: none; margin: 0.5rem 0 1rem; padding: 0; }
.roles li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--line);
}
.roles li:last-child { border-bottom: 0; }
.roles__name { color: var(--ink); font-weight: 500; }
.roles__name small { color: var(--muted); font-weight: 400; }
.roles__when { color: var(--muted); font-size: 0.9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Recognition cards */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
.card {
  position: relative;
  padding: 1.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover { transform: translateY(-4px) rotate(-0.5deg); box-shadow: var(--shadow); }
.card::after {
  content: "";
  position: absolute;
  width: 140px; height: 140px;
  right: -50px; top: -50px;
  border-radius: 50%;
  background: var(--accent, transparent);
  opacity: 0.35;
  filter: blur(20px);
}
.card--sun  { --accent: var(--sun); }
.card--clay { --accent: var(--clay); }
.card--sage { --accent: var(--sage); }
.card__year { display: block; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 1.5rem; }
.card h3 { font-size: 1.6rem; color: var(--ink); margin-bottom: 0.6rem; }
.card__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; font-size: 0.95rem; color: var(--ink); }
.card__list li::before { content: "✦ "; color: var(--clay); }

/* Repos */
.repos { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 3rem; }
.repos a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: padding 0.25s ease, color 0.25s ease;
}
.repos a:hover { padding-left: 0.6rem; color: var(--clay); }
.repo__name { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.95rem; }
.repo__note { color: var(--muted); font-size: 0.875rem; text-align: right; }

/* Writing */
.writing { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.writing li {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem 1.75rem;
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.writing__kind { font-size: 0.8rem; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }
.writing__title { font-family: var(--serif); font-size: 1.35rem; line-height: 1.25; }

/* Contact */
.contact { padding: clamp(6rem, 14vw, 10rem) 0 4rem; }
.contact__inner {
  position: relative;
  padding: clamp(3rem, 8vw, 6rem) clamp(1.5rem, 6vw, 5rem);
  border-radius: calc(var(--radius) * 2);
  background:
    radial-gradient(circle at 85% 15%, color-mix(in srgb, var(--sun) 55%, transparent), transparent 45%),
    radial-gradient(circle at 10% 90%, color-mix(in srgb, var(--clay) 35%, transparent), transparent 50%),
    var(--bg-soft);
  text-align: center;
  overflow: hidden;
}
.contact__kicker { color: var(--ink-soft); font-weight: 500; margin-bottom: 1rem; }
.contact__title { font-size: clamp(2rem, 5vw, 3.5rem); max-width: 18em; margin: 0 auto 2.5rem; }
.socials { list-style: none; margin: 2.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.75rem; font-size: 0.95rem; }
.socials a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--line); transition: color 0.2s, border-color 0.2s; }
.socials a:hover { color: var(--clay); border-color: var(--clay); }

/* Footer */
.footer { width: var(--wrap); margin: 0 auto; padding: 2rem 0 3rem; text-align: center; color: var(--muted); font-size: 0.875rem; }

/* ---------- Reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .nav { display: none; }
  .tools { margin-left: auto; }
  .hero { grid-template-columns: 1fr; min-height: 0; padding-top: 1.5rem; }
  .hero__photo { order: -1; width: min(70%, 300px); }
  .sticker { left: -1rem; bottom: 1.5rem; }
  .about { grid-template-columns: 1fr; }
  .repos { grid-template-columns: 1fr; }

  .timeline::before { left: 5px; }
  .step { grid-template-columns: 1fr; gap: 0.6rem; padding-left: 2rem; }
  .step::before { left: 0; }
  .step__meta { flex-direction: row; gap: 0.75rem; text-align: left; align-items: baseline; }
  .step__card { padding: 1.5rem; }
}

@media (max-width: 520px) {
  .cards, .stats { grid-template-columns: 1fr; }
  .roles li { flex-direction: column; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
