@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/IBMPlexMono-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/*
 * Shared type, weight and spacing tokens. Print reuses the same roles with point-sized values.
 *
 * Type roles:
 *   title    – the name (h1)
 *   heading  – section titles (h2)
 *   body     – running text; h3 is body size in bold
 *   small    – secondary text: nav, contacts, dates, notes, descriptions. Muted text is always small.
 */
:root {
  color-scheme: light;

  --ink: #111;
  --muted: #5c5c5c;
  --paper: #fff;
  --canvas: #e8e7e3;
  --shadow: #b8b7b2;

  /* Signal colours: actions and state only, never body text. */
  --amber: #ffb700;
  --green: #00794c;
  --red: #e0242b;

  --font: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
  --text-title: 1.5rem;
  --text-heading: 1.25rem;
  --text-body: 1rem;
  --text-small: .8125rem;
  --leading: 1.5;
  --leading-tight: 1.25;
  --regular: 400;
  --bold: 700;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 36px;
  --space-7: 48px;

  --line: 1.5px;
  --step: 9px;
  --rail: 3ch;
  --measure: 46rem;

  font-family: var(--font);
  font-size: var(--text-body);
  font-weight: var(--regular);
  line-height: var(--leading);
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  font-variant-ligatures: none;
}

/* Base */
:where(p, h1, h2, h3, ul, ol) { margin: 0; }

body {
  margin: 0;
  padding: var(--space-6) var(--space-4) var(--space-7);
}

h1 { font-size: var(--text-title); line-height: var(--leading-tight); font-weight: var(--bold); }
h2 { font-size: var(--text-heading); font-weight: var(--bold); letter-spacing: -.01em; }
h3 { font-size: var(--text-body); font-weight: var(--bold); }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;

  &:hover { color: var(--paper); background: var(--ink); text-decoration: none; }
  &:focus-visible { outline: 2px solid var(--ink); outline-offset: 5px; }
}

.skip-link {
  position: absolute;
  top: -100px;
  padding: var(--space-2);
  background: var(--paper);

  &:focus { top: var(--space-2); }
}

/* Top controls */
.page-nav {
  max-width: var(--measure);
  margin: 0 auto var(--space-3);
  font-size: var(--text-small);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
}

.resume-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Buttons: square, inked border, hard offset shadow; pressing sinks into the shadow. */
.btn {
  /* A 1em line box centres Plex Mono caps in every browser; height = 1em + 2 × (pad + 1px border). */
  --btn-pad: 7px;

  display: inline-flex;
  align-items: center;
  gap: .75ch;
  padding: var(--btn-pad) 1.25ch;
  font: inherit;
  line-height: 1;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 var(--shadow);
  text-decoration: none;
  cursor: pointer;

  &:hover { color: var(--paper); background: var(--ink); }
  &:active { translate: 2px 2px; box-shadow: none; }
  &:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
}

.btn-amber { background: var(--amber); }
.btn-green { color: var(--paper); background: var(--green); }

/* Status lamp: hollow when off, lit red when on. */
.lamp {
  box-sizing: border-box;
  width: 9px;
  height: 9px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

[aria-expanded="true"] .lamp { border-color: var(--ink); background: var(--red); }

/* The sheet */
.paper {
  box-sizing: border-box;
  max-width: var(--measure);
  margin: auto;
  padding: var(--space-7);
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--shadow);
}

.identity {
  margin-bottom: var(--space-6);

  & .intro { margin-top: var(--space-2); }

  & address {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    row-gap: var(--space-1);
    margin-top: var(--space-4);
    font-size: var(--text-small);
    font-style: normal;
    overflow-wrap: anywhere;
  }
}

/* Career: each stage is a role with an arrow running past its companies */
.career {
  padding: 0;
  list-style: none;
}

.stage {
  & + & { margin-top: var(--space-5); }
}

.stage-body {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: 1ch;
  margin-top: var(--space-3);
}

.arrow {
  position: relative;
  display: block;
  margin: var(--space-1) 0 calc(-1 * var(--space-1));

  &::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 1px;
    left: 50%;
    border-left: var(--line) solid;
    transform: translateX(-50%);
  }

  & svg {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 10px;
    height: 6px;
    transform: translateX(-50%);
  }
}

.job {
  position: relative;
  break-inside: avoid;

  & + & { margin-top: var(--space-4); }

  /* Step marker on the arrow, level with the company name. */
  &::before {
    box-sizing: border-box;
    content: '';
    position: absolute;
    top: .5lh;
    left: calc(-1ch - var(--rail) / 2);
    width: var(--step);
    height: var(--step);
    border: var(--line) solid var(--ink);
    border-radius: 50%;
    background: var(--paper);
    transform: translate(-50%, -50%);
  }

  & ul {
    margin-top: var(--space-1);
    padding-left: 2ch;
    list-style: '- ';
  }

  & li + li { margin-top: calc(var(--space-1) / 2); }
}

.job-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: var(--space-3);
}

.dates, .aside { font-size: var(--text-small); color: var(--muted); }
.site { font-size: var(--text-small); white-space: nowrap; }

/* Project URLs wrap as a group: beside every name while the longest pair fits
   ("Wedding invitation" + its URL in Plex Mono, 0.6em per character), all under their names below that. */
.projects { container-type: inline-size; }

@container (max-width: 24rem) {
  /* The name takes the full row, so each URL wraps below it at its own width (its hover fill stays fitted). */
  .projects .job-head h3 { flex-basis: 100%; }
}

/* Footer: the text and the button share a line and wrap cleanly. */
.home-extra footer p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.next {
  padding-block-end: var(--space-4);

  &.job { margin-block-start: var(--space-5); }

  /* The step marker sits on the button's centre line: padding + border + half the 1em line. */
  &.job::before { top: calc(7px + 1px + .5em); }

  & p:first-child { display: flex; }
  & .btn { font-weight: var(--bold); }
}

/* Homepage extras, screen only */
.home-extra {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px dashed var(--muted);

  & section + section, & footer { margin-top: var(--space-6); }
}


.lore {
  & p { margin-top: var(--space-4); }

  & .reading-list {
    margin-block-start: var(--space-2);
    padding-inline-start: 2ch;
    list-style: '- ';

    & li + li { margin-block-start: var(--space-1); }
  }
}

/* Experiment: type sheet of the page's building blocks, screen only */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.typesheet {
  box-sizing: border-box;
  scroll-margin-top: var(--space-4);
  max-width: var(--measure);
  margin: var(--space-6) auto 0;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--shadow);
  font-size: var(--text-small);
  line-height: var(--leading-tight);

  & h2, & h3 { font-size: inherit; letter-spacing: .06em; text-transform: uppercase; }
  /* Focused by script when the toggle scrolls to it; keep the ring for keyboard users only. */
  &:focus:not(:focus-visible) { outline: none; }
  & code { font: inherit; }
}

.ts-head {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-3);
  align-items: stretch;
  /* No vertical padding here, so the rule after PS-01 runs from edge to edge. */
  padding: 0 var(--space-3);
  color: var(--paper);
  background: var(--ink);

  & > * { display: flex; align-items: center; padding-block: var(--space-3); }
  & .ts-part { padding-inline-end: var(--space-3); border-inline-end: 1px solid; font-size: var(--text-heading); font-weight: var(--bold); }
}

.ts-block {
  padding: var(--space-3);
  border-top: 1px solid var(--ink);

  & h3 { display: flex; align-items: center; gap: 1ch; margin-bottom: var(--space-3); }
  & > * + :not(h3) { margin-top: var(--space-3); }
}

/* A fixed line box centres Plex Mono digits in every browser; no reliance on text-box trimming. */
.ts-num {
  display: inline-block;
  padding: 0 .5ch;
  border: 1px solid;
  line-height: 16px;
  letter-spacing: 0;
}

.ts-specimen {
  font-size: var(--text-title);
  font-weight: var(--bold);
  line-height: var(--leading-tight);
}

/*
 * Ruled rows: every list and table in the sheet bleeds to the sheet's edges, with one fixed row
 * height and a rule under each row. When rows end a block, the block's own border closes them.
 */
.ts-spec, .ts-table, .ts-swatches, .ts-scale {
  --row: 26px;
  --rule: #d6d5d0;

  margin-inline: calc(-1 * var(--space-3));
  margin-bottom: 0;
  border-top: 1px solid var(--rule);
}

.ts-block:has(> :is(.ts-spec, .ts-table, .ts-swatches, .ts-scale):last-child) {
  padding-bottom: 0;

  & > :last-child :is(dt:nth-last-child(2), dd:last-child, li:last-child, tr:last-child > *) { border-bottom: 0; }
}

.ts-spec {
  display: grid;
  grid-template-columns: auto 1fr;

  & dt, & dd {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    min-height: var(--row);
    margin: 0;
    border-bottom: 1px solid var(--rule);
  }
  & dt { padding-inline: var(--space-3) 1ch; color: var(--muted); }
  & dd { justify-content: flex-end; padding-inline: 1ch var(--space-3); }
}

.ts-table {
  width: calc(100% + 2 * var(--space-3));
  border-collapse: collapse;

  & tr { height: var(--row); }
  & th, & td { padding: 0 0 0 1ch; border-bottom: 1px solid var(--rule); text-align: end; font-weight: var(--regular); }
  & :is(th, td):first-child { padding-inline-start: var(--space-3); text-align: start; }
  & :is(th, td):last-child { padding-inline-end: var(--space-3); }
  & thead th { color: var(--muted); border-bottom-color: var(--ink); }
  & tbody th { line-height: 1; }
}

.ts-role-title { font-size: var(--text-title); font-weight: var(--bold) !important; }
.ts-role-heading { font-size: var(--text-heading); font-weight: var(--bold) !important; }
.ts-role-body { font-size: var(--text-body); }
.ts-role-small { font-size: var(--text-small); color: var(--muted); }

.ts-note, .ts-caption, .ts-foot { color: var(--muted); }
.ts-caption { font-style: italic; }

.ts-swatches, .ts-scale {
  padding: 0;
  list-style: none;

  & li {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 1ch;
    min-height: var(--row);
    padding-inline: var(--space-3);
    border-bottom: 1px solid var(--rule);
  }
  & code { min-width: 9ch; }
}

.ts-colorbar {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-top: 1px solid var(--ink);

  & span { flex: 1; height: 8px; background: var(--swatch); }
}

/* Sub-heading row inside a ruled list, closed by an ink rule. */
.ts-swatches .ts-group {
  font-weight: var(--bold);
  border-bottom-color: var(--ink);
}

.ts-swatch {
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  border: 1px solid var(--ink);
  background: var(--swatch);
}

.ts-bar {
  width: var(--w);
  height: 8px;
  background: var(--ink);

  & + span { color: var(--muted); }
}

.ts-figure {
  padding: var(--space-3);
  border: 1px dashed var(--muted);
  font-size: var(--text-small);

  & .stage-body { margin-top: 0; }
  & .arrow { margin-block-end: 0; }
  & .job + .job { margin-top: var(--space-3); }
  & .aside { font-size: inherit; }
}

.ts-foot {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--ink);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: inherit;
}

/* The bottom spec sheet toggle: under the page, right above where the sheet opens.
   Shown only while the sheet opens below the page (narrower than 72rem); the top one hides then. */
.sheet-bar {
  max-width: var(--measure);
  margin: var(--space-5) auto 0;
  font-size: var(--text-small);
}

@media screen and (max-width: 71.99rem) {
  .page-nav .sheet-toggle { display: none; }
  .sheet-bar + .typesheet { margin-top: var(--space-3); }
}

/* Wide screens: while open, the sheet sits right of the page, level with the buttons, and scrolls with it. */
@media screen and (min-width: 72rem) {
  .sheet-bar { display: none; }

  body:has(.typesheet:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, var(--measure)) 20rem;
    justify-content: center;
    align-items: start;
    column-gap: var(--space-6);

    & .page-nav { grid-column: 1; grid-row: 1; width: 100%; margin: 0 0 var(--space-3); }
    & .paper { grid-column: 1; grid-row: 2; width: 100%; margin: 0; }
  }

  .typesheet {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
  }
}

@media screen and (max-width: 600px) {
  :root { --rail: 2ch; }
  body { padding: var(--space-5) var(--space-4); }
  .paper { padding: var(--space-5) var(--space-4); }
  .identity { margin-bottom: var(--space-5); }
}

/* Print: zero page margin leaves no room for browser headers/footers; .paper carries the spacing. */
@page { size: A4 portrait; margin: 0; }

@media print {
  :root {
    --canvas: #fff;
    --text-title: 18pt;
    --text-heading: 12pt;
    --text-body: 10pt;
    --text-small: 9pt;
    --leading: 1.35;
    --space-1: 3pt;
    --space-2: 6pt;
    --space-3: 9pt;
    --space-4: 12pt;
    --space-5: 18pt;
    --space-6: 24pt;
    --space-7: 36pt;
    --line: .75pt;
    --step: 6pt;
  }

  body {
    padding: 0;
    background: var(--paper);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* The story and the call to action stay on screen. */
  .page-nav, .skip-link, .next, .typesheet, .sheet-bar, .home-extra { display: none; }
  /* Links stay clickable in the PDF but print as plain text. */
  a { text-decoration: none; }

  .paper {
    box-shadow: none;
    max-width: none;
    margin: 0;
    padding: 16mm 18mm;
    border: 0;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
  }

  h1, h2, h3 { break-after: avoid; }
  .identity, .stage, .job { break-inside: avoid; }
  p, li { orphans: 2; widows: 2; }
}
