/* Parkinsans, SIL Open Font License 1.1. Latin subset, variable weight, hosted here so no third-party request. */
@font-face { font-family: Parkinsans; src: url("fonts/parkinsans.woff2") format("woff2"); font-weight: 300 800; font-display: swap; }

:root {
  --bg: #0e0f12;
  --card: #17191e;
  --line: #262a32;
  --text: #eceef2;
  --muted: #8d93a0;
  --red: #f0604a;
  --yellow: #f6c343;
  --blue: #6b8cff;
  --violet: #b59cf6;
  --green: #3ecf8e;
  --sans: Parkinsans, ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, monospace;
  --bar: 52px;
  /* one page width for everything: side margin grows with the screen, content stops at 1720px */
  --gutter: clamp(20px, 4.3vw, 90px);
  --read: 1000px; /* rows of reading text stop here so lines stay readable */
}

/* one rule maps a domain to its colour and the dark text that sits on it */
[data-domain="research"] { --c: var(--violet); --on: #2a1a5e; }
[data-domain="hardware"] { --c: var(--green); --on: #053a24; }
[data-domain="software"] { --c: var(--blue); --on: #0f1f5c; }
[data-domain="ai"] { --c: var(--red); --on: #4a0f08; }
[data-domain="finance"] { --c: var(--yellow); --on: #3d2c00; }

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font: clamp(16px, 12px + 0.35vw, 19px)/1.6 var(--sans); -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
/* the page behind an open popup does not scroll */
html:has(:popover-open) { overflow: hidden; }
/* while a popup is open, a click on the blurred page only closes it and never reaches the card underneath */
html:has(:popover-open) body { pointer-events: none; transition: none; }
/* iPhone Safari aims the closing tap after the popup is gone, so clicks come back a moment later, not at once */
body { margin: 0; transition: pointer-events 0s 350ms allow-discrete; }
[id] { scroll-margin-top: calc(var(--bar) + 16px); }

a { color: inherit; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }

nav, .hero, main, footer { max-width: calc(1720px + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

nav {
  position: sticky; top: 0; z-index: 2; height: var(--bar);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-bottom: 1px solid var(--line);
  font: 14px var(--mono); color: var(--muted);
  max-width: none; padding-inline: max(var(--gutter), calc((100% - 1720px) / 2));
}
nav a { text-decoration: none; padding: 8px 0; white-space: nowrap; }
nav a:hover { color: var(--text); }
nav { gap: 16px; }
nav .links { display: flex; gap: 22px; }

.hero { padding-block: clamp(56px, 14vh, 130px) 40px; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; }
.nick { white-space: nowrap; }
.lede { font-size: clamp(1.1rem, 2.4vw, 1.5rem); margin-top: 10px; }
.lede .ai { color: var(--red); }
.lede .software { color: var(--blue); }
.lede .finance { color: var(--yellow); }
.meta { color: var(--muted); font: 14px var(--mono); margin-top: 10px; }
.contact { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.contact a { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; text-decoration: none; font-size: 14px; }
.contact a:hover { border-color: var(--muted); }
.contact svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.contact a:hover svg { color: var(--text); }
/* the one call to action on the page: filled, so it reads before anything else */
.contact .cta { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; padding: 9px 18px; }
.contact .cta:hover { background: none; color: var(--text); }

section { padding-block: 56px; }
h2 { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 28px; }
h3 { font-size: 1.05rem; font-weight: 650; line-height: 1.3; }

/* work experience and education share one row layout: dates left, content right */
.jobs { display: grid; max-width: var(--read); }
.job { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 4px 20px; padding-block: 20px; border-top: 1px solid var(--line); }
.when { font: 13px var(--mono); color: var(--muted); padding-top: 4px; }
.job h3::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); margin-right: 10px; }
.job.upcoming h3::before { background: none; box-shadow: inset 0 0 0 2px var(--c); }
.org { display: block; font-weight: 400; font-size: 14px; color: var(--muted); margin: 2px 0 0 19px; }
.job p, .job .tags { margin: 8px 0 0 19px; font-size: 14px; max-width: 62ch; }
.job .tags { max-width: none; }
.job .course-label { color: var(--muted); font: 12px/1.7 var(--mono); margin-top: 16px; }
/* an award phrase in a work row takes the row's domain colour so it is seen at a skim */
.job .award b { color: var(--c); font-weight: 700; }
.see button { font: inherit; color: var(--c); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* a tag takes its domain colour as an outline, never as a fill */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { border: 1px solid var(--c, var(--line)); color: var(--c, var(--muted)); border-radius: 6px; padding: 1px 9px; font: 12px/1.7 var(--mono); }

.skills { margin: 0; display: grid; gap: 14px; max-width: var(--read); }
.skills div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 20px; align-items: baseline; }
.skills dt { color: var(--muted); font: 13px var(--mono); }
.skills dd { margin: 0; }


/* projects: every card is the same size and holds a summary; a click opens the full detail in a popup */
/* the card grid spans the page width; the gap grows with the screen */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2.4vw, 48px); }
.project.card { position: relative; display: flex; flex-direction: column; aspect-ratio: 1 / 1.05; padding: clamp(22px, 2.2vw, 38px); background: var(--c); color: var(--on); border-radius: 22px; font-size: clamp(15px, 1.15vw, 20px); }
.project.card { transition: transform 120ms ease-out, filter 120ms ease-out; }
.project.card:hover { filter: brightness(1.06); }
.project.card:active { transform: scale(0.99); }
@media (prefers-reduced-motion: reduce) { .project.card { transition: none; } .project.card:active { transform: none; } }
/* domain as a pill, kind beside it */
.top { display: flex; align-items: center; gap: 10px; font: 600 14px/1 var(--sans); }
.top span:first-child { border: 1.5px solid currentColor; border-radius: 999px; padding: 5px 11px; }
/* on very narrow phones the labels wrap instead of squeezing */
.project.card > .top { flex-wrap: wrap; row-gap: 8px; }
.project.card > h3 { font-size: clamp(1.6rem, 2.6vw, 2.7rem); line-height: 1.06; letter-spacing: -0.02em; text-wrap: balance; margin-top: auto; }
.project.card h3 button { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
/* the title button covers the whole card, so the card is one click target */
.project.card h3 button::before { content: ""; position: absolute; inset: 0; border-radius: 22px; }
.project.card h3 button:focus-visible { outline: none; }
.project.card h3 button:focus-visible::before { outline: 2px solid var(--text); outline-offset: 3px; }
.result { margin-top: 10px; line-height: 1.4; }
/* a pinned card shows a pin in the top right corner; the ongoing project also says Active in a filled pill */
.top .pin { flex: none; width: 28px; height: 28px; margin-left: auto; }
.top .active { background: var(--on); color: var(--c); border-radius: 999px; padding: 5px 11px; }
.project.card > .date { margin-top: 12px; font: 13px var(--mono); }
.project.card > .result { min-height: 4.2em; font-size: 1.05em; } /* three lines, so titles line up across a row */
.project .tags li { border-color: var(--on); color: var(--on); }
.project b { font-weight: 700; }
.project a:focus-visible, .detail button:focus-visible { outline-color: var(--on); }

.detail { width: min(680px, 100vw - 32px); max-height: min(86dvh, 780px); overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 22px; padding: clamp(22px, 4vw, 40px); background: var(--c); color: var(--on); font-size: 16px; pointer-events: auto; }
/* the popup takes focus when it opens (autofocus), so the Close button does not light up; Tab still reaches it */
.detail:focus-visible { outline: none; }
.detail:popover-open { display: grid; gap: 12px; }
.detail::backdrop { background: rgb(14 15 18 / 0.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.detail h3 { font-size: clamp(1.5rem, 4vw, 2rem); }
.detail .result { margin: 0; }
.detail figure { margin: 4px 0; display: grid; gap: 6px; justify-items: center; text-align: center; }
.detail img { width: 100%; height: auto; border-radius: 12px; background: rgb(0 0 0 / 0.12); }
.detail figcaption { font: 13px var(--mono); }
/* phone screenshots sit side by side, sized like a phone, not stretched across the popup */
/* a tall poster is capped so it does not fill the whole popup on a laptop */
.detail img.poster { max-width: 340px; }
.detail .shots { display: grid; grid-template-columns: repeat(2, minmax(0, 190px)); justify-content: center; gap: 14px; width: 100%; }
/* role and tools share one quiet line under the summary */
.detail .facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding-bottom: 14px; border-bottom: 1px solid currentColor; }
.detail .role { font-size: 13px; font-weight: 600; }
.detail .facts .tags li { font-size: 11px; padding: 0 7px; }
/* section labels sit above body size, so each section visibly starts */
.detail h4 { font-size: clamp(1.15rem, 2.8vw, 1.3rem); font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; margin: 14px 0 -4px; }
.detail .built { list-style: disc; padding-left: 1.2em; display: grid; gap: 6px; }
.detail figure svg { width: 100%; max-width: 420px; height: auto; }
/* Close shares the first line with the labels (the negative margin pulls them up beside it) and stays pinned at the top while a long popup scrolls; the labels leave it room */
.detail > .top { padding-right: 84px; flex-wrap: wrap; row-gap: 8px; }
.close { position: sticky; top: 10px; z-index: 1; justify-self: end; align-self: start; margin-bottom: -43px; background: var(--c); font: 13px var(--mono); color: inherit; border: 1px solid var(--on); border-radius: 8px; padding: 6px 14px; cursor: pointer; }
:target { outline: 2px solid var(--text); outline-offset: 5px; border-radius: 8px; }
section:target, header:target { outline: none; }


footer { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding-block: 28px 40px; border-top: 1px solid var(--line); color: var(--muted); font: 13px var(--mono); }

/* "Show more" exists only on phones; a laptop always shows all eight cards */
.more, .more-toggle { display: none; }
@keyframes reveal { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: no-preference) and (max-width: 699px) {
  #projects:has(#more-projects:checked) .project.card:nth-child(n+5) { animation: reveal 280ms ease-out both; }
}

@media (max-width: 940px) and (min-width: 700px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 699px) {
  .job, .skills div { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: minmax(0, 1fr); }
  nav { font-size: 13px; gap: 12px; }
  nav .links { gap: 12px; }
  section { padding-block: 40px; }
  /* phone cards are as tall as their content, so eight of them do not make a long scroll */
  .project.card { aspect-ratio: auto; }
  .project.card > h3 { margin-top: 28px; }
  .project.card > .result { min-height: 0; }
  /* the first four cards show; the rest give up their box but keep their popups, so Work experience links still open them */
  #projects:not(:has(#more-projects:checked)) .project.card:nth-child(n+5) { display: contents; }
  #projects:not(:has(#more-projects:checked)) .project.card:nth-child(n+5) > :not(dialog) { display: none; }
  .more-toggle { display: block; position: absolute; opacity: 0; pointer-events: none; }
  .more { display: block; margin-top: 16px; padding: 12px; text-align: center; border: 1px solid var(--line); border-radius: 12px; font: 600 15px var(--sans); cursor: pointer; }
  .more:hover { border-color: var(--muted); }
  #projects:has(.more-toggle:focus-visible) .more { outline: 2px solid var(--text); outline-offset: 3px; }
  .more .when-open, #projects:has(#more-projects:checked) .more .when-closed { display: none; }
  #projects:has(#more-projects:checked) .more .when-open { display: inline; }
}

/* very narrow phones: the name in the bar gives way so the three section links fit on one line */
@media (max-width: 379px) { nav .home { display: none; } nav { justify-content: flex-end; } }
