/* Shared by every page. Dark is the default; light is opt-in via the toggle. */
:root {
  --bg: #000;
  --fg: #fff;
  --muted: #999;
  --rule: #2b2b2b;

  /* Vertical rhythm. Every vertical gap is a fraction or multiple of one
     line of body text (line-height 1.6 x root size), so spacing and text
     share one beat. In rem, so it scales down with the phone font size. */
  --line: 1.6rem;
  --quarter: calc(var(--line) / 4);  /* inside one item */
  --half: calc(var(--line) / 2);     /* heading to its content, list rows */
  --double: calc(var(--line) * 2);   /* page title, figures */
  --triple: calc(var(--line) * 3);   /* between sections */
  --quad: calc(var(--line) * 4);     /* before the footer */
  --gutter: 1.25rem;                 /* horizontal gaps */
}
[data-theme="light"] {
  --bg: #fff;
  --fg: #000;
  --muted: #666;
  --rule: #ddd;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  max-width: 38rem;
  margin: 0 auto;
  padding: var(--line) 1.5rem var(--double);
}
@media (min-width: 48rem) {
  body { padding-top: var(--double); }
}

/* Reset vertical margins; spacing below is set deliberately, one rule per gap. */
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { list-style: none; padding: 0; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color 0.2s ease;
}
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

img { max-width: 100%; height: auto; display: block; }
p, li, dd, figcaption { text-wrap: pretty; }
h1, h2, .page-title, .lede { text-wrap: balance; }

/* Header and navigation */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--half) var(--gutter);
  flex-wrap: wrap;
}
.name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.name > :first-child { margin-right: 0.4rem; }
.home-link {
  font-weight: 600;
  text-decoration: none;
}
.icon-link {
  position: relative;
  display: inline-flex;
  color: var(--muted);
  transition: color 0.2s ease;
}
.icon-link:hover { color: var(--fg); }
.icon-link svg { width: 1.05rem; height: 1.05rem; }
h1 ~ .icon-link svg { width: 1.2rem; height: 1.2rem; }
.icon-link[href*="linkedin"] svg { transform: scale(0.88); }
.icon-link[href^="mailto:"] svg { transform: scale(1.12); }
/* Confirmation after the email icon copies the address. */
.icon-link[data-note]::after {
  content: attr(data-note);
  position: absolute;
  left: 0;
  top: calc(100% + 0.4rem);
  white-space: nowrap;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--fg);
  background: var(--bg);
  animation: note-in 0.2s ease both;
}
@keyframes note-in { from { opacity: 0; transform: translateY(-3px); } }
.site-nav {
  display: flex;
  align-items: baseline;
  gap: var(--gutter);
  font-size: 0.9375rem;
}
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--fg); }
.theme-toggle {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}
.theme-toggle:hover { color: var(--fg); }

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.page-title { margin-top: var(--double); font-size: 2rem; }

/* Intro block: name, then the two lines that belong to it. */
.intro { margin-top: var(--line); }
.seeking { color: var(--muted); }
.seeking a { color: var(--fg); }
.lede { margin-top: var(--half); font-size: 1.1875rem; }

/* Sections and headings */
main > section { margin-top: var(--triple); }
h2 {
  margin-bottom: var(--half);
  font-size: 1.125rem;
  font-weight: 600;
}
h3 {
  font-size: 1rem;
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
}
section p + p { margin-top: var(--line); }

/* Contests and results: the one bold element on the page. */
.results + h3 { margin-top: var(--line); }
.results { margin-top: var(--quarter); }
.results li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gutter);
  padding: var(--half) 0;
  border-bottom: 1px solid var(--rule);
}
.results li:first-child { border-top: 1px solid var(--rule); }
.results .event { flex: 1; min-width: 0; }
.results .score { text-align: right; max-width: 50%; }
.results .figure {
  display: block;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: lining-nums tabular-nums;
}
.results .note { display: block; font-size: 0.875rem; color: var(--muted); }

/* Plain lists of roles and projects: one line of space between items,
   none inside an item except a quarter before the stack. */
.entries > li + li { margin-top: var(--line); }
.entries .what { display: block; }
.entries .detail { display: block; color: var(--muted); }
.entries .stack { display: block; margin-top: var(--quarter); font-size: 0.875rem; font-style: italic; color: var(--muted); }
.entries .when { margin-left: 0.4rem; font-size: 0.875rem; color: var(--muted); }

/* Project pages */
.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--quarter) var(--gutter);
  margin-top: var(--line);
  padding: var(--half) 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
}
.meta dt { color: var(--muted); }
.meta dd.stack { font-style: italic; }

.steps { counter-reset: step; }
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2rem;
}
.steps li + li { margin-top: var(--half); }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}

.decision + .decision { margin-top: var(--line); }
.decision h3 { font-style: normal; color: var(--fg); font-weight: 600; }
.decision p { margin-top: var(--quarter); color: var(--muted); }

main > figure { margin-top: var(--double); }
figure img { border: 1px solid var(--rule); }
figcaption { margin-top: var(--quarter); font-size: 0.875rem; color: var(--muted); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: var(--gutter);
  margin-top: var(--triple);
  font-size: 0.9375rem;
}
.pager span { display: block; color: var(--muted); font-size: 0.875rem; }
.pager .next { text-align: right; margin-left: auto; }

footer {
  margin-top: var(--quad);
  padding-top: var(--half);
  border-top: 1px solid var(--rule);
  color: var(--muted);
}
footer ul { display: flex; flex-wrap: wrap; gap: var(--quarter) var(--gutter); }
footer a { color: var(--fg); }

/* Motion: a short fade-up as each page loads, staggered by --i,
   plus a crossfade between pages where the browser supports it. */
.reveal {
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.25s; }

@media (prefers-reduced-motion: reduce) {
  html, a, .theme-toggle, .icon-link { transition: none; }
  .icon-link[data-note]::after { animation: none; }
  .reveal { animation: none; }
  @view-transition { navigation: none; }
}

@media (max-width: 30rem) {
  html { font-size: 1rem; }
  .results .figure { font-size: 1.875rem; }
  .intro br { display: none; }
}
