/* ============================================================
   Iván Barrios · sitio personal
   Dirección visual "Cátedra": editorial académico.
   El azul #1F5C8B es el mismo del libro de bioestadística.
   ============================================================ */

/* ---------- 1. Tokens ---------- */

:root {
  --paper:      #FBFAF6;
  --paper-2:    #F4F2EB;
  --paper-3:    #EDEAE1;
  --ink:        #16191C;
  --ink-2:      #3C4248;
  --soft:       #6B7178;
  --rule:       #DFDCD3;
  --rule-soft:  #EAE7DE;
  --blue:       #1F5C8B;
  --blue-deep:  #123C5C;
  --blue-tint:  rgba(31, 92, 139, .075);
  --live:       #3B8F58;

  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans:  "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --wrap: 1140px;
  --gutter: clamp(20px, 5vw, 56px);

  --s1: 8px;  --s2: 14px; --s3: 22px; --s4: 34px;
  --s5: 52px; --s6: 78px; --s7: 112px;

  --shadow: 0 1px 2px rgba(22, 25, 28, .04), 0 14px 38px -18px rgba(22, 25, 28, .18);
  --focus: 0 0 0 3px rgba(31, 92, 139, .32);
}

/* El sitio se compromete con el fondo claro, que es la dirección "Cátedra" aprobada.
   Antes seguía el modo oscuro del sistema, y por eso Iván lo veía en negro: su equipo
   está en modo oscuro. Se declara color-scheme para que el navegador dibuje también
   los controles y las barras de scroll en claro. */
:root { color-scheme: light; }

/* ---------- 2. Base ---------- */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.015em; text-wrap: balance; line-height: 1.16; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }

/* La regla de arriba es de hoja de autor y le ganaría a la del navegador para
   [hidden]. Sin esto, un elemento marcado como oculto se seguiría viendo. */
[hidden] { display: none !important; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-deep); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 3px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: var(--gutter); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--blue); color: #fff; padding: 12px 20px;
  font-family: var(--sans); font-size: 14px; border-radius: 0 0 4px 0;
}
.skip:focus { left: 0; color: #fff; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Etiquetas en versalitas: el recurso de énfasis del sitio, en lugar de la cursiva. */
.label {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--blue);
}
.label-soft { color: var(--soft); }

.num { font-variant-numeric: tabular-nums; }

/* ---------- 3. Encabezado ---------- */

.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.7) blur(12px);
  -webkit-backdrop-filter: saturate(1.7) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease;
}
.site-head[data-stuck="true"] { border-bottom-color: var(--rule); }

.site-head .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); min-height: 62px;
}

.brand { font-size: 16px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { color: var(--blue); }

.site-nav { display: flex; align-items: center; gap: var(--s4); }
.site-nav a {
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  letter-spacing: .11em; text-transform: uppercase; color: var(--soft);
  padding: 6px 0; border-bottom: 1px solid transparent;
}
.site-nav a:hover, .site-nav a[aria-current="true"] { color: var(--blue); border-bottom-color: var(--blue); }

.lang {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 11px; letter-spacing: .1em; color: var(--soft);
}
.lang a { color: var(--soft); }
.lang a:hover { color: var(--blue); }
.lang [aria-current="true"] { color: var(--ink); font-weight: 600; }
.lang span { opacity: .45; }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--rule); border-radius: 4px;
  padding: 7px 11px; font-family: var(--sans); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-2); cursor: pointer;
}

/* ---------- 4. Portada ---------- */

.hero { padding: clamp(48px, 8vw, 92px) 0 var(--s5); border-bottom: 1px solid var(--rule); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(34px, 6vw, 76px); align-items: start; }

.hero h1 { font-size: clamp(42px, 6.4vw, 66px); line-height: 1.03; letter-spacing: -.028em; margin-bottom: var(--s3); }
/* El título académico acompaña al nombre, no compite con él: va más chico,
   sin negrita y en el gris de apoyo. */
.hero h1 .post { font-size: .38em; font-weight: 400; color: var(--soft); letter-spacing: -.005em; white-space: nowrap; }
.hero .rol { font-size: clamp(20px, 2.4vw, 25px); color: var(--soft); font-weight: 400; line-height: 1.36; letter-spacing: -.008em; margin-bottom: var(--s3); }
.hero .bio { font-size: 17.5px; line-height: 1.68; color: var(--ink-2); max-width: 48ch; }

.hero-kicker { margin-bottom: var(--s3); }

.ids { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s4); }
.ids a, .ids span {
  font-family: var(--sans); font-size: 12.5px; color: var(--soft);
  display: inline-flex; align-items: baseline; gap: 7px;
}
.ids a strong { color: var(--blue); font-weight: 600; font-family: var(--mono); font-size: 11.5px; letter-spacing: .01em; }
.ids a:hover strong { color: var(--blue-deep); text-decoration: underline; text-underline-offset: 3px; }

/* Artículo destacado, como la portada de una revista */
.featured { border-left: 2px solid var(--blue); padding-left: var(--s3); }
.featured h2 { font-size: 20px; line-height: 1.34; margin: var(--s2) 0 var(--s2); font-weight: 600; }
.featured a:hover h2 { color: var(--blue); }
.featured .src { font-family: var(--sans); font-size: 12.5px; color: var(--soft); line-height: 1.6; }
.featured .src b { color: var(--ink-2); font-weight: 600; }
.featured .doi {
  display: inline-block; margin-top: var(--s2);
  font-family: var(--mono); font-size: 11px; color: var(--blue);
  border-bottom: 1px solid color-mix(in srgb, var(--blue) 32%, transparent);
  word-break: break-all;
}

/* ---------- 5. Métricas ---------- */

.figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); padding: var(--s5) 0; border-bottom: 1px solid var(--rule); }
.figure .n { font-size: clamp(30px, 3.6vw, 40px); font-weight: 600; letter-spacing: -.035em; line-height: 1; }
.figure .n sup { font-size: .42em; color: var(--blue); vertical-align: super; margin-left: 1px; }
.figure .l { font-family: var(--sans); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); margin-top: var(--s1); line-height: 1.5; }
.figure .src { font-family: var(--sans); font-size: 10.5px; color: var(--soft); opacity: .72; margin-top: 3px; }

/* ---------- 6. Secciones ---------- */

.section { padding: var(--s6) 0; border-bottom: 1px solid var(--rule); scroll-margin-top: 72px; }
.section:last-of-type { border-bottom: 0; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.section-head h2 { font-size: clamp(26px, 3.2vw, 34px); letter-spacing: -.022em; }
.section-head .intro { color: var(--soft); font-size: 16px; max-width: 56ch; margin-top: var(--s2); }

.live-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--soft);
  white-space: nowrap;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--soft); flex: none; }
.live-badge[data-state="ok"] .live-dot { background: var(--live); }
.live-badge[data-state="ok"] { color: var(--live); }
.live-badge[data-state="loading"] .live-dot { animation: blink 1.1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- 7. Publicaciones ---------- */

.controls { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; margin-bottom: var(--s3); }

.search { position: relative; flex: 1 1 320px; min-width: 240px; }
.search input {
  width: 100%; font-family: var(--serif); font-size: 16px; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px;
  padding: 11px 15px 11px 40px;
}
.search input::placeholder { color: var(--soft); }
.search input:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; stroke: var(--soft); fill: none; stroke-width: 2; pointer-events: none; }

.filters { display: flex; gap: var(--s1); flex-wrap: wrap; }
.chip {
  font-family: var(--sans); font-size: 11.5px; letter-spacing: .05em;
  padding: 7px 13px; border: 1px solid var(--rule); border-radius: 999px;
  background: transparent; color: var(--soft); cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s, background-color .15s;
}
.chip:hover { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 45%, transparent); }
.chip[aria-pressed="true"] { color: var(--blue); border-color: var(--blue); background: var(--blue-tint); font-weight: 600; }

.result-count { font-family: var(--sans); font-size: 12.5px; color: var(--soft); padding: var(--s2) 0 var(--s3); border-bottom: 1px solid var(--rule); }
.result-count b { color: var(--ink); font-weight: 600; }

.pubs { display: flex; flex-direction: column; }
.pub { display: grid; grid-template-columns: 58px minmax(0, 1fr) minmax(0, 250px); gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--rule-soft); align-items: baseline; }
.pub .yr { font-family: var(--mono); font-size: 12.5px; color: var(--soft); }
.pub .ti { font-size: 16.5px; line-height: 1.42; color: var(--ink); }
.pub a.ti:hover { color: var(--blue); }
.pub .au { font-family: var(--sans); font-size: 12.5px; color: var(--soft); margin-top: 6px; line-height: 1.5; }
.pub .au b { color: var(--ink-2); font-weight: 600; }
.pub .jr { font-family: var(--sans); font-size: 12.5px; color: var(--soft); line-height: 1.5; }
.pub .jr .name { color: var(--ink-2); display: block; }
.pub .jr .doi { font-family: var(--mono); font-size: 10.5px; color: var(--blue); display: block; margin-top: 5px; word-break: break-all; }
.pub mark { background: color-mix(in srgb, var(--blue) 18%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.pub .flag { font-family: var(--sans); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--live); margin-left: 8px; white-space: nowrap; }

.more-row { display: flex; justify-content: center; gap: var(--s2); flex-wrap: wrap; padding-top: var(--s4); }
/* El segundo botón es la salida rápida, no la acción principal: se ve secundario. */
.btn-quiet { border-color: var(--rule); color: var(--soft); }
.btn-quiet:hover { background: transparent; border-color: var(--blue); color: var(--blue); }
.btn {
  font-family: var(--sans); font-size: 12px; letter-spacing: .13em; text-transform: uppercase; font-weight: 600;
  color: var(--blue); background: transparent; border: 1px solid var(--blue);
  padding: 13px 30px; border-radius: 3px; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn:hover { background: var(--blue); color: var(--paper); }

.empty { padding: var(--s5) 0; text-align: center; color: var(--soft); }

/* ---------- 8. Libros ---------- */

.books { display: flex; flex-direction: column; gap: var(--s5); }
.book { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: var(--s4); align-items: start; }
.book-cover {
  aspect-ratio: 3 / 4; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 3px;
  box-shadow: var(--shadow); overflow: hidden; display: grid; place-items: center; padding: var(--s3);
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover .placeholder { font-family: var(--sans); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: var(--soft); text-align: center; line-height: 1.7; }
.book h3 { font-size: 23px; line-height: 1.26; margin-bottom: var(--s2); }
.book .subtitulo { font-size: 17px; line-height: 1.36; color: var(--ink-2); margin-top: -6px; margin-bottom: var(--s2); }
.book .au { font-family: var(--sans); font-size: 13px; color: var(--soft); margin-bottom: var(--s3); }
.book .au b { color: var(--ink-2); font-weight: 600; }
.book .sinopsis { color: var(--ink-2); font-size: 16.5px; max-width: 62ch; margin-bottom: var(--s3); }
.book .meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); font-family: var(--sans); font-size: 12px; color: var(--soft); }
.book .meta b { color: var(--ink-2); font-weight: 600; }

.chapters { display: flex; flex-direction: column; margin-top: var(--s5); border-top: 1px solid var(--rule); }
.chapters h3 { font-size: 15px; padding-top: var(--s4); padding-bottom: var(--s2); }
.chapter { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--rule-soft); align-items: baseline; }
.chapter .yr { font-family: var(--mono); font-size: 12.5px; color: var(--soft); }
.chapter .ti { font-size: 16.5px; line-height: 1.42; }
.chapter a.ti:hover { color: var(--blue); }
.chapter .src { font-family: var(--sans); font-size: 12.5px; color: var(--soft); margin-top: 6px; line-height: 1.55; }
.chapter .src b { color: var(--ink-2); font-weight: 600; }

/* ---------- 9. Trayectoria ---------- */

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(34px, 6vw, 76px); align-items: start; }
.prose p { color: var(--ink-2); font-size: 17px; max-width: 62ch; }
.prose p + p { margin-top: var(--s3); }

.portrait { margin: 0 0 var(--s4); width: 186px; }
.portrait img {
  width: 100%; height: auto; aspect-ratio: 1; object-fit: cover;
  border-radius: 3px; border: 1px solid var(--rule);
  filter: saturate(.92);
}

.block + .block { margin-top: var(--s5); }
.block > .label { display: block; margin-bottom: var(--s3); }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 94px minmax(0, 1fr); gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--rule-soft); align-items: baseline; }
.tl-item:first-child { border-top: 0; padding-top: 0; }
.tl-item .yr { font-family: var(--mono); font-size: 12px; color: var(--soft); white-space: nowrap; }
.tl-item h4 { font-size: 17px; line-height: 1.34; }
.tl-item .where { font-family: var(--sans); font-size: 13px; color: var(--soft); margin-top: 5px; line-height: 1.55; }
.tl-item .detail { font-size: 14.5px; color: var(--soft); margin-top: 7px; line-height: 1.56; max-width: 54ch; }
.tl-item .detail b { color: var(--ink-2); font-weight: 600; }

.pill-list { display: flex; flex-wrap: wrap; gap: var(--s1); }
.pill {
  font-family: var(--sans); font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--rule); border-radius: 999px; padding: 6px 13px; background: var(--paper-2);
}
.pill .q { color: var(--blue); font-weight: 600; font-size: 10.5px; letter-spacing: .06em; margin-left: 6px; }

.lines { display: flex; flex-direction: column; gap: var(--s2); }
.lines li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--s2); color: var(--ink-2); font-size: 16.5px; line-height: 1.5; }
.lines li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); margin-top: 11px; }

/* ---------- 10. Contacto y pie ---------- */

.contact-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(34px, 6vw, 76px); align-items: start; }
.contact-mail { font-size: clamp(21px, 2.8vw, 29px); font-weight: 600; letter-spacing: -.02em; color: var(--blue); word-break: break-all; }
.contact-mail:hover { color: var(--blue-deep); text-decoration: underline; text-underline-offset: 5px; }
.contact-note { color: var(--soft); font-size: 16.5px; max-width: 46ch; margin-top: var(--s3); }

.profile-links { display: flex; flex-direction: column; }
.profile-links a {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) 0; border-top: 1px solid var(--rule-soft); color: var(--ink);
  font-size: 16.5px;
}
.profile-links a:first-child { border-top: 0; }
.profile-links a:hover { color: var(--blue); }
.profile-links .v { font-family: var(--mono); font-size: 11.5px; color: var(--soft); text-align: right; }

.site-foot { padding: var(--s5) 0 var(--s6); border-top: 1px solid var(--rule); }
.site-foot .wrap { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; align-items: baseline; }
.site-foot p, .site-foot a { font-family: var(--sans); font-size: 12.5px; color: var(--soft); }
.site-foot a:hover { color: var(--blue); }

/* ---------- 11. Entrada en escena ---------- */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

/* ---------- 12. Adaptación a pantallas chicas ---------- */

@media (max-width: 1000px) {
  /* Son cuatro cifras: a tres columnas quedaría una sola huérfana abajo. */
  .figures { grid-template-columns: repeat(2, 1fr); row-gap: var(--s5); }
  .pub { grid-template-columns: 50px minmax(0, 1fr); }
  .pub .jr { grid-column: 2; }
}

@media (max-width: 860px) {
  body { font-size: 16.5px; }
  .hero-grid, .two-col, .contact-grid { grid-template-columns: minmax(0, 1fr); }
  .featured { margin-top: var(--s2); }
  .book { grid-template-columns: 128px minmax(0, 1fr); gap: var(--s3); }

  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--paper); border-block: 1px solid var(--rule);
    padding: var(--s2) var(--gutter) var(--s3);
  }
  .site-nav[data-open="true"] { display: flex; }
  .site-nav a { padding: 13px 0; width: 100%; border-bottom: 1px solid var(--rule-soft); }
  .site-nav a:last-child { border-bottom: 0; }
  .nav-toggle { display: block; }
  .site-head .wrap { position: relative; }
}

@media (max-width: 560px) {
  .figures { grid-template-columns: repeat(2, 1fr); }
  .book { grid-template-columns: minmax(0, 1fr); }
  .book-cover { max-width: 168px; }
  .tl-item, .chapter { grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
  .tl-item .yr, .chapter .yr { font-size: 11.5px; }
  .pub { grid-template-columns: minmax(0, 1fr); gap: var(--s1); }
  .pub .jr { grid-column: 1; }
}

/* ---------- 13. Impresión ---------- */

@media print {
  .site-head, .controls, .more-row, .site-foot, .live-badge { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .section { padding: 12pt 0; border-bottom: 0; }
  .pub { break-inside: avoid; }
}
