@font-face {
  font-family: "Bodoni Moda";
  src: url("assets/bodoni-moda-italic.woff2") format("woff2");
  font-weight: 560;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("assets/cormorant-garamond.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

* { box-sizing: border-box; }
html { background: #21171a; }
body {
  margin: 0;
  color: #282023;
  font-family: "Cormorant Garamond", Georgia, serif;
  background:
    url("assets/cloth.webp") repeat,
    radial-gradient(ellipse at 34% 28%, #533a40 0%, #39272d 41%, #21181c 77%, #161216 100%);
}

.reader {
  --leaf-width: min(calc(100vw - 2.5rem), max(17.5rem, calc(66.667vh - 4.5rem)), 34rem);
  --leaf-width: min(calc(100vw - 2.5rem), max(17.5rem, calc(66.667svh - 4.5rem)), 34rem);
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(.75rem, env(safe-area-inset-bottom));
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.closed-book, .spread, .story-page {
  position: relative;
  box-shadow: 1px 1px 2px #120c10, 4px 5px 0 -2px #7f7164, 7px 7px 0 -2px #352129,
    9px 12px 12px -5px #160e14ab, 22px 30px 46px -10px #100b10bd;
}
.closed-book {
  width: var(--leaf-width);
  max-width: calc(66.667svh - 2rem);
  display: block;
  border-radius: 2px 4px 4px 2px;
  isolation: isolate;
  transform: perspective(1100px) rotateY(-2deg);
  transition: transform .3s ease;
}
.closed-book img, .title-leaf img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: inherit;
}
.closed-book::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, #160b1361, transparent 1%, #ffcfb61a 1.45%,
    #18081740 2.2%, transparent 3.3%);
  box-shadow: inset 0 0 0 1px #f2d2b92b;
}
.closed-book.bookmarked::before {
  content: "";
  position: absolute;
  z-index: -1;
  right: 12%;
  top: 1px;
  width: 17%;
  aspect-ratio: 1 / 3;
  transform: translateY(-27%) rotate(4deg);
  transform-origin: 50% 27%;
  background: url("assets/rose-bookmark.webp") center / contain no-repeat;
}
.cover-reader:has(.bookmarked) { padding-top: max(4rem, env(safe-area-inset-top)); }
.closed-book.bookmarked { width: min(var(--leaf-width), calc(66.667svh - 4rem)); }
.reading-bookmark {
  position: absolute;
  top: 0;
  right: 5%;
  z-index: 2;
  height: min(16rem, 42vh);
  height: min(16rem, 42dvh);
  width: auto;
  max-width: 24%;
  object-fit: contain;
  object-position: top;
  pointer-events: none;
  transform: rotate(5deg);
  transform-origin: top;
  filter: drop-shadow(2px 3px 2px #2b111d55);
}
@media (hover: hover) {
  .closed-book:hover { transform: perspective(1100px) rotateY(-5deg) translateY(-2px); }
  .book-nav a:hover { color: white; text-decoration: underline; text-underline-offset: .25em; }
}
a:focus-visible {
  outline: 3px solid #d9bfff;
  outline-offset: 5px;
  z-index: 1;
}
.volume { max-width: 100%; }
.spread {
  display: flex;
  background: #6d4d4e;
  border-radius: 3px;
}
.leaf, .verso {
  position: relative;
  width: var(--leaf-width);
  aspect-ratio: 2 / 3;
  flex: none;
}
.leaf {
  background: #fffefb;
  border-radius: 1px 2px 2px 1px;
}
.leaf::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, #3923231e, #66474609 3%, transparent 9%);
}
.verso { display: none; }
.title-leaf, .endpaper { max-width: calc(66.667svh - 3.5rem); }
.contents-leaf {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14% 7% 13%;
  background: linear-gradient(112deg, #fbfaf7, #fffefc 65%, #faf8f3);
}
.contents-leaf h1 {
  font-family: "Bodoni Moda", Georgia, serif;
  font-weight: 560;
  font-style: italic;
  line-height: 1.15;
  font-size: max(2.6rem, calc(var(--leaf-width) * .137));
  margin: 0;
}
.printer-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  width: 27%;
  margin: 6% 0 8%;
  color: #927a72;
}
.printer-rule::before, .printer-rule::after {
  content: "";
  height: 1px;
  flex: 1;
  background: currentColor;
}
.printer-rule span { width: 4px; height: 4px; background: currentColor; transform: rotate(45deg); }
.entries { margin: 0; padding: 0; list-style: none; text-align: center; }
.entries li {
  font-size: max(1.5rem, calc(var(--leaf-width) * .079));
  font-weight: 500;
  line-height: 1.05;
}
.entries li + li { margin-top: max(1rem, calc(var(--leaf-width) * .058)); }
.entries .prologue { margin-bottom: calc(var(--leaf-width) * .075); }
.entries a {
  display: inline-block;
  padding: .15em .25em;
  color: #623847;
  text-decoration-thickness: 1px;
  text-underline-offset: .17em;
}
.paged-reader {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
}
.paged-reader .volume {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template: minmax(0, 1fr) auto / minmax(0, 1fr);
  justify-items: center;
}
.story-reader .volume { max-width: 45rem; }
.contents-reader .spread {
  align-self: center;
  height: min(100%, calc(1.5 * var(--leaf-width)));
}
.contents-reader .leaf, .contents-reader .verso { height: 100%; }
.story-page, .contents-leaf {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  min-height: 0;
}
.story-page:focus-visible, .contents-leaf:focus-visible {
  outline: 2px solid #795965;
  outline-offset: -3px;
}
.story-page {
  width: 100%;
  padding: clamp(1.25rem, 5vw, 3.25rem);
  background: #fffdf9;
  font-size: clamp(1.23rem, 2.2vw, 1.45rem);
  font-weight: 500;
  line-height: 1.5;
  border-radius: 3px;
}
.story-plate { display: block; width: 100%; height: auto; }
.story-page h1 {
  margin: .48em 0 .44em;
  text-align: center;
  font: italic 560 clamp(2.65rem, 5vw, 4rem)/1.15 "Bodoni Moda", Georgia, serif;
}
.story-page p { margin: 0; }
.story-page p + p { margin-top: .7em; }
.contact-slip {
  width: min(100%, 18rem);
  margin: 1.6em auto .4em;
  padding: 1.25em .5em 3.75rem;
  background:
    url("assets/slip-rose.webp") left .65rem bottom .5rem / 50% auto no-repeat,
    linear-gradient(177deg, #f9f0dd 47%, #e5d6bc 50%, #f4e8d2 52%, #f8eedb);
  color: #392a26;
  box-shadow: 1px 3px 7px #3c281b29;
  text-align: center;
  font: italic 560 clamp(1.4rem, 3vw, 1.75rem)/1.4 "Bodoni Moda", Georgia, serif;
}
.contact-slip a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .15em;
}
.contact-slip a:focus-visible { outline-color: #654279; }
.chapter-playlist { margin-top: 1.5em; }
.chapter-playlist iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 200px;
  max-height: max(200px, calc(100dvh - 6rem));
  border: 0;
  background: #17221c;
}
.chapter-playlist iframe:not([hidden]) { display: block; }
.playlist-actions { display: flex; align-items: center; gap: 1rem; min-height: 44px; margin-top: .65em; }
.playlist-actions button {
  flex: none;
  width: 4rem;
  min-height: 44px;
  border: 1px solid #4c503e;
  border-radius: .5rem;
  background: #273b30;
  box-shadow: 0 2px 0 #18281e;
  color: #f9e8c5;
  font-size: 1.1rem;
  cursor: pointer;
}
.playlist-actions button:focus-visible { outline: 3px solid #754e89; outline-offset: 3px; }
.playlist-actions a { color: #563340; text-underline-offset: .17em; }
#playlist-status:not(:empty) { margin-top: .6em; font-size: 1rem; }
.chapter {
  display: block;
  margin-bottom: .32em;
  font-family: Georgia, serif;
  font-weight: 400;
  font-size: max(.8125rem, calc(var(--leaf-width) * .032));
  font-variant-caps: small-caps;
  letter-spacing: .1em;
  color: #6c5856;
}
.book-nav {
  display: flex;
  justify-content: space-between;
  padding: .5rem .15rem 0;
}
.book-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #f2e6dd;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.15rem;
}
.paged-reader .book-nav {
  width: min(100%, 45rem);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
}
.paged-reader .book-nav a:first-child { justify-self: start; }
.paged-reader .book-nav a:nth-child(2) { justify-self: center; text-align: center; }
.paged-reader .book-nav a:last-child { justify-self: end; text-align: right; }
@media (min-width: 56rem) {
  .reader:not(.cover-reader) {
    --leaf-width: min(calc(50vw - 2.75rem), max(17.5rem, calc(66.667svh - 4.5rem)), 34rem);
  }
  .verso { display: block; border-radius: 2px 0 0 2px; }
  .endpaper {
    background: linear-gradient(90deg, transparent 82%, #2e152069 97%, #1e0e19b3),
      url("assets/endpaper.webp") center / 42% auto repeat;
  }
  .back-of-title {
    background: linear-gradient(90deg, #f7f4ee, #fffdf8 46%, #f4f0e8 91%, #cfc7b9 100%);
  }
  .back-of-title::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("assets/title-page.webp") center / 100% 100% no-repeat;
    mix-blend-mode: multiply;
    opacity: .055;
    transform: scaleX(-1);
  }
  .contents-leaf { padding: calc(var(--leaf-width) * .14) 1rem calc(var(--leaf-width) * .13); }
}
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation-duration: .15s; }
  ::view-transition-new(root) { animation-duration: .25s; }
}
@media (prefers-reduced-motion: reduce) {
  .closed-book, .closed-book:hover { transition: none; transform: none; }
}
