:root {
  --paper: #e6e8ec;
  --paper-dim: #d9dce3;
  --ink: #1c1932;
  --soft: #4c4865;
  --rule: #b4b7c6;
  --night: #15122b;
  --night-text: #c9c5e2;
  --lantern: #ffd27a;
  --ember: #9a5300;
  --display: "Bricolage Grotesque", "Arial Narrow", sans-serif;
  --text: Literata, Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --gutter: 11rem;
  --gap: 2.5rem;
  --measure: 37rem;
  --bleed: 9rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.125rem/1.65 var(--text);
  font-optical-sizing: auto;
}

.wrap {
  max-width: calc(var(--gutter) + var(--gap) + var(--measure) + var(--bleed) + 2rem);
  margin: 0 auto;
  padding: 0 1rem;
}

a {
  color: inherit;
  text-decoration-color: var(--ember);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--ember); }
:focus-visible { outline: 3px solid var(--ember); outline-offset: 3px; }

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

/* The masthead is the one dark band: the game's night, with the lantern-coloured wordmark and its cyan echo. */
.masthead { background: var(--night); color: var(--night-text); }
.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.brand { display: flex; align-items: flex-end; gap: 0.75rem; text-decoration: none; color: var(--night-text); }
.brand img { display: block; width: 180px; height: 40px; }
.brand span { font: italic 1rem/1 var(--text); padding-bottom: 0.2rem; }
.masthead nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; font: 700 1rem var(--display); }
.masthead nav a { color: var(--night-text); text-decoration-color: transparent; }
.masthead nav a:hover { color: var(--lantern); text-decoration-color: var(--lantern); }
.masthead :focus-visible { outline-color: var(--lantern); }

main { padding-top: 1rem; padding-bottom: 3rem; }

h1, h2, h3 { font-family: var(--display); color: var(--ink); }
h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 2.5rem 0 1.5rem;
  text-wrap: balance;
}
h2 { font-size: 1.6rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; margin: 2.75rem 0 0.75rem; }
h3 { font-size: 1.2rem; font-weight: 700; margin: 2rem 0 0.5rem; }

p, li { overflow-wrap: anywhere; }
p { margin: 0 0 1.1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin-bottom: 0.3rem; }
strong { font-weight: 600; }

code { font-family: var(--mono); font-size: 0.82em; background: var(--paper-dim); padding: 0.08em 0.3em; border-radius: 2px; }

pre {
  overflow-x: auto;
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  font-size: 0.85rem;
  line-height: 1.55;
  background: var(--paper-dim);
  border-radius: 2px;
}
pre code { background: none; padding: 0; font-size: inherit; }

blockquote { margin: 1.5rem 0; padding-left: 1.1rem; border-left: 3px solid var(--ink); font-style: italic; }

table { border-collapse: collapse; width: 100%; margin: 1.5rem 0; font-size: 0.95rem; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--rule); padding: 0.45rem 0.75rem 0.45rem 0; text-align: left; }
th { font: 700 0.95rem var(--display); border-bottom: 2px solid var(--ink); }

kbd {
  font: 600 0.8em var(--mono);
  padding: 0.05em 0.4em;
  border: 1px solid var(--ink);
  border-bottom-width: 3px;
  border-radius: 3px;
  background: #f4f5f7;
  white-space: nowrap;
}

/* Shots are 960x540. Nearest-neighbour only helps when the screen upscales them. On a 1x screen or a phone
   the image covers fewer than 960 device pixels, and pixelated downscaling drops letters. */
@media (min-width: 46rem) and (min-resolution: 1.5dppx) {
  img.game { image-rendering: pixelated; }
}

.shot { margin: 2rem 0; }
.shot a { display: block; }
.shot img { display: block; width: 100%; height: auto; background: var(--night); }
.shot figcaption { margin-top: 0.55rem; color: var(--soft); font-size: 0.875rem; line-height: 1.5; font-style: italic; }
.shot figcaption code { font-style: normal; }

.pair { display: grid; gap: 0 1rem; margin: 2rem 0; }
.pair .shot { margin: 0 0 1.25rem; }
@media (min-width: 40rem) { .pair { grid-template-columns: 1fr 1fr; } }

/* The playable build: a live screen framed like a screenshot, with its controls in a caption line below. */
.game { margin: 2rem 0; }
.game .screen { position: relative; aspect-ratio: 16 / 9; background: var(--night); }
.game iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.game .bar { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 0.55rem; color: var(--soft); font-size: 0.875rem; }
.game button {
  font: 700 0.9rem var(--display);
  color: var(--ink);
  background: var(--paper-dim);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.game button:hover { border-color: var(--ember); color: var(--ember); }
.game:fullscreen,
.game:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  margin: 0;
  background: #000;
}
.game:fullscreen .screen,
.game:-webkit-full-screen .screen {
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: auto;
  width: 100%;
}
.game:fullscreen .bar,
.game:-webkit-full-screen .bar {
  flex: none;
  margin: 0;
  padding: 0.55rem 1rem;
  background: var(--paper);
}

/* Index: a contents page. The part number sits in the margin, the entry and its cover share the line. */
.postlist { list-style: none; padding: 0; margin: 3rem 0 0; border-top: 3px solid var(--ink); }
.postlist li { margin: 0; padding: 1.4rem 0; border-bottom: 1px solid var(--rule); }
.postlist .num { display: block; font: 800 1.75rem/1 var(--display); color: var(--ember); margin-bottom: 0.4rem; }
.postlist a { display: grid; gap: 0.9rem; text-decoration: none; }
.postlist .title { display: block; font: 800 1.45rem/1.12 var(--display); letter-spacing: -0.01em; text-wrap: balance; }
.postlist a:hover .title { text-decoration: underline; text-decoration-color: var(--ember); text-decoration-thickness: 0.08em; }
.postlist .summary { display: block; margin-top: 0.45rem; color: var(--soft); font-size: 1rem; line-height: 1.55; }
.postlist a:hover .summary { color: var(--soft); }
.postlist img { display: block; width: 100%; height: auto; background: var(--night); }
@media (min-width: 40rem) {
  .postlist a { grid-template-columns: 1fr 15rem; align-items: start; gap: 1.5rem; }
}

.pager { display: grid; gap: 1rem; margin-top: 3.5rem; padding-top: 1.25rem; border-top: 3px solid var(--ink); }
.pager a { display: block; font: 700 1.1rem/1.25 var(--display); text-decoration: none; }
.pager a:hover { text-decoration: underline; }
.pager span { display: block; margin-bottom: 0.3rem; font: italic 400 0.9rem var(--text); color: var(--soft); }
.pager .next { text-align: right; }
@media (min-width: 40rem) { .pager { grid-template-columns: 1fr 1fr; } .pager .next { grid-column: 2; } }

.head .note { color: var(--soft); font-size: 0.9rem; line-height: 1.5; }
.head .note p { margin: 0 0 0.35rem; }
.head .part { font: 800 1rem var(--display); color: var(--ember); }
.head .commits code { font-size: 0.85em; }
.head .note:empty { display: none; }
.head .note + h1 { margin-top: 0.75rem; }
main > .post .head { margin-top: 2.5rem; }
.head h1 { margin-top: 0; }

.footer { color: var(--soft); font-size: 0.875rem; line-height: 1.6; padding-bottom: 3rem; }
.footer p { border-top: 1px solid var(--rule); padding-top: 1.25rem; max-width: var(--measure); }

/* Wide screens: a printed page with an outer margin. Captions, part numbers and commit lists become margin
   notes beside the text, and screenshots run out past the text column into the bleed. */
@media (min-width: 64rem) {
  .page, .postlist {
    display: grid;
    grid-template-columns: [note] var(--gutter) [text] minmax(0, var(--measure)) [bleed] minmax(0, var(--bleed)) [end];
    column-gap: var(--gap);
  }
  .page > * { grid-column: text; }
  .footer p { margin-left: calc(var(--gutter) + var(--gap)); }

  .page > .head { grid-column: note / end; display: grid; grid-template-columns: subgrid; align-items: end; }
  .head .note { grid-column: note; text-align: right; padding-bottom: 0.35rem; }
  .head .note:empty { display: block; }
  .head h1 { grid-column: text / end; margin: 0; }
  .head .note + h1 { margin-top: 0; }
  .page > .head { margin-bottom: 2rem; }
  .intro > h1 { grid-column: text / end; }

  .page > .shot { grid-column: note / end; display: grid; grid-template-columns: subgrid; align-items: end; margin: 2.25rem 0; }
  .page > .shot > a { grid-column: text / end; grid-row: 1; }
  .page > .shot > figcaption { grid-column: note; grid-row: 1; margin: 0; text-align: right; }
  .page > .pair { grid-column: text / end; }
  .page > .game { grid-column: text / end; }
  .page > pre, .page > .highlight { grid-column: text / end; }

  .postlist { grid-column: note / end; }
  .postlist li { grid-column: note / end; display: grid; grid-template-columns: subgrid; }
  .postlist .num { grid-column: note; font-size: 3rem; letter-spacing: -0.03em; text-align: right; margin: -0.2rem 0 0; }
  .postlist a { grid-column: text / end; grid-template-columns: 1fr 17rem; }
}
