:root {
  --bg: #ffffff;
  --ink: #1b2228;
  --muted: #55606a;
  --faint: #8a949c;
  --rule: #d9dee2;
  --accent: #7A003C;

  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;

  --column: 620px;
  --bar: 60px;
}

/* Dark theme: chosen with the toggle (data-theme), or from the system
   setting when nothing has been chosen. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1219;
  --ink: #e9f0f4;
  --muted: #a3b2bc;
  --faint: #6f8492;
  --rule: #22313c;
  --accent: #e68fb4;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1219;
    --ink: #e9f0f4;
    --muted: #a3b2bc;
    --faint: #6f8492;
    --rule: #22313c;
    --accent: #e68fb4;
  }
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.bar, main, .foot {
  width: min(100% - 40px, var(--column));
  margin-inline: auto;
}

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

a { color: inherit; text-decoration: none; }
a:focus-visible, summary:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
}

.logo {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.bar nav { display: flex; gap: 22px; margin-left: auto; }
.bar nav a {
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s;
}
.bar nav a:hover, .bar nav a[aria-current="page"] { color: var(--accent); }

/* Shown only once theme.js has run, since it does nothing without it. */
.theme {
  display: none;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0 -6px 0 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s;
}
:root[data-theme] .theme { display: grid; }
.theme:hover { color: var(--accent); }
.theme svg { width: 17px; height: 17px; }
:root[data-theme="dark"] .theme .moon,
:root[data-theme="light"] .theme .sun { display: none; }

/* ---------- Hero ---------- */

.hero {
  min-height: calc(100vh - var(--bar));
  min-height: calc(100svh - var(--bar));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 1fr auto;
  column-gap: 40px;
}
.hero-body { align-self: center; padding: 32px 0 48px; }
.hero .portrait { align-self: center; }

.eyebrow {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(44px, 10vw, 72px);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* Karpathy's fading <hr>, redrawn as a rhythm strip. */
.trace {
  position: relative;
  height: 56px;
  margin: 22px 0 20px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.trace canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* And the plain version, for pages without a monitor. */
.fade {
  height: 1px;
  margin: 28px 0 44px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--rule) 14%, var(--rule) 86%, transparent);
}

.bio {
  margin: 0 0 34px;
  font-size: 20px;
  line-height: 1.6;
  color: var(--muted);
}

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 28px;
}

.icons { display: flex; gap: 10px; }

.icons a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--ink);
  transition: color .2s, border-color .2s, transform .2s;
}
.icons a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.icons svg { width: 17px; height: 17px; }

.cv {
  font-size: 13px;
  padding-bottom: 3px;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}
.cv span { display: inline-block; transition: transform .2s; }
.cv:hover span { transform: translateX(4px); }

.scroll {
  grid-column: 1 / -1;
  justify-self: center;
  padding: 0 0 28px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--faint);
  transition: color .2s;
}
.scroll span { display: inline-block; transition: transform .2s; }
.scroll:hover { color: var(--accent); }
.scroll:hover span { transform: translateY(3px); }

/* ---------- Sections ---------- */

.section {
  padding: 56px 0 24px;
  scroll-margin-top: var(--bar);
}

.section > h2 {
  margin: 0 0 28px;
  font-weight: 400;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.prose p {
  margin: 0 0 18px;
  font-size: 18px;
  line-height: 1.65;
  color: var(--muted);
}
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.prose a:hover { text-decoration-thickness: 2px; }

/* A photo slot. Drop an <img> inside to fill it; until then it shows a
   dashed placeholder. Used for the hero portrait and Journey thumbnails. */
.portrait, .thumb {
  margin: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--rule) 40%, transparent);
}
.portrait img, .thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portrait:not(:has(img)), .thumb:not(:has(img)) {
  border: 1px dashed var(--rule);
  background: transparent;
}

.portrait {
  width: clamp(150px, 26vw, 210px);
  aspect-ratio: 1;
  border-radius: 50%;
}
.portrait img { object-position: 50% 30%; }
.portrait:not(:has(img)) {
  display: grid;
  place-items: center;
}
.portrait:not(:has(img))::after {
  content: "DLN";
  font-size: 30px;
  letter-spacing: 0.06em;
  color: var(--faint);
  opacity: .6;
}

.facts {
  clear: both;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 28px 0;
  margin: 24px 0 0;
}
.facts dt {
  padding-top: 13px;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.facts dd { margin: 0; }
.facts ul { list-style: none; margin: 0; padding: 0; }
.facts li {
  padding: 10px 0;
  border-top: 1px solid var(--rule);
  font-size: 17px;
  line-height: 1.45;
}
.facts li span { display: block; font-size: 15px; color: var(--muted); }

.lede { margin-bottom: 24px; }

.threads details { border-top: 1px solid var(--rule); }
.threads details:last-of-type { border-bottom: 1px solid var(--rule); }
.threads summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  list-style: none;
  cursor: pointer;
  transition: color .2s;
}
.threads summary::-webkit-details-marker { display: none; }
.threads summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  color: var(--accent);
  transition: transform .2s;
}
.threads summary:hover { color: var(--accent); }
.threads details[open] summary::after { transform: rotate(45deg); }
.threads p {
  margin: -4px 0 0;
  padding: 0 0 18px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
}

.more { margin-top: 28px; }

/* ---------- Journey ---------- */

.page-head { padding: 56px 0 0; }
.page-head .bio { margin: 22px 0 0; }

/* Each entry is a three-column row: date, text, photo. The rail and its dot
   are drawn on the row itself so the line runs unbroken between entries. */
.timeline {
  list-style: none;
  margin: 0 0 40px;
  padding: 0;
}
.entry {
  --rail: 100px;
  --dot: 8.5px;
  position: relative;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 88px;
  grid-template-areas: "when what thumb";
  padding-bottom: 44px;
}
.entry::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--rail);
  width: 1px;
  background: var(--rule);
}
.entry:first-child::before { top: calc(var(--dot) + 4px); }
.entry:last-child::before { background: linear-gradient(var(--rule), transparent); }
.entry::after {
  content: "";
  position: absolute;
  top: var(--dot);
  left: calc(var(--rail) - 4px);
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
}
.entry:first-child::after { background: var(--accent); }

.when {
  grid-area: when;
  margin: 0;
  font-size: 12px;
  line-height: 26px;
  letter-spacing: 0.04em;
  text-align: right;
  color: var(--faint);
}

.what { grid-area: what; padding: 0 22px 0 36px; }
.what h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
}
.where {
  margin: 2px 0 8px;
  font-style: italic;
  font-size: 16px;
  color: var(--muted);
}
.what p:not(.where) {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
}

.thumb {
  grid-area: thumb;
  align-self: start;
  width: 88px;
  aspect-ratio: 1;
  margin-top: 4px;
  border-radius: 8px;
  position: relative;
}
/* Only the first photo shows on the timeline; the rest are for the slideshow. */
.thumb img + img { display: none; }

/* journey.js lays a button over each tile with photos. */
.thumb-open {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: zoom-in;
  transition: box-shadow .2s;
}
.thumb-open:hover, .thumb-open:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.thumb-count {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: 500 11px/16px var(--sans);
  letter-spacing: 0.02em;
  box-shadow: 0 1px 3px rgb(0 0 0 / .25);
}

/* ---------- Photo viewer ---------- */

html:has(.viewer[open]) { overflow: hidden; }

.viewer {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 64px 72px 32px;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.viewer[open] {
  display: grid;
  place-items: center;
}
.viewer::backdrop {
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(6px);
}

.viewer-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
}
.viewer-photo img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  max-height: calc(100dvh - 160px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgb(0 0 0 / .18);
}
.viewer-photo figcaption {
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-content: center;
  max-width: 60ch;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}
.viewer-count {
  flex: none;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.viewer-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.viewer-btn svg { width: 20px; height: 20px; }
.viewer-btn:hover, .viewer-btn:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.viewer-prev, .viewer-next { top: 50%; translate: 0 -50%; }
.viewer-prev { left: 16px; }
.viewer-next { right: 16px; }
.viewer-close { top: 12px; right: 16px; }
.viewer.single .viewer-prev, .viewer.single .viewer-next { display: none; }

/* ---------- Footer ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 56px;
  padding: 26px 0 48px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--faint);
}
.foot nav { display: flex; gap: 20px; }
.foot a { transition: color .2s; }
.foot a:hover { color: var(--accent); }

/* ---------- Small screens ---------- */

@media (max-width: 560px) {
  .entry {
    --rail: 4px;
    --dot: 5.5px;
    grid-template-columns: minmax(0, 1fr) 64px;
    grid-template-areas: "when thumb" "what thumb";
    padding-bottom: 36px;
  }
  .when { line-height: 20px; text-align: left; padding-left: 26px; }
  .what { padding: 4px 16px 0 26px; }
  .thumb { width: 64px; }

  .viewer { padding: 60px 16px 84px; }
  .viewer-photo img { max-height: calc(100dvh - 200px); }
  .viewer-prev, .viewer-next { top: auto; bottom: 20px; translate: none; }
  .viewer-prev { left: calc(50% - 56px); }
  .viewer-next { right: calc(50% - 56px); }
}

@media (max-width: 520px) {
  .bio { font-size: 18px; }
  .links { flex-direction: column; align-items: flex-start; }
  .bar nav { gap: 16px; }
  .theme { margin-left: 8px; }
  .hero { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
  .hero .portrait { grid-row: 1; width: 132px; margin-top: 32px; }
  .hero-body { align-self: start; padding-top: 24px; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 10px 0; }
  .facts dt { padding-top: 0; }
  .facts dd + dt { margin-top: 18px; }
}

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

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
