/* Portfolio v2 styles. Sections: 1 tokens, 2 base, 3 type, 4 layout and header,
   5 intro and sections, 6 definition rows, 7 featured projects, 8 figures and stats,
   9 more work, 10 experience and reading, 11 footer, 12 responsive, 13 motion. */

/* 1. Tokens. Dark values apply by system preference unless the reader chose light. */
:root {
  --bg: #fafaf8;
  --surface: #f2f1ed;
  --ink: #161615;
  --ink-2: #45443f;
  --muted: #85847d;
  --line: #e3e2dc;
  --bar: #cfcec7;                 /* non-highlighted bars in figures */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --col: 680px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0a; --surface: #141413; --ink: #ecebe7; --ink-2: #b3b2ab;
    --muted: #7d7c76; --line: #252523; --bar: #3a3a37;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0a; --surface: #141413; --ink: #ecebe7; --ink-2: #b3b2ab;
  --muted: #7d7c76; --line: #252523; --bar: #3a3a37;
  color-scheme: dark;
}

/* 2. Base and reset */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font: 16px/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dt, dd, ul, figure, figcaption { margin: 0; }
ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 120ms ease;
}
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
}
/* Keeps the last word and its arrow on one line. */
.nw { white-space: nowrap; }
/* Arrow after external link text. Screen readers skip it. */
.ext {
  display: inline-block;
  margin-left: 2px;
  font-family: var(--font-mono);
  font-size: 0.8em;
  text-decoration: none;
}

/* 3. Type */
h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h2 {
  margin-bottom: 20px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.25;
  color: var(--ink);
}
h3 { font-family: var(--font-serif); font-weight: 500; color: var(--ink); }
.label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11.5px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.links { font-family: var(--font-mono); font-size: 13px; }
.project-head .label { text-transform: none; letter-spacing: 0.02em; }

/* 4. Layout and header */
.wrap { max-width: var(--col); margin: 0 auto; padding: 0 20px; }
.skip-link {
  position: absolute;
  top: 8px;
  left: 16px;
  z-index: 10;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.header-row {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
}
.header-right { display: flex; align-items: center; gap: 24px; }
.site-nav { display: flex; gap: 20px; font-size: 14px; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--ink); }
.theme-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle svg { width: 16px; height: 16px; }

/* 5. Intro and sections. Each section gets a full-width hairline on top. */
.intro { padding: 28px 0 56px; }
/* Banner: grayscale until hovered, focused, or tapped, then it fades into color. */
.banner {
  margin: 0;
  aspect-ratio: 680 / 250;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  filter: grayscale(1) contrast(1.05);
  transform: scale(1.01);
  transition: filter 700ms ease, transform 1200ms ease;
}
.banner:hover img,
.banner:focus-visible img,
.banner:focus img { filter: grayscale(0) contrast(1); transform: scale(1.04); }
.banner:focus { outline: none; }
.banner:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.avatar {
  position: relative;
  display: block;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 20px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  object-fit: cover;
  filter: grayscale(1) contrast(1.1);
}
.intro h1 { margin-top: 20px; }
.lead { margin-top: 4px; color: var(--muted); }
.intro p + p { margin-top: 16px; }
.now { margin-top: 40px; }
.now .label { margin-bottom: 12px; }
.section { border-top: 1px solid var(--line); padding: 56px 0; }
.reading-intro { margin-bottom: 20px; }
.subhead {
  margin: 40px 0 16px;
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.3;
  color: var(--ink);
}
.about p + p,
#how p + p { margin-top: 16px; }

/* 6. Definition rows (Now, Stack, Reading). Label column, then text. */
.rows { --label-col: 96px; }
.rows-wide { --label-col: 112px; }
.rows > div {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  align-items: baseline;
  gap: 16px;
  padding: 6px 0;
}
.rows dd { color: var(--ink-2); overflow-wrap: break-word; }

/* 7. Featured projects. Each project sits below a hairline with 64px space. */
.project + .project {
  margin-top: 64px;
  padding-top: 64px;
  border-top: 1px solid var(--line);
}
.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}
.project h3 { font-size: 23px; line-height: 1.25; }
.hook {
  margin-top: 12px;
  font-weight: 500;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
}
.project-body { margin-top: 12px; }
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.project-links > span { color: var(--muted); }

/* 8. Figures and stats */
.fig {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.fig figcaption {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.fig-art svg { display: block; width: 100%; height: auto; }
/* Phones get a figure drawn for a 340-unit viewBox; wider screens get the 640 one. */
.fig-narrow { display: none; }
@media (max-width: 559px) {
  .fig-wide { display: none; }
  .fig-narrow { display: block; }
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px 16px;
  margin-top: 24px;
}
.stats > div { min-width: 0; padding-top: 10px; border-top: 1px solid var(--line); }
.stats dt {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.3;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stats dd { font-size: 13px; line-height: 1.45; color: var(--muted); }

/* SVG helper classes for the inline figures. Figures use these, not raw colors. */
.f-ink { fill: var(--ink); }
.f-muted { fill: var(--muted); }
.f-bar { fill: var(--bar); }
.f-line { stroke: var(--line); fill: none; }
.f-stroke { stroke: var(--ink); fill: none; }
.f-bg { fill: var(--surface); }
.f-label { font-family: var(--font-sans); font-size: 13px; }
.f-num { font-family: var(--font-mono); font-size: 12.5px; }
.f-small { font-size: 12px; }

/* 9. More work list: name column, then description. Stacks below 640px. */
.more li {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 0;
}
.more li + li { border-top: 1px solid var(--line); }
.more a { font-weight: 500; color: var(--ink); }
.more li > span { font-size: 15px; color: var(--ink-2); }

/* 10. Experience and reading lists */
.job {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}
.job strong { font-weight: 500; color: var(--ink); }
.job-note { margin-top: 12px; }
.papers { padding-left: 20px; list-style: disc; }
.papers li + li { margin-top: 8px; }
.papers li::marker { color: var(--muted); }

/* 11. Footer */
.site-footer { padding: 48px 0 64px; }
.site-footer p + p { margin-top: 16px; }
.small { font-size: 13px; color: var(--muted); }

/* 12. Responsive. 639px stacks the More work rows; 479px is the phone layout. */
@media (max-width: 639px) {
  .more li { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 479px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 30px; }
  .intro, .section { padding: 40px 0; }
  .site-nav { display: none; }
  .fig { padding: 14px; }
  .rows > div { grid-template-columns: 1fr; gap: 4px; }
}

/* 13. Motion. Theme switch reveals as a circle from the button (View Transitions API).
   Figures reveal once when they scroll into view; motion.js adds .motion only when the
   reader allows motion, so without JS or with reduced motion every figure is static. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.motion .fig-art svg rect.f-ink,
.motion .fig-art svg rect.f-bar {
  transform: scaleX(0);
  transform-box: fill-box;
  transform-origin: left center;
  transition: transform 700ms cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--i, 0) * 60ms);
}
.motion .fig-art svg circle {
  opacity: 0;
  transform: scale(0.4);
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 300ms ease calc(var(--i, 0) * 12ms), transform 300ms ease calc(var(--i, 0) * 12ms);
}
.motion .fig-art svg text { opacity: 0; transition: opacity 400ms ease 450ms; }
.motion .fig-art.revealed svg rect.f-ink,
.motion .fig-art.revealed svg rect.f-bar { transform: scaleX(1); }
.motion .fig-art.revealed svg circle { opacity: 1; transform: scale(1); }
.motion .fig-art.revealed svg text { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
