/* Sections */
main > section { padding-block: 2.75rem; }
main > section + section { border-top: 1px solid var(--rule); }

.split-head h2, .pubs h2 {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* About */
.hero { padding-block: 2rem 3rem; }
.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}
.hero-name {
  font-size: clamp(2.1rem, 6.5vw, 3rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.025em;
}
.hero-role { margin-top: .6rem; color: var(--muted); }
/* Portrait: a black-and-white photo with a colour laid over it.
   The "color" blend keeps the photo's light and shade and takes only the hue,
   so whites stay white. The tint drifts slowly between muted Nordic tones. */
.portrait {
  --tint: #3b5573;
  position: relative;
  display: block;
  flex: none;
  width: clamp(4.5rem, 14vw, 6.5rem);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  /* An explicit circle clip: border-radius + overflow alone is ignored by
     some browsers (Safari) once the inner images are transformed. */
  clip-path: circle(50% at 50% 50%);
  isolation: isolate;
}
.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  border-radius: 50%;
}
.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tint);
  mix-blend-mode: color;
  pointer-events: none;
  z-index: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .portrait::after { animation: portrait-tint 150s ease-in-out infinite; }
}

/* Hover: the original colour photo is revealed by a small WebGL shader
   (see the portrait script in index.html): iridescent bands of colour roll
   outwards and the colour photo appears behind them. Without WebGL, or for
   people who prefer reduced motion, the colour photo simply fades in. */
.portrait-colour {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity .6s ease;
}
.portrait-gl {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
@media (hover: hover) {
  .portrait:not(.has-gl):hover .portrait-colour { opacity: 1; }
}
/* Blue and orange: the two hues that stay distinct for red-green colour
   blindness (as in GitHub's colour-blind themes). Pedro sees this drift. */
@keyframes portrait-tint {
  0%, 100% { background-color: #3b5573; }  /* muted blue (from GitHub's colour-blind blue) */
  33%      { background-color: #4a5260; }  /* slate */
  66%      { background-color: #75593d; }  /* muted amber (from GitHub's colour-blind orange) */
}
.bio { font-size: 1.25rem; line-height: 1.55; font-weight: 400; }
.hero-more { margin-top: 1.5rem; color: var(--muted); }
.hero-more a { color: var(--ink); }
.hero-more a:hover { color: var(--accent); }
.profiles { display: inline; list-style: none; margin: 0; padding: 0; }
.profiles li { display: inline; }
.profiles li:not(:last-child)::after { content: ", "; }
.profiles li:nth-last-child(2)::after { content: " and "; }
.profiles li:last-child::after { content: "."; }
.hero-actions { margin-top: .4rem; }
.hero-more .profiles a, .hero-actions a { color: var(--ink); }

/* Research */
.split-body { display: grid; gap: 2rem; }
.label { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; }
.interests { display: inline; list-style: none; margin: 0; padding: 0; }
.interests li { display: inline; }
.interests li:not(:last-child)::after { content: ", "; }
.interests li:last-child::after { content: "."; }
.edu { list-style: none; margin: 0; padding: 0; }
.edu li {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  column-gap: 1rem;
  padding-block: .35rem;
}
.edu-year { grid-row: span 2; color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.edu-school { color: var(--muted); font-size: .9375rem; }

/* Publications */
.pubs-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem 1rem; margin-bottom: 1.25rem; }
.pubs-head h2 { margin: 0; }
.pubs-summary, .pub-status { color: var(--muted); font-size: 1rem; }
.pub-status { margin-bottom: 1rem; }
.pub-status:empty { display: none; }

.pub-toolbar { display: none; }
.js .pub-toolbar { display: grid; gap: 1rem; margin-bottom: 2rem; }
.pub-search-field label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.pub-search-field { max-width: 30rem; }
.pub-search-box { position: relative; }
.pub-search-box svg {
  position: absolute;
  top: 50%;
  left: .9rem;
  width: 1.05rem;
  height: 1.05rem;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.pub-search {
  width: 100%;
  min-height: 2.875rem;
  padding: .55rem 2.75rem .55rem 2.6rem;
  background: var(--wash);
  border: 1px solid transparent;
  border-radius: .7rem;
  font-size: 1rem;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.pub-search:hover { border-color: var(--rule); }
.pub-search:focus {
  outline: none;
  background: var(--page);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--rule));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.pub-search-box:focus-within svg { stroke: var(--accent); }
.pub-search::placeholder { color: var(--muted); opacity: 1; }
.pub-search::-webkit-search-decoration { -webkit-appearance: none; }
.pub-search::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; cursor: pointer; }
.pub-search-kbd {
  position: absolute;
  top: 50%;
  right: .75rem;
  transform: translateY(-50%);
  min-width: 1.4rem;
  padding: .05rem .35rem;
  border: 1px solid var(--rule);
  border-radius: .35rem;
  background: var(--page);
  color: var(--muted);
  font: .75rem/1.4 var(--sans);
  text-align: center;
  pointer-events: none;
  transition: opacity .15s;
}
.pub-search-box:focus-within .pub-search-kbd,
.pub-search:not(:placeholder-shown) ~ .pub-search-kbd { opacity: 0; }
@media (hover: none), (max-width: 36rem) {
  .pub-search-kbd { display: none; }
  .pub-search { padding-right: 1rem; }
}
@media (max-width: 36rem) {
  .pub-search-field { max-width: none; }
  .pub-search { font-size: 1rem; } /* 16px: no iOS zoom on focus */
}

.pub-filters { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.filter-btn {
  min-height: 2.75rem;
  color: var(--muted);
  font-size: .9375rem;
  font-variant-numeric: lining-nums tabular-nums;
}
.filter-btn:hover { color: var(--accent); text-decoration: underline; text-underline-offset: .35em; text-decoration-thickness: 1px; }
.filter-btn[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: .35em; text-decoration-thickness: 1px; }

/* Bigger tap areas for the small links without changing the layout */
.pub-link, .pub-cite, .pub-authors-toggle { position: relative; }
.pub-link::after, .pub-cite::after, .pub-authors-toggle::after {
  content: "";
  position: absolute;
  inset: -.7rem -.45rem;
}

.pub-year-group + .pub-year-group { margin-top: 2.25rem; }
.pub-year {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: lining-nums;
  margin-bottom: .75rem;
}
.pub + .pub { margin-top: 1.5rem; }
.pub-title { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; }
.pub-title a { text-decoration: none; }
.pub-authors, .pub-venue { margin-top: .2rem; font-size: .9375rem; line-height: 1.5; color: var(--muted); }
.pub-authors .me { color: var(--ink); }
.pub-authors.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.pub-authors-toggle { color: var(--muted); font-size: .875rem; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: .2em; }
.pub-authors-toggle:hover { color: var(--accent); }
.pub-venue { font-style: italic; margin-top: 0; }
.pub-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1rem; margin-top: .3rem; font-size: .875rem; }
.pub-link, .pub-cite { color: var(--muted); }
.pub-link { text-decoration: none; }
.pub-link:hover, .pub-cite:hover { color: var(--accent); text-decoration: underline; text-underline-offset: .25em; }
.pub-cite { display: none; }
.js .pub-cite { display: inline; }
.pub-show-all {
  margin-top: 2rem;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: .2em;
}
.pub-show-all:hover { color: var(--accent); text-decoration-color: currentColor; }

/* Blog */
.posts { display: grid; gap: 1.25rem; }
.post-card { display: grid; gap: .15rem; text-decoration: none; }
.post-card .post-meta { color: var(--muted); font-size: 1rem; font-variant-numeric: lining-nums; }
.post-card .post-title { font-size: 1.1875rem; font-weight: 600; }
.post-card:hover .post-title { color: var(--accent); }
.post-excerpt { color: var(--muted); }
.post-more { display: none; }

/* BibTeX dialog */
.bib-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.bib-modal-backdrop { position: absolute; inset: 0; background: rgb(15 15 15 / .45); backdrop-filter: blur(2px); }
.bib-modal-box {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(100%, 40rem);
  max-height: 100%;
  min-height: 0;
  padding: 1.5rem;
  background: var(--page);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgb(0 0 0 / .18);
}
.bib-modal-header, .bib-modal-footer { display: flex; align-items: baseline; flex-wrap: wrap; gap: .5rem 1.25rem; }
.bib-modal-header { justify-content: space-between; }
.bib-modal-title { font-size: 1.125rem; font-weight: 600; }
.bib-modal-close { color: var(--muted); font-size: 1rem; }
.bib-modal-close:hover, .bib-modal-btn:hover { color: var(--accent); }
.bib-modal-btn { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: .2em; }
.bib-modal-content {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  background: var(--wash);
  border-radius: 4px;
  font-size: .8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

@media (max-width: 30rem) {
  .bio { font-size: 1.125rem; }
}

/* Subtle parallax and reveals, driven by scroll position (no JavaScript).
   Browsers without scroll-driven animations, and anyone who prefers
   reduced motion, simply get the static page. */
@supports (animation-timeline: view()) {
  @media screen and (prefers-reduced-motion: no-preference) {
    .hero { view-timeline-name: --hero; }
    .hero-head > div, .bio, .hero-more {
      animation: hero-drift linear both;
      animation-timeline: --hero;
      animation-range: exit 0% exit 100%;
    }
    .portrait {
      animation: portrait-drift linear both;
      animation-timeline: --hero;
      animation-range: exit 0% exit 100%;
    }
    /* Every section: blocks rise into view as they arrive and drift up,
       softening, as they slip under the sticky header. Headings travel
       further than the text below them, which gives the sense of depth. */
    .split-head h2, .pubs-head, .pub-year { --depth: 2.25rem; }
    .split-body > *, .edu li, .pub-toolbar, .pub, .post-card { --depth: 1rem; }
    .split-head h2, .pubs-head, .pub-year,
    .split-body > *, .edu li, .pub-toolbar, .pub, .post-card {
      animation: section-flow linear both;
      animation-timeline: view(block 4rem 0);
      animation-range: entry 0% exit 100%;
    }
  }
}
@keyframes hero-drift { to { transform: translateY(-2rem); opacity: .45; } }
@keyframes portrait-drift { to { transform: translateY(-3.25rem) scale(.97); opacity: .45; } }
@keyframes section-flow {
  entry 0%   { opacity: 0;   transform: translateY(var(--depth)); }
  entry 100% { opacity: 1;   transform: none; }
  exit 0%    { opacity: 1;   transform: none; }
  exit 100%  { opacity: .3;  transform: translateY(calc(var(--depth) * -1)); }
}

.print-contact { display: none; }

/* Printing the homepage produces a CV */
@media print {
  @page {
    size: A4;
    margin: 15mm 17mm 16mm;
    @bottom-left { content: "Pedro Ortiz Suarez · pjox.co"; font: 7.5pt "Albert Sans", sans-serif; color: #777; }
    @bottom-right { content: counter(page) " / " counter(pages); font: 7.5pt "Albert Sans", sans-serif; color: #777; }
  }
  body { font-size: 9.5pt; line-height: 1.4; background: #fff; }
  a { text-decoration: none !important; color: inherit !important; }
  main > section { padding-block: 0; }
  main > section + section { border-top: 0; margin-top: 7mm; }
  .wrap { max-width: none; padding-inline: 0; }

  #blog, .hero-more, .pub-toolbar, .pub-status, .pub-cite, .pub-show-all, .pub-links,
  .pub-authors-toggle, .bib-modal, .pubs-summary { display: none !important; }

  .hero { padding: 0; }
  .hero-head { margin-bottom: 3mm; gap: 6mm; }
  .hero-name { font-size: 22pt; }
  .hero-role { margin-top: 1mm; font-size: 10.5pt; }
  .portrait { width: 19mm; }
  .bio { font-size: 10pt; line-height: 1.45; max-width: 150mm; }
  .print-contact { display: block; margin-top: 2.5mm; color: var(--muted); font-size: 8.5pt; }

  .split-head h2, .pubs h2 {
    font-size: 8pt;
    color: #000;
    border-bottom: .5pt solid #999;
    padding-bottom: 1mm;
    margin-bottom: 3mm;
    break-after: avoid;
  }
  .pubs-head { margin-bottom: 0; }
  .split-body { gap: 4mm; }
  .label { font-size: 9.5pt; margin-bottom: 1mm; }
  .edu li { padding-block: .6mm; grid-template-columns: 13mm 1fr; }
  .edu-year { grid-row: auto; }
  .edu-school { grid-column: 2; font-size: 9pt; }

  .pub[hidden], .pub-year-group[hidden] { display: grid !important; }
  .pub[hidden] { display: block !important; }
  .pub-year-group {
    display: grid !important;
    grid-template-columns: 13mm 1fr;
    column-gap: 0;
  }
  .pub-year-group + .pub-year-group { margin-top: 3.5mm; }
  .pub-year { font-size: 9.5pt; margin: 0; color: #000; }
  .pub + .pub { margin-top: 2.2mm; }
  .pub { break-inside: avoid; }
  .pub-title { font-size: 9.5pt; line-height: 1.3; }
  .pub-authors, .pub-venue { font-size: 8.5pt; line-height: 1.35; margin-top: .3mm; }
  .pub-authors.is-clamped { display: block; overflow: visible; -webkit-line-clamp: unset; line-clamp: none; }
}
}
