/* Each spread sets its own type area, illustration and paper. */
.reader .swipe-window {
  position: relative;
  background: #dfd7c7;
  box-shadow: 0 2px #a79d8b, 0 4px #f6edd9, 0 5px #b8ad99, 0 9px 18px #4434221a;
}
.reader .leaf {
  position: relative;
  min-height: clamp(25rem,41vw,33rem);
  grid-template-rows: 1fr auto;
  align-content: start;
}
.leaf::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg,transparent 47%,#49381a14 49.8%,#fff8 50%,transparent 51.4%);
}
.page-folio {
  grid-column: 1/-1; display: flex; justify-content: space-between; align-items: center;
  padding: .55rem 1.2rem; border-top: 1px solid currentColor;
  font: .75rem/1.3 ui-monospace,monospace; letter-spacing: .12em;
}
.reader .leaf-text { background: none; min-width: 0; }
.leaf-0 { background: #f4ead4; }
.leaf-0 .type-print {
  background: radial-gradient(ellipse at center,#d9aa58 0 14%,transparent 14.3%),
    linear-gradient(#ab8d5e55 1px,transparent 1px),linear-gradient(90deg,#ab8d5e55 1px,transparent 1px),#e8d5af;
  background-size: auto, 2rem 2rem, 2rem 2rem, auto;
}
.leaf-0 .type-print i {
  font: 400 clamp(12rem,24vw,22rem)/.9 Georgia,serif;
  letter-spacing: 0; border: 0; outline: 1px dashed #765c39; color: #332a24;
}
.leaf-0 h3 { font-style: italic; }
.reader .leaf-1 {
  grid-template-columns: 1fr; grid-template-rows: auto 1fr auto;
  background: #27355b; color: #fff0c7;
}
.leaf-1 .type-print {
  display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: center; justify-items: center;
  min-height: 0; padding: 1.4rem .8rem; background: #27355b;
  border-bottom: 1px solid #b7bcd4;
}
.leaf-1 .type-print i { font: 600 clamp(3.5rem,10vw,9rem)/1 Arial,sans-serif; padding: 0; }
.leaf-1 .type-print i:first-child { letter-spacing: .08em; color: #b5bdd9; }
.leaf-1 .type-print .kern-pair { letter-spacing: 0; color: #f8bc79; }
.kern-pair span { margin-inline-start: var(--pair-spacing,-.18em); }
.kerning-control {
  grid-column: 1/-1; display: flex; align-items: center; gap: .85rem;
  margin: .5rem auto 0; max-width: 100%; font: .875rem/1.3 Arial,sans-serif;
}
.kerning-control span { white-space: nowrap; }
.kerning-control input { width: clamp(5rem,22vw,12rem); accent-color: #f8bc79; }
.bookmark-tools { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; }
#resume-bookmark { display: inline-flex; align-items: center; min-height: 44px; }
.contents a { position: relative; padding-inline-end: 1.75rem; }
.contents a.is-bookmarked::after {
  content: ""; position: absolute; inset: 0 .7rem auto auto; width: .6rem; height: 1.15rem;
  background: #b6452b; clip-path: polygon(0 0,100% 0,100% 100%,50% 77%,0 100%);
}
.contents a.is-bookmarked[aria-current]::after { background: #f8bc79; }
.leaf-1 .leaf-text {
  display: grid; grid-template-columns: 1fr 1fr; column-gap: clamp(1.5rem,4vw,4rem);
  align-content: center; padding-block: 1.5rem;
}
.leaf-1 .leaf-text small { grid-column: 1/-1; }
.leaf-1 h3 { grid-column: 1; font: 600 clamp(2rem,4vw,4.4rem)/.98 Arial,sans-serif; }
.leaf-1 p { grid-column: 2; grid-row: 2/4; }
.leaf-1 .leaf-text blockquote { color: #f8bc79; margin: .7rem 0 0; }
.leaf-2 { grid-template-columns: repeat(2,minmax(0,1fr)); background: #f8eee1; }
.leaf-2 .leaf-text { grid-column: 1; grid-row: 1; }
.leaf-2 .type-print {
  grid-column: 2; grid-row: 1; color: #332333;
  background: radial-gradient(#cc4949 1px,transparent 1.35px) 0 0 / 5px 5px,#efc9b8;
}
.leaf-2 .type-print i {
  font: italic 600 clamp(8rem,18vw,18rem)/1 Georgia,serif;
  transform: rotate(-11deg); letter-spacing: -.13em; padding-right: .12em;
  text-shadow: -.035em .025em #008b94,.04em -.02em #e34c4e;
}
.ink-key { position: absolute; bottom: 1rem; right: 1rem; display: flex; }
.ink-key b { width: 1.15rem; height: 1.15rem; border-radius: 50%; background: #008b94; }
.ink-key b + b { margin-left: -.38rem; background: #df5051; mix-blend-mode: multiply; }
.ink-key b:last-child { background: #48323e; }
@media(max-width:740px) {
  .reader .leaf { grid-template-columns: 1fr; min-height: 0; }
  .leaf-0 .type-print { grid-column: 1; grid-row: 1 / 3; min-height: 11rem; }
  .leaf-0 .type-print i { font-size: clamp(5.5rem,27vw,10rem); }
  .leaf-1 .leaf-text { display: block; }
  .reader :is(.leaf-0,.leaf-2) { grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: auto auto 1fr auto auto; }
  .reader :is(.leaf-0,.leaf-2) .leaf-text { display: contents; }
  :is(.leaf-0,.leaf-2) .leaf-text small { grid-area: 1 / 1; padding: 1rem .8rem .4rem; align-self: end; }
  :is(.leaf-0,.leaf-2) .leaf-text h3 { grid-area: 2 / 1; margin: 0; padding: .4rem .8rem 1rem; font-size: clamp(1.5rem,6.6vw,2.6rem); }
  .leaf-2 .type-print { grid-column: 2; grid-row: 1 / 3; min-height: 10rem; }
  .leaf-2 .type-print i { font-size: clamp(5rem,22vw,10rem); }
  :is(.leaf-0,.leaf-2) .leaf-text p, :is(.leaf-0,.leaf-2) .leaf-text blockquote { grid-column: 1/-1; margin: 1rem 1.1rem; }
  :is(.leaf-0,.leaf-2) .leaf-text blockquote { margin-top: 0; }
  .leaf-0 .leaf-text :is(small,h3) { grid-column: 2; }
  .leaf::after { background: none; }
}

/* Two stationary halves and a double-sided leaf share a spine. */
.turn-proof { position: absolute; inset: 0; pointer-events: none; perspective: 1700px; background: var(--paper); overflow: clip; }
.turn-half, .turn-wing { position: absolute; top: 0; bottom: 0; width: 50%; }
.turn-half { overflow: hidden; background: var(--paper); }
.turn-half > .leaf { width: 200%; margin: 0; }
.turn-half.right { left: 50%; }
.turn-half.right > .leaf { margin-left: -100%; }
.turn-wing { left: 50%; transform-origin: left center; transform-style: preserve-3d; }
.turn-proof.backward .turn-wing { left: 0; transform-origin: right center; }
.turn-wing > .turn-half { inset: 0; width: 100%; backface-visibility: hidden; }
.turn-wing > .verso { transform: rotateY(180deg); }
.turn-wing > .turn-half::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg,#38271891,#74552b29 35%,#fff7 94%,#5b46243d); opacity: var(--shade,0); }

.page-corners { display: none; }
@media (any-pointer: fine), (pointer: none) {
  .page-corners { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 2; }
  .page-corners span {
    position: absolute; width: 44px; height: 44px; cursor: grab;
    pointer-events: auto; user-select: none;
  }
  .page-corners span::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(135deg,transparent 48%, #b0a694 50%, #eee4d0 78%, #fffbeb 100%);
    transform: scale(.32); transform-origin: bottom right;
    transition: transform .15s ease;
  }
  .page-corners span:hover::after { transform: scale(.64); }
  .page-corners [data-step="-1"] { left: 0; transform: scaleX(-1); }
  .page-corners [data-step="1"] { right: 0; }
  .page-corners .upper { top: 0; scale: 1 -1; }
  .page-corners .lower { bottom: 0; }
  .page-corners[data-dragging] { cursor: grabbing; pointer-events: auto; }
  .page-corners[data-dragging] span { opacity: 0; }
}

/* All spreads size the same grid cell, including the hidden typesetting. */
.reader .swipe-track { display: grid; }
.reader .swipe-track > .leaf { grid-area: 1 / 1; }
.reader .swipe-track > .leaf[hidden] {
  display: grid !important;
  visibility: hidden;
  pointer-events: none;
}
.reader .swipe-track > .leaf[data-swipe-side] { position: relative; }
.turn-half > .leaf { height: 100%; }
