/* One accent, a system font stack, light and dark through prefers-color-scheme. */
:root {
  --bg: #f5f6f5;
  --surface: #ffffff;
  --fg: #14191b;
  --muted: #59636a;
  --rule: #dce1e2;
  --panel: #e8edec;
  --accent: #0b6e69;
  --on-accent: #ffffff;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1314;
    --surface: #161b1c;
    --fg: #e6eaec;
    --muted: #9aa5ab;
    --rule: #283133;
    --panel: #1b2223;
    --accent: #4fc1b9;
    --on-accent: #07211f;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}

h1 {
  font-size: clamp(2rem, 1.5rem + 2.5vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
h2 { font-size: 1.125rem; line-height: 1.3; margin: 2.5rem 0 0.75rem; }
h3 { line-height: 1.25; }

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

img { max-width: 100%; height: auto; }

.handle { margin: 0; color: var(--muted); }

/* Status: a small pill beside a project's name. */
.status {
  display: inline-block;
  vertical-align: 0.2em;
  margin-left: 0.5rem;
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--muted);
  white-space: nowrap;
}

/* The title's last word and its pill wrap together, so a pill never sits alone on a line. */
.title-end { white-space: nowrap; }

/* Links under a project: one optional button, then quiet text links. */
.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  font-size: 0.9375rem;
}

/* Live and released work: the pill takes the accent. */
.status-live { color: var(--accent); border-color: currentColor; }

.button {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  transition: filter 120ms ease;
}
.button:hover { filter: brightness(1.12); }
.button:focus-visible { border-radius: 999px; }

footer { margin-top: 3rem; color: var(--muted); font-size: 0.875rem; }

/* ---- The home page ---------------------------------------------------- */

.home { max-width: 70rem; padding-top: 3rem; }

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.masthead h1 {
  font-size: clamp(2.5rem, 1.6rem + 4vw, 4.25rem);
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1;
  margin: 0;
}

.intro { margin: 0; }

.home h2 {
  margin: 3rem 0 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.projects { list-style: none; margin: 0; padding: 0; }
.project p { margin: 0.5rem 0 0; }
.project .links { margin-top: 1.25rem; }
.project h3 { margin: 0; }

/* Each project: a large picture of the thing beside its name. */
.projects > .project + .project { margin-top: 3.5rem; }
.projects h3 { font-size: 1.625rem; letter-spacing: -0.015em; }
/* Below 360px a slightly smaller name and pill keep "Wizard Shootout" and its pill on one line. */
@media (max-width: 22.4rem) {
  .projects h3 { font-size: 1.375rem; }
  .projects .status { margin-left: 0.375rem; padding: 0.1rem 0.45rem; font-size: 0.6875rem; }
}
.projects .body p:not(.links) { max-width: 34rem; }

.media {
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  aspect-ratio: 3 / 2;
}
.media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media picture { display: contents; }

/* A phone screenshot rises from the foot of its panel. */
.media-phone { position: relative; }
.media-phone img {
  position: absolute;
  left: 50%;
  top: 9%;
  width: 46%;
  height: auto;
  transform: translateX(-50%);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 0 0 1px var(--rule), 0 18px 40px rgba(20, 25, 27, 0.18);
}
.media-shiftie { background: #f1e3d7; }
.media-shunt { background: #fcf6ed; }
/* Prisma Puzzles' screenshots are dark in both schemes, so its panel is too. */
.media-prisma { background: #1d1a2b; }
/* Vouched's page is wider than the panel: keep its headline, on the left, whole. */
.media-vouched img { object-position: left center; }

/* On a phone the map itself, not its side panel, fills the picture. */
@media (max-width: 40rem) {
  .media-map { aspect-ratio: 4 / 3; }
  .media-map img { object-position: 82% 40%; }
}

.body { margin-top: 1.25rem; }

@media (min-width: 52rem) {
  .projects .project {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 2.5rem;
    align-items: center;
  }
  .projects .body { margin-top: 0; }
}

/* gaffer has no picture in its repo, so its panel is set in type: a poster whose
   three lines are sized to the panel's own width (cqi) and centred top to bottom.
   The longest line is about 7.9em wide, so 10.4cqi fills 82% of the panel and
   leaves room for a wider system font. The clamps are for browsers without cqi. */
.media-type {
  display: flex;
  align-items: center;
  container-type: inline-size;
}
.media-type p {
  margin: 0;
  padding: 0 clamp(1.25rem, 0.5rem + 2.5vw, 2.25rem);
  font-size: clamp(1.625rem, 1rem + 2.5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--accent);
}
@supports (font-size: 1cqi) {
  .media-type p { padding: 0 9cqi; font-size: 10.4cqi; }
}

@media (prefers-color-scheme: dark) {
  .media-shiftie { background: #2a1a18; }
  .media-shunt { background: #1b1918; }
  .media-phone img { box-shadow: 0 0 0 1px var(--rule), 0 18px 40px rgba(0, 0, 0, 0.45); }
}

/* S-8: the "Also" names sit in a quieter list under the projects. */
.also {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2rem;
  color: var(--muted);
}

.home footer { padding-top: 1.5rem; border-top: 1px solid var(--rule); }

/* ---- Case studies and the plain pages (Shiftie, 404) ------------------- */

/* S-2: the plain pages get a way home and room for prose. */
.crumb { margin: 0 0 2rem; font-size: 0.9375rem; }
.crumb a { text-decoration: none; font-weight: 600; }
.crumb a:hover { text-decoration: underline; }

.lede { font-size: 1.1875rem; line-height: 1.5; color: var(--fg); }
.muted { color: var(--muted); }

.prose h1 { margin-bottom: 0.75rem; }
.prose h2 {
  margin: 2.75rem 0 0.75rem;
  font-size: 1.3125rem;
  letter-spacing: -0.01em;
}
.prose > .links { margin: 1.25rem 0 0; }
.prose ul { padding-left: 1.25rem; }
.prose li + li { margin-top: 0.4rem; }
.prose footer { padding-top: 1.25rem; border-top: 1px solid var(--rule); }

/* S-4: a figure from the project's own site scales to the phone. */
figure { margin: 2rem 0; }
figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
figcaption { margin-top: 0.6rem; color: var(--muted); font-size: 0.875rem; }

/* A case study's lead picture sits on the same panel as on the home page. */
.hero picture { display: block; }
.hero-phone .frame {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
}
.hero-phone img {
  width: auto;
  max-height: 34rem;
  border-radius: 22px;
}
.hero-shiftie .frame { background: #f1e3d7; }
.hero-shunt .frame { background: #fcf6ed; }

@media (prefers-color-scheme: dark) {
  .hero-shunt .frame { background: #1b1918; }
  .hero-shiftie .frame { background: #2a1a18; }
}

/* The agent-workflow case study's diagram: inline SVG drawn in the site's tokens. */
.flow svg { display: block; width: 100%; max-width: 25rem; height: auto; }
.flow-box { fill: var(--surface); stroke: var(--rule); stroke-width: 1.5; }
.flow-mac { stroke: var(--accent); }
.flow-end { fill: var(--panel); }
.flow-name { fill: var(--fg); font-size: 14px; font-weight: 600; }
.flow-note { fill: var(--muted); font-size: 11.5px; }
.flow-tag { fill: var(--accent); font-size: 11.5px; font-weight: 600; }
.flow-line path { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.flow-head path { fill: var(--muted); }
.flow-mac-line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.flow-mac-head { fill: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
