:root {
  --paper: #f3f2ed;
  --ink: #171917;
  --muted: #626761;
  --line: #c8cac3;
  --accent: #f04d2d;
  --accent-soft: rgba(240, 77, 45, 0.1);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(23, 25, 23, 0.06) calc(100% - 1px)) 0 0 / 9rem 100%,
    var(--paper);
  font-family: var(--serif);
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 20;
  padding: .65rem .9rem;
  background: var(--ink);
  color: var(--paper);
  font: 700 .75rem/1 var(--sans);
  text-decoration: none;
}

.skip-link:focus { top: 1rem; }

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 10;
  background: transparent;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transform-origin: left;
}

.masthead {
  position: absolute;
  inset: 1.5rem 1.75rem auto;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  font-family: var(--sans);
}

.wordmark {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  color: var(--ink);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .12em;
  line-height: .95;
  text-decoration: none;
  text-transform: uppercase;
}

.domain {
  margin: 0;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.cover {
  position: relative;
  min-height: 100svh;
  display: grid;
  align-content: center;
  grid-template-columns: minmax(1.25rem, 1fr) minmax(0, 52rem) minmax(1.25rem, 1fr);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.cover::after {
  content: "";
  position: absolute;
  width: min(44vw, 36rem);
  aspect-ratio: 1;
  right: -14vw;
  top: 50%;
  border: 1px solid var(--line);
  border-radius: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 0 3rem var(--paper), 0 0 0 calc(3rem + 1px) var(--line), 0 0 0 8rem var(--paper), 0 0 0 calc(8rem + 1px) var(--line);
  opacity: .7;
}

.cover h1 {
  grid-column: 2;
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(4.6rem, 14vw, 10.5rem);
  font-weight: 800;
  letter-spacing: -.075em;
  line-height: .76;
}

.cover h1::first-line { color: var(--accent); }

.dek {
  grid-column: 2;
  position: relative;
  z-index: 1;
  max-width: 26rem;
  margin: 2.75rem 0 0 .35rem;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.4;
}

.puzzle-link {
  grid-column: 2;
  position: relative;
  z-index: 1;
  justify-self: start;
  margin: 1.65rem 0 0 .35rem;
  padding: .55rem 0;
  border-bottom: 2px solid var(--accent);
  font: 800 .75rem/1.3 var(--sans);
  letter-spacing: .07em;
  text-decoration: none;
  text-transform: uppercase;
}

.puzzle-link span { color: var(--accent); }
.puzzle-link:hover, .puzzle-link:focus-visible { color: var(--accent); }

.begin {
  grid-column: 2;
  position: absolute;
  bottom: 2rem;
  left: max(1.25rem, calc((100vw - 52rem) / 2));
  z-index: 1;
  display: inline-flex;
  gap: .65rem;
  align-items: center;
  color: var(--ink);
  font: 700 .7rem/1 var(--sans);
  letter-spacing: .1em;
  text-decoration: none;
  text-transform: uppercase;
}

.begin span { color: var(--accent); font-size: 1rem; }

.cover-mark {
  position: absolute;
  right: 9vw;
  bottom: 8vh;
  z-index: 1;
  display: grid;
  gap: .55rem;
  width: clamp(5rem, 9vw, 8rem);
}

.cover-mark i {
  display: block;
  height: 2px;
  background: var(--accent);
  transform-origin: right;
}

.cover-mark i:nth-child(2) { transform: scaleX(.82); }
.cover-mark i:nth-child(3) { transform: scaleX(.64); }
.cover-mark i:nth-child(4) { transform: scaleX(.46); }
.cover-mark i:nth-child(5) { transform: scaleX(.28); }

.reading-layout {
  display: grid;
  grid-template-columns: minmax(11rem, 1fr) minmax(0, 39rem) minmax(2rem, 1fr);
  column-gap: clamp(2rem, 7vw, 8rem);
  padding: 0 2rem;
}

.chapter-rail {
  position: sticky;
  top: 2.5rem;
  align-self: start;
  justify-self: end;
  width: 10.5rem;
  max-height: calc(100vh - 5rem);
  margin-top: 5rem;
  font-family: var(--sans);
}

.chapter-rail > p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.chapter-rail ul,
.mobile-toc ul { margin: 0; padding: 0; list-style: none; }

.chapter-rail li { margin: 0 0 .85rem; }

.chapter-rail a {
  display: block;
  border-left: 2px solid var(--line);
  padding-left: .85rem;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .01em;
  line-height: 1.25;
  text-decoration: none;
  transition: border-color 180ms ease, color 180ms ease;
}

.chapter-rail a:hover,
.chapter-rail a:focus-visible,
.chapter-rail a.active {
  border-color: var(--accent);
  color: var(--ink);
}

.essay {
  grid-column: 2;
  min-width: 0;
  padding: 1rem 0 8rem;
  counter-reset: chapter;
}

.essay h1 {
  counter-increment: chapter;
  position: relative;
  margin: 8.5rem 0 3.25rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--ink);
  font-family: var(--sans);
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  font-weight: 800;
  letter-spacing: -.055em;
  line-height: .96;
}

.essay h1::before {
  content: "0" counter(chapter);
  position: absolute;
  top: -2.2rem;
  left: 0;
  color: var(--accent);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .12em;
}

.essay h1:first-child { margin-top: 5rem; }

.essay p {
  margin: 0 0 1.35em;
  font-size: clamp(1.05rem, 1.5vw, 1.14rem);
}

.essay hr {
  width: 2.5rem;
  margin: 3.8rem 0;
  border: 0;
  border-top: 2px solid var(--accent);
}

.essay strong {
  font-weight: 700;
}

.essay em { font-style: italic; }

.mobile-toc { display: none; }

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
}

footer a {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
}

footer span { color: var(--accent); }

.footer-contact { min-width: 0; }

.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.4rem;
}
.footer-contact p {
  margin: 0 0 .5rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}
.footer-contact a {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: .2em;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  body { background: var(--paper); }
  .masthead { inset: 1.25rem; }
  .cover { grid-template-columns: 1.25rem minmax(0, 1fr) 1.25rem; }
  .cover::after { width: 65vw; right: -33vw; }
  .cover h1 { font-size: clamp(4.2rem, 23vw, 7rem); }
  .cover-mark { right: 1.25rem; bottom: 5.5rem; }
  .begin { left: 1.25rem; }
  .reading-layout { display: block; padding: 0 1.25rem; }
  .chapter-rail { display: none; }
  .mobile-toc {
    display: block;
    margin: 0;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    font-family: var(--sans);
  }
  .mobile-toc summary {
    cursor: pointer;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
  }
  .mobile-toc nav { padding: 1rem 0 .2rem; }
  .mobile-toc li { margin: .75rem 0; }
  .mobile-toc a { color: var(--muted); font-size: .78rem; text-decoration: none; }
  .essay { max-width: 39rem; margin: 0 auto; padding-bottom: 5rem; }
  .essay h1 { margin-top: 6.5rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101210;
    --ink: #e9ece5;
    --muted: #9fa69d;
    --line: #353a34;
    --accent: #ff6547;
    --accent-soft: rgba(255, 101, 71, 0.12);
  }
  body {
    background:
      linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(233, 236, 229, 0.035) calc(100% - 1px)) 0 0 / 9rem 100%,
      var(--paper);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
