/* site.css — Aiden Xia
 *
 * One ink, two sheets. On the paper sheet everything is printed in a
 * single ink; on the ink sheet the page is flooded with that ink and the
 * type is left as paper. There is no third colour: emphasis is always the
 * ink turned inside out.
 *
 * The figures are set in type by js/glyph.js and lit by the pointer, so
 * everything in this file stays quiet around them.
 */

:root {
  /* The colourway: five values. Every other colour on the site is mixed
   * from these, so changing them recolours everything, figures included.
   * (The tab icon is the one exception: its two colours are written into
   * the <link rel="icon"> line of each .html file.)
   *
   * This one is graphite. */
  --c-ink: #17171a; /* display type, rules, figures */
  --c-deep: #17171a; /* reading text (with a coloured ink: the ink, taken darker) */
  --c-paper: #f6f5f1; /* the paper sheet */
  --c-flood: #141416; /* the ink sheet: the page flooded with ink */
  --c-light: #f4f2ec; /* type on the ink sheet */

  /* Other colourways drawn up for this design. To switch, copy a row's
   * five values over the five above, in the same order. Each keeps small
   * text readable on both sheets.
   *
   *                    ink      deep     paper    flood    light
   *   Oxblood on blush #8a1230  #2e0812  #fdf2ef  #730f28  #ffe9e3
   *   Pine on pink     #0f5a3a  #0b2e20  #ffe4ea  #0f5236  #ffdbe4
   *   Evergreen        #0b7a55  #082b1f  #f5faf6  #0a6446  #f2fff7
   *   Plum on lilac    #5b1f7a  #260c33  #f6effb  #4d1a68  #f3e6fb
   *   Vermilion        #d42b16  #3a0c06  #fffaf7  #a91e0e  #fff7f2
   *   Ultramarine      #2433ff  #10175c  #fbfbff  #1629d9  #ffffff
   */

  /* the paper sheet */
  --paper: var(--c-paper);
  --ink: var(--c-ink);
  --text: var(--c-deep);
  --text-2: color-mix(in srgb, var(--c-deep) 70%, var(--c-paper));
  --line: color-mix(in srgb, var(--ink) 22%, transparent);
  --line-soft: color-mix(in srgb, var(--ink) 11%, transparent);
  --wash: color-mix(in srgb, var(--ink) 5%, transparent);
  --dot: color-mix(in srgb, var(--ink) 13%, transparent);
  --on-ink: var(--paper); /* type set on a block of ink */

  /* what the figures are drawn with (read by js/glyph.js) */
  --fig-ink: var(--ink);
  --fig-paper: var(--paper);
  --fig-mode: paper;

  --sans: 'Bricolage Grotesque', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --measure: 1240px;
  --gutter: clamp(20px, 4.4vw, 56px);
  --snap: cubic-bezier(0.3, 0.7, 0.2, 1);

  color-scheme: light;
}

/* the ink sheet */
:root[data-theme='ink'] {
  --paper: var(--c-flood);
  --ink: var(--c-light);
  --text: var(--c-light);
  --text-2: color-mix(in srgb, var(--c-light) 76%, var(--c-flood));
  --line: color-mix(in srgb, var(--ink) 30%, transparent);
  --line-soft: color-mix(in srgb, var(--ink) 15%, transparent);
  --wash: color-mix(in srgb, var(--ink) 7%, transparent);
  --dot: color-mix(in srgb, var(--ink) 16%, transparent);

  --fig-mode: ink;

  color-scheme: dark;
}

/* browsers from before 2023 cannot mix colours: give them plain rules
   and no tints rather than nothing at all */
@supports not (color: color-mix(in srgb, red, blue)) {
  :root,
  :root[data-theme='ink'] {
    --text-2: var(--text);
    --line: var(--ink);
    --line-soft: var(--ink);
    --wash: transparent;
    --dot: transparent;
  }
}

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

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  /* drafting dots, one every 24px */
  background-image: radial-gradient(var(--dot) 1px, transparent 1.25px);
  background-size: 24px 24px;
  background-position: 12px 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1;
}

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

a {
  color: inherit;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

/* phones flash a tinted box over whatever is tapped; every control here
   already answers a press in its own way */
a,
button,
summary {
  -webkit-tap-highlight-color: transparent;
}

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

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

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

button {
  font: inherit;
  color: inherit;
}

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

/* an author display rule must never out-rank the hidden attribute */
[hidden] {
  display: none !important;
}

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

/* ── shared type ─────────────────────────────────────────────────── */

/* the drafting hand: small capitals in the monospace */
.label {
  font: 500 11px/1.5 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

/* a text link turns its ink inside out */
.link {
  padding: 1px 3px;
  margin-inline: -3px;
  border-radius: 2px;
  text-decoration: underline;
  text-decoration-color: var(--line);
  transition: background-color 0.12s, color 0.12s;
}

.link:hover,
.link:focus-visible {
  background: var(--ink);
  color: var(--on-ink);
  text-decoration-color: transparent;
}

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: 500 0.95em/1.55 var(--mono);
  text-align: center;
}

/* ── masthead ────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: center;
  gap: 12px 28px;
  padding-block: 22px;
}

.masthead__name {
  margin-right: auto;
  font-size: 21px;
  font-weight: 620;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.masthead__nav {
  display: flex;
  gap: 4px;
}

.masthead__nav a {
  padding: 6px 9px;
  border-radius: 2px;
  font: 500 11.5px/1 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  transition: background-color 0.12s, color 0.12s;
}

.masthead__nav a:hover,
.masthead__nav a:focus-visible {
  background: var(--wash);
  box-shadow: inset 0 0 0 1px var(--line);
}

.masthead__nav a[aria-current='page'] {
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: none;
}

/* the sheet switch: a chip of the other sheet, and its name */
.sheet {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  font: 500 11.5px/1 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s;
}

.sheet:hover {
  border-color: var(--ink);
}

.sheet__chip {
  width: 14px;
  height: 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  /* a folded corner showing this sheet's own paper */
  background-image: linear-gradient(135deg, var(--paper) 0 34%, transparent 35%);
}

/* shown when the page cannot build itself: JavaScript off, or a typo in
   content.js */
.notice {
  grid-column: 1 / -1;
  margin-block: 24px;
  padding: 14px 16px;
  border: 1px solid var(--ink);
  font: 500 13px/1.6 var(--mono);
  color: var(--ink);
}

/* ── colophon ────────────────────────────────────────────────────── */

.colophon {
  margin-top: clamp(72px, 12vh, 136px);
  padding-block: 22px 40px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 28px;
  font: 400 11.5px/1.7 var(--mono);
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.colophon p:nth-child(2) {
  text-align: center;
}

.colophon p:nth-child(3) {
  text-align: right;
}

.colophon .link {
  color: var(--ink);
}

.colophon__ps {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 18px;
  padding: 4px 8px;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: var(--text-2);
  cursor: pointer;
}

.colophon__ps:hover,
.colophon__ps:focus-visible {
  color: var(--ink);
}

.colophon__ps:hover kbd,
.colophon__ps:focus-visible kbd {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

/* ── plates: where the figures sit ───────────────────────────────── */

.plate {
  position: relative;
}

.plate__figure {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.plate__figure.is-held {
  cursor: grabbing;
}

.plate__figure canvas {
  display: block;
  pointer-events: none;
}

/* crop marks at the four corners */
.plate__figure::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  --m: linear-gradient(var(--ink), var(--ink));
  background: var(--m) top left / 13px 1px, var(--m) top left / 1px 13px,
    var(--m) top right / 13px 1px, var(--m) top right / 1px 13px,
    var(--m) bottom left / 13px 1px, var(--m) bottom left / 1px 13px,
    var(--m) bottom right / 13px 1px, var(--m) bottom right / 1px 13px;
  background-repeat: no-repeat;
}

.plate__caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 18px;
  margin-top: 13px;
  font: 500 11px/1.6 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
}

.plate__readout {
  font-variant-numeric: tabular-nums;
  white-space: pre;
}

.plate__hint {
  flex-basis: 100%;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-2);
}

/* ── page heads ──────────────────────────────────────────────────── */

.pagehead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 24px clamp(28px, 5vw, 80px);
  padding-top: clamp(30px, 6vh, 68px);
}

.pagehead h1 {
  margin: 0.14em 0 0 -0.045em;
  font-size: clamp(58px, 9.4vw, 124px);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.pagehead__deck {
  max-width: 46ch;
  margin-top: 26px;
  font-size: 19px;
  line-height: 1.48;
}

.pagehead__plate {
  width: clamp(210px, 24vw, 300px);
}

/* ── home ────────────────────────────────────────────────────────── */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  column-gap: clamp(32px, 6vw, 96px);
  align-items: start;
  padding-top: clamp(20px, 4vh, 44px);
}

.home__plate .plate__figure {
  aspect-ratio: 10 / 9;
}

.home__lead {
  grid-column: 1;
}

.home__name {
  margin: 0.13em 0 0.27em -0.04em;
  font-size: clamp(84px, 11.6vw, 150px);
  font-weight: 600;
  line-height: 0.86;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.home__bio {
  max-width: 46ch;
  font-size: 18px;
  line-height: 1.5;
}

.home__bio p + p {
  margin-top: 0.85em;
}

.home__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-top: 22px;
  font: 500 12.5px/1.6 var(--mono);
  letter-spacing: 0.03em;
  color: var(--ink);
}

.home__plate {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 24px;
}

/* the index: one row per section */
.index {
  grid-column: 1;
  margin-top: clamp(34px, 5vh, 52px);
  border-bottom: 1px solid var(--line);
}

.index__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  column-gap: 20px;
  padding: 12px 12px 14px 0;
  border-top: 1px solid var(--line);
  background: linear-gradient(var(--ink), var(--ink)) left / 0% 100% no-repeat;
  color: var(--ink);
  text-decoration: none;
  transition: background-size 0.24s var(--snap), padding-left 0.24s var(--snap),
    color 0.1s;
}

.index__row:hover,
.index__row:focus-visible {
  background-size: 100% 100%;
  padding-left: 14px;
  color: var(--on-ink);
  outline: none;
}

.index__title {
  font-size: clamp(26px, 2.4vw, 31px);
  font-weight: 580;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.index__desc {
  grid-column: 1;
  grid-row: 2;
  font-size: 15px;
  color: var(--text-2);
  transition: color 0.1s;
}

.index__row:hover .index__desc,
.index__row:focus-visible .index__desc {
  color: var(--on-ink);
}

.index__count {
  font: 500 11.5px/1 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.index__go {
  font: 400 15px/1 var(--mono);
  transition: transform 0.24s var(--snap);
}

.index__row:hover .index__go,
.index__row:focus-visible .index__go {
  transform: translateX(4px);
}

/* ── the switch (the views of the Experience page) ───────────────── */

.switch {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--ink);
}

.switch button {
  padding: 9px 14px;
  border: 0;
  background: transparent;
  font: 500 11.5px/1 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
}

.switch button:hover {
  background: var(--wash);
}

.switch button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--on-ink);
}

/* ── experience ──────────────────────────────────────────────────── */

.xp {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  column-gap: clamp(36px, 7vw, 110px);
  align-items: start;
}

.xp .pagehead {
  grid-template-columns: minmax(0, 1fr);
}

.xp__plate {
  position: sticky;
  top: 24px;
  margin-top: clamp(30px, 6vh, 68px);
}

.xp__switch {
  margin-block: clamp(30px, 5vh, 48px) clamp(26px, 4vh, 40px);
}

.roles {
  border-bottom: 1px solid var(--line);
}

.role {
  padding: 24px 0 28px;
  border-top: 1px solid var(--line);
}

.role__meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 16px;
}

.role__org {
  width: fit-content;
  margin: 9px 0 3px -4px;
  padding: 0 4px;
  border-radius: 2px;
  font-size: clamp(28px, 3.1vw, 40px);
  font-weight: 580;
  line-height: 1.12;
  letter-spacing: -0.04em;
  color: var(--ink);
  transition: background-color 0.14s, color 0.14s;
}

.role.is-active .role__org {
  background: var(--ink);
  color: var(--on-ink);
}

.role__title {
  font-size: 17px;
  font-weight: 560;
}

.role__note {
  max-width: 54ch;
  margin-top: 10px;
}

.more {
  margin-top: 14px;
}

.more summary {
  display: inline-block;
  padding: 2px 4px;
  margin-left: -4px;
  border-radius: 2px;
  list-style: none;
  cursor: pointer;
}

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

.more summary::before {
  content: '+ ';
}

.more[open] summary::before {
  content: '− ';
}

.more summary:hover,
.more summary:focus-visible {
  background: var(--ink);
  color: var(--on-ink);
}

.more ul {
  max-width: 56ch;
  margin-top: 8px;
}

.more li {
  position: relative;
  padding: 10px 0 10px 24px;
  border-top: 1px solid var(--line-soft);
  font-size: 16px;
  line-height: 1.5;
}

.more li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 1.32em;
  width: 10px;
  height: 1px;
  background: var(--ink);
}

/* education: one block per school */
.school + .school {
  margin-top: clamp(48px, 9vh, 84px);
}

.school__head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding-bottom: 22px;
}

/* a school listed without courses still gets closed off with a rule */
.school__head:last-child {
  border-bottom: 1px solid var(--line);
}

.school h2 {
  font-size: clamp(28px, 3.1vw, 40px);
  font-weight: 580;
  line-height: 1.12;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.school__head p {
  font-weight: 560;
}

.courses {
  padding: 22px 0 24px;
  border-top: 1px solid var(--line);
}

.courses:last-child {
  border-bottom: 1px solid var(--line);
}

.courses h3 {
  margin-bottom: 10px;
  font-size: 22px;
  font-weight: 580;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.courses li {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: baseline;
  padding: 6px 0;
  line-height: 1.4;
}

.courses .label {
  white-space: nowrap;
}

/* a course listed by title alone */
.courses li.is-plain {
  display: block;
}

/* honors: a title and a line under it */
.honors {
  border-bottom: 1px solid var(--line);
}

.honor {
  padding: 20px 0 22px;
  border-top: 1px solid var(--line);
}

.honor h2 {
  width: fit-content;
  margin-left: -4px;
  padding: 0 4px;
  border-radius: 2px;
  font-size: clamp(22px, 2.3vw, 29px);
  font-weight: 580;
  line-height: 1.16;
  letter-spacing: -0.03em;
  color: var(--ink);
  transition: background-color 0.14s, color 0.14s;
}

.honor.is-active h2 {
  background: var(--ink);
  color: var(--on-ink);
}

.honor p {
  max-width: 54ch;
  margin-top: 5px;
}

/* ── projects ────────────────────────────────────────────────────── */

.projects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(36px, 6vh, 64px) clamp(24px, 3.6vw, 52px);
  margin-top: clamp(40px, 7vh, 76px);
}

.project__plate .plate__figure {
  aspect-ratio: 16 / 10.5;
  background: var(--wash);
}

.project__tag {
  position: absolute;
  top: 12px;
  left: 14px;
  pointer-events: none;
}

.project__body {
  padding-top: 16px;
}

.project__meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.project h2 {
  width: fit-content;
  margin: 7px 0 8px -4px;
  padding: 0 4px;
  border-radius: 2px;
  font-size: clamp(24px, 2.3vw, 31px);
  font-weight: 580;
  line-height: 1.14;
  letter-spacing: -0.035em;
  text-wrap: balance;
  color: var(--ink);
  transition: background-color 0.14s, color 0.14s;
}

.project:hover h2 {
  background: var(--ink);
  color: var(--on-ink);
}

.project__desc {
  max-width: 50ch;
  font-size: 16px;
  line-height: 1.5;
}

.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 12px;
  font: 500 12px/1.6 var(--mono);
  letter-spacing: 0.03em;
  color: var(--ink);
}

/* a list with nothing in it yet */
.empty {
  grid-column: 1 / -1;
  padding: 26px 0;
  border-top: 1px solid var(--line);
  color: var(--text-2);
}

/* ── reading ─────────────────────────────────────────────────────── */

.shelfsec {
  margin-top: clamp(48px, 8vh, 84px);
}

.shelfsec__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-top: 12px;
  margin-bottom: 22px;
  border-top: 1px solid var(--line);
}

.shelfsec__head h2 {
  font-size: clamp(26px, 2.8vw, 36px);
  font-weight: 580;
  letter-spacing: -0.04em;
  color: var(--ink);
}

/* A cover is a picture of the real one, or (when a book names no picture,
   or the picture never arrives) a pattern drawn from its title. */
.cover {
  position: relative;
  flex: none;
  aspect-ratio: 2 / 3;
  background: var(--paper);
  border: 1px solid var(--ink);
  overflow: hidden;
}

.cover svg {
  display: block;
  width: 100%;
  height: 100%;
}

.cover .c-ink {
  fill: var(--ink);
}

.cover .c-paper {
  fill: var(--paper);
}

.cover .c-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.2;
}

.cover .c-line-paper {
  fill: none;
  stroke: var(--paper);
  stroke-width: 1.2;
}

/* a real cover keeps its own proportions, so books differ a little in
   height, the way they do on a shelf */
.cover--real {
  aspect-ratio: auto;
  border: 0;
  background: var(--wash);
}

.cover--real img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto 2 / 3; /* holds the space until the picture arrives */
  outline: 1px solid var(--line); /* so a pale cover still has an edge */
  outline-offset: -1px;
  opacity: 0;
  transition: opacity 0.3s;
}

.cover--real.is-in img {
  opacity: 1;
}

.desk {
  display: grid;
  grid-template-columns: clamp(120px, 15vw, 172px) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 52px);
  align-items: center;
  max-width: 820px;
}

.desk h3 {
  margin-top: 8px;
  font-size: clamp(30px, 4vw, 50px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--ink);
}

.desk__author {
  margin-top: 8px;
  font-weight: 560;
}

.desk__note {
  max-width: 46ch;
  margin-top: 14px;
}

.progress {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 16px;
}

.progress__bar {
  letter-spacing: 0;
  white-space: nowrap;
}

/* The shelf: favourites. A book with a picture of its cover stands
   face-out; one without stands spine-out. Books wrap onto further
   shelves when one is full. */
.shelf {
  --book-w: clamp(96px, 11.4vw, 148px);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 40px 14px;
  padding: 20px 6px 6px; /* headroom for a lifted book; room for the last plank */
  overflow: hidden; /* every plank runs off to the right and is cut here */
}

.shelf__slot {
  position: relative;
  display: flex;
}

/* The plank. Each book draws one under itself, running off to the right,
   so every row is a full shelf however many books stand on it. */
.shelf__slot::after {
  content: '';
  position: absolute;
  top: 100%;
  left: -20px;
  width: 200vw;
  height: 4px;
  background: var(--ink);
}

.shelf__book {
  display: block;
  width: var(--book-w);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s var(--snap);
}

.shelf__book:hover,
.shelf__book:focus-visible,
.shelf__book.is-out {
  transform: translateY(-12px);
}

/* spine-out: the title runs up the spine */
.shelf__book.is-spine {
  display: grid;
  place-items: center start;
  width: calc(var(--book-w) * var(--w, 0.3));
  height: calc(var(--book-w) * 1.5 * var(--h, 0.9));
  padding: 12px 0;
  border: 1px solid var(--ink);
  background: var(--paper);
  writing-mode: vertical-rl;
  font-size: 14.5px;
  font-weight: 580;
  line-height: 1;
  letter-spacing: -0.01em;
}

.shelf__book.is-spine span {
  max-height: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* bound in different cloths */
.shelf__slot:nth-child(3n + 2) .is-spine {
  background: var(--ink);
  color: var(--on-ink);
}

.shelf__slot:nth-child(4n) .is-spine {
  background-image: repeating-linear-gradient(
    0deg,
    var(--line) 0 1px,
    transparent 1px 5px
  );
}

.shelf__detail {
  min-height: 3.2em;
  margin-top: 16px;
  max-width: 70ch;
}

.shelf__detail b {
  font-weight: 620;
  color: var(--ink);
}

.booklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(24px, 3.6vw, 52px);
}

.book {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 13px 0;
  border-top: 1px solid var(--line-soft);
}

.book h3 {
  font-size: 18px;
  font-weight: 580;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.book p {
  font-size: 14.5px;
  color: var(--text-2);
}

/* where the cover pictures come from */
.credit {
  margin-top: clamp(40px, 7vh, 64px);
  font: 400 11.5px/1.7 var(--mono);
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.credit .link {
  color: var(--ink);
}

/* ── the figure lab (press F) ────────────────────────────────────── */

.lab {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.25px);
  background-size: 24px 24px;
  background-position: 12px 12px;
}

.lab.is-open {
  display: flex;
}

.lab__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 14px var(--gutter);
  border-bottom: 1px solid var(--line);
}

.lab__stage {
  flex: 1;
  min-height: 0;
  padding: 18px var(--gutter);
}

.lab__stage .plate__figure {
  height: 100%;
  aspect-ratio: auto;
}

.lab__foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 14px var(--gutter) 18px;
  border-top: 1px solid var(--line);
}

.lab__field {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.lab__field input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font: 500 13px/1.3 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.lab__field input::placeholder {
  color: var(--text-2);
  opacity: 0.8;
}

.lab__field input:focus {
  outline: none;
  background: var(--wash);
}

.lab__keys {
  font: 400 11.5px/1.9 var(--mono);
  color: var(--text-2);
}

.lab__btn {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  font: 500 11.5px/1 var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
}

.lab__btn:hover,
.lab__btn:focus-visible {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.lab__step {
  display: flex;
  gap: 6px;
}

@media (hover: none) {
  /* no keyboard to hint at, and 16px keeps phones from zooming the field */
  .lab__keys {
    display: none;
  }

  .lab__field input {
    font-size: 16px;
  }
}

/* ── 404 ─────────────────────────────────────────────────────────── */

.lost {
  display: grid;
  justify-items: start;
  gap: 18px;
}

.lost h1 {
  margin-left: -0.04em;
  font-size: clamp(56px, 9.4vw, 124px);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.035em;
  color: var(--ink);
}

/* ── moving between pages ────────────────────────────────────────────
 * js/site.js swaps <main> in place rather than loading a new document,
 * then moves focus to it so a screen reader and the Tab key carry on
 * from the top of the new page. <main> is not a control, so it shows no
 * focus ring. The fades and the figure's glide are run from site.js. */
main:focus {
  outline: none;
}

/* ── responsive ──────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .home,
  .xp {
    grid-template-columns: minmax(0, 1fr);
  }

  .home__plate,
  .xp__plate {
    grid-column: 1;
    grid-row: auto;
    position: static;
  }

  .home__plate {
    max-width: 520px;
    margin-top: 40px;
  }

  .home__plate .plate__figure,
  .xp__plate .plate__figure {
    aspect-ratio: 5 / 4;
  }

  /* one column: title, then the figure, then the list it describes */
  .xp__main {
    display: contents;
  }

  .xp .pagehead {
    order: 1;
  }

  .xp__plate {
    order: 2;
    max-width: 520px;
    margin-top: 32px;
  }

  .xp__switch {
    order: 3;
    justify-self: start;
  }

  .xp__panels {
    order: 4;
  }

  .projects,
  .booklist {
    grid-template-columns: minmax(0, 1fr);
  }

  /* three books to a shelf */
  .shelf {
    --book-w: clamp(84px, 25vw, 190px);
    gap: 36px 10px;
  }

  .shelf__book.is-spine {
    font-size: 12.5px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16.5px;
  }

  .masthead {
    flex-wrap: wrap;
    padding-block: 16px 12px;
  }

  .masthead__nav {
    order: 3;
    flex-basis: 100%;
    margin-inline: -9px;
    gap: 0;
    justify-content: space-between;
  }

  .masthead__nav a {
    padding-inline: 8px;
    font-size: 11px;
    letter-spacing: 0.06em;
  }

  .switch button {
    padding-inline: 10px;
    font-size: 11px;
    letter-spacing: 0.07em;
  }

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

  .pagehead__plate {
    width: min(64vw, 260px);
  }

  .home__bio,
  .pagehead__deck {
    font-size: 18px;
  }

  .index__row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .index__go {
    display: none;
  }

  /* course number and term share the first line; the title gets the
     whole of the second */
  .courses li {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
  }

  .courses li > :nth-child(1) {
    grid-area: 1 / 1;
  }

  .courses li > :nth-child(2) {
    grid-area: 2 / 1 / 3 / -1;
  }

  .courses li > :nth-child(3) {
    grid-area: 1 / 2;
  }

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

  .colophon p:nth-child(2),
  .colophon p:nth-child(3) {
    text-align: left;
  }

  .colophon__ps {
    justify-self: start;
    margin-top: 8px;
    padding-inline: 0;
    text-align: left;
  }

  .desk {
    grid-template-columns: 104px minmax(0, 1fr);
  }
}

/* nothing drifts for readers who asked for stillness */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* a printer gets the paper sheet, whichever was on screen */
@media print {
  :root,
  :root[data-theme='ink'] {
    --paper: #fff;
    --ink: var(--c-ink);
    --text: var(--c-deep);
    --text-2: color-mix(in srgb, var(--c-deep) 70%, #fff);
  }

  body {
    background-image: none;
  }

  /* figures drawn for the ink sheet are pale; keep their ground under them */
  :root[data-theme='ink'] .plate__figure {
    background: var(--c-flood);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .sheet,
  .colophon__ps,
  .lab {
    display: none;
  }
}
