:root {
  --bg: #fbfaf7;
  --card: #ffffff;
  --text: #1b1b19;
  --muted: #6b6963;
  --faint: #b3b0a9;
  --rule: #e9e6df;
  --hover: #f3f1ec;
  --shadow: 0 1px 2px rgb(27 27 25 / 0.04), 0 18px 40px -12px rgb(27 27 25 / 0.22);

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --label: 132px;
  --gap: 40px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --card: #1a1a18;
    --text: #ecebe7;
    --muted: #a19e97;
    --faint: #55534e;
    --rule: #262523;
    --hover: #1c1c1a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 18px 40px -12px rgb(0 0 0 / 0.7);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

html.viewing {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15.5px/1.65 var(--sans);
  font-feature-settings: "ss01", "cv11";
}

::selection {
  background: var(--text);
  color: var(--bg);
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 104px 24px 80px;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

/* ---------- header ---------- */

.intro {
  margin-bottom: 64px;
}

.name {
  margin: 0;
  font: 500 28px/1.2 var(--sans);
  letter-spacing: -0.022em;
}

.bio {
  margin: 14px 0 0;
  max-width: 580px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
}

.bio strong {
  font-weight: 400;
  color: var(--text);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--muted);
}

.links li + li::before {
  content: "·";
  margin-right: 10px;
  color: var(--faint);
}

.links a {
  color: var(--muted);
  text-decoration: none;
}

.links a:hover {
  color: var(--text);
}

/* ---------- sections ---------- */

.section {
  display: grid;
  grid-template-columns: var(--label) 1fr;
  gap: var(--gap);
  padding: 28px 0;
  border-top: 1px solid var(--rule);
}

.label {
  margin: 0;
  padding-top: 2px;
  font: 400 13px/1.6 var(--sans);
  color: var(--muted);
}

.body {
  min-width: 0;
}

.body > :last-child {
  margin-bottom: 0;
}

.sub {
  margin: 26px 0 8px;
  font: 400 13px/1.6 var(--sans);
  color: var(--muted);
}

/* ">" lists, the site's signature mark */

.marks {
  margin: 0;
  padding: 0;
  list-style: none;
}

.marks li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 10px;
}

.marks li:last-child {
  margin-bottom: 0;
}

.marks li::before {
  content: ">";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--faint);
}

/* rows: a title on the left, a quiet type tag on the right */

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rows + .rows {
  margin-top: 14px;
}

.row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 0 -10px;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

a.row:hover,
a.row.is-forked {
  background: var(--hover);
}

.row .title {
  flex: 1;
  min-width: 0;
}

.row .title small {
  display: block;
  font-size: 13.5px;
  color: var(--muted);
}

.row .tag {
  flex: none;
  font: 400 13px/1 var(--sans);
  color: var(--muted);
  white-space: nowrap;
}

a.row[href^="http"] .tag::after {
  content: " ↗";
}

a.row[href$=".html"] .tag::after {
  content: " →";
}

a.row[data-drive] .tag::after {
  content: "";
}

a.row:hover .tag,
a.row.is-forked .tag {
  color: var(--text);
}

/* tree: material that belongs to the row above it */

.tree {
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
}

.tree + .row {
  margin-top: 18px;
}

.tree .row {
  position: relative;
  padding-left: 38px;
}

.tree .row::before {
  content: "↳";
  position: absolute;
  left: 15px;
  top: 7px;
  font: 400 15px/1.65 var(--sans);
  color: var(--faint);
  transition: color 0.15s ease, transform 0.2s ease;
}

.tree .row:hover::before,
.tree .row.is-forked::before {
  color: var(--text);
  transform: translateX(2px);
}

.kind {
  margin-right: 8px;
  font: 400 13px/1 var(--sans);
  color: var(--muted);
}

/* entries: experience, honors, education */

.entries {
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  margin-bottom: 18px;
}

.entry:last-child {
  margin-bottom: 0;
}

.entry-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.entry-head .org {
  flex: 1;
  min-width: 0;
}

.entry-head .when {
  flex: none;
  font-variant-numeric: tabular-nums;
  font: 400 13px/1 var(--sans);
  color: var(--muted);
  white-space: nowrap;
}

.entry .what {
  margin: 2px 0 0;
  font-size: 14.5px;
  color: var(--muted);
}

.entry .role {
  color: var(--text);
}

/* essay overview */

details {
  margin-top: 6px;
}

summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  font: 400 13px/1.6 var(--sans);
  color: var(--muted);
}

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

summary::before {
  content: "+";
  width: 10px;
}

details[open] summary::before {
  content: "−";
}

summary:hover {
  color: var(--text);
}

.overview {
  margin: 12px 0 4px;
  padding-left: 18px;
  border-left: 1px solid var(--rule);
  font-size: 14.5px;
}

.overview dt {
  margin-top: 10px;
  font-weight: 500;
}

.overview dt:first-child {
  margin-top: 0;
}

.overview dd {
  margin: 0;
  color: var(--muted);
}

/* ---------- fork card: hover a material row and its preview forks out ---------- */

.fork-card {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-8px) scale(0.98);
  transform-origin: left center;
  transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1),
    visibility 0s linear 0.22s;
}

.fork-card[data-side="left"] {
  transform: translateX(8px) scale(0.98);
  transform-origin: right center;
}

.fork-card[data-side="below"] {
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
}

.fork-card.on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

/* the dashed branch from the row to the card */
.fork-card::before {
  content: "";
  position: absolute;
  top: var(--y, 50%);
  width: var(--reach, 0);
  border-top: 1px dashed var(--faint);
}

.fork-card[data-side="right"]::before {
  right: 100%;
}

.fork-card[data-side="left"]::before {
  left: 100%;
}

.fork-card[data-side="below"]::before {
  display: none;
}

.fork-media {
  overflow: hidden;
  border-radius: 6px;
  background: var(--hover);
}

.fork-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62vh;
  object-fit: contain;
}

.fork-card.no-thumb .fork-media {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  font: 400 13px/1.4 var(--sans);
  color: var(--muted);
}

.fork-card.no-thumb .fork-media img {
  display: none;
}

.fork-card.no-thumb .fork-media::after {
  content: "No preview yet";
}

.fork-cap {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 2px;
  font: 400 12px/1.4 var(--sans);
  color: var(--muted);
}

/* ---------- viewer: click a material row to read it on the page ---------- */

.viewer {
  width: min(1100px, calc(100vw - 32px));
  height: min(88vh, 920px);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.viewer[open] {
  display: flex;
  flex-direction: column;
}

.viewer::backdrop {
  background: rgb(12 12 11 / 0.5);
  backdrop-filter: blur(3px);
}

.viewer[data-kind="video"] {
  height: fit-content;
}

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--rule);
  font: 400 13px/1.4 var(--sans);
  color: var(--muted);
}

.viewer-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
}

.viewer-bar a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.viewer-bar a:hover {
  color: var(--text);
}

.viewer-close {
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.viewer-close:hover {
  color: var(--text);
  border-color: var(--muted);
}

.viewer-frame {
  flex: 1;
  background: var(--hover);
}

.viewer[data-kind="video"] .viewer-frame {
  flex: none;
  aspect-ratio: 16 / 9;
}

.viewer iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- lab page ---------- */

.back {
  display: inline-block;
  margin-bottom: 56px;
  font: 400 14px/1 var(--sans);
  color: var(--muted);
  text-decoration: none;
}

.back:hover {
  color: var(--text);
}

.lede {
  margin: 16px 0 0;
  max-width: 560px;
  font-size: 17px;
  color: var(--muted);
}

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 8px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
  font: 400 13px/1 var(--sans);
}

.flow li {
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.flow .arrow {
  padding: 0;
  border: 0;
  color: var(--faint);
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 10px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  font-variant-numeric: tabular-nums;
  font: 400 13px/1.95 var(--sans);
  color: var(--muted);
}

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

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font: 400 13px/1.6 var(--sans);
  color: var(--muted);
}

footer a {
  color: var(--muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--text);
}

/* ---------- motion ---------- */

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

  .reveal > * {
    animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .reveal > *:nth-child(2) { animation-delay: 0.05s; }
  .reveal > *:nth-child(3) { animation-delay: 0.1s; }
  .reveal > *:nth-child(4) { animation-delay: 0.15s; }
  .reveal > *:nth-child(5) { animation-delay: 0.2s; }
  .reveal > *:nth-child(6) { animation-delay: 0.25s; }
  .reveal > *:nth-child(7) { animation-delay: 0.3s; }
  .reveal > *:nth-child(n + 8) { animation-delay: 0.35s; }

  .viewer[open] {
    animation: open 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

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

  @keyframes open {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.99);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .fork-card,
  .fork-card.on {
    transition: none;
    transform: none;
  }
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  main {
    padding: 64px 20px 56px;
  }

  .intro {
    margin-bottom: 48px;
  }

  .name {
    font-size: 26px;
  }

  .section {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 24px 0;
  }


  .row .title small {
    font-size: 13px;
  }

  .tree .row {
    padding-left: 32px;
  }

  .tree .row::before {
    left: 11px;
  }

  .viewer {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .viewer[data-kind="video"] {
    height: fit-content;
  }

  footer {
    flex-direction: column;
    gap: 4px;
  }
}

@media print {
  .reveal > * {
    animation: none;
  }

  .fork-card,
  .viewer {
    display: none;
  }
}
