/* ==========================================================
   P. Quinn White — site styles
   One typeface (Valkyrie), one accent colour.
   ========================================================== */

/* ---------- Fonts ----------
   Valkyrie OT A by Matthew Butterick (MB Type), self-hosted from the fonts folder.
   The OT files include true small caps (smcp) and oldstyle figures.
   If a file is missing, the browser falls back to Palatino, then Georgia. */
@font-face {
  font-family: "Valkyrie";
  src: url("fonts/valkyrie_ot_a_regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Valkyrie";
  src: url("fonts/valkyrie_ot_a_italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Valkyrie";
  src: url("fonts/valkyrie_ot_a_bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Valkyrie";
  src: url("fonts/valkyrie_ot_a_bold_italic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- Colours and measures ---------- */
:root {
  --paper: #FEFDFB;
  --ink: #26221E;
  --soft: #4A443D;
  --muted: #6B635A;
  --rule: #EAE6DF;
  --accent: #6E2B26;          /* very dark red */
  --accent-hover: #4A1B17;
  --row-hover: rgba(110, 43, 38, 0.05);   /* faint tint behind a paper's row on hover */
  --placeholder: #EFE9DF;

  --serif: "Valkyrie", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --text-width: 40rem;      /* comfortable line length for body text */
  --note-width: 13rem;      /* right-hand column: photo on Home, journal and year on Research */
  --gap: 3rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1E1B18;
    --ink: #EDE6DC;
    --soft: #D3CABE;
    --muted: #A99E92;
    --rule: #3A342E;
    --accent: #E3A79D;
    --accent-hover: #F0C6BF;
    --placeholder: #2A2622;
    --row-hover: rgba(227, 167, 157, 0.08);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;         /* 18px */
  line-height: 1.6;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-hover); }
a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

p { margin: 0 0 1.1rem; }

.page {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
}

.skip-link { position: absolute; left: -999px; }
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: var(--paper);
  padding: 0.5rem 0.75rem;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem 1.5rem;
  padding: 2.75rem 0 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.site-name {
  color: var(--ink);
  text-decoration: none;
  font-variant-caps: small-caps;   /* true small caps: P, Q and W stay full height */
  letter-spacing: 0.06em;
  font-size: 1.5rem;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  font-size: 1.05rem;
}
.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

main { padding-top: 3.5rem; }

h1 {
  margin: 0 0 1.25rem;
  font-size: 2.6rem;
  font-weight: normal;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.prose { max-width: var(--text-width); }
.prose p { color: var(--soft); }

/* ---------- Home: photo on the left, text beside it ----------
   Both columns have fixed widths, so the text always breaks into the same
   lines and the photo can be sized to match it exactly: the photo's top lines
   up with the first capital and its bottom with the last line's baseline.
   If you change the home-page text, adjust --portrait-width until the two
   line up again (photo height = width × 1494 / 1080). */
.home {
  --portrait-width: 18.225rem;
  display: grid;
  grid-template-columns: var(--portrait-width) minmax(0, 30rem);
  column-gap: var(--gap);
  align-items: start;
}
.portrait { margin: 0; }
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1080 / 1494;
  background: var(--placeholder);
}
.home .prose {
  margin-top: -0.5625rem;  /* lines the first capital up with the photo's top edge */
  line-height: 1.65;
}
/* On full-width screens (60rem and up) the text runs all the way to the menu's
   right edge, set a touch larger (the same 1.2rem as paper titles), so it still
   fills the photo's height exactly. Line height and offset are tuned to the
   current text; if the text changes, they need re-tuning, like --portrait-width. */
@media (min-width: 60rem) {
  .home { grid-template-columns: var(--portrait-width) minmax(0, 1fr); }
  .home .prose {
    max-width: none;
    font-size: 1.2rem;
    line-height: 1.683;
    margin-top: -0.532em;
  }
}
@media (max-width: 54.5rem) {
  .home { grid-template-columns: minmax(0, 30rem); }
  .portrait { max-width: 14rem; margin-bottom: 2rem; }
  .home .prose { margin-top: 0; }
}

/* ---------- Research: one line per paper, click to open ----------
   Each paper is a <details class="entry">. Its summary line shows the title
   and the journal; opening it shows the summary, links and a second
   <details class="abstract"> holding the full abstract. */
.label {
  margin: 3rem 0 0.4rem;
  font-size: 1.1rem;
  font-weight: normal;
  font-variant-caps: small-caps;   /* capitals stay full size; write labels in title case */
  letter-spacing: 0.08em;
  color: var(--muted);
}

.research-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.25rem 1.5rem;
  margin-top: 1.5rem;
}
#toggle-all {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
#toggle-all:hover { color: var(--accent-hover); }

.entry { border-top: 1px solid var(--rule); }

.entry > summary {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 1fr) var(--note-width);
  align-items: baseline;
  padding: 0.7rem 0;
  list-style: none;
  cursor: pointer;
}
.entry > summary::-webkit-details-marker { display: none; }
.entry > summary::before {
  content: "\25B8";            /* ▸ */
  font-size: 0.7em;
  color: var(--muted);
}
.entry[open] > summary::before { content: "\25BE"; }   /* ▾ */
.entry-title {
  font-size: 1.2rem;
  line-height: 1.3;
  padding-right: var(--gap);
}
.entry > summary:hover .entry-title { color: var(--accent); }
/* On devices with a mouse, the whole row tints faintly on hover and the triangle
   turns red, so it's clear the row opens. The tint reaches slightly past the text. */
@media (hover: hover) {
  .entry > summary {
    margin: 0 -0.6rem;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    border-radius: 4px;
    transition: background-color 0.15s;
  }
  .entry > summary:hover { background: var(--row-hover); }
  .entry > summary:hover::before { color: var(--accent); }
}
.entry-meta {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--muted);
}

/* An open entry's venue can wrap onto two or three lines. Let it hang down
   beside the summary instead of pushing the summary away from the title. */
@media (min-width: 46.01rem) {
  .entry[open] > summary .entry-meta { margin-bottom: -4rem; }
}

.entry-body {
  /* Without the page script: never wider than the title column, so a journal
     name that hangs down beside an open entry can't run into the summary. */
  max-width: min(var(--text-width), calc(100% - var(--note-width) - var(--gap)));
  padding: 0 0 1.5rem 1.4rem;
}
/* With the script (research.html): full width, and the summary wraps around a
   space the script reserves for the journal name. */
.runaround .entry-body { max-width: var(--text-width); }
.runaround .entry-body::before {
  content: "";
  float: right;
  width: var(--hang-w, 0px);
  height: var(--hang, 0px);
}
.entry-body .gist { margin: 0; color: var(--soft); }
.entry-honor {               /* a distinction shown under the title, without opening the entry */
  grid-column: 2;
  grid-row: 2;
  margin-top: 0.15rem;
  font-size: 0.9rem;
  color: var(--accent);
}
.entry > summary:has(.entry-honor) .entry-meta { grid-column: 3; grid-row: 1 / span 2; }  /* journal name sits beside both lines */
.entry-body .links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.2rem;
  margin: 0.6rem 0 0;
  font-size: 1rem;
}
.entry-body .abstract-text,
.abstract p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--soft);
  hyphens: auto;
}
.entry-body .abstract-text { margin: 0; }

.abstract { margin-top: 0.85rem; }
.abstract > summary {
  width: fit-content;
  cursor: pointer;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--muted);
}
.abstract > summary:hover { color: var(--accent); }
.abstract p { margin: 0.75rem 0 0.25rem; }

.backburner-intro {
  margin: 0;
  padding: 0.9rem 0 0.6rem;
  border-top: 1px solid var(--rule);
  color: var(--soft);
}

@media (max-width: 46rem) {
  .entry > summary { grid-template-columns: 1.4rem minmax(0, 1fr); }
  .entry-meta { grid-column: 2; padding-top: 0.15rem; }
  .entry > summary:has(.entry-honor) .entry-meta { grid-column: 2; grid-row: 2; }
  .entry-honor { grid-row: 3; }   /* on phones: title, then journal, then the distinction */
  .entry-title { padding-right: 0; }
  .entry-body { max-width: var(--text-width); }
}

/* ---------- Teaching ----------
   Same rhythm as the research page: full width, course title on the left,
   syllabus link in the right-hand column, description in lighter text. */
.lead {
  max-width: var(--text-width);
  color: var(--soft);
}
.course {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--note-width);
  align-items: baseline;
  border-top: 1px solid var(--rule);
  padding: 0.85rem 0 1rem;
}
.course-main { padding-right: var(--gap); }
.course h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: normal;
  line-height: 1.3;
}
.course p {
  margin: 0.3rem 0 0;
  max-width: var(--text-width);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--soft);
}
.course-meta { font-size: 0.95rem; }
.course-note {
  margin: 0;
  padding: 0.85rem 0 0;
  max-width: var(--text-width);
  border-top: 1px solid var(--rule);
  font-size: 1rem;
  color: var(--soft);
}
.course-note.listing-link {   /* the link to the department's course listings, after the Harvard courses */
  border-top: 0;
  padding-top: 0.75rem;
  color: var(--muted);
}
/* Courses inside the collapsed "Earlier courses" section are smaller. */
.entry-body .course { grid-template-columns: minmax(0, 1fr) auto; padding: 0.6rem 0 0.7rem; }
.entry-body .course:first-child { border-top: 0; padding-top: 0; }
.entry-body .course h3 { font-size: 1.1rem; }
.resources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 2rem;
  margin: 0;
  padding: 0.85rem 0 0;
  list-style: none;
  border-top: 1px solid var(--rule);
  font-size: 1rem;
  color: var(--soft);
}
@media (max-width: 46rem) {
  .course { grid-template-columns: minmax(0, 1fr); }
  .course-main { padding-right: 0; }
  .course-meta { padding-top: 0.3rem; }
}

/* ---------- About: photographs ----------
   Each row is a flex line. Every photo grows in proportion to its own
   width/height ratio (--ar, set on the link), so all photos in a row come out
   exactly the same height and nothing is cropped. Rows stack on phones. */
/* The About text runs the full width of the page, like the photos below it. */
.about .prose { max-width: none; }

.gallery {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 2.5rem;
}
.gallery-row {
  display: flex;
  gap: 0.75rem;
}
.gallery-row a {
  flex: var(--ar) 1 0;
  min-width: 0;
}
.gallery img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--placeholder);
}
@media (max-width: 40rem) {
  .gallery-row { flex-direction: column; }
}

/* ---------- CV ----------
   Generated from the LaTeX CV (see _tools/cv_to_html.py). Section headings in
   small caps with hairline rules, like the PDF; dates sit in a right-hand column.
   Every section and the longer subsections fold open and closed. */
.cv-masthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
}
.cv-masthead h1 {
  margin: 0;
  font-variant-caps: small-caps;
  letter-spacing: 0.04em;
}
.cv-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1.25rem;
  font-size: 1rem;
}
.cv-updated { color: var(--muted); }
.cv-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 2rem;
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
}
.cv-contents {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.1rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  font-size: 1rem;
}
.cv-contents a { color: var(--muted); text-decoration: none; }
.cv-contents a:hover { color: var(--accent); }
.cv-actions { display: flex; gap: 0 1.25rem; align-items: center; }
.cv-actions #toggle-all { font-size: 0.95rem; }

.cv-section { border-bottom: 1px solid var(--rule); }
.cv-section > summary,
.cv-sub > summary,
.cv-group > summary {
  list-style: none;
  cursor: pointer;
}
.cv-section > summary::-webkit-details-marker,
.cv-sub > summary::-webkit-details-marker,
.cv-group > summary::-webkit-details-marker { display: none; }
.cv-section > summary {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 1rem 0 0.55rem;
}
.cv-section > summary::before,
.cv-sub > summary::before,
.cv-group > summary::before {
  content: "\25B8";            /* ▸ */
  flex: 0 0 0.8rem;
  font-size: 0.7em;
  color: var(--muted);
}
.cv-section[open] > summary::before,
.cv-sub[open] > summary::before,
.cv-group[open] > summary::before { content: "\25BE"; }   /* ▾ */
.cv-section > summary h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: normal;
  font-variant-caps: small-caps;
  letter-spacing: 0.04em;
}
.cv-section > summary:hover h2 { color: var(--accent); }
.cv-body { padding: 0 0 1.1rem 1.4rem; }

.cv-list { margin: 0; padding: 0; list-style: none; }
.cv-list > li {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 2rem;
  padding: 0.2rem 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--soft);
}
.cv-list > li::before {
  content: "\00B7";            /* · as in the PDF */
  position: absolute;
  left: -0.9rem;
  color: var(--muted);
}
.cv-list > li.cv-group-item { display: block; }
.cv-list > li.cv-group-item::before { content: none; }
.cv-list .when {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: oldstyle-nums;
}
.cv-note {
  grid-column: 1 / -1;
  padding-left: 1rem;
  font-size: 0.95rem;
  color: var(--accent);
}
.cv-subhead,
.cv-sub > summary h3 {
  margin: 0.9rem 0 0.25rem;
  font-size: 1.05rem;
  font-weight: normal;
  font-variant-caps: small-caps;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.cv-sub > summary,
.cv-group > summary {
  display: grid;
  grid-template-columns: 0.8rem minmax(0, 1fr) auto;
  column-gap: 0.6rem;
  align-items: baseline;
}
.cv-sub > summary { margin-top: 0.9rem; }
.cv-sub > summary h3 { margin: 0; }
.cv-sub > .cv-list,
.cv-group > .cv-list { padding: 0.2rem 0 0.4rem 1.4rem; }
.cv-group > summary { padding: 0.25rem 0; font-size: 1rem; color: var(--ink); }
.cv-group > summary:hover .what,
.cv-sub > summary:hover h3 { color: var(--accent); }
.cv-sub .when, .cv-group > summary .when {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 40rem) {
  .cv-list > li { grid-template-columns: minmax(0, 1fr); }
  .cv-body { padding-left: 1rem; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-nav, .skip-link { display: none; }
  a { color: #000; }
}
