:root {
  --ink: #14213d;
  --ink-soft: #2b3a5a;
  --paper: #faf8f3;
  --surface: #ffffff;
  --accent: #9b1c31;
  --accent-soft: #f4e6e8;
  --muted: #5b6475;
  --line: #e5e0d4;
  --radius: 10px;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --max: 1120px;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Bilingüe: oculta el idioma no activo */
html[lang="es"] [data-lang="en"],
html[lang="en"] [data-lang="es"] { display: none !important; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 4.5vw, 3.25rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }

.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 100;
  background: var(--ink); color: #fff; padding: 0.5rem 1rem; border-radius: 6px;
}
.skip-link:focus { top: 1rem; }

.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;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250, 248, 243, 0.92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--ink); margin-right: auto; }
.monogram {
  display: grid; place-items: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  font-family: var(--font-serif); font-weight: 700; font-size: 0.95rem; letter-spacing: 0.04em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--font-serif); font-weight: 600; font-size: 1.02rem; }
.brand-role { font-size: 0.75rem; color: var(--muted); }
@media (max-width: 520px) { .brand-role { display: none; } }

.nav { display: none; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.15rem; }
.nav a {
  display: block; padding: 0.45rem 0.6rem; border-radius: 6px;
  color: var(--ink-soft); text-decoration: none; font-size: 0.875rem; font-weight: 500;
}
.nav a:hover { background: var(--accent-soft); color: var(--accent); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang-switch button {
  border: 0; background: transparent; cursor: pointer;
  font: 600 0.75rem var(--font-sans); letter-spacing: 0.05em;
  padding: 0.35rem 0.65rem; border-radius: 999px; color: var(--muted);
}
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.mobile-nav { border-top: 1px solid var(--line); padding: 0.5rem 0 1rem; }
.mobile-nav[hidden] { display: none; }
.mobile-nav ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; }
.mobile-nav a { display: block; padding: 0.6rem 0.75rem; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 500; }
.mobile-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

@media (min-width: 1080px) {
  .nav { display: block; }
  .menu-toggle, .mobile-nav { display: none !important; }
}

/* ---------- Page hero ---------- */
.page-hero { padding: 3.5rem 0 2.5rem; border-bottom: 1px solid var(--line); }
.eyebrow {
  display: inline-block; margin-bottom: 0.9rem;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.lead { font-size: 1.125rem; color: var(--ink-soft); max-width: 68ch; }

.section { padding: 3rem 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 1.5rem; }
.section-head h2 { margin: 0; }
.section-head a { font-size: 0.9rem; font-weight: 500; }

/* ---------- Home hero ---------- */
.home-hero { padding: 4rem 0 3rem; }
.home-grid { display: grid; gap: 2.5rem; align-items: start; }
@media (min-width: 900px) { .home-grid { grid-template-columns: 1.6fr 1fr; gap: 4rem; } }
.home-hero h1 { margin-bottom: 0.3em; }
.home-role { font-family: var(--font-serif); font-size: 1.35rem; color: var(--accent); margin-bottom: 1.25rem; }
.portrait { margin: 0 0 1.25rem; display: flex; justify-content: center; }
.portrait img, .portrait-fallback {
  width: 160px; height: 160px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.portrait-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; font: 600 3rem var(--font-serif);
}
  .portrait-fallback[hidden], .portrait img[hidden] { display: none; }
  .portrait img { object-position: 58% 22%; }
  .gallery img.img-top { object-position: 50% 20%; }

.gallery { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.gallery figure { flex: 1 1 260px; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.gallery img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
.gallery figcaption { padding: 0.75rem 1rem; font-size: 0.9rem; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1.15rem; border-radius: 8px; border: 1px solid transparent;
  font: 600 0.92rem var(--font-sans); text-decoration: none; cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--ink); color: var(--ink); }
.btn svg { width: 18px; height: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem;
}
.card h3 { margin-bottom: 0.35rem; }
.card-muted { color: var(--muted); font-size: 0.92rem; }

.facts { margin: 0; display: grid; gap: 1rem; }
.facts div { display: grid; gap: 0.15rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts dt { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--surface); padding: 1.35rem 1.25rem; }
.stat-value { display: block; font-family: var(--font-serif); font-size: 2.25rem; font-weight: 700; line-height: 1; color: var(--ink); }
.stat-label { display: block; margin-top: 0.45rem; font-size: 0.85rem; color: var(--muted); }
a.stat { text-decoration: none; }
a.stat:hover .stat-value { color: var(--accent); }

.grid-2 { display: grid; gap: 1.25rem; }
.grid-3 { display: grid; gap: 1.25rem; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 0; }
.tag {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.75rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 0.85rem;
}
.tag b { color: var(--accent); font-weight: 600; }

.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 4px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge-ink { background: #e7eaf1; color: var(--ink); }

/* ---------- Publications ---------- */
.toolbar {
  display: grid; gap: 0.75rem; margin-bottom: 1.5rem;
  padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
@media (min-width: 760px) { .toolbar { grid-template-columns: 2fr 1fr 1fr; align-items: end; } }
.field { display: grid; gap: 0.3rem; }
.field label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.field input, .field select {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 8px;
  font: 400 0.95rem var(--font-sans); color: var(--ink); background: var(--paper);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.result-count { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }

.year-group { margin-bottom: 2rem; }
.year-group h2 {
  font-size: 1.35rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--ink);
  display: flex; align-items: baseline; gap: 0.6rem;
}
.year-group h2 small { font-family: var(--font-sans); font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub { display: grid; gap: 0.35rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
@media (min-width: 760px) { .pub { grid-template-columns: 170px 1fr; gap: 1.5rem; } }
.pub-title { margin: 0; font-family: var(--font-serif); font-size: 1.05rem; font-weight: 500; line-height: 1.4; }
.pub-source { margin: 0.2rem 0 0; font-size: 0.88rem; color: var(--muted); font-style: italic; }
.empty { padding: 2rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Charts ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 0.5rem; height: 240px; padding-top: 1.5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 0.4rem; min-width: 0; }
.bar { width: 100%; max-width: 48px; background: var(--ink); border-radius: 4px 4px 0 0; position: relative; transition: background 0.15s; }
.bar-col:hover .bar { background: var(--accent); }
.bar-value { font-size: 0.78rem; font-weight: 600; color: var(--ink); }
.bar-label { font-size: 0.72rem; color: var(--muted); }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.85rem; }
.hbar-row { display: grid; gap: 0.3rem; }
.hbar-top { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; }
.hbar-top span:last-child { font-weight: 600; }
.hbar-track { height: 8px; background: #efebe1; border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.hbar-fill.ink { background: var(--ink); }

.note {
  font-size: 0.88rem; color: var(--muted);
  padding: 1rem 1.25rem; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0;
}

/* ---------- Timeline / items ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 1.75rem 2.25rem; }
.timeline li::before {
  content: ""; position: absolute; left: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--accent);
}
.timeline .when { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; color: var(--accent); text-transform: uppercase; }
.timeline h3 { margin: 0.25rem 0 0.35rem; font-size: 1.15rem; font-weight: 500; }
.timeline .meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: 0.88rem; color: var(--muted); }

.item-list { display: grid; gap: 1rem; }
.item { display: grid; gap: 0.5rem; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.item h3 { font-weight: 500; font-size: 1.1rem; margin: 0; }
.kv { display: flex; flex-wrap: wrap; gap: 0.35rem 1.5rem; font-size: 0.88rem; color: var(--muted); margin: 0; }
.kv dt { display: inline; font-weight: 600; color: var(--ink-soft); }
.kv dd { display: inline; margin: 0 0 0 0.3rem; }

/* ---------- Contact ---------- */
.profile-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .profile-grid { grid-template-columns: repeat(3, 1fr); } }
.profile {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.15rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); transition: border-color 0.15s, transform 0.15s;
}
.profile:hover { border-color: var(--ink); color: var(--ink); transform: translateY(-1px); }
.profile strong { display: block; font-family: var(--font-serif); font-size: 1.05rem; }
.profile span { font-size: 0.85rem; color: var(--muted); }
.profile svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent); }

.contact-big { font-family: var(--font-serif); font-size: clamp(1.4rem, 3vw, 2rem); word-break: break-all; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 3rem; background: var(--ink); color: #cfd5e2; padding: 2.5rem 0; font-size: 0.88rem; }
.site-footer a { color: #fff; }
.footer-inner { display: grid; gap: 1.25rem; }
@media (min-width: 760px) { .footer-inner { grid-template-columns: 1fr auto; align-items: end; } }
.footer-name { font-family: var(--font-serif); font-size: 1.2rem; color: #fff; margin-bottom: 0.25rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; list-style: none; margin: 0; padding: 0; }

/* ---------- CV ---------- */
.cv-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.cv-sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.5rem, 4vw, 3.5rem); margin: 2.5rem 0; }
.cv-header { display: grid; gap: 0.25rem; padding-bottom: 1.5rem; border-bottom: 2px solid var(--ink); margin-bottom: 1.75rem; }
.cv-header h2 { font-size: clamp(1.75rem, 3vw, 2.4rem); margin: 0; }
.cv-header .role { font-family: var(--font-serif); color: var(--accent); font-size: 1.15rem; }
.cv-header .contact { font-size: 0.88rem; color: var(--muted); }
.cv-section { margin-bottom: 1.75rem; break-inside: auto; }
.cv-section > h3 {
  font-family: var(--font-sans); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 0.4rem; margin-bottom: 0.85rem;
}
.cv-section h4 { font-family: var(--font-sans); font-size: 0.9rem; font-weight: 600; margin: 1rem 0 0.4rem; }
.cv-list { margin: 0; padding-left: 1.4rem; font-size: 0.9rem; }
.cv-list li { margin-bottom: 0.35rem; break-inside: avoid; }
.cv-list .src { font-style: italic; color: var(--muted); }
.cv-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.cv-table th, .cv-table td { text-align: left; vertical-align: top; padding: 0.45rem 0.6rem 0.45rem 0; border-bottom: 1px solid var(--line); }
.cv-table th { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.cv-table td:first-child { white-space: nowrap; color: var(--muted); }

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 16mm 14mm; }
  body { background: #fff; font-size: 10.5pt; }
  .site-header, .site-footer, .no-print, .skip-link, .page-hero { display: none !important; }
  .cv-sheet { border: 0; padding: 0; margin: 0; }
  .container { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .cv-section > h3 { break-after: avoid; }
}
