/* ==========================================================================
   xingyousong.github.io — stylesheet
   Plain CSS, no build step. Sections:

     1. Tokens        fonts, colours, layout  (re-theme the site from here)
     2. Base
     3. Header + section nav
     4. Hero
     5. Selected publications   (cards with pictures)
     6. Full list               (sections, publications, their figures)
     7. Footer
     8. Hover + press states
     9. Smaller screens + touch
    10. Motion
    11. Print
   ========================================================================== */

/* 1. Tokens
   ========================================================================== */

/* Stand-ins for the name at the top of the page while DM Sans downloads (or
   if it never does): a sans-serif the device already has, scaled to the
   width of DM Sans, so the name keeps to its one line and does not jump when
   the real font arrives. Arial and Helvetica cover Windows, macOS and iOS,
   Liberation Sans covers Linux, and Roboto covers Android and ChromeOS. */
@font-face {
  font-family: "Name Fallback";
  font-weight: 400;
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica"), local("Liberation Sans"), local("Arimo"), local("Roboto");
  size-adjust: 92%;
}

@font-face {
  font-family: "Name Fallback";
  font-weight: 600;
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"), local("Helvetica Bold"), local("Helvetica-Bold"), local("Liberation Sans Bold"), local("LiberationSans-Bold"), local("Arimo Bold"), local("Arimo-Bold"), local("Roboto Bold"), local("Roboto-Bold");
  size-adjust: 89%;
}

:root {
  color-scheme: light;

  /* Type. One family, DM Sans, for headings and text alike; the Chinese
     name is set in Noto Sans SC. Both load from Google Fonts in index.html;
     the stacks below are the fallbacks. */
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-zh: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;

  /* Colour: warm paper + ink, with one accent sampled from the cherry
     blossoms in the portrait. Change --accent (and its two tints) to re-theme. */
  --bg: #faf8f4;
  --bg-glass: rgb(250 248 244 / 0.82);
  --ink: #1b1917;
  --ink-soft: #46423c;
  --muted: #645f57;
  --line: rgb(27 25 23 / 0.1);
  --line-strong: rgb(27 25 23 / 0.2);
  --chip: rgb(27 25 23 / 0.06);
  --accent: #ad2550;
  --on-accent: #fff;
  --accent-wash: rgb(173 37 80 / 0.1);
  --accent-line: rgb(173 37 80 / 0.4);
  --glow: rgb(222 120 150 / 0.17);
  --photo-shadow: 0 1px 2px rgb(60 30 25 / 0.1), 0 22px 44px -18px rgb(60 30 25 / 0.35);
  --plate: #fff;
  --plate-shadow: 0 1px 2px rgb(60 30 25 / 0.08), 0 12px 24px -12px rgb(60 30 25 / 0.3);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.1'/%3E%3C/svg%3E");

  /* Layout */
  --wrap: 70rem;
  --gutter: clamp(1.25rem, 5vw, 2.5rem);
  --rail: 15rem;
  --rail-gap: clamp(2rem, 5vw, 4.5rem);
  --header-h: 3.5rem;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Dark palette. It is listed twice on purpose: once for "follow the OS"
   and once for the manual toggle (data-theme is set by the button in the
   header). Keep the two blocks identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141312;
    --bg-glass: rgb(20 19 18 / 0.8);
    --ink: #f4f0e9;
    --ink-soft: #d5d0c7;
    --muted: #a39d92;
    --line: rgb(244 240 233 / 0.11);
    --line-strong: rgb(244 240 233 / 0.22);
    --chip: rgb(244 240 233 / 0.08);
    --accent: #f590ab;
    --on-accent: #1d0f14;
    --accent-wash: rgb(245 144 171 / 0.14);
    --accent-line: rgb(245 144 171 / 0.5);
    --glow: rgb(222 120 150 / 0.13);
    --photo-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 26px 50px -18px rgb(0 0 0 / 0.7);
    --plate: #e2ded6;
    --plate-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 28px -12px rgb(0 0 0 / 0.7);
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.07'/%3E%3C/svg%3E");
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141312;
  --bg-glass: rgb(20 19 18 / 0.8);
  --ink: #f4f0e9;
  --ink-soft: #d5d0c7;
  --muted: #a39d92;
  --line: rgb(244 240 233 / 0.11);
  --line-strong: rgb(244 240 233 / 0.22);
  --chip: rgb(244 240 233 / 0.08);
  --accent: #f590ab;
  --on-accent: #1d0f14;
  --accent-wash: rgb(245 144 171 / 0.14);
  --accent-line: rgb(245 144 171 / 0.5);
  --glow: rgb(222 120 150 / 0.13);
  --photo-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 26px 50px -18px rgb(0 0 0 / 0.7);
  --plate: #e2ded6;
  --plate-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 28px -12px rgb(0 0 0 / 0.7);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.07'/%3E%3C/svg%3E");
}

/* 2. Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--header-h);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink-soft);
  font: 400 1rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  /* paper: a soft blossom-pink wash behind the portrait, over a fine grain */
  background-color: var(--bg);
  background-image: radial-gradient(closest-side, var(--glow), rgb(222 120 150 / 0)), var(--grain);
  background-size: 52rem 52rem, 180px 180px;
  background-position: calc(50% + 24rem) -11rem, 0 0;
  background-repeat: no-repeat, repeat;
}

h1,
h2,
h3,
h4,
p,
ul,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

b {
  font-weight: 600;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: var(--gutter);
  z-index: 20;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateY(-250%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus {
  transform: none;
}

/* 3. Header + section nav
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-glass);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.25s, border-color 0.25s;
}

/* With JS the bar is clear at the very top of the page and only frosts
   over once content starts sliding underneath it. */
.js .site-header:not(.is-scrolled) {
  border-bottom-color: transparent;
  background-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--header-h);
}

.brand {
  flex: none;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

/* With JS, the name in the header only appears once the big one has
   scrolled away. Without JS it is simply always there. */
.js .brand {
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.35rem);
  transition: opacity 0.3s, transform 0.3s var(--ease), visibility 0s linear 0.3s;
}

.js .is-past-hero .brand {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.site-nav {
  display: flex;
  gap: 0.125rem;
  min-width: 0;
  margin-left: auto;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  --fade-start: 0rem;
  --fade-end: 0rem;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
}

.site-nav[data-fade~="start"] {
  --fade-start: 1.5rem;
}

.site-nav[data-fade~="end"] {
  --fade-end: 1.5rem;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  flex: none;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s, background-color 0.15s;
}

.site-nav a[aria-current] {
  background: var(--chip);
  color: var(--ink);
}

/* the nav clips its overflow, so draw the focus ring inside the link */
.site-nav a:focus-visible {
  outline-offset: -2px;
}

.theme-toggle {
  display: none; /* needs JS; shown below */
  flex: none;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.js .theme-toggle {
  display: grid;
}

.theme-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
  transition: transform 0.6s var(--ease);
}

.theme-toggle[aria-pressed="true"] svg {
  transform: rotate(180deg);
}

/* 4. Hero
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(14rem, 28vw, 20rem);
  align-items: center;
  gap: clamp(2rem, 5vw, 4rem);
  padding-block: clamp(2.5rem, 7vw, 5.5rem) clamp(3rem, 8vw, 6rem);
}

.hero-text {
  container-type: inline-size; /* lets the headline size itself to this column */
}

/* The name is sized against the width of its column (cqi units), so
   "Xingyou (Richard) Song" always fits on one line: it fills about nine
   tenths of the column. The first font-size is for browsers without
   container units. "opsz" 40 keeps DM Sans to its display cut at every
   size; left to itself it widens as it gets smaller, and the fit would
   drift. */
.hero h1 {
  color: var(--ink);
  font-family: "DM Sans", "Name Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1rem, 4.9vw, 4.5rem);
  font-size: clamp(1rem, 9.7cqi, 4.5rem);
  font-weight: 600;
  font-variation-settings: "opsz" 40;
  line-height: 1.05;
  letter-spacing: -0.032em;
}

.hero h1 .nick {
  color: var(--muted);
  font-weight: 400;
}

.name-zh {
  display: block;
  margin-top: 0.7em;
  color: var(--accent);
  font: 500 clamp(1.0625rem, 0.34em, 1.375rem) / 1 var(--font-zh);
  letter-spacing: 0.3em;
}

.bio {
  max-width: 37rem;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem);
  line-height: 1.62;
  text-wrap: pretty;
}

.bio p + p {
  margin-top: 0.9em;
}

.bio a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
}

.contact a {
  display: block;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s, transform 0.18s var(--ease);
}

.portrait {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 1.25rem;
  background: var(--chip);
  box-shadow: var(--photo-shadow);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 51% 0;
  transition: transform 1.2s var(--ease);
}

/* hairline highlight so the photo edge stays crisp on any background */
.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14);
  pointer-events: none;
}

/* 5. Selected publications
   ========================================================================== */

/* A "part" is one of the two big blocks of the page: Selected, Full List. */
.part {
  padding-top: clamp(2.75rem, 6vw, 4.5rem);
  border-top: 1px solid var(--line);
}

.part-title {
  color: var(--ink);
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.375rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.026em;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.75rem 2rem;
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
  padding-bottom: clamp(2.75rem, 6vw, 4.5rem);
}

.feature-art {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 0.875rem;
  background: var(--chip);
}

.feature-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* a card with two papers: a hairline between them */
.feature-paper + .feature-paper {
  margin-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.feature-title {
  margin-top: 1.1rem;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.feature .pub-authors,
.feature .pub-role,
.feature .pub-venue {
  font-size: 0.875rem;
}

.feature .pub-venue {
  color: var(--muted);
}

.feature .links {
  margin-top: 0.85rem;
}

/* a paper that is not out yet: a short bold note where the venue would be */
.coming-soon {
  margin-top: 0.5rem;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.55;
}

/* "All links" on a card: a quiet text link down to the full entry */
.links a.jump {
  padding-inline: 0.3em;
  background: none;
  color: var(--muted);
}

/* The illustrations are line drawings that take their colours from the
   theme. Classes: l ink line, m muted line, a accent line, d dashed,
   fi / fm / fa ink, muted and accent fills. */
.art {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.8s var(--ease);
}

.art .l,
.art .m,
.art .a {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.art .l {
  stroke: var(--ink-soft);
  stroke-width: 1.35;
}

.art .m {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-opacity: 0.6;
}

.art .a {
  stroke: var(--accent);
  stroke-width: 1.6;
}

.art .d {
  stroke-dasharray: 2.5 4;
}

.art .fi {
  fill: var(--ink);
}

.art .fm {
  fill: var(--muted);
}

.art .fa {
  fill: var(--accent);
}

/* matrix cells: a stroke in the fill colour rounds their corners */
.art .cell {
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.art .cell.fi {
  stroke: var(--ink);
}

.art .cell.fa {
  stroke: var(--accent);
}

.art text {
  fill: var(--ink-soft);
  font: 500 10px var(--font-sans);
  text-anchor: middle;
  dominant-baseline: central;
}

.art text.s {
  text-anchor: start;
}

.art text.num {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.art text.big {
  font-size: 15px;
}

/* 6. Full list
   ========================================================================== */

.part-title + .section {
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
}

.section {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: var(--rail-gap);
  padding-block: clamp(2.5rem, 6vw, 4rem);
  border-top: 1px solid var(--line);
}

/* The heading sits in the left rail and stays in view while its papers
   scroll past. */
.section-title {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  align-self: start;
  color: var(--ink);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

.section-title span {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
}

.pub {
  padding-block: 1.75rem;
}

.pub:first-child {
  padding-top: 0.25rem;
}

.pub:last-child {
  padding-bottom: 0;
}

.pub + .pub {
  border-top: 1px solid var(--line);
}

/* entries that a "Selected" card links to: land a little below the header */
.pub[id] {
  scroll-margin-top: 1.5rem;
}

/* An entry with a figure: text on the left, the figure on the right. The
   figure's column is 30% of the entry, within limits. The last row is a
   spare one: if a figure is ever taller than its text, the extra height
   goes there and the lines of text stay together. */
.pub.has-fig {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(10.5rem, 30%, 15rem);
  grid-template-rows: repeat(15, auto) 1fr;
  column-gap: clamp(1.25rem, 4%, 2rem);
  align-items: start;
}

.pub.has-fig > * {
  grid-column: 1;
}

.pub.has-fig > .pub-fig {
  grid-column: 2;
  grid-row: 1 / -1;
  margin-top: 0.2rem;
}

/* The figure sits on a white plate of a fixed shape, whatever its own
   proportions. It is a link: script.js opens the picture larger in place,
   and without the script the image file opens. */
.pub-fig {
  display: block;
  aspect-ratio: 16 / 10;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--plate);
  cursor: zoom-in;
  transition: border-color 0.2s, box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}

/* "multiply" lets the white of the figure take the colour of the plate,
   which is what softens the figures in the dark theme */
.pub-fig img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.pub-title {
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.pub-authors,
.pub-role,
.pub-venue {
  margin-top: 0.3rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.pub-authors {
  margin-top: 0.45rem;
  color: var(--muted);
}

.pub-authors b {
  color: var(--ink);
  white-space: nowrap;
}

.pub-role {
  margin-top: 0.45rem;
  color: var(--ink);
  font-weight: 500;
}

.award {
  display: inline-block;
  padding: 0.16em 0.7em;
  border-radius: 1em;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: 0.09em;
}

.award.quiet {
  background: var(--chip);
  color: var(--ink-soft);
}

/* Link rows: an optional small label followed by chips. */
.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.pub > .links,
.pub > .more {
  margin-top: 0.45rem;
}

.pub > :is(.pub-authors, .pub-role, .pub-venue, .pub-fig) + :is(.links, .more) {
  margin-top: 0.95rem;
}

.links-label,
.more > summary {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.links-label {
  margin-right: 0.3rem;
}

.links a {
  padding: 0.32em 0.7em;
  border-radius: 0.5rem;
  background: var(--chip);
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  transition: background-color 0.15s, color 0.15s, transform 0.15s var(--ease);
}

/* Long link lists (press coverage etc.) fold away behind a disclosure. */
.more > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: -0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, color 0.15s;
}

.more > summary::-webkit-details-marker {
  display: none;
}

/* chevron */
.more > summary::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  margin: -0.15rem 0.15rem 0 0.1rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  transition: transform 0.25s var(--ease), margin 0.25s var(--ease);
}

.more[open] > summary::after {
  margin-top: 0.2rem;
  transform: rotate(225deg);
}

/* number of links inside, added by script.js */
.more .count {
  padding: 0.1em 0.6em;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink-soft);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.more > .links {
  padding-block: 0.3rem 0.4rem;
}

/* The larger view of a figure: a <dialog> that script.js adds to the page. */
.lightbox {
  width: min(100% - 2rem, 64rem);
  max-width: none;
  max-height: calc(100% - 2rem);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 1rem;
  background: var(--bg);
  color: var(--ink-soft);
  box-shadow: 0 2rem 5rem -1rem rgb(0 0 0 / 0.55);
}

.lightbox::backdrop {
  background: rgb(20 19 18 / 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.lightbox-plate {
  padding: clamp(0.75rem, 3vw, 1.75rem);
  background: var(--plate);
  cursor: zoom-out;
}

.lightbox-plate img {
  width: auto;
  height: auto;
  max-height: calc(100vh - 13rem);
  max-height: calc(100dvh - 13rem);
  margin-inline: auto;
  mix-blend-mode: multiply;
}

/* under the picture: the paper's title and what the figure shows on the
   left, the close button on the right */
.lightbox figcaption {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.85rem 0.85rem 1rem clamp(1rem, 3vw, 1.75rem);
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  line-height: 1.5;
}

.lightbox-text {
  flex: 1;
  min-width: 0;
  padding-top: 0.2rem;
  text-wrap: pretty;
}

.lightbox-text b {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.35;
  letter-spacing: -0.012em;
}

.lightbox-text span {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
}

.lightbox-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chip);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.lightbox-close svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* 7. Footer
   ========================================================================== */

.site-footer {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: var(--rail-gap);
  align-items: baseline;
  padding-block: 2rem 4.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer b {
  color: var(--ink-soft);
}

.to-top {
  justify-self: start;
  font-weight: 500;
  transition: color 0.15s;
}

/* 8. Hover + press states
   Hover styles only apply where there is a real pointer, so nothing stays
   highlighted after a tap on a phone. Press states apply everywhere.
   ========================================================================== */

@media (hover: hover) {
  .site-nav a:hover,
  .to-top:hover {
    color: var(--ink);
  }

  .theme-toggle:hover,
  .more > summary:hover {
    background: var(--chip);
    color: var(--ink);
  }

  .bio a:hover {
    color: var(--accent);
    text-decoration-color: currentColor;
  }

  .contact a:hover {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--bg);
    transform: translateY(-1px);
  }

  .links a:hover {
    background: var(--accent);
    color: var(--on-accent);
    transform: translateY(-1px);
  }

  .links a.jump:hover {
    background: none;
    color: var(--accent);
    transform: none;
  }

  .portrait:hover img,
  .feature:hover .art {
    transform: scale(1.035);
  }

  .pub-fig:hover {
    border-color: var(--line-strong);
    box-shadow: var(--plate-shadow);
    transform: translateY(-2px);
  }

  .lightbox-close:hover {
    background: var(--ink);
    color: var(--bg);
  }
}

.contact a:active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  transform: none;
}

.links a:active {
  background: var(--accent);
  color: var(--on-accent);
  transform: none;
}

.links a.jump:active {
  background: none;
  color: var(--accent);
}

.theme-toggle:active,
.more > summary:active {
  background: var(--chip);
  color: var(--ink);
}

.pub-fig:active {
  border-color: var(--line-strong);
  transform: none;
}

.lightbox-close:active {
  background: var(--ink);
  color: var(--bg);
}

/* 9. Smaller screens + touch
   ========================================================================== */

@media (max-width: 60rem) {
  .section,
  .site-footer {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 1.5rem;
  }

  .section-title {
    position: static;
  }

  .section-title span {
    margin-top: 0.3rem;
  }

  .features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-footer {
    row-gap: 1rem;
  }

  .brand {
    display: none;
  }

  .to-top {
    order: 2;
  }
}

@media (max-width: 46rem) {
  body {
    background-size: 40rem 40rem, 180px 180px;
    background-position: 50% -16rem, 0 0;
  }

  .site-nav {
    margin-left: -0.75rem;
    margin-right: auto;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
    padding-top: 1rem;
  }

  .portrait {
    order: -1;
    aspect-ratio: 3 / 2;
    border-radius: 1rem;
  }
}

/* Phones: the selected cards become one row you swipe through. */
@media (max-width: 40rem) {
  .features {
    display: flex;
    gap: 1rem;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
  }

  .features::-webkit-scrollbar {
    display: none;
  }

  .feature {
    flex: 0 0 min(84%, 21rem);
    scroll-snap-align: start;
  }

  /* the figure moves under its entry's text, above the links */
  .pub.has-fig {
    display: block;
  }

  .pub.has-fig > .pub-fig {
    max-width: 24rem;
    margin-top: 0.95rem;
    aspect-ratio: 2 / 1;
  }
}

@media (pointer: coarse) {
  .links {
    gap: 0.5rem;
  }

  .links a {
    padding-block: 0.5em;
  }
}

/* 10. Motion
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .hero-text > *,
  .portrait {
    animation: rise 0.8s var(--ease) both;
  }

  .hero-text > :nth-child(2) {
    animation-delay: 0.08s;
  }

  .hero-text > :nth-child(3) {
    animation-delay: 0.16s;
  }

  .portrait {
    animation-delay: 0.12s;
  }

  /* smooth open/close for the disclosures, where the browser can do it */
  @supports (interpolate-size: allow-keywords) {
    :root {
      interpolate-size: allow-keywords;
    }

    .more::details-content {
      block-size: 0;
      overflow: clip;
      opacity: 0;
      transition: block-size 0.35s var(--ease), opacity 0.25s, content-visibility 0.35s allow-discrete;
    }

    .more[open]::details-content {
      block-size: auto;
      opacity: 1;
    }
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.9rem);
  }
}

/* the larger figure eases in */
@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] {
    animation: rise 0.35s var(--ease) both;
  }

  .lightbox[open]::backdrop {
    animation: fade 0.3s both;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* the full-list entry you just jumped to from a card lights up briefly */
.pub:target {
  border-radius: 0.5rem;
  animation: arrive 2.2s var(--ease);
}

@keyframes arrive {
  from,
  35% {
    background-color: var(--accent-wash);
    box-shadow: 0 0 0 0.75rem var(--accent-wash);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }
}

/* 11. Print
   ========================================================================== */

@media print {
  /* Paper is always light, whichever theme is on screen. The second and
     third selectors are there to outrank the two dark-palette blocks at
     the top of this file. */
  :root,
  :root[data-theme],
  :root:not([data-theme="light"]) {
    color-scheme: light;
    --bg: #fff;
    --ink: #000;
    --ink-soft: #222;
    --muted: #444;
    --line: rgb(0 0 0 / 0.15);
    --line-strong: rgb(0 0 0 / 0.3);
    --accent: #000;
    --on-accent: #fff;
    --chip: transparent;
    --accent-wash: transparent;
    --plate: #fff;
  }

  body {
    background: #fff;
    font-size: 10.5pt;
  }

  .site-header,
  .skip-link,
  .to-top,
  .more > summary::after {
    display: none;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) 9rem;
    padding-block: 0 1.5rem;
  }

  .portrait {
    box-shadow: none;
  }

  .part {
    padding-top: 1.25rem;
  }

  .part-title {
    break-after: avoid;
  }

  .features {
    gap: 1.25rem 1rem;
    padding-bottom: 1.25rem;
  }

  .feature {
    break-inside: avoid;
  }

  .jump {
    display: none;
  }

  .section {
    display: block;
    padding-block: 1.25rem;
  }

  .section-title {
    position: static;
    margin-bottom: 0.75rem;
    break-inside: avoid;
    break-after: avoid;
  }

  .pub {
    padding-block: 0.75rem;
    break-inside: avoid;
  }

  .pub-fig {
    border-color: #ccc;
  }

  .links a {
    padding-inline: 0;
    margin-right: 0.6em;
    text-decoration: underline;
  }
}
