/* ---------------------------------------------------------------
   Personal homepage — minimal academic style
   Single stylesheet, no build step, no dependencies.
   Tweak the variables below to restyle the whole site.
--------------------------------------------------------------- */

:root {
  --text:        #1f1f1f;
  --text-muted:  #5a5a5a;
  --link:        #1a4fa0;
  --link-hover:  #0d3373;
  --accent:      #b02b23;   /* awards, "Spotlight", "Deployed to ..." */
  --rule:        #e2e2e2;
  --bg:          #ffffff;
  --bg-soft:     #f7f7f5;

  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino,
           "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --measure: 1180px;
  --sidebar: 240px;
  --gap: 64px;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Keep text selection inside the text column.
   WebKit/Blink paint the "selection gaps" between block elements starting from
   the nearest ancestor that has its own paint layer. If there isn't one, that
   ancestor is the viewport — so dragging across two paragraphs bleeds the
   highlight edge to edge. Giving each container a paint layer (position:
   relative is enough, and doesn't disturb the sticky sidebar the way
   overflow:hidden would) makes the column itself the selection root. */
.page,
.content,
.content > section,
.essay { position: relative; }

::selection { background: #cfe0f7; color: var(--text); }
::-moz-selection { background: #cfe0f7; color: var(--text); }

/* ----------------------------- layout ----------------------------- */

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 56px 28px 120px;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.sidebar { position: sticky; top: 56px; }

@media (max-width: 860px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    padding: 36px 22px 80px;
  }
  .sidebar { position: static; }
  body { font-size: 18px; }
}

/* ----------------------------- sidebar ----------------------------- */

.avatar {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 1px solid var(--rule);
  background: var(--bg-soft);
}

.sidebar h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 22px 0 2px;
  letter-spacing: -0.01em;
}

.sidebar .tagline {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 1rem;
}

.contact { list-style: none; margin: 0; padding: 0; font-size: 0.97rem; }

.contact li {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-bottom: 9px;
}

.contact .ico {
  flex: 0 0 18px;
  display: inline-flex;
  justify-content: center;
  position: relative;
  top: 2px;
  color: var(--text-muted);
}

.contact .ico svg { width: 15px; height: 15px; fill: currentColor; }

/* ----------------------------- content ----------------------------- */

.content > section { margin-bottom: 58px; scroll-margin-top: 24px; }

h2 {
  font-size: 1.42rem;
  font-weight: 600;
  margin: 0 0 18px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--rule);
  letter-spacing: -0.01em;
}

h3 { font-size: 1.1rem; font-weight: 600; margin: 30px 0 10px; }

p { margin: 0 0 15px; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

strong { font-weight: 600; }
.accent { color: var(--accent); font-weight: 600; }
.muted { color: var(--text-muted); }
.small { font-size: 0.92rem; }

ul { margin: 0 0 15px; padding-left: 1.25em; }
li { margin-bottom: 7px; }
li > ul { margin-top: 7px; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 34px 0; }

/* inline link row: Blog / GitHub / Scholar / ... */
.linkrow { margin-top: 4px; }
.linkrow a { white-space: nowrap; }
.linkrow .sep { color: var(--text-muted); padding: 0 4px; }

/* ----------------------------- news ----------------------------- */

.news { padding-left: 1.25em; }
.news > li { margin-bottom: 11px; }
.news .date { font-weight: 600; }

/* collapsible "Olds" */
details.olds { display: inline; }
details.olds > summary {
  display: inline;
  cursor: pointer;
  list-style: none;
  color: var(--link);
  font-weight: 600;
}
details.olds > summary::-webkit-details-marker { display: none; }
details.olds > summary::after { content: " \203A"; }
details.olds[open] > summary::after { content: " \2039"; }
details.olds > summary:hover { text-decoration: underline; }

/* ----------------------------- research ----------------------------- */

.pub-controls { margin-bottom: 6px; font-size: 1rem; }

.pub-controls button {
  font: inherit;
  font-size: 1rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--link);
}
.pub-controls button:hover { text-decoration: underline; }
.pub-controls button[aria-pressed="true"] {
  color: var(--text);
  font-weight: 600;
  cursor: default;
  text-decoration: none;
}
.pub-controls .sep { color: var(--text-muted); padding: 0 7px; }

.pub {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 26px;
  margin-bottom: 38px;
  align-items: start;
}

.pub-thumb {
  width: 100%;
  border: 1px solid var(--rule);
  background: var(--bg-soft);
  display: block;
}

/* entries with no figure yet span the full width */
.pub.no-thumb { grid-template-columns: minmax(0, 1fr); gap: 0; }

.pub-title { font-weight: 600; margin-bottom: 2px; }
.pub-authors { margin-bottom: 2px; }
.pub-authors .me { font-weight: 600; text-decoration: underline; }
.pub-venue { font-weight: 600; margin-bottom: 2px; }
.pub-note { margin-bottom: 2px; }
.pub .linkrow { margin-top: 7px; }

@media (max-width: 640px) {
  .pub { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pub-thumb { max-width: 300px; }
}

/* hidden when "Show Selected" is active */
.pub[hidden] { display: none; }

/* ----------------------------- writing ----------------------------- */

.entries { list-style: none; padding: 0; margin: 0; }
.entries li {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 12px;
}
.entries .when { color: var(--text-muted); font-size: 0.95rem; padding-top: 1px; }
.entries .what .blurb { color: var(--text-muted); font-size: 0.95rem; }

@media (max-width: 560px) {
  .entries li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* ----------------------------- footer ----------------------------- */

.foot {
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

/* ----------------------------- essay pages ----------------------------- */

.essay {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 120px;
}
.essay h1 { font-size: 2rem; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.015em; }
.essay .meta { color: var(--text-muted); margin-bottom: 34px; }
.essay p { margin: 0 0 20px; }
.essay blockquote {
  margin: 0 0 20px;
  padding-left: 18px;
  border-left: 2px solid var(--rule);
  color: var(--text-muted);
}
.essay .back { display: inline-block; margin-bottom: 30px; font-size: 0.95rem; }
.essay h2 { font-size: 1.3rem; margin-top: 46px; }
.essay ul { margin-bottom: 20px; }
.essay li { margin-bottom: 10px; }

/* subpage nav: Home / Writing / Building / Music / Reading */
.subnav {
  font-size: 0.95rem;
  margin-bottom: 30px;
  color: var(--text-muted);
}
.subnav .sep { padding: 0 6px; }
.subnav .here { color: var(--text); font-weight: 600; }

/* lede paragraph under a page title */
.lede { font-size: 1.08rem; margin-bottom: 30px; }

/* ----------------------------- bookshelf ----------------------------- */

.book { margin-bottom: 44px; }

.book-head { margin-bottom: 10px; }
.book-title { font-weight: 600; font-size: 1.1rem; }
.book-author { color: var(--text-muted); }

.tag {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--text-muted);
  vertical-align: 2px;
  margin-left: 8px;
}
.tag.now { border-color: var(--accent); color: var(--accent); }

.takeaways { padding-left: 1.1em; }
.takeaways li { margin-bottom: 8px; }
.takeaways strong { font-weight: 600; }

/* ----------------------------- schema tables ----------------------------- */

/* Colours are the video palette, darkened to sit on a white page. */
.schema {
  --t-driver:      #2f6fd0;
  --t-race:        #b6660d;
  --t-constructor: #3d8b50;
  --t-bridge:      #7549c9;
  --t-hub:         #b02ba6;
  --t-task:        #7549c9;   /* the stapled-on task table */
  --t-gold:        #8a6d15;   /* the transfer twin: a database never seen */

  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 18px;
  margin: 26px 0 10px;
}

/* the two junction tables carry the argument — give them the full width */
.schema .wide { grid-column: 1 / -1; }

.tbl {
  border: 1px solid var(--rule);
  border-top: 3px solid var(--tc, var(--rule));
  border-radius: 4px;
  /* Cells are white-space:nowrap, so on a narrow screen a wide table must be
     able to SCROLL. overflow:hidden here silently clipped the right-hand
     columns on a phone, losing data rather than degrading. */
  overflow-x: auto;
  overflow-y: hidden;
}

.tbl-name {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tc, var(--text));
  padding: 9px 12px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 7px;
}

.tbl-role {
  font-weight: 500;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tbl table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.78rem;
  margin-top: 8px;
}

.tbl th,
.tbl td {
  text-align: left;
  padding: 5px 12px;
  border-top: 1px solid var(--rule);
  white-space: nowrap;
}

.tbl th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* primary-key and foreign-key columns */
.tbl .pk { color: var(--tc, var(--text)); font-weight: 600; }
.tbl .fk { background: var(--bg-soft); }
.tbl th.fk::after {
  content: " ↗";
  font-size: 0.85em;
  opacity: 0.65;
}

.schema-key {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 4px 0 30px;
}

/* ---- numeric matrices inside .tbl ----------------------------------
   .tbl was built for schemas (left-aligned text). A matrix of numbers
   wants right alignment and tabular figures so the columns line up, plus
   a row-header column. Set --rc on a row header to colour it. */

.tbl td.num,
.tbl th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tbl th.rowh {
  text-align: right;
  font-weight: 600;
  color: var(--rc, var(--tc, var(--text)));
}

/* ----------------------------- slides / figures ----------------------------- */

/* Frames lifted from the video series. They are rendered on black, so they sit
   in their own dark card rather than fighting the white page. */
.slide { margin: 30px 0 34px; }

.slide img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 7px;
  background: #000;
  border: 1px solid #1c1c1c;
}

.slide figcaption {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 9px;
}

/* pull figures a little wider than the text column on roomy screens */
@media (min-width: 900px) {
  .essay .slide { margin-left: -60px; margin-right: -60px; }
}

/* inline + display math, kept as plain text so there's no MathJax dependency */
.math {
  font-family: var(--sans);
  font-size: 0.93em;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.mathblock {
  font-family: var(--sans);
  font-size: 0.93rem;
  line-height: 1.75;
  background: var(--bg-soft);
  border-left: 2px solid var(--rule);
  padding: 14px 18px;
  margin: 0 0 22px;
  overflow-x: auto;
  white-space: pre;
}

/* chapter divider inside a long essay */
.chapter {
  margin-top: 60px;
  padding-top: 4px;
}
.chapter-tag {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* the "try this" exercise blocks that close each chapter */
.exercise {
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 16px 20px 4px;
  margin: 26px 0 30px;
}
.exercise h4 {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-weight: 600;
}

/* table of contents at the top of a long piece */
.toc { font-size: 0.97rem; margin-bottom: 40px; }
.toc ol { padding-left: 1.3em; margin: 8px 0 0; }
.toc li { margin-bottom: 5px; }

/* ----------------------------- poems ----------------------------- */

.poem { margin: 0 0 40px; }

.poem-title { font-weight: 600; font-size: 1.08rem; margin-bottom: 8px; }

.poem-body {
  white-space: pre-line;   /* keeps the line breaks you type in the HTML */
  line-height: 1.7;
  margin: 0;
}

.poem-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 10px;
}

/* a poem by someone else: short excerpt, attributed */
.admired { margin: 0 0 34px; }
.admired blockquote {
  margin: 0 0 8px;
  padding-left: 18px;
  border-left: 2px solid var(--rule);
  white-space: pre-line;
  line-height: 1.7;
}
.admired cite { font-style: normal; color: var(--text-muted); font-size: 0.95rem; }
.admired .why { font-size: 0.95rem; margin: 8px 0 0; }

/* a quiet call-out for "help me / tell me more" asks */
.aside-note {
  background: var(--bg-soft);
  border-left: 2px solid var(--rule);
  padding: 14px 18px;
  margin: 0 0 22px;
  font-size: 0.95rem;
  color: var(--text-muted);
}
