/* After editing this file, run `python3 tools/stamp.py` so pages link the
   new version instead of a browser's cached copy.

   Source Serif 4 by Frank Grießhammer, subset and renamed per its OFL
   Reserved Font Name; see tools/subset-fonts.py and fonts/OFL.txt. */

@font-face {
  font-family: "AC Text";
  src: url("/fonts/text-roman.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "AC Display";
  src: url("/fonts/display-roman.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f6f4ef;
  --ink: #1c1b18;
  --muted: #69655d;
  --accent: #9a3b22;
  --rule: #dcd8ce;
  --signal: #c8331e; /* the tenth dot in the Tenth Man Labs mark */
  --serif: "AC Text", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151412;
    --ink: #e8e5de;
    --muted: #9d988e;
    --accent: #e08f72;
    --rule: #2f2d29;
    --signal: #e2553d;
  }

  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

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

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-synthesis: none;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
}

ul {
  list-style: none;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  transition: text-decoration-color 120ms ease-out;
}

a:hover {
  text-decoration-color: currentColor;
}

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

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

.nb {
  white-space: nowrap;
}

.print-only {
  display: none;
}

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

/* Layout: every line of text starts at one left edge. Section names hang
   in the left margin; years sit in a narrow column on the right. */

.page {
  display: grid;
  column-gap: 2rem;
  grid-template-columns:
    [full-start] minmax(0, 1fr)
    [label-start] 6.5rem
    [label-end main-start] minmax(0, 33rem)
    [main-end year-start] 4.5rem
    [year-end] minmax(0, 1fr) [full-end];
  padding-block: clamp(3rem, 10vh, 7rem) clamp(3rem, 8vh, 5rem);
}

.masthead,
.intro,
.colophon {
  grid-column: main-start / year-end;
}

.content,
.block {
  grid-column: label-start / year-end;
  display: grid;
  grid-template-columns: subgrid;
}

.block > ul,
.entry {
  grid-column: main-start / year-end;
  display: grid;
  grid-template-columns: subgrid;
}

/* Masthead and intro */

.masthead .name {
  font-weight: 500;
}

.masthead .name a {
  text-decoration: none;
}

.masthead p:not(.name) {
  color: var(--muted);
}

.intro {
  margin-top: clamp(2.5rem, 7vh, 4.5rem);
  max-width: 31em;
  font-family: "AC Display", var(--serif);
  font-size: clamp(1.375rem, 1.05rem + 1.05vw, 1.6875rem);
  line-height: 1.36;
  letter-spacing: -0.006em;
}

.intro > * + * {
  margin-top: 0.7em;
  color: var(--muted);
}

/* Sections */

.block {
  margin-top: clamp(3rem, 7vh, 4.25rem);
  align-items: baseline;
}

.block > h2 {
  grid-column: label;
  grid-row: 1;
  font-size: 0.9375rem;
  color: var(--muted);
}

.block > ul {
  grid-row: 1;
  row-gap: 1.4rem;
}

.block > ul.rows {
  row-gap: 0.3rem;
}

.entry {
  align-items: baseline;
}

.title {
  grid-column: main;
  font-weight: 500;
}

.rows .title {
  font-weight: 400;
}

.title .org {
  white-space: nowrap;
  font-weight: 400;
  color: var(--muted);
}

.year {
  grid-column: year;
  text-align: right;
  font-size: 0.9375rem;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}

.desc {
  grid-column: main;
  margin-top: 0.2rem;
  color: var(--muted);
}

/* Tenth Man Labs: the mark in the margin, the description in ink. */

.lead .mark {
  grid-column: label;
  grid-row: 1;
  align-self: start;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.3rem;
  fill: currentColor;
}

.lead .mark .tenth {
  fill: var(--signal);
}

.lead .desc {
  color: var(--ink);
}

.lead .desc + .desc {
  margin-top: 0.6rem;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.82em;
}

/* Project pages: prose in the main column, section names in the margin. */

.block > .prose {
  grid-column: main;
  grid-row: 1;
}

.prose > * + * {
  margin-top: 0.9em;
}

.prose .figure {
  margin: 1.5rem 0 1.6rem;
}

.figure .scroll {
  overflow-x: auto;
}

.figure .scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.figure figcaption {
  margin-top: 0.6rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Figures are drawn by tools/figures.py; colors follow the theme. */

.chart {
  display: block;
  width: 100%;
  min-width: 440px;
  height: auto;
  overflow: visible;
}

.chart text {
  font-family: var(--serif);
  font-size: 13px;
  fill: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
}

.chart text.strong { fill: var(--ink); }
.chart text.em { fill: var(--accent); }
.chart text.on-dark { fill: var(--paper); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.chart .line.strong { stroke: var(--ink); }
.chart .line.em { stroke: var(--accent); }
.chart .line.dash { stroke-dasharray: 5 4; }
.chart .line.faint { stroke-width: 1; opacity: 0.45; }
.chart .mean { stroke: var(--ink); stroke-width: 2.5; }
.chart .dot { fill: var(--muted); }
.chart .dot.strong { fill: var(--ink); }
.chart .dot.em { fill: var(--accent); }
.chart .dot.hollow { fill: var(--paper); stroke: var(--muted); stroke-width: 1; }
.chart .dot.hollow.em { stroke: var(--accent); stroke-width: 1.5; }
.chart .dot.hollow.strong { stroke: var(--ink); stroke-width: 1.5; }
.chart .ci { stroke: var(--muted); stroke-width: 1; opacity: 0.7; }
.chart .ci.strong { stroke: var(--ink); }
.chart .ci.em { stroke: var(--accent); }
.chart .seg.ink { fill: var(--ink); }
.chart .seg.em { fill: var(--accent); }
.chart .seg.muted { fill: var(--muted); }
.chart .seg.light { fill: var(--rule); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  font-variant-numeric: lining-nums tabular-nums;
}

.table th {
  text-align: left;
  font-weight: 400;
  color: var(--muted);
  padding: 0 0.75rem 0.4rem 0;
  border-bottom: 1px solid var(--rule);
}

.table td {
  padding: 0.4rem 0.75rem 0.4rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}

.table .num {
  text-align: right;
}

.table tr > :last-child {
  padding-right: 0;
}

.colophon {
  margin-top: clamp(3.5rem, 8vh, 5rem);
  font-size: 0.875rem;
  color: var(--muted);
}

/* Medium screens: same structure, narrower margins. */

@media screen and (max-width: 62rem) {
  .page {
    column-gap: 1.5rem;
    grid-template-columns:
      [full-start] minmax(1.25rem, 1fr)
      [label-start] 5.25rem
      [label-end main-start] minmax(0, 33rem)
      [main-end year-start] 3.75rem
      [year-end] minmax(1.25rem, 1fr) [full-end];
  }
}

/* Small screens: one column. Section names sit above their entries and
   years share the title line. */

@media screen and (max-width: 40rem) {
  body {
    font-size: 1.03125rem;
  }

  .page {
    column-gap: 0;
    grid-template-columns:
      [full-start] 1.25rem
      [label-start main-start] minmax(0, 1fr)
      [main-end year-start] auto
      [year-end label-end] 1.25rem [full-end];
  }

  .block > h2,
  .lead .mark {
    margin-bottom: 0.9rem;
  }

  .block > ul {
    grid-row: auto;
  }

  .block > .prose {
    grid-row: auto;
    grid-column: main-start / year-end;
  }

  .year {
    padding-left: 1rem;
  }

  .desc {
    grid-column: main-start / year-end;
  }

  .figure .scroll {
    margin-inline: -1.25rem;
    padding-inline: 1.25rem;
  }

  .chart {
    min-width: 480px;
  }
}

/* Print: a CV. Chromium cannot fragment nested subgrids across pages
   (pushed rows overlap the next section), so print uses blocks, floats
   for the margin labels, and a small grid per entry. */

@media print {
  :root {
    --paper: #fff;
    --ink: #000;
    --muted: #555;
    --signal: #c8331e;
  }

  @page {
    margin: 11mm 15mm;
  }

  html {
    font-size: 11px;
  }

  body {
    line-height: 1.4;
  }

  .page,
  .content,
  .block,
  .block > ul {
    display: block;
    padding: 0;
  }

  .masthead,
  .intro,
  .colophon,
  .block > ul {
    margin-left: 8.5rem;
  }

  .intro {
    margin-top: 0.8rem;
    font-size: 1.2rem;
    max-width: 34em;
  }

  .block {
    margin-top: 1rem;
  }

  .block > h2,
  .lead .mark {
    float: left;
    width: 6.5rem;
  }

  .lead .mark {
    width: 1.05rem;
  }

  .entry {
    grid-template-columns: [main-start] minmax(0, 1fr) [main-end year-start] 4.5rem [year-end];
    column-gap: 2rem;
    break-inside: avoid;
  }

  .entry + .entry {
    margin-top: 0.4rem;
  }

  .rows > .entry + .entry {
    margin-top: 0.15rem;
  }

  a {
    text-decoration: none;
  }

  [data-print]::after {
    content: "\2002" attr(data-print);
    font-weight: 400;
    font-size: 0.9em;
    color: var(--muted);
  }

  .colophon,
  .contact,
  .screen-only,
  .brief .desc {
    display: none;
  }

  .masthead .print-only {
    display: block;
  }
}
