/* Tokens. Sections re-theme themselves by overriding these. */
:root {
  color-scheme: light dark;

  --bg: #fff;
  --bg-alt: #f5f5f7;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --line: rgba(0, 0, 0, 0.12);
  --accent: #0066cc;
  --button: #0071e3;
  --todo-bg: rgba(255, 159, 10, 0.18);
  --todo-ink: #8f5500;

  --gutter: max(1.375rem, calc((100% - 68rem) / 2));
  --radius: 1.25rem;

  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
}

.theme-dark {
  --bg: #1d1d1f;
  --bg-alt: #1d1d1f;
  --ink: #f5f5f7;
  --ink-2: #a1a1a6;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #2997ff;
  --todo-bg: rgba(255, 179, 64, 0.16);
  --todo-ink: #ffb340;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-alt: #161617;
    --ink: #f5f5f7;
    --ink-2: #a1a1a6;
    --line: rgba(255, 255, 255, 0.16);
    --accent: #2997ff;
    --todo-bg: rgba(255, 179, 64, 0.16);
    --todo-ink: #ffb340;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }

html {
  font: 100%/1.5 var(--font-text);
  scroll-behavior: smooth;
  scroll-padding-top: 3.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; padding: 0; }
ul { list-style: none; }
b { font-weight: 600; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

.wrap { padding-inline: var(--gutter); }

/* Unfilled content. Delete this rule's use by replacing each span. */
.todo {
  padding: 0.05em 0.35em;
  border-radius: 0.3em;
  background: var(--todo-bg);
  color: var(--todo-ink);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Type */
h1, h2, .statement p {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
}

h1 {
  font-size: clamp(2.5rem, 7vw, 5rem);
  line-height: 1.06;
  letter-spacing: -0.028em;
  text-wrap: balance;
}

h2 {
  font-size: clamp(2.5rem, 6.5vw, 4.75rem);
  line-height: 1.06;
  letter-spacing: -0.026em;
}

.section-title {
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
  font-size: clamp(2.25rem, 5vw, 3.5rem);
}

h3 {
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

.eyebrow {
  margin-bottom: 0.75rem;
  color: var(--ink-2);
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.008em;
}

/* Navigation: translucent layer, content scrolls under it */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(22, 22, 23, 0.88);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 3rem;
  padding-inline: var(--gutter);
  font-size: 0.8125rem;
  letter-spacing: 0.005em;
}

.nav a {
  color: var(--ink);
  white-space: nowrap;
}

.nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav-brand { font-weight: 600; }

.nav nav {
  display: flex;
  gap: clamp(0.875rem, 3vw, 1.75rem);
}

/* Buttons: feedback lives on the press */
.btn {
  display: inline-block;
  padding: 0.9375rem 2rem;
  font-size: 1.1875rem;
  border-radius: 999px;
  background: var(--button);
  color: #fff;
  font-weight: 500;
  overflow-wrap: anywhere;
  transition: transform 100ms ease-out, background-color 100ms ease-out;
}

.btn:hover {
  background: #0077ed;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-quiet {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.btn-quiet:hover {
  background: transparent;
}

/* Black boxes: empty slots for video and images */
.media {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: #000;
  box-shadow: inset 0 0 0 1px var(--line);
}

.media > video,
.media > img,
.media > iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}

/* Set --zoom, --ox and --oy on a video to crop a screen recording to the game view */
.media > video {
  transform: scale(var(--zoom, 1));
  transform-origin: var(--ox, 50%) var(--oy, 50%);
}

.media-label {
  color: #6e6e73;
  font-size: 0.8125rem;
  letter-spacing: 0.005em;
}

/* Hero */
.hero {
  padding-top: clamp(4rem, 11vw, 7.5rem);
  padding-bottom: clamp(2rem, 5vw, 3.5rem);
  text-align: center;
}

.portrait {
  display: block;
  width: clamp(10rem, 22vw, 14rem);
  height: auto;
  margin: 0 auto 1.75rem;
}

.hero-sub {
  max-width: 44rem;
  margin: 1.25rem auto 0;
  color: var(--ink);
  font-size: clamp(1.5rem, 3.2vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* Statement */
.statement {
  padding-block: clamp(5rem, 12vw, 9rem);
}

.statement p {
  max-width: 56rem;
  color: var(--ink-2);
  font-size: clamp(1.75rem, 4.2vw, 3rem);
  line-height: 1.14;
  letter-spacing: -0.02em;
}

.statement b {
  color: var(--ink);
  font-weight: inherit;
}

/* Project chapters */
.chapter {
  padding-block: clamp(5rem, 11vw, 8.5rem);
  background: var(--bg);
  color: var(--ink);
}

.chapter-alt { background: var(--bg-alt); }

.media-feature {
  margin-top: clamp(2.25rem, 5vw, 3.5rem);
}

.chapter-body {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: clamp(2rem, 6vw, 5rem);
  margin-top: clamp(2.25rem, 5vw, 3.5rem);
}

.chapter-copy p {
  font-size: clamp(1.1875rem, 2vw, 1.3125rem);
  line-height: 1.4;
}

.chapter-copy p + p { margin-top: 1rem; }

/* Fact lists */
.facts > div {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
  padding-block: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.facts > div:first-child {
  padding-top: 0;
  border-top: 0;
}

.facts dt { color: var(--ink-2); }

.facts-wide > div { grid-template-columns: 9rem minmax(0, 1fr); }

/* Gallery: dragged with Pointer Events, settled by a spring in script.js */
.gallery { margin-top: clamp(3rem, 7vw, 4.5rem); }

.gallery-viewport {
  overflow: hidden;
  padding-inline: var(--gutter);
  cursor: grab;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.gallery.is-dragging .gallery-viewport { cursor: grabbing; }

.gallery-track {
  position: relative;
  display: flex;
  gap: 1.25rem;
  width: max-content;
  will-change: transform;
}

.slide { width: clamp(17rem, 72vw, 42rem); }

.slide figcaption {
  margin-top: 0.875rem;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.slide figcaption > b:not(.todo) { color: var(--ink); }

.gallery-controls {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.gallery.is-static .gallery-controls { display: none; }
.gallery.is-static .gallery-viewport { cursor: auto; }

.gallery-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink);
  cursor: pointer;
  transition: transform 100ms ease-out, opacity 200ms ease-out;
}

.gallery-btn svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-btn:active:not(:disabled) { transform: scale(0.92); }

.gallery-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Generic sections */
.section {
  padding-block: clamp(5rem, 10vw, 7.5rem);
  background: var(--bg);
}

.section-alt { background: var(--bg-alt); }

/* Other projects */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem 1.25rem;
}

.tile h3 { margin-top: 1rem; }

.tile-meta {
  margin-top: 0.25rem;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.tile-meta + p { margin-top: 0.625rem; }

/* Experience */
.entry {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1rem;
}

.entry-side {
  padding-top: 0.1875rem;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.entry-org { color: var(--ink-2); }

.entry ul {
  margin-top: 1rem;
  display: grid;
  gap: 0.625rem;
}

.entry li {
  max-width: 44rem;
  padding-left: 1rem;
  text-indent: -1rem;
}

.entry li::before {
  content: "";
  display: inline-block;
  width: 0.3125rem;
  height: 0.3125rem;
  margin-right: 0.6875rem;
  border-radius: 50%;
  background: var(--ink-2);
  vertical-align: 0.2em;
}

.subhead {
  margin-top: clamp(3rem, 6vw, 4.5rem);
  margin-bottom: 0.75rem;
}

.subhead-first { margin-top: 0; }

.compact li {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  flex-wrap: wrap;
  padding-block: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.compact li:first-child { border-top: 0; }
.compact li > span:last-child { color: var(--ink-2); }

/* Skills and education */
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3rem clamp(2rem, 6vw, 5rem);
}

/* Contact */
.contact {
  padding-block: clamp(5rem, 12vw, 9rem) 2.5rem;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
}

.contact-sub {
  max-width: 34rem;
  margin: 1.25rem auto 0;
  color: var(--ink-2);
  font-size: clamp(1.1875rem, 2vw, 1.3125rem);
  line-height: 1.4;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
  font-size: 0.9375rem;
}

.fineprint {
  margin-top: clamp(4rem, 9vw, 6rem);
  color: var(--ink-2);
  font-size: 0.75rem;
}

/* Reveal on scroll. Only hidden when JS is running to show it again. */
.js .reveal {
  opacity: 0;
  transform: translateY(1.5rem);
}

.js .reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity 700ms cubic-bezier(0.25, 1, 0.5, 1), transform 700ms cubic-bezier(0.25, 1, 0.5, 1);
}

/* Small screens */
@media (max-width: 52rem) {
  .chapter-body,
  .split { grid-template-columns: minmax(0, 1fr); }

  .tiles {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
  }

  .entry {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }

  .entry-side { order: 1; padding-top: 0; }
  .entry > div:last-child { display: contents; }
  .entry h3 { order: 0; }
  .entry-org { order: 2; }
  .entry ul { order: 3; }
}

@media (max-width: 30rem) {
  .nav-optional { display: none; }
  .facts-wide > div { grid-template-columns: 6.5rem minmax(0, 1fr); }
}

/* Accessibility preferences */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .js .reveal { transform: none; }
  .js .reveal.is-in { transition: opacity 200ms ease; }

  .btn, .gallery-btn { transition: none; }
  .btn:active, .gallery-btn:active:not(:disabled) { transform: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .nav {
    background: #161617;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root, .theme-dark { --ink-2: var(--ink); }

  .nav {
    background: #161617;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom: 1px solid var(--ink);
  }

  .btn-quiet, .gallery-btn { box-shadow: inset 0 0 0 1px var(--ink); }
}

/* Disclaimer on footage made with AI-edited code. Top left, clear of video controls. */
.ai-tag {
  position: absolute;
  top: 0.875rem;
  left: 0.875rem;
  z-index: 1;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  color: #f5f5f7;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Two-part projects: what was written by hand, then what AI changed */
.part-label {
  margin-top: 1rem;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 600;
}

.part {
  margin-top: clamp(4rem, 9vw, 7rem);
}

.part-title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.022em;
}

.part .part-label { margin-top: 0; margin-bottom: 0.5rem; }

/* Code samples */
.samples {
  display: grid;
  gap: clamp(3.5rem, 8vw, 6rem);
  margin-top: clamp(4rem, 9vw, 7rem);
}

.sample {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

.sample-copy p {
  margin-top: 0.5rem;
  color: var(--ink-2);
  line-height: 1.45;
}

.sample-copy .media { margin-top: 1.25rem; }

.code {
  margin: 0;
  padding: 1.25rem;
  overflow-x: auto;
  border-radius: 1rem;
  background: #000;
  box-shadow: inset 0 0 0 1px var(--line);
  color: #f5f5f7;
  font: 0.8125rem/1.55 ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  tab-size: 2;
  color-scheme: dark;
  scrollbar-width: thin;
}

.code .c { color: #98989d; }
.code .del, .code .add { display: block; width: max-content; min-width: 100%; }
.code .del { background: rgba(255, 69, 58, 0.18); }
.code .add { background: rgba(48, 209, 88, 0.16); }

.inline {
  font: 0.875em ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

.diff-figure { margin-top: clamp(2.25rem, 5vw, 3.5rem); }

.diff-figure figcaption {
  margin-top: 0.875rem;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.4;
}

@media (max-width: 52rem) {
  .sample { grid-template-columns: minmax(0, 1fr); }
}
