/* ---------------------------------------------------------------
   Tokens
   --------------------------------------------------------------- */
:root {
  --ground: #0b0a09;
  --ink: #efe9df;
  --muted: #9a9388;
  --surface: #121110;
  --line: #262320;
  --line-strong: #453f38;
  --accent: #cbb08a;

  --sans: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --gutter: clamp(1.25rem, 5vw, 3rem);
  --section-gap: clamp(5rem, 11vw, 9.5rem);
  --label-col: 8.5rem;
}

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: 1.5rem;
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
p,
ul,
ol,
dl,
dd {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
}

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

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Images, the canvas and any future embeds never grow past their box */
img,
video,
canvas,
iframe,
embed,
object {
  max-width: 100%;
}

img,
video {
  height: auto;
}

.wrap {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  left: max(0.75rem, env(safe-area-inset-left, 0px));
  z-index: 10;
  padding: 0.625rem 0.875rem;
  background: var(--ink);
  color: var(--ground);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 2px;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* Small spaced capitals: the label voice of the page */
.site-name,
.nav-link,

.work-status,
.work-tags,
.contact-label,
.site-footer {
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  line-height: 1.6;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------
   Links: an underline that draws in from the left
   --------------------------------------------------------------- */
.nav-link,
.contact-link,
.footer-link,
.site-name {
  position: relative;
}

.nav-link::after,
.contact-link::after,
.footer-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--underline-bottom, 0.5rem);
  height: 1px;
  background: currentColor;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 260ms var(--ease-out);
}

/* Links that sit in content keep a quiet resting underline */
.contact-link::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--underline-bottom, 0.5rem);
  height: 1px;
  background: var(--line-strong);
}

@media (hover: hover) and (pointer: fine) {
  .nav-link:hover::after,
  .contact-link:hover::after,
  .footer-link:hover::after {
    clip-path: inset(0);
  }

  .nav-link:hover,
  .footer-link:hover {
    color: var(--ink);
  }
  .contact-link:hover {
    color: var(--accent);
  }
}

.nav-link:active,
.contact-link:active,
.footer-link:active,
.site-name:active {
  opacity: 0.6;
}

/* ---------------------------------------------------------------
   Header
   --------------------------------------------------------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: max(1.25rem, env(safe-area-inset-top, 0px));
  padding-bottom: 1.25rem;
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.75rem;
  white-space: nowrap;
}

@media (max-width: 26rem) {
  .site-name,
  .nav-link {
    letter-spacing: 0.1em;
  }

  .nav-list {
    gap: 0.875rem;
  }
}

/* The phone "Menu" button: hidden on larger screens and without JavaScript */
.nav-toggle {
  display: none;
}

.nav-list {
  display: flex;
  gap: clamp(1rem, 3vw, 2.5rem);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--muted);
  transition: color 160ms ease;
  --underline-bottom: 0.75rem;
}

/* ---------------------------------------------------------------
   Hero
   --------------------------------------------------------------- */
.hero {
  padding-top: clamp(3.5rem, 9vw, 7.5rem);
  padding-bottom: var(--section-gap);
}

.hero h1 {
  max-width: 13em;
  font-size: clamp(2.375rem, 0.9rem + 5.4vw, 5.25rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

@media (min-width: 40rem) {
  .hero h1 {
    text-wrap: balance;
  }
}

/* The last word: accent colour, with a blinking text cursor after it */
.hero h1 .tech {
  color: var(--accent);
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-size: 1.16em;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.hero h1 .tech .cursor {
  height: 0.66em;
  margin-left: 0.02em;
}

.cursor {
  display: inline-block;
  width: 0.07em;
  height: 0.8em;
  margin-left: 0.07em;
  background: var(--accent);
  vertical-align: -0.04em;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .cursor {
    animation: blink 1100ms steps(1) infinite;
  }
}

/* The RP monogram: the initials inside a thin champagne ring.
   It is the logo: small beside the name, large as the sign-off above
   the footer, and the tab icon. */
.rp {
  position: relative;
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1em;
  height: 1em;
  color: var(--ink);
  line-height: 1;
  text-transform: none;
}

.rp svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--accent);
  transform: rotate(-90deg);
}

.rp-letters {
  display: inline-flex;
  padding: 0.04em 0.03em;
  overflow: hidden;
  font-family: var(--sans);
  font-size: 0.38em;
  font-weight: 500;
  letter-spacing: -0.06em;
}

.rp-letters b {
  display: inline-block;
  font-weight: inherit;
}

.rp--small {
  font-size: 1.875rem;
}

.rp--small svg {
  stroke-width: 4;
}

.rp--small .rp-letters {
  font-size: 0.36em;
  font-weight: 600;
  letter-spacing: -0.03em;
}

/* No room for it beside the name on a phone */
@media (max-width: 30rem) {
  .rp--small {
    display: none;
  }
}

.signoff {
  padding-top: clamp(1rem, 4vw, 3rem);
  padding-bottom: clamp(2.5rem, 6vw, 4.5rem);
}

.signoff-line {
  max-width: 46em;
  font-size: 1.0625rem;
  line-height: 1.55;
}

.signoff-ps {
  margin-top: 0.375rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* The </> mark beside the headline: the same one that is on the hoodie
   in the portrait. It draws itself in on load. */
.mark {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.mark--hero {
  display: none;
  width: clamp(10rem, 17vw, 15rem);
  height: auto;
  margin-right: clamp(0rem, 3vw, 3rem);
  color: var(--accent);
  stroke-width: 1.6;
}

@media (min-width: 56rem) {
  .mark--hero {
    display: block;
  }
}

/* Under the headline: the portrait beside "About me" */
.intro {
  display: grid;
  gap: clamp(2rem, 5vw, 2.75rem);
  margin-top: clamp(2.75rem, 6vw, 5rem);
}

@media (min-width: 56rem) {
  .intro {
    grid-template-columns: minmax(0, 21rem) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(3rem, 6vw, 5.5rem);
  }
}

.portrait {
  display: block;
  width: 100%;
  max-width: 21rem;
  height: auto;
  aspect-ratio: 4 / 5;
  border-radius: 1.25rem;
  object-fit: cover;
}

.intro-title {
  font-size: clamp(1.75rem, 1.3rem + 1.9vw, 2.75rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

/* The name is the one accent in the paragraph */
.intro-text em {
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
}

.intro-text {
  max-width: 31em;
  margin-top: clamp(1.25rem, 2.5vw, 1.75rem);
  font-size: clamp(1.125rem, 1.02rem + 0.45vw, 1.375rem);
  line-height: 1.5;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}

.tools-label {
  margin-top: clamp(2rem, 4vw, 2.75rem);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  line-height: 1.6;
  text-transform: uppercase;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.875rem;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.375rem;
  padding: 0 0.875rem 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1;
  transition: border-color 200ms ease;
}

.tool .icon {
  color: var(--muted);
  transition: color 200ms ease;
}

.icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

@media (hover: hover) and (pointer: fine) {
  .tool:hover {
    border-color: var(--line-strong);
  }

  .tool:hover .icon {
    color: var(--accent);
  }
}

/* The figure: a real model training on the page */
.fig {
  margin: 0;
  min-width: 0;
}

.fig-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
}

@media (min-width: 40rem) {
  .fig-frame {
    aspect-ratio: 21 / 9;
  }
}

.fig-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.fig-stats {
  position: absolute;
  top: 0.875rem;
  left: 1rem;
  padding: 0.125rem 0.375rem;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  border-radius: 2px;
  pointer-events: none;
}

.fig-stats span {
  color: var(--ink);
}

.fig-caption {
  max-width: 40em;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* "New data": a quiet outlined pill in the corner of the plot */
.fig-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 1.125rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 140ms var(--ease-out), border-color 200ms ease, color 200ms ease;
}

.fig-button:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .fig-button:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
}

/* How the figure works: four short steps under it */
.how {
  display: grid;
  gap: 1.5rem 2rem;
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
}

@media (min-width: 36rem) {
  .how {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 62rem) {
  .how {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.how-title {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  line-height: 1.6;
  text-transform: uppercase;
}

.how-title span {
  margin-right: 0.5rem;
  color: var(--accent);
  font-family: var(--mono);
  letter-spacing: 0;
}

.how-text {
  max-width: 24em;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
  text-wrap: pretty;
}

/* Entrance, once on load: the headline arrives word by word, the
   portrait unrolls from the top, and the introduction rises last. */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(var(--rise));
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes unroll {
  from {
    clip-path: inset(0 0 100% 0);
  }

  to {
    clip-path: inset(0 0 0 0);
  }
}

.hero h1 .w {
  display: inline-block;
}

@media (prefers-reduced-motion: no-preference) {
  .hero h1 .w {
    --rise: 0.45em;
    animation: rise 760ms var(--ease-out) both;
    animation-delay: calc(var(--i) * 60ms);
  }

  .portrait {
    animation: unroll 1100ms cubic-bezier(0.77, 0, 0.175, 1) 320ms both;
  }

  /* The mark draws itself: left bracket, slash, right bracket */
  .mark--hero > * {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 700ms cubic-bezier(0.65, 0, 0.35, 1) forwards;
  }

  .mark--hero > :nth-child(1) { animation-delay: 550ms; }
  .mark--hero > :nth-child(2) { animation-delay: 850ms; animation-duration: 550ms; }
  .mark--hero > :nth-child(3) { animation-delay: 1050ms; }

  .intro-title {
    --rise: 14px;
    animation: rise 760ms var(--ease-out) 440ms both;
  }

  .intro-text {
    --rise: 12px;
    animation: rise 760ms var(--ease-out) 520ms both;
  }

  .tools-label {
    animation: fade 600ms ease 640ms both;
  }

  .tool {
    --rise: 8px;
    animation: rise 620ms var(--ease-out) both;
    animation-delay: calc(680ms + var(--i) * 40ms);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero h1,
  .intro {
    animation: fade 200ms ease both;
  }
}

/* ---------------------------------------------------------------
   Sections
   --------------------------------------------------------------- */
.section {
  padding-top: clamp(2.25rem, 4.5vw, 3.25rem);
  padding-bottom: var(--section-gap);
}

/* The rule sits inside the gutters, so it lines up with the text */
.section::before {
  content: "";
  display: block;
  height: 1px;
  margin-bottom: clamp(2.25rem, 4.5vw, 3.25rem);
  background: var(--line);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
}

.section h2 {
  font-size: clamp(1.75rem, 1.3rem + 1.9vw, 2.75rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.prose {
  max-width: 36em;
  color: var(--muted);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.6;
  text-wrap: pretty;
}

.prose-lead {
  max-width: 30em;
  color: var(--ink);
  font-size: clamp(1.1875rem, 1.05rem + 0.6vw, 1.5rem);
  line-height: 1.45;
  letter-spacing: -0.015em;
}

/* ---------------------------------------------------------------
   Work
   --------------------------------------------------------------- */
.work-list {
  border-top: 1px solid var(--line);
}

.work-row {
  border-bottom: 1px solid var(--line);
}

.work-item {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  align-items: baseline;
  column-gap: clamp(0.5rem, 2vw, 1.5rem);
  padding-block: clamp(1.75rem, 3.6vw, 2.75rem);
}

.work-num {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  transition: color 160ms ease;
}

.work-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Empty slot: a dotted leader, like a contents page waiting for its entry */
.leader {
  display: block;
  height: 0;
  border-bottom: 1px dotted var(--line-strong);
  transform: translateY(-0.2em);
}

.work-title {
  font-size: clamp(1.375rem, 1.15rem + 0.95vw, 1.9375rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.03em;
  transition: color 200ms ease;
}

.work-desc {
  max-width: 40em;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.work-tags {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.625rem;
}

.work-status {
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 1rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 200ms ease;
}

a.work-item .work-status {
  color: var(--ink);
}

.work-status .icon {
  width: 0.875rem;
  height: 0.875rem;
  margin-right: 0.125rem;
}

.work-status span {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.8125rem;
  letter-spacing: 0;
  transition: transform 220ms var(--ease-out);
}

@media (min-width: 48rem) {
  .work-item {
    grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  }

  .work-status {
    grid-column: 3;
    margin-top: 0;
  }
}

a.work-item:active {
  opacity: 0.6;
}

@media (hover: hover) and (pointer: fine) {
  a.work-item:hover .work-num,
  a.work-item:hover .work-title,
  a.work-item:hover .work-status {
    color: var(--accent);
  }

  a.work-item:hover .work-status span {
    transform: translate(2px, -2px);
  }
}

/* ---------------------------------------------------------------
   Contact rows: a label and a value
   --------------------------------------------------------------- */
.contact-list {
  margin-top: clamp(2.25rem, 5vw, 3.5rem);
  border-top: 1px solid var(--line);
}

.contact-row {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  align-items: baseline;
  column-gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.contact-label {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--muted);
}

.contact-label .icon {
  width: 1.0625rem;
  height: 1.0625rem;
  color: var(--accent);
}

.contact-row {
  padding-block: 0.25rem;
}

.contact-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 3.25rem;
  font-size: clamp(1.125rem, 1rem + 0.7vw, 1.5rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  transition: color 160ms ease;
  --underline-bottom: 0.7rem;
}

/* On phones the label sits above its value, so long addresses fit */
@media (max-width: 34rem) {
  .contact-row {
    grid-template-columns: minmax(0, 1fr);
    padding-block: 0.875rem 0.25rem;
  }
}

@media (max-width: 26rem) {
  :root {
    --label-col: 6rem;
  }
}

/* ---------------------------------------------------------------
   Footer
   --------------------------------------------------------------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  padding-top: 1.25rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.site-footer::before {
  content: "";
  flex: 0 0 100%;
  height: 1px;
  margin-bottom: 1rem;
  background: var(--line);
}

.footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  transition: color 160ms ease;
  --underline-bottom: 0.8rem;
}

/* ---------------------------------------------------------------
   Scroll reveals: each piece arrives once, the first time it is seen.
   Only with JavaScript (html.js) and only when motion is welcome.
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .js .section::before {
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 1000ms var(--ease-out);
  }

  .js .section.is-in::before {
    transform: none;
  }

  .js .section-head,
  .js .section-body,
  .js .work-row {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 600ms ease, transform 800ms var(--ease-out);
    transition-delay: var(--d, 0ms);
  }

  .js .section-head.is-in,
  .js .section-body.is-in,
  .js .work-row.is-in {
    opacity: 1;
    transform: none;
  }

  .js .section-body {
    --d: 90ms;
  }

  .js .work-row:nth-child(2) { --d: 70ms; }
  .js .work-row:nth-child(3) { --d: 130ms; }
  .js .work-row:nth-child(4) { --d: 180ms; }
  .js .work-row:nth-child(5) { --d: 220ms; }
}

/* ---------------------------------------------------------------
   Phones: everything below only applies up to 40rem (640px) wide,
   so the desktop layout is untouched.
   --------------------------------------------------------------- */
@media (max-width: 40rem) {
  /* Nothing can push the page sideways */
  html,
  body {
    overflow-x: clip;
  }

  /* Readable sizes: running text at 16px or more, labels a touch larger */
  .how-text,
  .fig-caption,
  .signoff-ps,
  .work-desc,
  .tool,
  .fig-button {
    font-size: 1rem;
  }

  .site-name,
  .nav-link,
  .work-status,
  .contact-label,
  .site-footer,
  .tools-label,
  .how-title {
    font-size: 0.75rem;
  }

  .work-tags {
    font-size: 0.6875rem;
    line-height: 1.7;
  }

  .work-num,
  .fig-stats {
    font-size: 0.8125rem;
  }

  /* Skill chips match the 44px touch size of everything else */
  .tool {
    min-height: 2.75rem;
  }

  /* The stats move to the bottom so they never sit under "New data" */
  .fig-stats {
    top: auto;
    bottom: 0.75rem;
    left: 0.75rem;
  }

  .contact-link {
    min-height: 3.25rem;
  }

  .footer-link {
    min-width: 2.75rem;
  }

  /* Navigation folds into a menu (only when JavaScript can open it) */
  .site-header {
    position: relative;
  }

  .js .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    margin-right: -0.5rem;
    padding: 0 0.5rem;
    border: 0;
    background: none;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    line-height: 1;
    text-transform: uppercase;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }

  .nav-toggle:active {
    opacity: 0.6;
  }

  .nav-toggle-icon {
    position: relative;
    display: block;
    width: 1.125rem;
    height: 0.5rem;
  }

  .nav-toggle-icon span {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent);
    transition: transform 240ms var(--ease-out);
  }

  .nav-toggle-icon span:first-child {
    top: 0;
  }

  .nav-toggle-icon span:last-child {
    bottom: 0;
  }

  .is-open .nav-toggle-icon span:first-child {
    transform: translateY(0.25rem) rotate(45deg);
  }

  .is-open .nav-toggle-icon span:last-child {
    transform: translateY(-0.25rem) rotate(-45deg);
  }

  .js .nav-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    display: block;
    padding: 0.25rem max(var(--gutter), env(safe-area-inset-right, 0px)) 1rem max(var(--gutter), env(safe-area-inset-left, 0px));
    background: var(--ground);
    border-bottom: 1px solid var(--line);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-0.5rem);
    transition: opacity 200ms ease, transform 260ms var(--ease-out), visibility 0s linear 260ms;
  }

  .js .is-open .nav-list {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity 200ms ease, transform 260ms var(--ease-out), visibility 0s;
  }

  .js .nav-list li {
    border-top: 1px solid var(--line);
  }

  .js .nav-link {
    display: flex;
    min-height: 3.25rem;
    color: var(--ink);
    font-size: 0.8125rem;
  }

  .js .nav-link::after {
    display: none;
  }
}

@media (max-width: 40rem) and (prefers-reduced-motion: reduce) {
  .js .nav-list,
  .js .is-open .nav-list,
  .nav-toggle-icon span {
    transition: none;
  }
}

/* ---------------------------------------------------------------
   Phones: text is centred. Desktop is untouched.
   --------------------------------------------------------------- */
@media (max-width: 40rem) {
  .hero,
  .section,
  .signoff {
    text-align: center;
  }

  .hero-top,
  .section-head,
  .tools {
    justify-content: center;
  }

  .hero h1,
  .portrait,
  .intro-text,
  .prose,
  .prose-lead,
  .fig-caption,
  .how-text,
  .work-desc,
  .signoff-line {
    margin-inline: auto;
  }

  /* Project rows: the number sits above the title, all centred */
  .work-item {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    row-gap: 0.5rem;
  }

  .work-body {
    align-items: center;
  }

  .work-status {
    grid-column: 1;
  }

  /* Contact rows: label above its value, both centred */
  .contact-row {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    padding-block: 0.875rem 0.25rem;
  }

  .contact-link {
    justify-self: center;
  }

  .site-footer {
    justify-content: center;
    text-align: center;
  }

  .js .nav-link {
    justify-content: center;
  }
}

/* Top section: centred whenever it is a single column (phones and
   small tablets). Side-by-side desktop layout starts at 56rem. */
@media (max-width: 55.99rem) {
  .hero,
  .intro,
  .intro-body {
    text-align: center;
  }

  .hero-top {
    justify-content: center;
  }

  .hero h1 {
    margin-inline: auto;
    text-wrap: balance;
  }

  .intro {
    justify-items: center;
  }

  .portrait {
    margin-inline: auto;
  }

  .intro-text {
    margin-inline: auto;
  }

  .tools {
    justify-content: center;
  }
}
