@property --mono {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

[data-edition="book"] {
  color-scheme: dark;
  background: var(--desk);

  /* Generated by tools/css_tokens.py */
  --burst: polygon(50.00% 0.00%, 54.98% 5.78%, 61.13% 1.25%, 64.70% 8.00%, 71.69% 4.95%, 73.68% 12.32%, 81.17% 10.91%, 81.47% 18.53%, 89.09% 18.83%, 87.68% 26.32%, 95.05% 28.31%, 92.00% 35.30%, 98.75% 38.87%, 94.22% 45.02%, 100.00% 50.00%, 94.22% 54.98%, 98.75% 61.13%, 92.00% 64.70%, 95.05% 71.69%, 87.68% 73.68%, 89.09% 81.17%, 81.47% 81.47%, 81.17% 89.09%, 73.68% 87.68%, 71.69% 95.05%, 64.70% 92.00%, 61.13% 98.75%, 54.98% 94.22%, 50.00% 100.00%, 45.02% 94.22%, 38.87% 98.75%, 35.30% 92.00%, 28.31% 95.05%, 26.32% 87.68%, 18.83% 89.09%, 18.53% 81.47%, 10.91% 81.17%, 12.32% 73.68%, 4.95% 71.69%, 8.00% 64.70%, 1.25% 61.13%, 5.78% 54.98%, 0.00% 50.00%, 5.78% 45.02%, 1.25% 38.87%, 8.00% 35.30%, 4.95% 28.31%, 12.32% 26.32%, 10.91% 18.83%, 18.53% 18.53%, 18.83% 10.91%, 26.32% 12.32%, 28.31% 4.95%, 35.30% 8.00%, 38.87% 1.25%, 45.02% 5.78%);

  & body {
    margin: 0;
    user-select: none;
    -webkit-user-select: none;
  }

  & main,
  & .edition-note {
    display: none;
  }

  /* Desk */

  & .desk {
    box-sizing: border-box;
    min-height: 100dvh;
    padding-top: 2.75rem;
    display: grid;
    grid-template-rows: 1fr 3rem;
    place-items: center;
    overflow: clip;
    -webkit-tap-highlight-color: transparent;
  }

  & .home {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    color: color-mix(in srgb, var(--paper) 72%, transparent);
    transition: color 0.2s;
  }

  & .home svg {
    width: 1.75rem;
    height: 1.75rem;
    fill: currentColor;
    transition: transform 0.5s cubic-bezier(0.3, 1.5, 0.5, 1);
  }

  & .home:hover svg,
  & .home:focus-visible svg {
    transform: rotate(45deg);
  }

  & .home[aria-current] {
    color: color-mix(in srgb, var(--paper) 26%, transparent);
    pointer-events: none;
  }

  & .home:hover,
  & .home:focus-visible {
    color: var(--paper);
  }

  & .desk :focus-visible {
    outline: 1.5px solid var(--red);
    outline-offset: 3px;
  }

  & .stock {
    display: none;
  }

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

  /* Book */

  & .book {
    position: relative;
    width: calc(var(--pw) * 2);
    height: var(--ph);
    touch-action: pan-y pinch-zoom;
    will-change: transform;
  }

  & .book.single {
    width: var(--pw);
  }

  & .book[data-zone] {
    cursor: pointer;
  }

  & .stage {
    position: absolute;
    top: 0;
    left: var(--pw);
  }

  & .single .stage {
    left: 0;
    clip-path: inset(-200vh -200vw -200vh 0);
  }

  /* Page stack: a few stepped bars either side, drawn rather than rendered */

  & .block {
    --bar: clamp(4px, calc(var(--pw) * 0.012), 6px);
    --gap: clamp(2px, calc(var(--pw) * 0.0045), 2.5px);
    position: absolute;
    top: 0;
    height: var(--ph);
    display: flex;
    align-items: center;
  }

  & .block.l {
    right: 100%;
    flex-direction: row-reverse;
  }

  & .block.r {
    left: 100%;
  }

  & .block i {
    --on: clamp(0, var(--bars, 0) - var(--n), 1);
    width: calc(var(--on) * var(--bar));
    height: calc(100% - (var(--n) + 1) * 2 * (var(--bar) + var(--gap)));
    background: var(--paper);
  }

  & .block.l i:not(:first-child) {
    margin-right: calc(var(--on) * var(--gap));
  }

  & .block.r i:not(:first-child) {
    margin-left: calc(var(--on) * var(--gap));
  }

  & .single .block {
    --bar: 3px;
    --gap: 2px;
  }

  & .single .block.l i {
    background: color-mix(in srgb, var(--paper) 42%, transparent);
  }

  /* Turning leaves */

  & .slot,
  & .rig-face,
  & .rig-under {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--pw);
    height: var(--ph);
  }

  & .slot,
  & .rig-face {
    container-type: size;
  }

  & .slot {
    will-change: transform;
  }

  & .slot.left,
  & .rig-under[data-dir="-1"] {
    left: calc(var(--pw) * -1);
  }

  & .rig-clip {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--clip);
    height: var(--clip);
    overflow: hidden;
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: none;
  }

  & .rig-face {
    overflow: hidden;
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: auto;
  }

  & .rig-under {
    overflow: hidden;
    pointer-events: none;
  }

  /* Crease is a ruled line on the flap. The cast is a sheared flat tone on the page beneath, pinned to that crease. */

  & .rig-band {
    position: absolute;
    top: 0;
    left: 0;
    width: 64px;
    height: var(--clip);
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: none;
  }

  & .rig-band.curl {
    background: var(--ink);
  }

  & .rig-band.cast {
    background: linear-gradient(
      to right,
      color-mix(in srgb, var(--ink) 50%, transparent) 0 34%,
      color-mix(in srgb, var(--ink) 18%, transparent) 34% 70%,
      color-mix(in srgb, var(--ink) 0%, transparent) 70%
    );
  }

  /* Page */

  & .page {
    --hair: max(1.25px, 0.26cqw);
    --rule: 1cqw;
    --line: max(1.5px, 0.32cqw);

    position: absolute;
    inset: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 17cqw 10cqw 10.5cqw 11.5cqw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--paper);
    box-shadow: inset 0 0 0 var(--line) var(--ink);
    color: var(--ink);
    font: 400 3.6cqw / 1.4 var(--text);
    font-kerning: normal;
    font-variant-numeric: oldstyle-nums;
    -webkit-font-smoothing: antialiased;
  }

  & .page.verso {
    padding-inline: 10cqw 11.5cqw;
  }

  & .single .page {
    font-size: 3.9cqw;
  }

  & .page .book-only[hidden] {
    display: none;
  }

  & .plain-only {
    display: none;
  }

  & .page ::selection {
    background: color-mix(in srgb, var(--ink) 18%, transparent);
  }

  & .page :focus-visible {
    outline: var(--hair) solid var(--red);
    outline-offset: 0.6cqw;
  }

  & .page[tabindex="-1"]:focus,
  & .page [tabindex="-1"]:focus {
    outline: none;
  }

  & .furniture {
    position: absolute;
    inset: 0 10cqw auto 11.5cqw;
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: flex-end;
  }

  & .verso .furniture {
    inset-inline: 10cqw 11.5cqw;
    flex-direction: row;
  }

  & .folio {
    box-sizing: border-box;
    min-width: 10.4cqw;
    padding: 4.6cqw 1.8cqw 1.7cqw;
    background: var(--ink);
    color: var(--paper);
    font: 700 5.8cqw / 1 var(--text);
    font-variant-numeric: lining-nums;
    text-align: center;
  }

  & .head {
    padding-bottom: 1.8cqw;
    font: 500 1.95cqw / 1 var(--caps);
    letter-spacing: 0.22em;
    text-transform: uppercase;
  }

  & .recto .head .of-book,
  & .verso .head .of-page {
    display: none;
  }

  & .page h2 {
    margin: 0 0 3.4cqw;
    padding-bottom: 3.5cqw;
    background:
      linear-gradient(var(--ink) 0 0) left bottom / 100% var(--hair) no-repeat,
      linear-gradient(var(--ink) 0 0) left calc(100% - 0.95cqw) / 100% var(--rule) no-repeat;
    font: 700 6.4cqw / 1.05 var(--text);
    letter-spacing: -0.012em;
    text-wrap: balance;
  }

  & .page p {
    margin: 0;
    text-align: justify;
    text-indent: 1.5em;
    text-wrap: pretty;
    hyphens: auto;
    hyphenate-limit-chars: 6 3 3;
  }

  & .page h2 + p,
  & .page p:first-child,
  & .page .furniture + p {
    text-indent: 0;
  }

  & .page a {
    color: inherit;
  }

  /* Choices */

  & .choices {
    margin: auto 0 0;
    padding: 3.2cqw 0 0;
    border-top: var(--hair) solid var(--ink);
    display: grid;
    gap: 2.3cqw;
    list-style: none;
    font-style: italic;
    line-height: 1.32;
  }

  & .choices li {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    padding-left: 16%;
    text-align: right;
    text-wrap: balance;
  }

  & .book:not(.single) .single-only {
    display: none;
  }

  & .choices a {
    display: block;
    text-decoration: none;
    outline: none;
  }

  & .choices b {
    font-style: normal;
    font-weight: 400;
    transition: color 0.18s;
  }

  & .choices a:hover b,
  & .choices a:focus-visible b {
    color: var(--red);
  }

  & .choices [data-turn] b {
    display: inline-block;
    min-width: 1.15em;
    margin-left: 0.12em;
    padding: 0.04em 0.34em 0.1em;
    background: var(--ink);
    color: var(--paper);
    font-weight: 700;
    font-variant-numeric: lining-nums;
    line-height: 1.12;
    text-align: center;
    transition: background-color 0.18s;
  }

  & .choices a:hover [data-turn] b,
  & .choices a:focus-visible [data-turn] b {
    background: var(--red);
    color: var(--paper);
  }

  & .fist {
    position: absolute;
    top: 0.12em;
    left: 0;
    width: 2.3em;
    height: 1.15em;
    fill: currentColor;
    opacity: 0;
    transform: translateX(-0.9em);
    transition: opacity 0.16s, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  & .choices a:hover .fist,
  & .choices a:focus-visible .fist {
    opacity: 1;
    transform: none;
  }

  & .page .the-end {
    margin: auto;
    font-size: 1.5em;
    font-weight: 700;
    text-indent: 0;
  }

  & #end .choices {
    margin: 0;
    padding: 0;
    border: 0;
  }

  /* Contents */

  & .key {
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.25cqw;
    list-style: none;
  }

  & .key a {
    display: grid;
    grid-template-columns: 2.5em 1fr;
    align-items: baseline;
    text-decoration: none;
  }

  & .key .num {
    font-weight: 700;
    font-variant-numeric: lining-nums tabular-nums;
    transition: color 0.18s;
  }

  & .key a:hover .num,
  & .key a:focus-visible .num {
    color: var(--red);
  }

  /* Figures */

  & .plate figure {
    position: relative;
    margin: 0.4cqw 0.5cqw 0;
  }

  & .shot {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
  }

  & .shot:hover .screen,
  & .shot:focus-visible .screen {
    outline-color: var(--red);
  }

  & .screen {
    position: relative;
    display: block;
    border: var(--hair) solid var(--ink);
    outline: 0.55cqw solid var(--ink);
    outline-offset: 0.75cqw;
    margin: 1.3cqw;
    overflow: hidden;
    background: #fff;
  }

  & .screen img {
    --mono: 1;
    display: block;
    width: 100%;
    height: auto;
    filter: grayscale(var(--mono));
    transition: --mono 0.45s ease;
  }

  & .plate figure:hover img,
  & .plate figure:focus-within img,
  & .resume:hover img,
  & .resume:focus-visible img {
    --mono: 0;
  }

  & .tall .screen {
    width: 62%;
    margin-inline: auto;
  }

  & .plate figcaption {
    margin-top: 3.4cqw;
    font-size: 0.88em;
    font-style: italic;
    text-align: center;
  }

  & .plate figcaption::before {
    content: "Fig. " attr(data-plate) ".";
    margin-right: 0.7em;
    font: 500 0.7em / 1 var(--caps);
    letter-spacing: 0.2em;
    text-transform: uppercase;
  }

  & .plate figcaption a {
    text-decoration: none;
  }

  & .plate figcaption a:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--hair);
    text-underline-offset: 0.2em;
  }

  & .stat {
    margin: auto 0 0;
    padding: 5cqw 0 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 1.1cqw 3.2cqw;
    align-items: baseline;
    background:
      linear-gradient(var(--ink) 0 0) left top / 100% var(--rule) no-repeat,
      linear-gradient(var(--ink) 0 0) left 1.7cqw / 100% var(--hair) no-repeat;
    font-size: 0.92em;
    line-height: 1.3;
  }

  & .stat dt {
    font: 500 0.66em / 1 var(--caps);
    letter-spacing: 0.2em;
    text-transform: uppercase;
  }

  & .stat dt::after {
    content: ":";
  }

  & .stat dd {
    margin: 0;
    overflow-wrap: anywhere;
  }

  & .stat a {
    text-decoration-thickness: var(--hair);
    text-underline-offset: 0.22em;
  }

  & .stat a:hover {
    color: var(--red);
  }

  & .sticker {
    position: absolute;
    z-index: 1;
    top: -3.4cqw;
    right: -4.6cqw;
    width: 23cqw;
    aspect-ratio: 1;
    display: grid;
    align-content: center;
    justify-items: center;
    background: var(--red);
    clip-path: var(--burst);
    color: var(--paper);
    font: 600 2.05cqw / 1.2 var(--caps);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transform: rotate(9deg);
    pointer-events: none;
  }

  & .sticker b {
    font: 700 5.6cqw / 0.95 var(--text);
    font-variant-numeric: lining-nums;
    letter-spacing: 0;
  }

  & .sticker i {
    max-width: 15cqw;
    margin-top: 0.7cqw;
    padding-top: 0.8cqw;
    border-top: var(--hair) solid currentColor;
    font-size: 0.72em;
    font-style: normal;
    letter-spacing: 0.1em;
    text-align: center;
  }

  /* Record sheet */

  & .field {
    margin: 0 0 5cqw;
    padding-bottom: 0.9cqw;
    border-bottom: var(--hair) solid var(--ink);
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 3cqw;
    align-items: baseline;
  }

  & .field dt,
  & .ledger dt,
  & .box h3 {
    font: 500 1.95cqw / 1 var(--caps);
    letter-spacing: 0.22em;
    text-transform: uppercase;
  }

  & .field dd {
    margin: 0;
    font-size: 1.2em;
  }

  & .box {
    position: relative;
    margin: 0 0 5.2cqw;
    padding: 4.2cqw 3cqw 3cqw;
    border: var(--hair) solid var(--ink);
  }

  & .sheet > .box:first-child {
    margin-top: 1.4cqw;
  }

  & #record-continued {
    padding-left: 8cqw;
    padding-right: 6.5cqw;
  }

  & .resume {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.4cqw;
    margin: 0;
    text-decoration: none;
    cursor: pointer;
  }

  & .resume .screen {
    flex: 1 1 auto;
    min-height: 0;
    width: auto;
    height: auto;
    max-width: calc(100% - 2.6cqw);
    max-height: calc(100% - 2.6cqw);
    aspect-ratio: 1191 / 1684;
    margin: 1.3cqw auto 0;
    transition: outline-color 0.25s ease;
  }

  & .resume .screen img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
  }

  & .resume:hover .screen,
  & .resume:focus-visible .screen {
    outline-color: var(--red);
  }

  & .resume-label {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55em;
    font-size: 0.92em;
    font-style: italic;
    text-align: center;
    transition: color 0.2s ease;
  }

  & .resume-label span {
    text-decoration: underline;
    text-decoration-thickness: var(--hair);
    text-underline-offset: 0.22em;
  }

  & .resume .fist {
    position: static;
    width: 2.3em;
    height: 1.15em;
    opacity: 1;
    transform: none;
    flex: none;
  }

  & .resume:hover .resume-label,
  & .resume:focus-visible .resume-label {
    color: var(--red);
  }

  & .box h3 {
    position: absolute;
    top: 0;
    left: 2cqw;
    margin: 0;
    padding: 0 1.2cqw;
    background: var(--paper);
    transform: translateY(-50%);
  }

  & .ledger {
    margin: 0;
    display: grid;
    gap: 0.9cqw;
  }

  & .ledger dt:not(:first-child) {
    margin-top: 2cqw;
  }

  & .ledger dd {
    margin: 0;
    font-size: 0.94em;
    line-height: 1.34;
  }

  & .page .blank {
    min-height: 4.2em;
    background: repeating-linear-gradient(transparent 0 calc(1.4em - var(--hair)), color-mix(in srgb, var(--ink) 45%, transparent) 0 1.4em);
    font-size: 0.88em;
    font-style: italic;
    line-height: 1.4em;
    text-align: left;
    text-indent: 0;
    color: color-mix(in srgb, var(--ink) 64%, transparent);
  }

  /* Map */

  & .map {
    padding-bottom: 8cqw;
  }

  & .map svg {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: visible;
  }

  & .map text {
    fill: var(--ink);
    font: 700 13px / 1 var(--text);
    font-variant-numeric: lining-nums;
  }

  & .map .north {
    font: 500 8px / 1 var(--caps);
  }

  & .map .no {
    paint-order: stroke;
    stroke: var(--paper);
    stroke-width: 4px;
    stroke-linejoin: round;
    transition: fill 0.18s;
  }

  & .map .room.seen .floor {
    fill: url(#seen);
  }

  & .map .room:hover .no,
  & .map .room:focus-visible .no {
    fill: var(--red);
  }

  & .map .room:focus-visible {
    outline: none;
  }

  & .map .here {
    display: none;
    fill: none;
    stroke: var(--red);
    stroke-width: 1.4px;
  }

  & .map .room.last .here {
    display: inline;
  }

  /* Cover stock */

  & .card {
    padding-top: 12cqw;
  }

  & #warning h2 {
    margin: 0 0 5cqw;
    padding: 4cqw 0 3.2cqw;
    background:
      linear-gradient(var(--ink) 0 0) left top / 100% var(--rule) no-repeat,
      linear-gradient(var(--ink) 0 0) left 1.7cqw / 100% var(--hair) no-repeat,
      linear-gradient(var(--ink) 0 0) left bottom / 100% var(--hair) no-repeat;
    font-size: 7.4cqw;
    letter-spacing: 0.04em;
    text-align: center;
    text-transform: uppercase;
  }

  & #warning p {
    text-indent: 0;
  }

  & #warning p + p {
    margin-top: 0.9em;
  }

  & #colophon {
    justify-content: flex-end;
  }

  & #colophon p {
    font-size: 0.86em;
    text-align: center;
    text-indent: 0;
  }

  & #colophon p + p {
    margin-top: 1.2em;
  }

  & .cover {
    padding: 6.5cqw 7cqw 7.5cqw;
  }

  & .cover .banner {
    margin: 0 0 4.4cqw;
    padding: 1.9cqw 0 1.75cqw;
    border-radius: 2.6cqw;
    background: var(--red);
    color: var(--paper);
    font: 600 3.1cqw / 1 var(--caps);
    letter-spacing: 0.3em;
    text-align: center;
    text-indent: 0.3em;
    text-transform: uppercase;
  }

  & .cover .frame {
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 1.6cqw;
    padding: 5.4cqw 5cqw 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 3.2cqw;
    outline: 0.7cqw solid var(--ink);
    outline-offset: 0.9cqw;
    overflow: hidden;
    background: var(--ink);
    color: var(--paper);
  }

  & .cover .frame::after {
    content: "";
    position: absolute;
    inset: 1.3cqw;
    border: var(--hair) solid color-mix(in srgb, var(--paper) 55%, transparent);
    border-radius: 2.1cqw;
    pointer-events: none;
  }

  & .cover h1 {
    margin: 0;
    font: 700 11.2cqw / 0.95 var(--text);
    letter-spacing: 0.01em;
    text-align: center;
    text-transform: uppercase;
  }

  & .cover .tagline {
    max-width: 62cqw;
    margin: 2.8cqw 0 0;
    padding-top: 2.6cqw;
    border-top: var(--hair) solid color-mix(in srgb, var(--paper) 55%, transparent);
    font-size: 2.95cqw;
    font-style: italic;
    line-height: 1.35;
    text-align: center;
    text-indent: 0;
    text-wrap: balance;
    hyphens: manual;
  }

  & .cover .art {
    flex: 1;
    min-height: 0;
    width: calc(100% + 10cqw);
    margin-top: 2cqw;
    object-fit: cover;
    object-position: 50% 100%;
    -webkit-mask-image: linear-gradient(#0000, #000 9cqw);
    mask-image: linear-gradient(#0000, #000 9cqw);
  }

  & .page.back {
    justify-content: space-between;
    padding: 15cqw 15cqw 14.5cqw;
  }

  & .back::before {
    content: "";
    position: absolute;
    inset: 8.1cqw 8.6cqw 9.1cqw;
    border: var(--hair) solid var(--ink);
    border-radius: 3.2cqw;
    outline: 0.7cqw solid var(--ink);
    outline-offset: 0.9cqw;
    pointer-events: none;
  }

  & .back .blurb {
    font-size: 1.22em;
    font-style: italic;
    line-height: 1.36;
    text-align: left;
    text-indent: 0;
  }

  & .back .isbn {
    align-self: flex-end;
    width: 46cqw;
    padding: 2cqw 2.4cqw 1.6cqw;
    border: var(--hair) solid var(--ink);
    font: 500 1.9cqw / 1 var(--caps);
    letter-spacing: 0.22em;
    text-align: center;
    text-indent: 0;
    text-transform: uppercase;
  }

  & .barcode svg {
    display: block;
    width: 100%;
    height: 9cqw;
    margin-bottom: 1.6cqw;
    fill: var(--ink);
    shape-rendering: crispEdges;
  }

  @media (prefers-reduced-motion: reduce) {
    & *,
    & *::before,
    & *::after {
      transition-duration: 0.01ms !important;
      animation-duration: 0.01ms !important;
    }
  }
}

