/* ---------------------------------------------------------------
   Ignacio Santamaria — personal site
   Tokens first, then base, layout, components, pages.
   --------------------------------------------------------------- */
:root {
  --paper: #f6f7f9;
  --ink: #172033;
  --muted: #566176;
  --rule: #dce1e9;
  --accent: #0f6b7a;
  --accent-ink: #0b5560;
  --tint: #e5f0f2;
  --focus: #0f6b7a;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --wrap: 68rem;
  --gutter: clamp(1.1rem, 4vw, 2rem);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161d;
    --ink: #e7ebf1;
    --muted: #9aa5b8;
    --rule: #27303f;
    --accent: #66c3d1;
    --accent-ink: #8fd6e1;
    --tint: #16292e;
    --focus: #66c3d1;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.62;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}
img, svg, object { max-width: 100%; display: block; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--ink); color: var(--paper); padding: 0.5rem 0.9rem; z-index: 20; font-family: var(--sans); }
.skip:focus { left: 0.5rem; }

/* ---- Header ---- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-block: 0.85rem; flex-wrap: wrap; }
.brand { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.site-nav { display: flex; gap: clamp(0.9rem, 3vw, 1.8rem); font-family: var(--sans); font-size: 0.92rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding-block: 0.2rem; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- Footer ---- */
.site-footer { margin-top: 5rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; padding-block: 1.6rem 2.4rem; }
.site-footer a { color: var(--muted); }
.site-footer ul { display: flex; gap: 1.2rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }

/* ---- Buttons and small UI ---- */
.btn {
  display: inline-block; font-family: var(--sans); font-size: 0.92rem; font-weight: 600;
  background: var(--accent); color: #fff; padding: 0.6rem 1.1rem; border-radius: 6px; text-decoration: none; border: 1px solid var(--accent);
}
@media (prefers-color-scheme: dark) { .btn { color: #0b1a1d; } }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--tint); filter: none; }

/* ---- Home ---- */
.home {
  display: grid; grid-template-columns: 13rem minmax(0, 1fr);
  grid-template-areas: "photo about" "who who";
  column-gap: clamp(2rem, 5vw, 3.5rem); row-gap: 1.3rem; align-items: start;
  padding-block: clamp(2rem, 5vw, 3.6rem) 0;
}
.portrait { grid-area: photo; justify-self: start; width: 13rem; height: 13rem; object-fit: cover; border-radius: 6px; }
.about { grid-area: about; }
.who { grid-area: who; }
.who h1 { font-size: clamp(1.45rem, 2.4vw, 1.75rem); letter-spacing: -0.02em; }
.affil { margin-top: 0.6rem; font-family: var(--sans); font-size: 0.92rem; line-height: 1.5; }
.affil p { margin: 0; }
.affil .job { font-weight: 600; }
.affil .dept { white-space: nowrap; font-size: min(0.92rem, 3.7vw); }
.contact-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 3rem; margin-top: 0.7rem; font-family: var(--sans); }
.addr { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.reach { display: flex; flex-wrap: wrap; align-items: center; font-size: 0.9rem; }
.mail { overflow-wrap: anywhere; margin-right: 1.3rem; }
.icons { display: flex; list-style: none; margin: 0; padding: 0; }
.icons li + li { margin-left: 0.95rem; }
.icons a { display: block; color: var(--muted); line-height: 0; }
.icons a:hover { color: var(--accent-ink); }
.icons svg { width: 1.3rem; height: 1.3rem; fill: currentColor; }
.about h2 { font-size: 1.5rem; margin-bottom: 0.9rem; line-height: 1; }
.about p { max-width: 38rem; font-size: 1.1rem; }

.block { padding-block: 3rem 0; }
.block > h2 { font-size: 1.5rem; margin-bottom: 1.2rem; }
.interests { list-style: none; margin: 0; padding: 0; columns: 2 20rem; column-gap: 3rem; }
.interests li { break-inside: avoid; padding: 0.55rem 0 0.55rem 1rem; border-left: 2px solid var(--rule); margin-bottom: 0.35rem; }

/* ---- Inner page header ---- */
.page-head { padding-block: clamp(2rem, 5vw, 3.4rem) 1rem; }
.page-head h1 { font-size: clamp(2.1rem, 5vw, 3rem); letter-spacing: -0.02em; }
.lede { max-width: 42rem; color: var(--muted); margin: 0.9rem 0 0; }

/* ---- Publications ---- */
.tools { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; margin-top: 1.6rem; font-family: var(--sans); }
.search { flex: 1 1 22rem; max-width: 34rem; }
.search input {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--muted); border-radius: 6px; padding: 0.65rem 0.85rem;
}
.search input::placeholder { color: var(--muted); }
.jump { display: flex; gap: 1.4rem; flex-wrap: wrap; font-size: 0.92rem; }
.jump a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); padding-bottom: 0.1rem; }
.jump a:hover { border-bottom-color: var(--accent); }
.jump span { color: var(--muted); margin-left: 0.25rem; font-variant-numeric: tabular-nums; }
.status { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); min-height: 1.3em; margin: 0.8rem 0 0; }

.pub-section { padding-top: 2.8rem; }
.pub-section > h2 { font-size: 1.6rem; display: flex; align-items: baseline; gap: 0.7rem; margin-bottom: 0.4rem; }
.pub-section .count { font-family: var(--sans); font-size: 0.85rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.pub-section .empty { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); }

.pub { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr); gap: 0 1rem; padding: 0.15rem 0 0.95rem; }
.pub.first-of-year { border-top: 1px solid var(--rule); padding-top: 1rem; margin-top: 0.4rem; }
.pub:not(.first-of-year) { padding-top: 0; }
.pub[hidden] { display: none; }
.pub-year { font-family: var(--sans); font-size: 0.9rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 0.2rem; }
.pub:not(.first-of-year) .pub-year { visibility: hidden; }
.pub-title { font-size: 1.07rem; font-weight: 500; line-height: 1.35; letter-spacing: 0; }
.pub-authors { margin: 0.2rem 0 0; font-size: 0.97rem; }
.pub-authors strong { font-weight: 600; }
.pub-venue { margin: 0.1rem 0 0; font-size: 0.95rem; color: var(--muted); }
.pub-meta { margin: 0.35rem 0 0; font-family: var(--sans); font-size: 0.78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; }
.pub-meta a { color: var(--accent-ink); font-weight: 600; }
.award { background: var(--tint); color: var(--accent-ink); padding: 0.12rem 0.5rem; border-radius: 3px; font-weight: 600; }
.pub-id { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---- Projects ---- */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.6rem; font-family: var(--sans); }
.filters button {
  font: inherit; font-size: 0.88rem; color: var(--ink); background: transparent; border: 1px solid var(--rule);
  border-radius: 999px; padding: 0.4rem 0.95rem; cursor: pointer;
}
.filters button:hover { border-color: var(--accent); }
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .filters button[aria-pressed="true"] { color: #0b1a1d; } }
.proj-section { padding-top: 2.6rem; }
.proj-section > h2 { font-size: 1.5rem; margin-bottom: 0.6rem; }
.project { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 0 1.2rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.project[hidden] { display: none; }
.proj-years { font-family: var(--sans); font-size: 0.88rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 0.25rem; }
.proj-name { font-size: 1.25rem; }
.proj-sub { margin: 0.15rem 0 0; font-size: 1rem; }
.proj-meta { margin: 0.5rem 0 0; font-family: var(--sans); font-size: 0.84rem; color: var(--muted); display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.15rem 0.9rem; }
.proj-meta dt { font-weight: 600; }
.proj-meta dd { margin: 0; }

/* ---- CV ---- */
.cv-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.5rem; align-items: center; }
.cv-actions small { font-family: var(--sans); color: var(--muted); font-size: 0.85rem; }
.cv-section { padding-top: 2.6rem; }
.cv-section > h2 { font-size: 1.45rem; margin-bottom: 0.6rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr); gap: 0 1.2rem; padding: 0.6rem 0; border-top: 1px solid var(--rule); }
.rows .when { font-family: var(--sans); font-size: 0.88rem; font-weight: 600; color: var(--muted); padding-top: 0.15rem; font-variant-numeric: tabular-nums; }
.rows .sub { display: block; color: var(--muted); font-size: 0.95rem; }
.rows .em { font-weight: 500; }
.cv-embed { margin-top: 1.2rem; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.cv-embed object { width: 100%; height: min(80vh, 62rem); background: #fff; }
.cv-embed p { padding: 1.2rem; margin: 0; font-family: var(--sans); font-size: 0.95rem; }

/* ---- Small screens ---- */
@media (max-width: 52rem) {
  .home { grid-template-columns: 1fr; grid-template-areas: "photo" "who" "about"; }
}
@media (max-width: 36rem) {
  .pub { grid-template-columns: 1fr; }
  .pub:not(.first-of-year) .pub-year { display: none; }
  .pub-year { margin-bottom: 0.2rem; }
  .project { grid-template-columns: 1fr; }
  .rows li { grid-template-columns: 1fr; }
}
@media print {
  .site-header, .site-footer, .tools, .filters { display: none; }
  body { background: #fff; color: #000; }
}
