@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/assets/fonts/atkinson-latin-ext.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/assets/fonts/atkinson-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #1b1b1b;
  --ink-2: #3f3f3f;
  --muted: #5c5c5c;
  --rule: #d4d4d4;
  --soft: #f3f3f1;
  --pen: #1f3a93;
  --pen-dark: #13245e;
  --marker: #ffe45c;
  --focus: #ffdd33;
  --sans: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 36rem;
  /* Fluid sizing from small phones to desktop; rem limits preserve text zoom. */
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2rem);
  --section-space: clamp(2rem, 1.25rem + 3.75vw, 3.5rem);
  --layout-gap: clamp(1rem, 0.5rem + 2.5vw, 2rem);
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1.0625rem, 1rem + 0.3125vw, 1.1875rem);
  line-height: 1.55;
}

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

.wrap {
  max-width: 62rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Links and focus */

a {
  color: var(--pen);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--pen-dark);
  text-decoration-thickness: 3px;
}

a:focus-visible {
  outline: 3px solid transparent;
  color: #000;
  background: var(--focus);
  box-shadow: 0 -2px var(--focus), 0 4px #000;
  text-decoration: none;
}

summary:focus-visible {
  outline: 3px solid var(--focus);
  box-shadow: inset 0 0 0 2px #000;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -10rem;
  padding: 0.5rem 0.75rem;
  z-index: 10;
}

.skip:focus {
  top: 0.5rem;
}

/* Page chrome */

.masthead {
  border-bottom: 1px solid var(--rule);
}

.masthead .wrap {
  padding-block: 1rem;
}

.wordmark {
  display: inline-block;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.wordmark:hover {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 3px;
}

.site-footer {
  margin-top: clamp(2.5rem, 1.75rem + 3.75vw, 4rem);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9375rem;
}

.site-footer .wrap {
  padding-block: 1.5rem 2.5rem;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
}

.site-footer p {
  margin: 0;
}

.site-footer .disclaimer {
  max-width: 52rem;
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.site-footer a {
  display: inline-block;
  padding-block: 0.35rem;
}

.site-footer a + a {
  margin-left: 1.25rem;
}

/* Headings and text */

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  text-wrap: balance;
  scroll-margin-top: 1.5rem;
}

h1 {
  margin: clamp(2rem, 1.5rem + 2.5vw, 3rem) 0 1.5rem;
  font-size: clamp(1.75rem, 1.3125rem + 2.1875vw, 2.625rem);
  font-weight: 800;
  letter-spacing: -0.015em;
}

h2 {
  margin: clamp(2rem, 1.75rem + 1.25vw, 2.5rem) 0 0.75rem;
  font-size: clamp(1.375rem, 1.3125rem + 0.3125vw, 1.5rem);
  font-weight: 750;
}

h3 {
  margin: 2rem 0 0.5rem;
  font-size: clamp(1.125rem, 1.09375rem + 0.15625vw, 1.1875rem);
  font-weight: 750;
}

h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.0625rem;
}

.prose > * {
  max-width: var(--measure);
}

.chapter,
.prose {
  min-width: 0;
  overflow-wrap: anywhere;
}

.prose > .figure-wide {
  max-width: 46rem;
}

.prose p,
.prose li {
  text-wrap: pretty;
}

p {
  margin: 0 0 1rem;
}

strong {
  font-weight: 650;
}

.nb {
  white-space: nowrap;
}

/* Rules worth remembering are marked like with a highlighter. */
mark {
  color: inherit;
  font-weight: 650;
  background: linear-gradient(to bottom, transparent 0.62em, var(--marker) 0.62em, var(--marker) 1.28em, transparent 1.28em);
  background-size: 100% 1.55em;
  border-radius: 0.15em 0.45em 0.25em 0.5em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-inline: 0.12em;
  margin-inline: -0.12em;
}

.lede > p:first-child {
  font-size: clamp(1.1875rem, 1.09375rem + 0.46875vw, 1.375rem);
  line-height: 1.45;
}

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.4em;
}

li {
  margin-bottom: 0.45rem;
}

li::marker {
  color: var(--muted);
}

.prose ol > li {
  padding-left: 0.25em;
  margin-bottom: 0.75rem;
}

.prose ol > li::marker {
  color: var(--ink);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

code {
  padding: 0.05em 0.25em;
  border-radius: 3px;
  background: var(--soft);
  font-family: var(--mono);
  font-size: 0.86em;
}

.note {
  padding: 0.9rem 1.1rem;
  background: var(--soft);
  font-size: 0.9375em;
}

/* Home */

.figure.home-photo {
  max-width: 16rem;
  margin-top: 2.5rem;
}

@media (min-width: 60rem) {
  .home-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18rem;
    gap: 4rem;
    align-items: start;
  }

  .figure.home-photo {
    max-width: none;
    margin: 3.3rem 0 0;
  }
}

.home h1 {
  max-width: 18ch;
}

.home .lede {
  margin-bottom: 1rem;
}

.chapters {
  max-width: var(--measure);
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
  counter-reset: chapter;
  border-top: 1px solid var(--rule);
}

.chapters li {
  counter-increment: chapter;
  display: grid;
  grid-template-columns: 2rem 1fr;
  margin: 0;
  padding-block: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
}

.chapters li::before {
  content: counter(chapter);
  grid-row: span 2;
  padding-top: 0.2rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chapters a {
  justify-self: start;
  padding-block: 0.2rem 0.1rem;
  font-weight: 700;
  text-decoration: none;
}

.chapters .hint {
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.chapters a:hover {
  text-decoration: underline;
  text-decoration-thickness: 3px;
}

.after-contents {
  color: var(--ink-2);
}

/* Chapter pages */

.chapter-layout {
  display: block;
}

.sidebar {
  display: none;
}

@media (min-width: 60rem) {
  .chapter-layout {
    display: grid;
    grid-template-columns: 13.5rem minmax(0, 1fr);
    gap: 3.5rem;
  }

  .sidebar {
    display: block;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    padding-top: 3.35rem;
    font-size: 1rem;
  }

  .mobile-contents {
    display: none;
  }
}

.contents-title {
  margin: 0 0 0.75rem;
  font-weight: 750;
}

.contents-list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.contents-list li {
  margin: 0;
  padding-block: 0.3rem;
  line-height: 1.35;
}

.contents-list a {
  text-decoration: none;
}

.contents-list a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.contents-list [aria-current="page"] {
  font-weight: 750;
}


.contents-extra {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
}

.mobile-contents {
  border-bottom: 1px solid var(--rule);
}

.mobile-contents summary {
  padding-block: 0.8rem;
  font-weight: 750;
  cursor: pointer;
}

.mobile-contents summary span {
  margin-left: 0.4rem;
  color: var(--muted);
  font-weight: 400;
}

.mobile-contents nav {
  padding-bottom: 0.5rem;
}

.mobile-contents .contents-list li {
  padding: 0;
}

.mobile-contents .contents-list a,
.mobile-contents .contents-list [aria-current="page"] {
  display: block;
  padding-block: 0.6rem;
}

.mobile-contents .contents-extra a {
  display: inline-block;
  padding-block: 0.4rem;
}

.chapter h1 {
  max-width: 24ch;
}

.toc {
  max-width: var(--measure);
  margin: -0.25rem 0 2rem;
  font-size: 1rem;
}

.toc p {
  margin: 0 0 0.35rem;
  color: var(--muted);
}

.toc ul,
.toc ol {
  margin: 0;
}

.toc li {
  margin: 0;
}

.toc a {
  display: inline-block;
  padding-block: 0.3rem;
}

.chapter .prose > h2:first-child,
.chapter .prose > :first-child h2:first-child {
  margin-top: 0;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1rem, 0.75rem + 1.25vw, 1.5rem);
  max-width: var(--measure);
  margin-top: var(--section-space);
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.pager a {
  display: flex;
  flex: 1 1 max-content;
  min-width: 0;
  max-width: 100%;
  flex-direction: column;
  gap: 0.15rem;
  font-weight: 700;
  text-decoration: none;
}

.pager a:hover {
  text-decoration: underline;
  text-decoration-thickness: 3px;
}

.pager span {
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 400;
}

.pager .next {
  text-align: right;
}

/* Single page */

.single .part {
  margin-top: var(--section-space);
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
}

/* PDF page */

.back {
  margin: 2rem 0 0;
  font-size: 1rem;
}

.doc h1 {
  margin-top: 1rem;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: 3px;
  background: var(--pen);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  background: var(--pen-dark);
  color: #fff;
}

.pdf-pages {
  display: grid;
  gap: var(--layout-gap);
  max-width: 46rem;
  margin: 2rem 0;
  padding: 0;
  list-style: none;
}

.pdf-pages li {
  margin: 0;
}

.pdf-pages .figure {
  margin: 0;
}

.pdf-pages img {
  border: 1px solid var(--rule);
}

/* Figures */

.figure {
  margin: 1.75rem 0 2rem;
}

.figure img {
  width: 100%;
}

figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.credit {
  white-space: nowrap;
}

.figure-portrait {
  max-width: 26rem;
}

.zoom {
  display: block;
}

.marked {
  position: relative;
  display: block;
}

.pen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.pen path {
  fill: none;
  stroke: var(--pen);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.zoom:focus-visible {
  box-shadow: 0 0 0 3px var(--focus), 0 0 0 6px #000;
}

.figure-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: clamp(1rem, 0.75rem + 1.25vw, 1.5rem);
  margin: 1.5rem 0 2rem;
}

.figure-pair .figure {
  margin: 0;
}

.figure-pair img {
  aspect-ratio: 1;
  object-fit: contain;
}

.diagram svg {
  max-width: 26rem;
  font-family: var(--sans);
  font-size: 17px;
}

.diagram .node rect {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 1.5;
}

.diagram .node-key rect {
  fill: var(--soft);
  stroke-width: 2.5;
}

.diagram .node text {
  fill: var(--ink);
  font-weight: 700;
}

.diagram .wires path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
}

.diagram .wires .wifi {
  stroke-dasharray: 3 4;
}

.diagram .label {
  fill: var(--ink-2);
  font-size: 16px;
}

/* On narrow phones the diagram uses the full screen width, so its labels stay readable. */
@media (max-width: 26rem) {
  .diagram svg {
    width: calc(100% + 2 * var(--gutter));
    max-width: none;
    margin-inline: calc(-1 * var(--gutter));
  }
}

.prose > .gallery {
  max-width: 46rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 0.75rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 36rem) {
  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem 1rem;
  }
}

.gallery li {
  margin: 0;
}

.gallery figure {
  margin: 0;
}

.gallery a {
  display: block;
}

.gallery img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.gallery figcaption {
  margin-top: 0.4rem;
  font-size: 0.875rem;
}

.gallery a:focus-visible {
  box-shadow: 0 0 0 3px var(--focus), 0 0 0 6px #000;
}

.not-found-photo {
  max-width: 20rem;
}

/* Cappuccino, the animated cat (src/assets/cappuccino.js) */

.cat {
  position: absolute;
  z-index: 20;
  pointer-events: none;
}

.cat-body {
  transform-origin: 50% 100%;
}

.cat canvas {
  display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  pointer-events: auto;
  cursor: pointer;
}

.cat.sleeping canvas {
  transform-origin: 50% 100%;
  animation: cat-breathe 2.6s ease-in-out infinite;
}

@keyframes cat-breathe {
  50% {
    transform: scaleY(1.06);
  }
}

.cat-z {
  position: absolute;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  animation: cat-z 2.2s ease-out forwards;
}

@keyframes cat-z {
  from {
    opacity: 0;
    transform: translate(0, 0);
  }

  20% {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translate(10px, -26px);
  }
}

.cat-say {
  position: absolute;
  padding: 0.1rem 0.45rem;
  border: 1.5px solid var(--ink);
  border-radius: 0.6rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* Print */

@media print {
  body {
    font-size: 11pt;
  }

  .skip,
  .wordmark,
  .sidebar,
  .mobile-contents,
  .pager,
  .footer-meta,
  .gallery,
  .home-photo,
  .cat {
    display: none;
  }

  .masthead {
    display: none;
  }

  .site-footer {
    margin-top: 2rem;
    border-top: 1px solid #999;
  }

  .site-footer .wrap {
    padding: 0.75rem 0 0;
  }

  .site-footer .disclaimer {
    margin: 0;
    color: inherit;
  }

  .prose a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }

  a {
    color: inherit;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  .figure,
  .note {
    break-inside: avoid;
  }

  mark {
    background: none;
    text-decoration: underline;
  }
}
