@font-face {
  font-family: "General Sans";
  src: url("./GeneralSans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #151515;
  --inactive-link: #d9d9d9;
  --edge: clamp(14px, 1.1vw, 26px);
  --display-size: clamp(15px, 1.78vw, 30px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: white;
  font: 500 var(--display-size)/1.04 "General Sans", Arial, sans-serif;
  letter-spacing: -.008em;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, ul, ol { margin: 0; }
a { color: inherit; }
button { font: inherit; letter-spacing: inherit; }

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

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

.stage {
  position: relative;
  min-height: 100vh;
  min-height: max(100svh, 24rem);
  padding: var(--edge);
}

.book-stage { height: 100dvh; min-height: 0; overflow: clip; }

.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.site-header:has(.release-banner:not([hidden])) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  row-gap: .7rem;
}
.site-header .wordmark { justify-self: start; }
.release-banner { grid-column: 1 / -1; min-width: 0; }
.release-banner a:hover .release-title, .release-banner a:focus-visible .release-title { text-decoration: underline; }
.edition-list a:has(.new-book-label:not([hidden])) { display: flex; align-items: center; gap: .35em; }
.edition-list .new-book-label:not([hidden]) { max-width: 40%; }
.edition-name { min-width: 0; overflow-wrap: anywhere; }

.book-stage .site-header { pointer-events: none; }
.book-stage .site-header a { pointer-events: auto; }

.wordmark, .primary-nav a, .edition-list a, .purchase, .cover-tile {
  text-decoration: none;
}

.wordmark { display: inline-block; }

.primary-nav, .edition-list {
  display: flex;
  flex-direction: column;
}

.primary-nav { align-items: flex-end; text-align: right; }
.edition-list { align-items: flex-start; }

.primary-nav a, .edition-list a { color: var(--inactive-link); }

.primary-nav a[aria-current], .edition-list a[aria-current],
.primary-nav a:hover, .edition-list a:hover, .primary-nav a:focus-visible,
.edition-list a:focus-visible { color: var(--ink); }

.edition-list {
  position: absolute;
  bottom: var(--edge);
  left: var(--edge);
  max-width: 46%;
}

.purchase, .book-actions {
  position: absolute;
  right: var(--edge);
  bottom: var(--edge);
  white-space: nowrap;
}

.book-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .45em;
}
.book-actions .purchase, .book-previews .purchase { position: static; }
.preview-link { font-size: .78em; text-underline-offset: .16em; }

.purchase-arrow {
  position: relative;
  display: inline-block;
  width: .8em;
  height: .64em;
  vertical-align: -.015em;
}
.purchase-arrow::before, .purchase-arrow::after {
  content: "";
  position: absolute;
  right: .06em;
  top: 50%;
}
.purchase-arrow::before {
  width: .72em;
  border-top: .085em solid;
  transform: translateY(-50%);
}
.purchase-arrow::after {
  width: .37em;
  height: .37em;
  border-top: .085em solid;
  border-right: .085em solid;
  transform: translateY(-50%) rotate(45deg);
}

.purchase:hover, .cover-tile:hover span, .destination-return:hover {
  text-decoration: underline;
  text-underline-offset: .12em;
}

.book-visual {
  /* 420px square in the reference's 480 × 640 composition. */
  --viewer-size: min(65.625svh, 87.5vw);
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--viewer-size);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.book-viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.book-artwork, .book-poster, .book-viewer canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.book-poster { object-fit: contain; }
/* Project the uploaded front into the viewer's opening pose, including its 1.1 zoom. */
.book-artwork:has(> .uploaded-cover) { perspective: calc(var(--viewer-size) * 1.797); }
.book-poster.uploaded-cover {
  inset: 11.71% auto auto 24.19%;
  width: 54%;
  height: 77.5%;
  object-fit: fill;
  background: #eee6d7;
  transform: translateZ(calc(var(--viewer-size) * .0313)) rotateX(-.4492rad) rotateY(.425rad) rotateX(.2431rad);
}
.book-artwork:has(> .uploaded-cover)::before {
  content: "";
  position: absolute;
  inset: 0;
  /* The four projected corners of the binding at the same camera angle. */
  clip-path: polygon(18% 13.33%, 19.1% 13.26%, 30.04% 93.96%, 28.86% 92.57%);
  background: linear-gradient(82deg, #d4c9b9 18%, #ebe2d5 30%);
}
.book-artwork:has(> .sized-jacket) { perspective: calc(var(--viewer-size) * 1.797); }
.sized-jacket {
  position: absolute; left: 50%; top: 50.5%;
  width: calc(var(--viewer-size) * var(--jacket-width));
  height: calc(var(--viewer-size) * var(--jacket-height));
  --depth: calc(var(--viewer-size) * var(--jacket-depth));
  transform-style: preserve-3d;
  transform: translate(-50%, -50%) rotateX(-.4492rad) rotateY(.425rad) rotateX(.2431rad);
}
.sized-jacket .book-poster { object-fit: fill; transform: translateZ(calc(var(--depth) / 2)); }
.poster-spine {
  position: absolute; inset: 0 auto 0 0; width: var(--depth);
  background: #e3d9c7; transform-origin: left center;
  transform: translateZ(calc(-.5 * var(--depth))) rotateY(-90deg);
}
.poster-spine img { display: block; width: 100%; height: 100%; }
.book-viewer[data-ready="true"] .sized-jacket { visibility: hidden; }
.book-viewer canvas { opacity: 0; }
.book-viewer[data-ready="true"] canvas { opacity: 1; }
.book-viewer[data-ready="true"] .book-poster { opacity: 0; }
.book-viewer[data-ready="true"] .book-artwork::before { opacity: 0; }

/* Keep the hint clear of the edition list in a narrow desktop window. */
@media (max-width: 700px) and (hover: hover) and (pointer: fine) {
  .book-rotation-hint { top: auto; bottom: 100%; }
}

.info-stage { display: flex; flex-direction: column; }
.page-copy { max-width: 68%; line-height: 1.06; }
.page-copy p { text-indent: 1.6em; }
.page-copy p + p { margin-top: .64em; }
.about-copy { margin-top: auto; padding-block: 2.5em max(1.7em, 6.4svh); }
.archive-copy { margin-top: max(2em, calc(27svh - 4.3em - var(--edge))); }
.archive-copy ul { padding: 0; list-style: none; }
.archive-copy a { display: table; margin-top: .4em; text-underline-offset: .1em; }
.archive-copy p + a { margin-top: .9em; }

.catalog-stage { display: flex; flex-direction: column; }
.empty-catalog { margin: auto; text-align: center; }
.empty-catalog + .cover-grid { display: none; }
.book-previews {
  width: min(100%, 42rem);
  margin: clamp(2.5rem, 8svh, 6rem) auto;
}
.book-previews > a:first-child { font-size: .78em; text-underline-offset: .16em; }
.book-previews h1 { margin: 1em 0; font: inherit; font-size: 1.4em; }
.book-previews h1 span { display: block; margin-top: .4em; font-size: .65em; color: #646464; }
.book-previews img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 1.2em;
  border: 1px solid #e6e6e6;
}
.cover-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: center;
  gap: clamp(2rem, 5svh, 4rem) clamp(1.25rem, 2.4vw, 3rem);
  width: min(100%, 80rem);
  margin: auto;
  padding-block: clamp(2rem, 5svh, 4rem) max(3.5rem, 7svh);
}

.cover-tile {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: .65em;
  text-align: center;
  font-size: clamp(14px, 1.05vw, 19px);
  line-height: 1.15;
  letter-spacing: -.025em;
}

.cover-tile img {
  display: block;
  width: 100%;
  height: clamp(8.5rem, 23svh, 16rem);
  object-fit: contain;
}
.cover-tile span { overflow-wrap: anywhere; }

@media (min-width: 701px), (hover: hover) and (pointer: fine) {
  .edition-list a {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .edition-list .edition-name { overflow: hidden; text-overflow: ellipsis; }
}

.destination-dialog, .destination-page {
  color: var(--ink);
  background: #fff;
  font-size: clamp(16px, 1.3vw, 21px);
  line-height: 1.28;
  letter-spacing: -.025em;
}

.destination-dialog {
  max-width: min(28rem, calc(100% - 2rem));
  border: 1px solid var(--ink);
  padding: clamp(1.4rem, 3vw, 2.5rem);
}

.destination-dialog::backdrop { background: rgb(0 0 0 / 16%); }
.destination-dialog h2, .destination-page h1 { font: inherit; font-size: 1.35em; }
.destination-dialog p, .destination-page p { margin: .8em 0 1.2em; }
.destination-dialog button, .destination-return {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0;
  color: inherit;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.destination-page {
  display: grid;
  flex: 1;
  justify-items: start;
  align-content: center;
  padding: max(var(--edge), 5vw);
}

@media (min-width: 701px) {
  .site-header { top: -.12em; }
  .purchase, .book-actions { bottom: calc(var(--edge) + .1em); }
  .about-copy p + p { margin-top: .9em; }
  .archive-copy a + a { margin-top: .5em; }
}

@media (prefers-contrast: more) {
  :root { --inactive-link: #626262; }
}

@media (max-width: 700px) {
  :root { --edge: 16px; --display-size: clamp(16px, 4.1vw, 21px); }
  .stage:not(.book-stage) { min-height: 100svh; }
  .primary-nav a { padding-block: .13em; }
  .info-stage { min-height: max(100svh, 25rem); }
  .page-copy { max-width: 100%; line-height: 1.16; }
  .about-copy { padding-block: 3em 3.75em; }
  .archive-copy { margin-top: clamp(2.5em, 10svh, 5em); margin-bottom: 3em; }
  .archive-copy a { padding-block: .15em; }
  .cover-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 4rem; }
  .cover-tile img { height: clamp(7rem, 40vw, 14rem); }
}

@media (max-width: 700px) and (hover: none), (max-width: 700px) and (pointer: coarse) {
  .book-stage {
    display: grid;
    height: auto;
    min-height: 100svh;
    overflow: visible;
    align-content: start;
    grid-template-areas: "hero" "buy" "editions";
    grid-template-columns: minmax(0, 1fr);
  }
  .book-stage .site-header { grid-area: hero; align-self: start; }
  .book-visual {
    grid-area: hero;
    position: static;
    margin: calc(50svh - var(--edge) - var(--viewer-size) / 2) auto 1.9rem;
    transform: none;
  }
  .book-actions {
    grid-area: buy;
    position: static;
    justify-self: end;
  }
  .book-actions a {
    padding-block: .35em;
  }
  .edition-list {
    grid-area: editions;
    position: static;
    max-width: 100%;
    margin-top: clamp(2rem, 7svh, 4rem);
  }
  .edition-list a { padding-block: .2em; }
}

@media (prefers-reduced-motion: reduce) {
  .book-viewer[data-ready="true"] .sized-jacket { visibility: visible; }
  .book-viewer[data-ready="true"] canvas { opacity: 0; }
  .book-viewer[data-ready="true"] .book-poster { opacity: 1; }
  .book-viewer[data-ready="true"] .book-artwork::before { opacity: 1; }
}
