/* ==========================================================================
   Ink on paper.
   Fraunces (display), Newsreader (text).
   ========================================================================== */

/* Fonts ------------------------------------------------------------------- */
/* Self-hosted from Google Fonts: Fraunces fixed at the soft, wonky cut the
   page uses, both families cut to the weights in use; latin-ext only loads
   for a character that needs it */
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 300 600;
  font-display: swap;
  src: url(/fonts/fraunces-italic-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 300 600;
  font-display: swap;
  src: url(/fonts/fraunces-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url(/fonts/fraunces-normal-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url(/fonts/fraunces-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url(/fonts/newsreader-italic-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url(/fonts/newsreader-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/newsreader-normal-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/newsreader-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Georgia, resized to each face's measure, stands in while the fonts load, so
   the swap barely moves the text */
@font-face {
  font-family: 'Newsreader fallback';
  font-style: normal;
  src: local('Georgia');
  size-adjust: 91.9%;
  ascent-override: 79.98%;
  descent-override: 28.84%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Newsreader fallback';
  font-style: italic;
  src: local('Georgia Italic'), local('Georgia-Italic');
  size-adjust: 83.52%;
  ascent-override: 88.01%;
  descent-override: 31.73%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Fraunces fallback';
  font-style: normal;
  src: local('Georgia');
  size-adjust: 87.7%;
  ascent-override: 111.51%;
  descent-override: 29.07%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Fraunces fallback';
  font-style: italic;
  src: local('Georgia Italic'), local('Georgia-Italic');
  size-adjust: 90.71%;
  ascent-override: 107.81%;
  descent-override: 28.11%;
  line-gap-override: 0%;
}

:root {
  /* Paper & ink */
  --paper: #f3eee3;
  --paper-deep: #e8e1d2;
  --ink: #23221f;          /* warm slate, like the riso prints' slate ink */
  --ink-soft: #3d3c38;
  --ink-faded: #6b675f;    /* graphite; still 4.5:1 on the paper */
  --rubric: #a4502f;       /* clay, deep enough for small text */
  --rubric-soft: rgba(164, 80, 47, 0.35);
  --hair: rgba(35, 34, 31, 0.22);
  --photo-blend: multiply;
  --grain-opacity: 0.06;

  /* Type */
  --font-display: 'Fraunces', 'Fraunces fallback', Georgia, serif;
  --font-serif: 'Newsreader', 'Newsreader fallback', Georgia, 'Times New Roman', serif;

  /* Layout */
  --max-width: 860px;
  --gutter: 1.5rem;

  /* Motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

[data-theme="dark"] {
  --paper: #1a1815;
  --paper-deep: #24211c;
  --ink: #ebe4d6;
  --ink-soft: #c9c1b2;
  --ink-faded: #948b7c;
  --rubric: #de9273;
  --rubric-soft: rgba(222, 146, 115, 0.4);
  --hair: rgba(235, 228, 214, 0.18);
  --photo-blend: normal;
  --grain-opacity: 0.035;
}

/* Reset ------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::selection {
  background: var(--rubric-soft);
  color: var(--ink);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.68;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-kerning: normal;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(ellipse 120% 60% at 50% 0%, rgba(255, 255, 255, 0.28), transparent 70%);
  background-attachment: fixed;
}

[data-theme="dark"] body {
  background-image: radial-gradient(ellipse 120% 60% at 50% 0%, rgba(255, 240, 210, 0.03), transparent 70%);
}

/* Paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
  z-index: 1000;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter) 6rem;
}

/* Typography -------------------------------------------------------------- */
h1, h2, h3 {
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
}

p {
  margin-bottom: 1rem;
  color: var(--ink-soft);
}

a {
  color: var(--rubric);
  text-decoration: none;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent; /* the :active states below stand in for the grey tap flash */
}

a:hover {
  color: var(--ink);
}

/* Inline links: a quiet red hairline that firms up on hover */
.bio a,
.elsewhere a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rubric-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

/* The small capitals sit high, so their hairline hangs a little lower */
.elsewhere a {
  text-underline-offset: 0.4em;
}

@media (hover: hover) and (pointer: fine) {
  .bio a:hover,
  .elsewhere a:hover {
    color: var(--rubric);
    text-decoration-color: var(--rubric);
  }
}

.bio a:active,
.elsewhere a:active {
  color: var(--rubric);
  text-decoration-color: var(--rubric);
}

/* Titles */
.page-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 350;
  font-style: italic;
  font-variation-settings: "opsz" 96, "SOFT" 100, "WONK" 1;
  letter-spacing: -0.01em;
  margin-bottom: 3rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 350;
  font-style: italic;
  font-variation-settings: "opsz" 72, "SOFT" 100, "WONK" 1;
  letter-spacing: -0.005em;
  margin: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faded);
  white-space: nowrap;
}

.section-link {
  transition: color 150ms ease;
}

.section-link-arrow {
  transition: transform 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .section-link:hover {
    color: var(--rubric);
  }

  .section-link:hover .section-link-arrow {
    transform: translateX(3px);
  }
}

.section-link:active {
  color: var(--rubric);
}

/* Only phones show the link under the list (see the small-screens block) */
.section-link--end {
  display: none;
}

/* Riso prints (art/riso.html, baked by art/export.mjs) ---------------------
   Each is baked at its exact CSS size; only solid line work (rules, underline)
   is allowed to stretch with its container. In dark mode the inks invert and
   keep their hue, so they print light on the dark page.                      */
.riso {
  display: block;
  line-height: 0;
}

.riso img {
  display: block;
  max-width: none;
}

.riso-rule img,
.riso-underline img,
.riso-underline-t1 img,
.riso-underline-t2 img,
.riso-underline-t3 img,
.riso-neuron-rule img,
.riso-neuron-rule-short img {
  width: 100%;
  height: auto;
}

[data-theme="dark"] .riso img {
  filter: invert(1) hue-rotate(180deg) brightness(1.05);
}

/* Motion: the entrance plays on every page load, and only for what is on screen
   when the page opens (see Layout.astro). Everything else is simply there.  */
.intro .rise {
  animation: rise 520ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Inking up: the stroke under the name prints first as a sparse halftone and
   fills in to solid ink in three steps, like a print taking ink pass by pass.
   Four stacked prints of the same stroke, each shown in turn.              */
.ink-up .ink-tone {
  position: absolute;
  inset: 0;
}

.ink-up .ink-tone img {
  opacity: 0;
}

.intro .ink-up .ink-tone1 img { animation: ink-tone1 640ms linear 260ms both; }
.intro .ink-up .ink-tone2 img { animation: ink-tone2 640ms linear 260ms both; }
.intro .ink-up .ink-tone3 img { animation: ink-tone3 640ms linear 260ms both; }
.intro .ink-up .ink-solid img { animation: ink-solid 640ms linear 260ms both; }

@keyframes ink-tone1 { 0% { opacity: 0; } 6%, 26% { opacity: 1; } 34%, 100% { opacity: 0; } }
@keyframes ink-tone2 { 0%, 26% { opacity: 0; } 34%, 52% { opacity: 1; } 60%, 100% { opacity: 0; } }
@keyframes ink-tone3 { 0%, 52% { opacity: 0; } 60%, 76% { opacity: 1; } 84%, 100% { opacity: 0; } }
@keyframes ink-solid { 0%, 76% { opacity: 0; } 84%, 100% { opacity: 1; } }

/* About ------------------------------------------------------------------- */
.about-section {
  display: grid;
  grid-template-columns: 1fr 196px;
  gap: 3.5rem;
  align-items: start;
  margin-bottom: 4.5rem;
}

.bio p {
  line-height: 1.72;
  margin-bottom: 1.1rem;
  hanging-punctuation: first;
  text-wrap: pretty;
}

.elsewhere {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0;
  margin-top: 1.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.elsewhere-sep {
  margin: 0 0.85em;
  color: var(--rubric);
}

/* Portrait: a print in a passe-partout */
.portrait {
  position: relative;
  padding: 9px;
  border: 1px solid var(--hair);
  background: color-mix(in srgb, var(--paper) 70%, white 30%);
  box-shadow: 0 1px 0 var(--hair), 0 8px 24px -14px rgba(40, 30, 10, 0.35);
}

[data-theme="dark"] .portrait {
  background: var(--paper-deep);
}

.portrait img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}


/* Section break --------------------------------------------------------- */
.section-break {
  display: flex;
  justify-content: center;
  margin-bottom: 4.5rem;
}

.neuron-rule {
  width: 100%;
}

.neuron-rule--short {
  display: none;
}

/* Every page ends on the stroke from under the name, like the ornament that
   closes a chapter */
.end-mark {
  display: flex;
  justify-content: center;
  margin-top: 4.5rem;
}

.end-mark .riso {
  width: 132px;
}

/* Publications ---------------------------------------------------------- */
.publications-list {
  display: flex;
  flex-direction: column;
}

.publication-item {
  position: relative;
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 2rem;
  padding: 2.1rem 0;
}

.publication-item:first-child {
  padding-top: 0;
}

.publication-item:first-child .publication-rule {
  display: none !important;
}

.publication-rule {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  opacity: 0.55;
}

.publication-thumbnail {
  padding: 5px;
  border: 1px solid var(--hair);
  background: color-mix(in srgb, var(--paper) 70%, white 30%);
}

[data-theme="dark"] .publication-thumbnail {
  background: var(--paper-deep);
}

.publication-thumbnail > img {
  display: block;
  width: 100%;
  aspect-ratio: 7 / 5;
  object-fit: cover;
  filter: grayscale(0.55) sepia(0.25) contrast(1.08) saturate(0.9);
  mix-blend-mode: var(--photo-blend);
  transition: filter 300ms ease;
}

[data-theme="dark"] .publication-thumbnail > img {
  filter: grayscale(0.5) sepia(0.35) brightness(0.72) contrast(1.05);
}

@media (hover: hover) and (pointer: fine) {
  .publication-item:hover .publication-thumbnail > img {
    filter: none;
  }

  [data-theme="dark"] .publication-item:hover .publication-thumbnail > img {
    filter: brightness(0.9);
  }
}


.publication-thumbnail--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 7 / 5;
}

.publication-thumbnail--empty span {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--ink-faded);
}

.publication-content h3 {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 550;
  line-height: 1.32;
  letter-spacing: -0.005em;
  margin-bottom: 0.35rem;
  text-wrap: pretty;
}

.publication-content h3 a {
  color: var(--ink);
}

.publication-content h3 a {
  transition: color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .publication-content h3 a:hover {
    color: var(--rubric);
  }
}

.publication-content h3 a:active {
  color: var(--rubric);
}

.publication-authors {
  font-size: 0.97rem;
  line-height: 1.5;
  color: var(--ink-faded);
  margin-bottom: 0.45rem;
  text-wrap: pretty;
}

.publication-authors .highlight {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
}

.publication-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

/* The venue is captioned under the figure, like the label on a print */
.publication-aside {
  align-self: start;
}

.publication-venue {
  margin: 0.6rem 0 0;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: lining-nums;
  color: var(--ink-soft);
}

.publication-venue-note {
  display: block;
  color: var(--rubric);
}

/* Links as small tags in the deeper paper tone, lettered like the venue caption */
.publication-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.1rem;
}

.publication-link {
  padding: 0.3rem 0.8rem 0.26rem;
  border-radius: 3px;
  background: var(--paper-deep);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out);
}

[data-theme="dark"] .publication-link {
  background: color-mix(in srgb, var(--paper-deep) 70%, white 6%);
}

@media (hover: hover) and (pointer: fine) {
  .publication-link:hover {
    background: color-mix(in srgb, var(--rubric) 14%, var(--paper));
    color: var(--ink);
  }
}

.publication-link:active {
  background: color-mix(in srgb, var(--rubric) 14%, var(--paper));
  color: var(--ink);
  transform: scale(0.97);
}

.publication-award {
  margin: 0.85rem 0 0;
  font-style: italic;
  font-size: 0.98rem;
  color: var(--rubric);
}

.award-detail {
  color: var(--ink-faded);
}

/* The key to the asterisks on author names, set under the list's title */
.page-heading {
  margin-bottom: 3rem;
}

.page-heading .page-title {
  margin-bottom: 0;
}

.equal-note {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-faded);
}

.equal-note span {
  font-style: normal;
  margin-right: 0.15em;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 0;
  color: var(--ink-faded);
  font-style: italic;
}

/* Small screens ---------------------------------------------------------- */
@media (max-width: 600px) {
  :root {
    --gutter: 1.25rem;
  }

  body {
    font-size: 1.0625rem;
  }

  .about-section {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 2.25rem;
    margin-bottom: 2.25rem;
  }

  .portrait {
    width: 170px;
  }

  .elsewhere {
    justify-content: center;
  }

  .section-break {
    margin-bottom: 2.25rem;
  }

  .neuron-rule--long {
    display: none;
  }

  .neuron-rule--short {
    display: block;
  }

  .section-header {
    flex-wrap: wrap;
    margin-bottom: 2rem;
  }

  /* On a phone, "All publications" waits under the list instead of between
     the equal-contribution note and the papers it explains */
  .section-header .section-link {
    display: none;
  }

  .section-link--end {
    display: inline-flex;
    margin-top: 1.5rem;
  }

  .elsewhere {
    font-size: 0.74rem;
    letter-spacing: 0.1em;
  }

  .elsewhere-sep {
    margin: 0 0.55em;
  }

  .section-title {
    font-size: 1.45rem;
  }

  .publication-item {
    grid-template-columns: 96px 1fr;
    gap: 1.1rem;
    padding: 1.75rem 0;
  }

  .publication-thumbnail {
    padding: 3px;
  }

  .publication-content h3 {
    font-size: 1.08rem;
  }

  .publication-meta {
    gap: 0.25rem 0.75rem;
  }

  .publication-links {
    gap: 0.35rem;
  }

  .publication-link {
    padding: 0.26rem 0.55rem 0.22rem;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
  }

  /* Keep a phone to one row of tags; the blog link shows on wider screens */
  .publication-link--blog {
    display: none;
  }

  .publication-venue {
    margin-top: 0.5rem;
    font-size: 0.68rem;
    letter-spacing: 0.05em;
  }
}

/* Touch: the small uppercase links get a finger-sized hit area (about 44px
   tall) without changing how they look. Sideways it stops short of the gap
   to the next link, so neighbours never overlap.                           */
@media (pointer: coarse) {
  .elsewhere a,
  .section-link,
  .publication-link {
    position: relative;
  }

  .elsewhere a::after,
  .section-link::after,
  .publication-link::after {
    content: "";
    position: absolute;
    inset: -12px -8px;
  }

  .publication-link::after {
    inset: -11px -2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .section-link-arrow {
    transition: none;
  }
}

/* Switching theme: one short cross-fade of the whole page (ThemeToggle.astro),
   with every other transition held off so nothing changes on its own clock */
.theme-switching,
.theme-switching * {
  transition: none !important;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 200ms;
  animation-timing-function: ease;
}
