/* Refined terminal: one character grid, two monospaced voices (Monaspace
   Argon for text, Monaspace Xenon for names and titles), indigo ink and ivory.
   Type sizes are whole multiples of the cell: 1x text, 2x titles, 3-5x name. */
@font-face {
  font-family: "Monaspace Argon";
  src: url("/assets/monaspace-argon-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Monaspace Argon";
  src: url("/assets/monaspace-argon-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Monaspace Xenon";
  src: url("/assets/monaspace-xenon-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #1b1f3a;
  --raised: #222747;
  --line: #3d4372;
  --fg: #ece6d6;
  --dim: #adb1cd;
  --accent: #eaa66c;
  --highlight: #eaa66c;
  --pawn-lit: #ece6d6;
  --pawn-shade: #b3aecb;
  --pawn-deep: #7d7aa8;
  --text:
    "Monaspace Argon", ui-monospace, "SFMono-Regular", Menlo, Consolas,
    monospace;
  --display:
    "Monaspace Xenon", "Monaspace Argon", ui-monospace, Menlo, Consolas,
    monospace;
  /* One row of the grid. Vertical spacing is counted in rows, horizontal in ch. */
  --row: 1.6rem;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f0eadb;
  --raised: #e7e0cd;
  --line: #c4bba3;
  --fg: #1f2342;
  --dim: #535879;
  --accent: #96470f;
  --highlight: #e39a5c;
  --pawn-lit: #474d82;
  --pawn-shade: #2a2f5a;
  --pawn-deep: #171a38;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--row) * 2);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem / var(--row) var(--text);
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
}
::selection {
  background: var(--highlight);
  color: #1b1f3a;
}
h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}
ul,
ol {
  padding: 0;
  list-style: none;
}
img {
  display: block;
  max-width: 100%;
  height: auto;
}
.nowrap {
  white-space: nowrap;
}

/* Links read as text with a quiet rule. Hover and focus select them the way a
   terminal selects a row: reverse video. */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}
a:hover,
a:focus-visible {
  background: var(--fg);
  color: var(--bg);
  text-decoration-color: transparent;
  box-shadow:
    -0.5ch 0 0 var(--fg),
    0.5ch 0 0 var(--fg);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
a:focus-visible {
  outline-offset: 5px;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.format {
  color: var(--dim);
}
a:hover .format,
a:focus-visible .format {
  color: inherit;
}

.skip {
  position: absolute;
  left: 2ch;
  top: 0;
  padding: 0 1ch;
  background: var(--fg);
  color: var(--bg);
  transform: translateY(-120%);
}
.skip:focus {
  transform: translateY(var(--row));
  z-index: 10;
}

.shell {
  width: min(100% - 2rem, 104ch);
  margin-inline: auto;
}

/* Header: the tab line. */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2ch;
  padding-block: var(--row);
}
.brand {
  display: block;
  line-height: 0;
}
.brand:hover,
.brand:focus-visible {
  background: none;
  box-shadow: none;
}
.mark-bg {
  fill: var(--fg);
}
.mark-fg {
  fill: var(--bg);
}
.mark-cursor {
  fill: var(--bg);
  opacity: 0.45;
}
.brand:hover .mark-cursor,
.brand:focus-visible .mark-cursor {
  opacity: 1;
}
.header nav {
  display: flex;
  align-items: center;
  gap: 3ch;
}
.header nav a {
  text-decoration: none;
  color: var(--dim);
}
.header nav a:hover,
.header nav a:focus-visible {
  color: var(--bg);
}
.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.7rem;
}
.theme-toggle[hidden] {
  display: none;
}
.tg-frame {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1.5;
}
.tg-fill {
  fill: var(--dim);
}
.theme-toggle:hover .tg-frame,
.theme-toggle:focus-visible .tg-frame {
  stroke: var(--fg);
}
.theme-toggle:hover .tg-fill,
.theme-toggle:focus-visible .tg-fill {
  fill: var(--fg);
}

/* Hero. The pawn is the only thing on screen until it lands. */
.hero {
  --pawn-h: clamp(21rem, 58svh, 36.25rem);
  --pawn-w: calc(var(--pawn-h) * 320 / 580);
  --cell: calc(var(--pawn-h) / 29);
  --band: calc(var(--cell) / 2);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 4ch;
  align-items: center;
  padding-top: var(--row);
  overflow: hidden;
  overflow: clip;
}
.hero-copy {
  padding-block: var(--row);
}
h1 {
  font: 500 3rem / 1.2 var(--display);
  letter-spacing: 0;
}
h1 .line {
  position: relative;
  display: block;
  width: fit-content;
  white-space: nowrap;
}
h1 .typed {
  display: block;
}
.caret {
  position: absolute;
  left: 0;
  top: 0.12em;
  width: 1ch;
  height: 0.96em;
  background: var(--highlight);
  opacity: 0;
}
.hero-role {
  margin-top: var(--row);
  color: var(--fg);
  font-weight: 600;
}
.hero-text {
  margin-top: var(--row);
  max-width: 56ch;
  color: var(--dim);
}
.hero-text a {
  color: var(--fg);
}
.hero-text a:hover,
.hero-text a:focus-visible {
  color: var(--bg);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--row) 3ch;
  margin-top: calc(var(--row) * 2);
}
.button {
  display: inline-block;
  padding: calc(var(--row) / 2) 2ch;
  background: var(--fg);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}
.button .format {
  color: inherit;
  font-weight: 400;
  opacity: 0.75;
}
.button:hover,
.button:focus-visible {
  background: var(--highlight);
  color: #1b1f3a;
  box-shadow: none;
}

.pawn-stage {
  position: relative;
  grid-column: 2;
  width: var(--pawn-w);
  /* Half a column of air either side of the highlighted square. */
  margin-inline: calc(var(--cell) * 1.5);
  padding-bottom: var(--band);
}
.pawn {
  position: relative;
  z-index: 1;
}
.pawn-svg {
  display: block;
  width: var(--pawn-w);
  height: var(--pawn-h);
}
.pw-base {
  fill: var(--pawn-lit);
}
.pw-shade {
  fill: var(--pawn-shade);
}
.pw-deep {
  fill: var(--pawn-deep);
}
/* The character grid shows through the piece as hairlines. */
.pw-grid {
  stroke: var(--bg);
  stroke-width: 1px;
  opacity: 0.28;
}
/* The square it lands on, lit like the last move on a terminal board. */
.pawn-stage::after {
  content: "";
  position: absolute;
  inset: auto calc(var(--cell) * -1.5) 0;
  height: var(--band);
  background: var(--highlight);
}
.ground {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--line);
  transform-origin: calc(100% - var(--pawn-w) / 2 - var(--cell) * 1.5) 50%;
}
.hero-status {
  grid-column: 1 / -1;
  justify-self: end;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2ch;
  width: calc(var(--pawn-w) + var(--cell) * 3);
  min-height: calc(var(--row) * 2);
  padding-top: calc(var(--row) / 2);
  color: var(--dim);
}
.replay {
  color: var(--dim);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  padding-block: 0.4rem;
}
.replay:hover,
.replay:focus-visible {
  color: var(--fg);
  text-decoration-color: var(--accent);
}

/* The drop. Everything moves in whole cells and appears in whole rows, as a
   terminal redraws: the pawn falls row by row, the square lights, the name is
   typed, and the rest prints line by line. Base styles are the finished
   state, so with animations off the page is simply complete. */
.pawn {
  animation: pawn-fall 0.82s step-end 0.15s both;
}
.pawn-stage::after {
  animation: appear 1ms linear 0.79s both;
}
.ground {
  animation: ground 0.4s steps(20, end) 0.79s both;
}
.move {
  animation: appear 1ms linear 0.9s both;
}
.line-first .typed {
  animation: type 0.4s steps(11, end) 1s both;
}
.line-first .caret {
  animation: caret-first 0.4s linear 1s forwards;
}
.line-last .typed {
  animation: type 0.33s steps(9, end) 1.4s both;
}
.line-last .caret {
  animation: caret-last 0.63s linear 1.4s forwards;
}
.hero-role {
  animation: appear 1ms linear 1.83s both;
}
.hero-text {
  animation: appear 1ms linear 1.93s both;
}
.hero-actions {
  animation: appear 1ms linear 2.03s both;
}
.replay {
  animation: appear 1ms linear 2.2s both;
}
.hero.resetting *,
.hero.resetting *::after {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .hero:not(.replaying) *,
  .hero:not(.replaying) *::after {
    animation: none !important;
  }
}
@keyframes appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes type {
  from {
    clip-path: inset(-0.3em 100% -0.3em 0);
  }
  to {
    clip-path: inset(-0.3em 0 -0.3em 0);
  }
}
@keyframes caret-first {
  0% {
    opacity: 1;
    transform: none;
    animation-timing-function: steps(11, end);
  }
  99.9% {
    opacity: 1;
    transform: translateX(1100%);
  }
  100% {
    opacity: 0;
    transform: translateX(1100%);
  }
}
/* The second caret rests at the end of the name for a beat, then leaves. */
@keyframes caret-last {
  0% {
    opacity: 1;
    transform: none;
    animation-timing-function: steps(9, end);
  }
  52% {
    opacity: 1;
    transform: translateX(900%);
    animation-timing-function: step-end;
  }
  100% {
    opacity: 0;
    transform: translateX(900%);
  }
}
@keyframes ground {
  from {
    transform: scaleX(0);
  }
  to {
    transform: none;
  }
}
@keyframes pawn-fall {
  0% {
    transform: translateY(calc(var(--cell) * -34));
  }
  4.33% {
    transform: translateY(calc(var(--cell) * -34));
  }
  8.67% {
    transform: translateY(calc(var(--cell) * -34));
  }
  13% {
    transform: translateY(calc(var(--cell) * -33));
  }
  17.33% {
    transform: translateY(calc(var(--cell) * -32));
  }
  21.67% {
    transform: translateY(calc(var(--cell) * -31));
  }
  26% {
    transform: translateY(calc(var(--cell) * -30));
  }
  30.33% {
    transform: translateY(calc(var(--cell) * -29));
  }
  34.67% {
    transform: translateY(calc(var(--cell) * -27));
  }
  39% {
    transform: translateY(calc(var(--cell) * -26));
  }
  43.33% {
    transform: translateY(calc(var(--cell) * -24));
  }
  47.67% {
    transform: translateY(calc(var(--cell) * -21));
  }
  52% {
    transform: translateY(calc(var(--cell) * -19));
  }
  56.33% {
    transform: translateY(calc(var(--cell) * -16));
  }
  60.67% {
    transform: translateY(calc(var(--cell) * -13));
  }
  65% {
    transform: translateY(calc(var(--cell) * -10));
  }
  69.33% {
    transform: translateY(calc(var(--cell) * -7));
  }
  73.67% {
    transform: translateY(calc(var(--cell) * -4));
  }
  78% {
    transform: translateY(calc(var(--cell) * 0));
  }
  84% {
    transform: translateY(calc(var(--cell) * -0.5));
  }
  92%,
  100% {
    transform: none;
  }
}

/* Sections are panes: a rule with the title set into it. */
.section {
  position: relative;
  margin-top: calc(var(--row) * 5);
  padding-top: calc(var(--row) * 3);
  border-top: 1px solid var(--line);
}
.section > h2,
.section-head {
  position: absolute;
  top: calc(var(--row) / -2);
  left: 2ch;
  right: 2ch;
}
.section > h2,
.section-head h2 {
  width: fit-content;
  padding-inline: 1ch;
  background: var(--bg);
  font: 500 1rem / var(--row) var(--display);
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
}
.section-head a {
  padding-inline: 1ch;
  background: var(--bg);
  color: var(--dim);
  white-space: nowrap;
}
.section-head a:hover,
.section-head a:focus-visible {
  background: var(--fg);
  color: var(--bg);
  box-shadow: none;
}

h3 {
  font: 500 2rem / calc(var(--row) * 2) var(--display);
}
.project-kind {
  color: var(--dim);
}

/* Projects. */
.project {
  display: grid;
  grid-template-columns: minmax(0, 46ch) minmax(0, 1fr);
  gap: calc(var(--row) * 2) 6ch;
  align-items: start;
}
.project + .project {
  margin-top: calc(var(--row) * 5);
}
.project-copy > * + * {
  margin-top: var(--row);
}
.project-copy > a {
  display: inline-block;
}
.project-copy > .project-kind {
  margin-top: 0;
}
.ssh > p {
  color: var(--dim);
}
.ssh-command {
  display: flex;
  align-items: stretch;
  margin-top: calc(var(--row) / 2);
  border: 1px solid var(--line);
  background: var(--raised);
}
.prompt {
  padding: calc(var(--row) / 2) 0 calc(var(--row) / 2) 2ch;
  color: var(--accent);
  user-select: none;
}
.ssh-command code {
  flex: 1;
  min-width: 0;
  padding: calc(var(--row) / 2) 1ch;
  font: inherit;
  white-space: nowrap;
  overflow-x: auto;
}
.ssh-command button {
  padding-inline: 2ch;
  border-left: 1px solid var(--line);
  min-width: 10ch;
}
.ssh-command button:hover,
.ssh-command button:focus-visible {
  background: var(--fg);
  color: var(--bg);
}
.ssh-command button:focus-visible {
  outline-offset: 2px;
}
.copy-status {
  display: block;
  min-height: var(--row);
  color: var(--dim);
}
.project-copy > .ssh + .facts {
  margin-top: 0;
}
.facts > div {
  display: grid;
  grid-template-columns: 12ch minmax(0, 1fr);
  gap: 0 2ch;
}
.facts dt {
  color: var(--dim);
}
.shot {
  grid-column: 2;
}
.shot img {
  width: 100%;
  border: 1px solid var(--line);
}
figcaption {
  margin-top: calc(var(--row) / 2);
  color: var(--dim);
}

/* Zander's differential test, drawn with pane borders. */
.diff {
  padding-top: calc(var(--row) / 2);
}
.diff-flow {
  display: grid;
  justify-items: center;
  padding: calc(var(--row) * 1.5) 2ch;
  border: 1px solid var(--line);
  background: var(--raised);
}
.node {
  padding: calc(var(--row) / 2) 2ch;
  border: 1px solid var(--line);
  background: var(--bg);
  text-align: center;
}
.node small {
  display: block;
  font-size: inherit;
  color: var(--dim);
}
.node-result {
  border-color: var(--fg);
}
.diff-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-items: center;
  gap: 2ch;
  width: 100%;
}
.fork {
  position: relative;
  width: calc(50% + 1ch);
  height: calc(var(--row) * 2);
  border: 1px solid var(--line);
  border-bottom: 0;
  margin-top: var(--row);
}
.fork::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  height: var(--row);
  border-left: 1px solid var(--line);
}
.fork-join {
  border: 1px solid var(--line);
  border-top: 0;
  margin: 0 0 var(--row);
}
.fork-join::before {
  top: 100%;
  bottom: auto;
}

/* Local Cinema and the earlier work share a row of two smaller panes. */
.more {
  display: grid;
  grid-template-columns: minmax(0, 46ch) minmax(0, 1fr);
  gap: calc(var(--row) * 3) 6ch;
  margin-top: calc(var(--row) * 5);
  padding-top: calc(var(--row) * 2);
  border-top: 1px solid var(--line);
}
.more h3 {
  font-size: 1rem;
  line-height: var(--row);
}
.cinema > * + * {
  margin-top: var(--row);
}
.cinema > .project-kind {
  margin-top: 0;
}
.earlier ul {
  margin-top: var(--row);
}
.earlier li {
  display: grid;
  grid-template-columns: 17ch minmax(0, 1fr);
  gap: 0 2ch;
}
.earlier li + li {
  margin-top: var(--row);
}
.earlier a {
  width: fit-content;
  height: fit-content;
}
.earlier-text {
  grid-column: 2;
}
.earlier-stack {
  grid-column: 2;
  color: var(--dim);
}

/* Experience: dates in a fixed column, like a log. */
.timeline li {
  display: grid;
  grid-template-columns: 22ch minmax(0, 28ch) minmax(0, 1fr);
  gap: 0 4ch;
}
.timeline li + li {
  margin-top: calc(var(--row) * 2);
  padding-top: calc(var(--row) * 2);
  border-top: 1px solid var(--line);
}
.when {
  color: var(--dim);
}
.when-now {
  color: var(--accent);
}
.timeline h3 {
  font-size: 1rem;
  line-height: var(--row);
}
.role span {
  display: block;
  color: var(--dim);
}
.job-text {
  max-width: 48ch;
  color: var(--dim);
}

/* About. */
.about-body {
  max-width: 64ch;
  margin-left: 26ch;
}
.about-body p + p {
  margin-top: var(--row);
}
.about-body p:not(.about-lead) {
  color: var(--dim);
}

/* Contact. */
.contact-body {
  margin-left: 26ch;
}
.contact-lead {
  color: var(--dim);
}
.contact-email {
  display: inline-block;
  margin-top: var(--row);
  font: 500 2rem / calc(var(--row) * 2) var(--display);
  overflow-wrap: anywhere;
}
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--row) / 2) 4ch;
  margin-top: calc(var(--row) * 2);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--row) / 2) 4ch;
  margin-top: calc(var(--row) * 5);
  padding-block: var(--row) calc(var(--row) * 2);
  border-top: 1px solid var(--line);
  color: var(--dim);
}
.footer span:first-child {
  margin-right: auto;
}

@media (min-width: 62rem) {
  h1 {
    font-size: 4rem;
  }
}
@media (min-width: 78rem) {
  h1 {
    font-size: 5rem;
  }
}

@media (max-width: 61.99rem) {
  .project,
  .more {
    grid-template-columns: minmax(0, 1fr);
  }
  .shot {
    grid-column: auto;
  }
  .timeline li {
    grid-template-columns: 22ch minmax(0, 1fr);
  }
  .job-text {
    grid-column: 2;
    margin-top: var(--row);
  }
  .about-body,
  .contact-body {
    margin-left: 0;
  }
}

/* Narrow screens: the pawn lands first, the name is typed beneath it. */
@media (max-width: 47.99rem) {
  .hero {
    --pawn-h: clamp(15rem, 38svh, 20rem);
    grid-template-columns: minmax(0, 1fr);
    padding-top: 0;
  }
  .pawn-stage {
    grid-column: 1;
    grid-row: 1;
  }
  .ground {
    grid-row: 2;
    transform-origin: calc(var(--pawn-w) / 2 + var(--cell) * 1.5) 50%;
  }
  .hero-status {
    position: absolute;
    top: 0;
    right: 0;
    width: calc(100% - var(--pawn-w) - var(--cell) * 3 - 2ch);
    height: calc(var(--pawn-h) + var(--band));
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 0;
    padding: 0 0 calc(var(--row) / 2);
    text-align: right;
  }
  .hero-copy {
    grid-row: 3;
    padding-block: calc(var(--row) * 1.5) 0;
  }
  .pw-grid {
    display: none;
  }
  .header nav {
    gap: 1.5ch;
    font-size: 0.875rem;
  }
  .theme-toggle {
    width: 2rem;
    margin-right: -0.45rem;
  }
  .timeline li,
  .earlier li {
    grid-template-columns: minmax(0, 1fr);
  }
  .job-text,
  .earlier-text,
  .earlier-stack {
    grid-column: 1;
  }
  .what {
    margin-top: calc(var(--row) / 2);
  }
  .contact-email {
    font-size: 1rem;
    line-height: var(--row);
    font-weight: 500;
  }
  .section-head a {
    display: none;
  }
  .ssh-command {
    flex-wrap: wrap;
  }
  .ssh-command button {
    flex: 1 0 100%;
    padding-block: calc(var(--row) / 2);
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .facts > div {
    grid-template-columns: 11ch minmax(0, 1fr);
    gap: 0 1ch;
  }
}
@media (max-width: 23rem) {
  h1 {
    font-size: 2.5rem;
  }
  .header nav {
    gap: 1ch;
  }
}
