/* ──────────────  RESET & BASE  ────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

:root,
:root[data-theme="dark"] {
  --bg:         #0a0b0e;
  --bg-2:       #12141a;
  --surface:    #16181f;
  --ink:        #e8eaed;
  --ink-soft:   #a4abb6;
  --ink-dim:    #6b7280;
  --hairline:   #1f232c;
  --hairline-2: #2c313c;
  --accent:     #5b8def;
  --accent-2:   #7aa3ff;
  --orb-tint:   rgba(91, 141, 239, .18);
  --orb-tint-2: rgba(91, 141, 239, .06);
  --grain-tint: rgba(232, 234, 237, .025);
  --accent-glow: rgba(91, 141, 239, .14);
  --accent-soft: rgba(91, 141, 239, .06);
  --shadow:     rgba(0, 0, 0, .6);
}

:root[data-theme="light"] {
  --bg:         #f5f6f8;
  --bg-2:       #ebeef3;
  --surface:    #ffffff;
  --ink:        #14161b;
  --ink-soft:   #4a5160;
  --ink-dim:    #8a8f99;
  --hairline:   #e1e5eb;
  --hairline-2: #cdd2db;
  --accent:     #2e5fde;
  --accent-2:   #1f4ac0;
  --orb-tint:   rgba(46, 95, 222, .14);
  --orb-tint-2: rgba(46, 95, 222, .04);
  --grain-tint: rgba(20, 22, 27, .04);
  --accent-glow: rgba(46, 95, 222, .14);
  --accent-soft: rgba(46, 95, 222, .05);
  --shadow:     rgba(20, 22, 27, .14);
}

:root {
  --maxw: 1100px;
  --pad: clamp(1.25rem, 4vw, 2.5rem);
  --serif: 'Fraunces', 'Times New Roman', serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, monospace;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.lede,
.entry-card p,
.bullets li,
.pub-card p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.mono { font-family: var(--mono); font-size: .78rem; letter-spacing: .04em; }
.dim  { color: var(--ink-dim); }
.accent { color: var(--accent); font-style: italic; font-weight: 400; }

/* ──────────────  ATMOSPHERE  ────────────── */
.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--grain-tint) 1px, transparent 1px);
  background-size: 3px 3px;
  z-index: 1;
  opacity: .8;
}
.orb {
  position: fixed;
  top: -20vh; right: -15vw;
  width: 70vw; height: 70vw;
  max-width: 900px; max-height: 900px;
  background: radial-gradient(circle at 30% 30%,
                var(--orb-tint),
                var(--orb-tint-2) 35%,
                transparent 60%);
  filter: blur(50px);
  z-index: 0;
  pointer-events: none;
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate(0,0)        scale(1);   }
  100% { transform: translate(-4vw,3vh)   scale(1.05);}
}

/* ──────────────  NAV  ────────────── */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem var(--pad);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--hairline);
}
.brand-group {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: inline-flex; align-items: center;
  flex-shrink: 0;
}
.brand-mark {
  display: block;
  width: 28px; height: 28px;
  color: var(--ink);
}
.brand-mark .bm-bg     { fill: currentColor; }
.brand-mark .bm-text   { fill: var(--bg); }
.brand-mark .bm-dot    { fill: var(--accent); }

.header-contact {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--ink-dim);
  white-space: nowrap;
}
.header-contact a {
  color: var(--ink-soft);
  transition: color .2s ease;
}
.header-contact a:hover { color: var(--accent); }
.hc-sep { opacity: .4; }
@media (max-width: 900px) { .header-contact { display: none; } }

.cv-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  height: 28px;
  padding: 0 .8rem;
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
  flex-shrink: 0;
  white-space: nowrap;
}
.cv-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.cv-btn svg { width: 12px; height: 12px; }

.nav-end {
  display: inline-flex; align-items: center; gap: 1.2rem;
}
.nav nav { display: flex; gap: 1.6rem; }
.nav nav a {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--ink-soft);
  letter-spacing: .04em;
  transition: color .2s ease;
}
.nav nav a:hover { color: var(--accent); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.theme-toggle svg { width: 15px; height: 15px; }
[data-theme="dark"]  .t-moon { display: none; }
[data-theme="light"] .t-sun  { display: none; }

.lang-toggle {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s ease;
  flex-shrink: 0;
}
.lang-toggle:hover { border-color: var(--accent); }
.lang-opt {
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .08em;
  padding: 0 .55rem;
  height: 100%;
  display: inline-flex;
  align-items: center;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.lang-opt:hover { color: var(--accent); }
:root[data-lang="en"] .lang-toggle .l-en,
:root[data-lang="es"] .lang-toggle .l-es {
  color: var(--bg);
  background: var(--ink);
}

/* Bilingual show/hide */
:root[data-lang="en"] .i-es,
:root:not([data-lang="es"]) .i-es { display: none !important; }
:root[data-lang="es"] .i-en      { display: none !important; }

@media (max-width: 700px) {
  .nav nav { display: none; }
}

/* ──────────────  LAYOUT  ────────────── */
main { position: relative; z-index: 2; }
section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(4rem, 10vh, 7rem) var(--pad);
  position: relative;
}
.section-head {
  display: flex; flex-direction: column; gap: .9rem;
  margin-bottom: 3rem;
  max-width: 720px;
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -.01em;
}

/* ──────────────  HERO  ────────────── */
.hero {
  padding-top: clamp(5rem, 14vh, 9rem);
  padding-bottom: clamp(5rem, 12vh, 8rem);
  border-bottom: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
.hero-text { min-width: 0; }
.hero-portrait {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--hairline-2);
  box-shadow: 0 24px 60px -28px var(--shadow);
}
.hero-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
}
@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .hero-portrait {
    order: -1;
    max-width: 240px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
  }
  .hero-portrait img { object-position: center 22%; }
}
.display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  line-height: 1.02;
  letter-spacing: -.025em;
  margin-bottom: 2rem;
}
.lede {
  max-width: 620px;
  font-size: clamp(1.05rem, 1.6vw, 1.18rem);
  color: var(--ink-soft);
  margin-bottom: 2.5rem;
}

.hero-actions {
  display: flex; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 4rem;
}
.btn {
  display: inline-flex; align-items: center;
  padding: .85rem 1.4rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.btn.primary {
  background: var(--ink); color: var(--bg);
}
.btn.primary:hover {
  background: var(--accent);
  transform: translateY(-1px);
}
.btn.ghost {
  border: 1px solid var(--hairline-2);
  color: var(--ink-soft);
}
.btn.ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.btn.static { cursor: default; pointer-events: none; }

.hero-roles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  max-width: 720px;
}
.role-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: .9rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}
.role-label {
  grid-row: 1 / span 2;
  align-self: center;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  border-right: 1px solid var(--hairline);
  padding-right: .9rem;
}
.role-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1rem;
}
.role-org { color: var(--ink-dim); font-size: .85rem; }

/* ──────────────  TIMELINE  ────────────── */
.work { border-bottom: 1px solid var(--hairline); }
.timeline {
  position: relative;
  padding-left: clamp(0px, 4vw, 40px);
}
.timeline::before {
  content: "";
  position: absolute;
  left: clamp(8px, 4vw, 40px);
  top: 8px; bottom: 8px;
  width: 1px;
  background: linear-gradient(to bottom,
                transparent,
                var(--hairline-2) 8%,
                var(--hairline-2) 92%,
                transparent);
}
.entry {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: clamp(1rem, 3vw, 2.5rem);
  padding: 1.6rem 0 1.6rem 1.6rem;
  position: relative;
}
.entry::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 2.2rem;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--accent);
}
.entry-when {
  padding-top: 1.6rem;
  color: var(--ink-dim);
  white-space: nowrap;
}
.entry-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.entry-card:hover {
  transform: translateY(-2px);
  border-color: var(--hairline-2);
  box-shadow: 0 12px 40px -20px var(--shadow);
}
.org {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: .8rem;
}
.logo {
  width: 44px; height: 44px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--hairline);
  object-fit: contain;
  padding: 5px;
  flex-shrink: 0;
}
.entry h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.12rem;
  letter-spacing: -.005em;
  line-height: 1.2;
  margin-bottom: .15rem;
}
.org-name {
  font-size: .85rem;
  color: var(--ink-dim);
}
.entry-card p {
  color: var(--ink-soft);
  font-size: .96rem;
}
.bullets {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding-top: .25rem;
}
.bullets li {
  position: relative;
  padding-left: 1.15rem;
  color: var(--ink-soft);
  font-size: .94rem;
  line-height: 1.55;
}
.bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .7rem;
  width: 7px;
  height: 1px;
  background: var(--accent);
  opacity: .85;
}
@media (max-width: 720px) {
  .timeline { padding-left: 1.2rem; }
  .timeline::before { left: 0; }
  .entry { grid-template-columns: 1fr; padding-left: 1.2rem; }
  .entry::before { left: -5px; top: 1.6rem; }
  .entry-when { padding-top: 0; font-size: .72rem; }
}

/* ──────────────  STACK  ────────────── */
.stack { border-bottom: 1px solid var(--hairline); }
.chips {
  display: flex; flex-wrap: wrap; gap: .55rem;
}
.chips.chips-row {
  flex-wrap: wrap;
}
.chips.chips-row li { flex: 0 0 auto; }
.chips li {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-size: .82rem;
  padding: .5rem .9rem .5rem .75rem;
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  color: var(--ink-soft);
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.chips li:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.chip-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask-image: var(--icon);
          mask-image: var(--icon);
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
}

/* ──────────────  STUDY  ────────────── */
.study { border-bottom: 1px solid var(--hairline); }
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.edu-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 1.4rem;
  transition: border-color .25s ease, transform .25s ease;
}
.edu-card:hover {
  border-color: var(--hairline-2);
  transform: translateY(-2px);
}
.edu-logo {
  width: 38px; height: 38px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--hairline);
  object-fit: contain;
  padding: 5px;
  margin-bottom: 1rem;
}
.edu-card h4 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.02rem;
  line-height: 1.3;
  margin-bottom: .35rem;
  letter-spacing: -.005em;
}
.edu-card p { color: var(--ink-dim); font-size: .85rem; }
.edu-year { font-size: .78rem; margin-top: .4rem; }

/* ──────────────  PUBLICATION  ────────────── */
.pub { border-bottom: 1px solid var(--hairline); }
.pub-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 1.6rem 1.8rem;
  max-width: 760px;
}
.pub-card h4 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.18rem;
  line-height: 1.3;
  margin-bottom: .6rem;
}
.pub-card p { font-size: .9rem; }
.pub-meta { margin-top: .4rem; }
.pub-actions { margin-top: 1.2rem; }

/* ──────────────  PROJECTS  ────────────── */
.projects { border-bottom: 1px solid var(--hairline); }
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  max-width: 760px;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 1.6rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}
.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px -20px var(--shadow);
}
.project-card h4 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.18rem;
  line-height: 1.3;
  margin-bottom: .4rem;
}
.project-tagline {
  color: var(--ink-soft);
  font-size: .95rem;
  white-space: nowrap;
}
.project-link {
  align-self: flex-start;
  gap: .5rem;
}
.project-link svg { width: 14px; height: 14px; }

/* ──────────────  PDF MODAL  ────────────── */
.pdf-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(.75rem, 3vw, 2rem);
}
.pdf-modal[hidden] { display: none; }
.pdf-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.pdf-modal-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 860px;
  height: 90vh;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 32px 90px -20px rgba(0,0,0,.7);
}
.pdf-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.2rem;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.pdf-modal-close {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  background: transparent;
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}
.pdf-modal-close:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: var(--accent-soft);
}
.pdf-canvas-wrap {
  flex: 1;
  overflow-y: auto;
  background: #525659;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  user-select: none;
  -webkit-user-select: none;
}
.pdf-page {
  display: block;
  max-width: 100%;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.pdf-status {
  color: #ccc;
  padding: 2rem;
  font-family: var(--mono);
  font-size: .82rem;
}


/* ──────────────  REVEAL  ────────────── */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
@media (max-width: 600px) {
  .pdf-modal { padding: 0; }
  .pdf-modal-box { height: 100dvh; max-height: 100dvh; border-radius: 0; }
}
@media (max-width: 720px) {
  .edu-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }
  .edu-card {
    padding: 0.75rem 0.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .edu-card h4,
  .edu-card > p:not(.edu-year) { display: none; }
  .edu-logo { width: 32px; height: 32px; margin-bottom: 0.4rem; }
  .edu-year { font-size: 0.68rem; }
}
