/* ===========================
   TOKENS
   one paper, one ink, one accent. three typefaces, each with one job:
   serif speaks, sans explains, mono labels.
   =========================== */
:root {
  --bg: #efe8dc;
  --surface: #e6decf;
  --ink: #1d1b19;
  --ink-2: #57524b;
  --ink-3: #6f685e;
  --accent: #c22a21;
  --line: rgba(29, 27, 25, 0.14);
  --line-2: rgba(29, 27, 25, 0.3);

  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --col: 960px;
  --gutter: 24px;

  /* "only" stops browsers like chrome from auto-darkening the page: the site has its own dark mode */
  color-scheme: only light;
}

:root[data-theme="dark"] {
  color-scheme: only dark;
  --bg: #000;
  --surface: #131210;
  --ink: #ece4d6;
  --ink-2: #b9b0a2;
  --ink-3: #8f8779;
  --accent: #f0564a;
  --line: rgba(236, 228, 214, 0.16);
  --line-2: rgba(236, 228, 214, 0.34);
}

/* ===========================
   BASE
   =========================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* a little grain so the light page reads as paper, not a flat fill */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] body::before {
  display: none;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

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

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

.mono {
  font-family: var(--mono);
}

/* small mono label: the one style every piece of metadata uses */
.label,
.tile-meta,
.crumb,
.facts dt {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* links inside running text: ink, with the accent in the underline */
.prose a,
.hello-text a,
.article-body a,
.release a,
.facts a,
.foot a,
.article-origin a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: color 0.15s, text-decoration-color 0.15s;
}

.prose a:hover,
.hello-text a:hover,
.article-body a:hover,
.release a:hover,
.facts a:hover,
.foot a:hover,
.article-origin a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ===========================
   FRAME: top bar + column
   =========================== */
.topbar,
.col,
.foot-inner {
  position: relative;
  z-index: 1;
  width: min(var(--col), 100% - var(--gutter) * 2);
  margin-inline: auto;
}

.narrow {
  --col: 720px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 0;
}

.topnav {
  display: flex;
  align-items: baseline;
  gap: 22px;
  font-size: 14.5px;
  color: var(--ink-2);
}

.topnav a {
  transition: color 0.15s;
}

.topnav a:hover {
  color: var(--accent);
}

.topnav .home {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
  margin-right: 6px;
  white-space: nowrap;
}

.live {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.lamp {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  transition: color 0.15s, background-color 0.15s;
}

@media (hover: hover) {
  .lamp:hover {
    color: var(--accent);
    background: color-mix(in srgb, var(--ink) 7%, transparent);
  }
}

.col {
  padding: 56px 0 96px;
}

/* ===========================
   HOME: hello
   =========================== */
.hello {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 56px;
  align-items: start;
}

.name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(50px, 8.2vw, 84px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-bottom: 30px;
}

.hello-text p {
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1.42;
  max-width: 34em;
  margin-bottom: 16px;
  text-wrap: pretty;
}

.hello-text .hello-meta {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--ink-3);
  max-width: none;
  margin: 30px 0 0;
}

.hello-meta a {
  color: var(--ink-2);
  text-decoration-color: var(--line-2);
  text-decoration-thickness: 1px;
}

.portrait {
  padding-top: 10px;
}

.portrait-frame {
  display: block;
  border-radius: 4px;
  overflow: hidden;
}

/* the photo's white backdrop takes on whatever is behind it: the paper in light mode,
   and in dark mode a frame the colour of the text, so it never sits there as a cold white box */
.portrait img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  mix-blend-mode: multiply;
}

:root[data-theme="dark"] .portrait-frame {
  background: #d8d0c2;
}

.portrait figcaption {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 10px;
}

/* ===========================
   HOME: commit log
   =========================== */
.graph[hidden] {
  display: none;
}

.graph {
  margin-top: 64px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.graph-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}

.graph-foot {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: right;
  transition: color 0.15s;
}

.graph-foot:hover {
  color: var(--accent);
}

.contrib {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, auto);
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
  min-height: 60px;
}

.contrib i {
  display: block;
  aspect-ratio: 1;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

/* one hue, four strengths */
.contrib i[data-l="1"] { background: color-mix(in srgb, var(--accent) 26%, var(--bg)); }
.contrib i[data-l="2"] { background: color-mix(in srgb, var(--accent) 48%, var(--bg)); }
.contrib i[data-l="3"] { background: color-mix(in srgb, var(--accent) 74%, var(--bg)); }
.contrib i[data-l="4"] { background: var(--accent); }

/* ===========================
   SECTIONS
   =========================== */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 88px 0 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-head h1,
.section-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.more {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: color 0.15s;
}

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

/* ===========================
   TILES: projects and posts share one card
   =========================== */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 40px 24px;
}

.tiles-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.shot {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 1400 / 806;
  margin-bottom: 11px;
  border-radius: 4px;
  background: var(--surface);
}

/* the hairline sits over the image so dark screenshots still have an edge in dark mode */
.shot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--line);
  pointer-events: none;
}

.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
  transition: transform 0.6s cubic-bezier(.2, .8, .2, 1);
}

.shot-cover {
  aspect-ratio: 16 / 9;
}

.shot-cover img {
  object-position: center;
}

@media (hover: hover) {
  .tile:hover .shot img {
    transform: scale(1.025);
  }
}

.tile-title {
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1.16;
  letter-spacing: -0.005em;
  text-wrap: balance;
  transition: color 0.15s;
}

.tiles-2 .tile-title {
  font-size: 26px;
}

.tile:hover .tile-title {
  color: var(--accent);
}

.tile-desc {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-top: 2px;
}

/* a post without an image gets its title instead */
.shot-blank {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10%;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.15;
  text-align: center;
  color: var(--ink-2);
}

/* the lead project: screenshot beside its text */
.tile-feature {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 36px;
  align-items: center;
}

.tile-feature .shot {
  margin-bottom: 0;
}

.tile-feature .tile-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tile-feature .tile-title {
  font-size: 31px;
  line-height: 1.1;
}

/* ===========================
   LEDGER: dotted rows, the way a statement lists things
   =========================== */
.ledger {
  display: grid;
  gap: 5px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
}

.ledger .row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ledger .row i {
  flex: 1;
  min-width: 16px;
  border-bottom: 1px dotted var(--line-2);
  transform: translateY(-3px);
}

.ledger .total {
  margin-top: 6px;
  padding-top: 9px;
  border-top: 1px dashed var(--line-2);
  color: var(--ink);
  font-weight: 500;
}

.tile-feature .ledger {
  margin-top: 18px;
}

/* side quests: one row each */
.quests {
  margin-top: 56px;
}

.quests .label {
  display: block;
  margin-bottom: 10px;
}

.quests a {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) auto;
  gap: 24px;
  align-items: baseline;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 15px;
  transition: color 0.15s;
}

.quests a:last-child {
  border-bottom: 1px solid var(--line);
}

.quests .mono {
  font-size: 13px;
  color: var(--ink);
  transition: color 0.15s;
}

.quests .arrow {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-3);
  transition: transform 0.2s, color 0.15s;
}

.quests a:hover,
.quests a:hover .mono,
.quests a:hover .arrow {
  color: var(--accent);
}

.quests a:hover .arrow {
  transform: translateX(3px);
}

/* ===========================
   FOOTER
   =========================== */
.foot {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
}

.foot-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 24px 40px;
  padding: 44px 0 56px;
}

.foot-hi {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.foot-side {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: right;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 20px;
}

.foot a {
  text-decoration-color: var(--line-2);
  text-decoration-thickness: 1px;
}

.foot-meta {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ===========================
   PROJECT PAGE
   =========================== */
.crumb a {
  transition: color 0.15s;
}

.crumb a:hover {
  color: var(--accent);
}

.doc-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(52px, 9vw, 92px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 14px 0 22px;
}

.doc-summary {
  font-family: var(--serif);
  font-size: clamp(23px, 3.2vw, 29px);
  line-height: 1.25;
  max-width: 26em;
  text-wrap: pretty;
}

.facts {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 18px 48px;
  margin: 40px 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.facts dt {
  margin-bottom: 4px;
}

.facts dd {
  font-size: 15px;
}

.facts dd a + a {
  margin-left: 14px;
}

.doc-shot {
  margin: 0 0 20px;
}

.doc-shot[hidden] {
  display: none;
}

.doc-part {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 8px 40px;
  padding: 30px 0;
  border-top: 1px solid var(--line);
}

/* the first part follows the facts row or the screenshot, which already draw the break */
#docBody .doc-part:first-child {
  border-top: 0;
}

.doc-shot[hidden] + #docBody .doc-part:first-child {
  padding-top: 0;
}

.doc-part h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 25px;
  line-height: 1.15;
}

.doc-part p {
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 40em;
}

.doc-next {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-top: 8px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
  transition: color 0.15s;
}

.doc-next .label {
  flex: none;
}

.doc-next:hover {
  color: var(--accent);
}

/* post titles are long: label above, title below */
.article .doc-next {
  flex-direction: column;
  gap: 6px;
  text-wrap: balance;
}

/* ===========================
   ARTICLE
   =========================== */
.article-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 6.4vw, 58px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 14px 0 14px;
  text-wrap: balance;
}

.article-desc {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(20px, 2.6vw, 23px);
  line-height: 1.3;
  color: var(--ink-2);
}

.article-tags {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 18px;
}

.article-body {
  font-size: 17.5px;
  line-height: 1.72;
  overflow-wrap: break-word;
  border-top: 1px solid var(--line);
  margin: 34px 0 48px;
  padding-top: 34px;
}

.article-body > * + * {
  margin-top: 1.1em;
}

.article-body h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin-top: 1.7em;
}

.article-body h3,
.article-body h4 {
  font-weight: 600;
  font-size: 18px;
  margin-top: 1.5em;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4em;
}

.article-body li + li {
  margin-top: 0.4em;
}

.article-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 18px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  line-height: 1.4;
  color: var(--ink-2);
}

.article-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface);
  border-radius: 3px;
  padding: 1px 5px;
}

.article-body pre {
  background: var(--surface);
  border-radius: 4px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
}

.article-body pre code {
  font-size: inherit;
  background: none;
  padding: 0;
}

.article-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--line);
}

.article-body p:has(> img:only-child) {
  margin: 1.8em 0;
}

.article-body p:has(> img) + p > em:only-child {
  display: block;
  margin-top: -1em;
  text-align: center;
  font-size: 14px;
  color: var(--ink-3);
}

.article-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

.article-body table {
  border-collapse: collapse;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

.article-body th,
.article-body td {
  border-bottom: 1px solid var(--line);
  padding: 6px 12px 6px 0;
  text-align: left;
}

.article-origin {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 22px;
}

/* ===========================
   WRITING INDEX
   =========================== */
.page-head {
  margin-bottom: 44px;
}

.page-head .doc-title {
  font-size: clamp(46px, 7.4vw, 76px);
  margin-top: 0;
}

/* ===========================
   PATCH NOTES
   =========================== */
.notes .doc-summary {
  margin-bottom: 44px;
}

.release {
  padding: 22px 0 24px;
  border-top: 1px dashed var(--line-2);
  font-family: var(--mono);
  font-size: 13px;
}

.release-head {
  color: var(--ink);
  font-size: 13px;
}

.release-head b {
  font-weight: 600;
}

.release-name {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.1;
  margin: 8px 0 10px;
}

.release-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.release ul {
  list-style: none;
  color: var(--ink-2);
  line-height: 1.6;
}

.release li {
  padding-left: 18px;
  position: relative;
  margin-bottom: 4px;
}

.release li::before {
  content: '+';
  position: absolute;
  left: 0;
  color: var(--ink-3);
}

.release > a {
  display: inline-block;
  margin-top: 10px;
  color: var(--ink);
}

.notes .ledger .total {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* ===========================
   SMALLER SCREENS
   =========================== */
@media (max-width: 900px) {
  .tiles-index {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  :root {
    --gutter: 20px;
  }

  .col {
    padding: 32px 0 72px;
  }

  .hello {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* photo first on a phone, small, so the name is not pushed off the first screen */
  .portrait {
    order: -1;
    width: 112px;
    padding: 0;
    margin-bottom: 26px;
  }

  .portrait figcaption {
    display: none;
  }

  .hello-text p {
    font-size: 21px;
  }

  .graph {
    margin-top: 48px;
  }

  .graph-head {
    flex-direction: column;
    gap: 4px;
  }

  .graph-foot {
    text-align: left;
  }

  .contrib {
    gap: 2px;
  }

  .section-head {
    margin: 64px 0 24px;
  }

  .section-head h1,
  .section-head h2 {
    font-size: 30px;
  }

  .tiles,
  .tiles-2 {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .tile-feature {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tile-title,
  .tiles-2 .tile-title,
  .tile-feature .tile-title {
    font-size: 26px;
  }

  .quests a {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 16px;
  }

  .quests a span:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .quests .arrow {
    grid-row: 1 / span 2;
    align-self: center;
  }

  .foot-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 36px 0 48px;
  }

  .foot-side {
    text-align: left;
  }

  .foot-links {
    justify-content: flex-start;
  }

  .facts {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px 32px;
    margin: 32px 0;
  }

  .doc-part {
    grid-template-columns: 1fr;
    padding: 24px 0;
  }

  .doc-next {
    flex-direction: column;
    gap: 4px;
    font-size: 24px;
  }
}

@media (max-width: 560px) {
  .tiles-index {
    grid-template-columns: 1fr;
  }

  .topnav {
    gap: 16px;
  }

  /* inner pages carry the name in the bar, so the clock and the last link make room for it */
  .topbar-sub .live-clock,
  .topbar-sub .topnav .opt {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}
