/*
  handform: black on white, Helvetica, a 40px spacing unit.
  The only ornament is the hairline ruler along the top edge, which
  counts 40px steps from the left edge of the content column.
*/

:root {
  --ink: #000;
  --grey: #6b6b6b;
  --rule: #d4d4d4;
  --wash: #f3f3f3;
  --paper: #fff;

  --unit: 40px;
  --column: 1120px;
  --ruler-x: 0px;

  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

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

html {
  font-family: var(--sans);
  font-size: 112.5%; /* 18px */
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { margin: 0; }

/*
  Narrow screens: the column starts one unit in from the left edge.
  Wide screens: the column is centred, and calc(50% + 140px) shifts the
  ruler's 8px and 40px tick patterns so a tick lands on the column's
  left edge, at 50% - 560px.
*/
.frame,
.ruler-numbers {
  margin-left: var(--unit);
  margin-right: var(--unit);
}

@media (min-width: 1200px) {
  :root { --ruler-x: calc(50% + 140px); }
  .frame,
  .ruler-numbers {
    width: var(--column);
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 599px) {
  :root { --ruler-x: calc(var(--unit) / 2); }
  .frame,
  .ruler-numbers {
    margin-left: calc(var(--unit) / 2);
    margin-right: calc(var(--unit) / 2);
  }
}

/* ---------- Ruler ---------- */

.ruler {
  height: 32px;
  border-top: 1px solid var(--ink);
  background-image:
    linear-gradient(90deg, var(--ink) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: var(--unit) 10px, 8px 5px;
  background-repeat: repeat-x;
  background-position: var(--ruler-x) 0;
  overflow: hidden;
}

.ruler-numbers {
  position: relative;
  height: 100%;
}

.ruler-numbers span {
  position: absolute;
  left: calc(var(--n) * var(--unit));
  top: 13px;
  transform: translateX(-50%);
  font-size: 0.55rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--grey);
}

/* ---------- Type ---------- */

h1, h2, h3 {
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
}

p { margin: 0; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--unit);
  height: calc(var(--unit) * 3);
}

.wordmark img {
  display: block;
  height: 32px;
  width: auto;
}

.elsewhere {
  display: flex;
  gap: 24px;
  font-size: 0.9rem;
}

.elsewhere a { text-decoration: none; }
.elsewhere a:hover { text-decoration: underline; }

/* ---------- Intro ---------- */

.intro {
  padding: calc(var(--unit) * 1.5) 0 calc(var(--unit) * 3);
}

.intro h1 {
  font-size: clamp(2.6rem, 7.5vw, 5.5rem);
  letter-spacing: -0.035em;
  line-height: 0.95;
  max-width: 18ch;
}

.intro p {
  margin-top: var(--unit);
  max-width: 32em;
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--grey);
}

/* ---------- Sections ---------- */

.shelf {
  border-top: 1px solid var(--ink);
  padding-top: 16px;
}

.shelf + .shelf { margin-top: calc(var(--unit) * 3); }

.shelf > h2 {
  font-size: 1rem;
  margin-bottom: calc(var(--unit) * 1.5);
}

/* ---------- Browser projects ---------- */

.pieces {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--unit) * 2) var(--unit);
}

.piece {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.piece:first-child {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--unit);
  align-items: end;
}

.piece-shot {
  display: block;
  text-decoration: none;
  color: inherit;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--wash);
}

.piece-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
}

.piece-shot.is-pixel { background: #000; }

.piece-shot.is-pixel img {
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
}

.piece-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.035em;
}

.piece-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: 34em;
}

.piece h3 {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.piece:first-child h3 { font-size: 2.2rem; }

.piece h3 a { text-decoration: none; }
.piece h3 a:hover { text-decoration: underline; }

.made-with {
  font-size: 0.85rem;
  color: var(--grey);
}

.play {
  margin-top: 8px;
  display: inline-block;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}

.play:hover { background: #333; }

/* ---------- App-store apps ---------- */

.apps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: calc(var(--unit) * 1.5) var(--unit);
}

.app img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--rule);
  margin-bottom: 16px;
}

.app h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.app p {
  font-size: 0.875rem;
  color: var(--grey);
}

.app .stores {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 10px;
  color: var(--ink);
}

/* ---------- Writing ---------- */

.posts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--unit);
  max-width: 40em;
}

.posts a {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.posts a:hover { text-decoration: underline; }

.posts p {
  margin-top: 4px;
  color: var(--grey);
}

.posts time {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--grey);
}

/* ---------- Footer ---------- */

.colophon {
  margin-top: calc(var(--unit) * 4);
  padding: 16px 0 calc(var(--unit) * 2);
  border-top: 1px solid var(--ink);
  font-size: 0.8rem;
  color: var(--grey);
}

.colophon ul {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.colophon a { color: var(--ink); }

/* ---------- Reading pages: posts and others ---------- */

.sheet {
  max-width: 680px;
  padding: var(--unit) 0 0;
  line-height: 1.6;
}

.sheet h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}

.sheet h2, .sheet h3 {
  margin: 2em 0 0.6em;
  letter-spacing: -0.01em;
}

.sheet h2 { font-size: 1.4rem; }
.sheet h3 { font-size: 1.15rem; }

.sheet p, .sheet ul, .sheet ol, .sheet table, .sheet pre { margin: 0 0 1em; }

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

.sheet table { border-collapse: collapse; }
.sheet td, .sheet th { padding: 6px 12px 6px 0; border-bottom: 1px solid var(--rule); text-align: left; }

.sheet code {
  font-family: var(--mono);
  font-size: 0.85em;
}

.sheet pre {
  overflow-x: auto;
  padding: 16px 20px;
  background: var(--wash);
  line-height: 1.45;
}

.sheet pre code { background: none; padding: 0; }

.post .standfirst {
  font-size: 1.25rem;
  color: var(--grey);
}

.post .byline {
  margin: 12px 0 40px;
  font-size: 0.85rem;
  color: var(--grey);
}

.comments {
  margin-top: calc(var(--unit) * 2);
  padding-top: 16px;
  border-top: 1px solid var(--ink);
}

.comments h2 {
  margin-top: 0;
  font-size: 1rem;
}

/* ---------- Small screens ---------- */

@media (max-width: 799px) {
  .pieces { grid-template-columns: 1fr; }
  .piece:first-child {
    display: flex;
    gap: 20px;
  }
  .piece:first-child h3 { font-size: 1.5rem; }
  .masthead { height: calc(var(--unit) * 2); }
  .wordmark img { height: 24px; }
}
