:root {
  color-scheme: dark;
  --desk: #101214;
  --desk-deep: #070809;
  --silk: #16181b;
  --silk-deep: #0d0e10;
  --silk-light: #23262b;
  --gold: #b09a6a;
  --gold-soft: #cfc3a4;
  --gold-deep: #7a6a45;
  --paper: #f3ead7;
  --paper-shadow: #e4d6bc;
  --ink: #2c2418;
  --ink-soft: #5c5144;
  --endpaper: #1a1c1f;
  --serif: "Cormorant Garamond", "Palatino Linotype", Palatino, serif;
  --display: "Cinzel", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  background: var(--desk-deep);
  color: var(--gold-soft);
  font-family: var(--serif);
}

.scene {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 48% at 50% 36%, rgba(48, 52, 58, 0.28), transparent 62%),
    radial-gradient(ellipse 90% 80% at 50% 120%, rgba(0, 0, 0, 0.78), transparent 55%),
    linear-gradient(180deg, #121416 0%, #0b0c0e 48%, #070808 100%);
}

.scene-grain,
.scene-light {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene-grain {
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.scene-light {
  background:
    radial-gradient(circle at 50% 30%, rgba(210, 214, 220, 0.05), transparent 34%),
    radial-gradient(ellipse 40% 18% at 50% 72%, rgba(0, 0, 0, 0.5), transparent 70%);
}

.topbar,
.folio {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 8px 0;
}

.topbar[hidden],
.folio[hidden],
.reader[hidden],
.phone-reader[hidden] {
  display: none !important;
}

.phone-reader {
  display: none;
}

.running-title,
#folioLabel {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
}

.text-btn,
.icon-nav {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--gold-soft);
  font-family: var(--display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
}

.text-btn {
  font-size: 10px;
  padding: 8px 0;
}

.topbar .text-btn:last-child,
.folio .icon-nav:last-child {
  justify-self: end;
}

.text-btn:hover,
.icon-nav:hover {
  color: #fff6e4;
}

.icon-nav {
  font-size: 28px;
  line-height: 1;
  padding: 4px 10px;
  font-family: var(--serif);
  letter-spacing: 0;
}

.folio {
  padding: 0 8px 28px;
}

.stage {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 36px;
  padding: 48px 24px 72px;
}

.scene.is-open .stage {
  display: none;
}

.volume {
  position: relative;
  width: min(380px, 78vw);
  height: min(560px, 72dvh);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: perspective(1800px) rotateY(-10deg) rotateX(3deg);
  transform-style: preserve-3d;
  transition: transform 0.7s ease;
}

.volume:hover,
.volume:focus-visible {
  transform: perspective(1800px) rotateY(-6deg) rotateX(2deg) translateY(-4px);
  outline: none;
}

.volume-shadow {
  position: absolute;
  left: 8%;
  right: -6%;
  bottom: -28px;
  height: 48px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55), transparent 70%);
  filter: blur(8px);
  transform: rotateX(90deg);
}

.volume-cover,
.volume-back,
.volume-spine,
.volume-pages-edge {
  position: absolute;
  inset: 0;
  border-radius: 3px 14px 14px 3px;
}

.volume-back {
  inset: 0 auto 0 -10px;
  width: 100%;
  background: linear-gradient(90deg, #0a0b0c, var(--silk-deep));
  transform: translateZ(-28px);
}

.volume-pages-edge {
  left: auto;
  right: -11px;
  width: 12px;
  border-radius: 0 8px 8px 0;
  background: repeating-linear-gradient(
    180deg,
    #f7f0df 0 2px,
    #eadcc2 2px 3px,
    #f3e7cf 3px 5px
  );
  box-shadow: inset 2px 0 4px rgba(90, 60, 30, 0.18);
  transform: translateZ(-8px);
}

.volume-spine {
  left: -18px;
  width: 22px;
  border-radius: 4px 0 0 4px;
  background:
    linear-gradient(90deg, rgba(176, 154, 106, 0.08), transparent 28%, rgba(0, 0, 0, 0.45)),
    linear-gradient(180deg, #2a2d32 0%, #14161a 22%, #1b1e22 52%, #0d0e10 100%);
  box-shadow: inset -3px 0 6px rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.spine-title,
.spine-author {
  position: absolute;
  left: 50%;
  writing-mode: vertical-rl;
  transform: translateX(-50%) rotate(180deg);
  font-family: var(--display);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}

.spine-title {
  top: 48px;
  font-size: 10px;
}

.spine-author {
  bottom: 48px;
  font-size: 8px;
  opacity: 0.8;
}

.volume-cover {
  overflow: hidden;
  background-color: var(--silk);
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.018) 0 1px,
      transparent 1px 4px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.16) 0 1px,
      transparent 1px 5px
    ),
    linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 42%, rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(180deg, var(--silk-light), var(--silk) 42%, var(--silk-deep));
  box-shadow:
    0 28px 50px rgba(0, 0, 0, 0.48),
    inset 0 0 0 1px rgba(176, 154, 106, 0.16),
    inset 10px 0 18px rgba(0, 0, 0, 0.18);
}

.silk-sheen {
  display: none;
}

.cover-frame {
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(176, 154, 106, 0.38);
  box-shadow: none;
}

.cover-frame::before,
.cover-frame::after {
  display: none;
}

.cover-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 72px 40px 108px;
  text-align: center;
}

.cover-mark {
  width: 1px;
  height: 28px;
  background: var(--gold);
  opacity: 0.7;
  position: relative;
}

.cover-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 1px solid var(--gold);
  background: transparent;
}

.cover-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(24px, 5.4vw, 32px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1.35;
  color: var(--gold-soft);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  text-shadow: none;
}

.cover-kicker,
.cover-foot,
.cover-author {
  font-family: var(--display);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

.cover-kicker {
  font-size: 8px;
  max-width: 20em;
  line-height: 1.8;
  opacity: 0.82;
}

.cover-rule {
  width: 48px;
  height: 1px;
  background: rgba(176, 154, 106, 0.55);
}

.cover-author {
  font-size: 10px;
  letter-spacing: 0.46em;
  font-weight: 400;
}

.cover-album {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.cover-album-kicker,
.cover-album-title {
  font-family: var(--display);
  text-transform: uppercase;
  color: var(--gold);
}

.cover-album-kicker {
  font-size: 8px;
  letter-spacing: 0.34em;
  opacity: 0.75;
}

.cover-album-title {
  font-size: 15px;
  letter-spacing: 0.46em;
  color: var(--gold-soft);
}

.cover-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 38px;
  font-size: 7px;
  opacity: 0.55;
  letter-spacing: 0.32em;
}

.volume-headband {
  position: absolute;
  top: -2px;
  left: 22%;
  right: 16%;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: repeating-linear-gradient(
    90deg,
    #1a1c1f 0 6px,
    var(--gold-deep) 6px 8px
  );
}

.invite {
  margin: 0;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
}

.reader {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  width: min(980px, 100%);
  margin: 12px auto 8px;
  min-height: calc(100dvh - 150px);
}

.nav-hit {
  height: min(620px, 72dvh);
  border: 0;
  background: transparent;
  cursor: pointer;
}

.book-open {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 18px 1fr;
  height: min(680px, 78dvh);
  filter: drop-shadow(0 28px 40px rgba(0, 0, 0, 0.45));
}

.bookmark {
  position: absolute;
  top: -12px;
  right: 18%;
  width: 14px;
  height: 78px;
  background: linear-gradient(180deg, #9a3040, #6e2230);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  z-index: 2;
  transition: right 0.45s ease;
}

.running-head {
  margin: 0 0 20px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-align: center;
  color: var(--gold-deep);
}

.leaf {
  position: relative;
  overflow: hidden auto;
  padding: 40px 38px 52px;
}

.leaf::-webkit-scrollbar {
  width: 0;
}
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, rgba(90, 50, 20, 0.05), transparent 18px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='.08'/%3E%3C/svg%3E");
  color: var(--ink);
  box-shadow: inset 0 0 40px rgba(90, 60, 30, 0.06);
}

.leaf-left {
  border-radius: 8px 0 0 8px;
  box-shadow:
    inset -18px 0 28px rgba(80, 50, 20, 0.08),
    inset 0 0 40px rgba(90, 60, 30, 0.05);
}

.leaf-right {
  border-radius: 0 8px 8px 0;
  background-image:
    linear-gradient(270deg, rgba(90, 50, 20, 0.04), transparent 16px),
    linear-gradient(90deg, rgba(90, 50, 20, 0.07), transparent 22px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='.08'/%3E%3C/svg%3E");
}

.gutter {
  background:
    linear-gradient(90deg, #d9c9aa, #b89b74 18%, #8a6a46 50%, #b89b74 82%, #d9c9aa);
  box-shadow:
    inset 4px 0 10px rgba(40, 20, 10, 0.18),
    inset -4px 0 10px rgba(40, 20, 10, 0.18);
}

.leaf.turning {
  animation: pageIn 0.45s ease;
}

@keyframes pageIn {
  from {
    opacity: 0.35;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-blank {
  height: 100%;
  background: transparent;
}

.page-endpaper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(227, 208, 166, 0.18), transparent 30%),
    repeating-radial-gradient(circle at 50% 50%, rgba(227, 208, 166, 0.12) 0 1px, transparent 1px 18px),
    linear-gradient(145deg, #7a3340, #4a1c26 60%, #6e2c38);
}

.page-center {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}

.kicker {
  margin: 0;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.half-title,
.chapter-roman {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
}

.half-title {
  font-size: 22px;
}

.main-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 34px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  font-size: 18px;
  font-style: italic;
  color: var(--ink-soft);
}

.author {
  margin: 8px 0 0;
  font-family: var(--display);
  letter-spacing: 0.36em;
  text-transform: uppercase;
  font-size: 12px;
}

.rule {
  width: 64px;
  height: 1px;
  background: var(--gold-deep);
  opacity: 0.7;
}

.dedication p,
.rights p,
.chapter-body p,
.colophon p {
  margin: 0 0 0.9em;
  font-size: 17.5px;
  line-height: 1.64;
  text-align: justify;
  hyphens: auto;
}

.dedication {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.dedication p {
  text-align: center;
  font-style: italic;
  font-size: 20px;
}

.chapter-roman {
  font-size: 13px;
  margin-bottom: 10px;
}

.chapter-title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chapter-kicker {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-deep);
  line-height: 1.55;
}

.drop-cap::first-letter {
  float: left;
  font-family: var(--display);
  font-size: 62px;
  line-height: 0.7;
  padding: 10px 10px 0 0;
  color: var(--gold-deep);
}

.page-num {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.toc-page ol {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.toc-page li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: baseline;
  margin: 0 0 12px;
  font-size: 17px;
}

.toc-page button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.toc-page .dots {
  border-bottom: 1px dotted rgba(44, 36, 24, 0.35);
  transform: translateY(-4px);
}

.toc-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--paper);
}

.toc-dialog::backdrop {
  background: rgba(12, 8, 7, 0.62);
}

.toc-panel {
  width: min(420px, 92vw);
  padding: 36px 32px 28px;
  background: linear-gradient(180deg, #4a222b, #32151c);
  border: 1px solid rgba(198, 165, 106, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.toc-kicker {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

.toc-panel h2 {
  margin: 0 0 22px;
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 18px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list button {
  width: 100%;
  appearance: none;
  border: 0;
  border-bottom: 1px solid rgba(198, 165, 106, 0.16);
  background: transparent;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 18px;
  text-align: left;
  padding: 10px 0;
  cursor: pointer;
}

.toc-list button:hover {
  color: var(--gold-soft);
}

.toc-close {
  margin-top: 18px;
  color: var(--gold);
}

@media (max-width: 860px) {
  .reader {
    display: none !important;
  }

  .phone-reader {
    display: none;
    position: relative;
    z-index: 3;
    width: min(560px, calc(100% - 24px));
    margin: 4px auto 0;
    height: calc(100dvh - 140px);
  }

  .scene.is-open .phone-reader:not([hidden]) {
    display: block;
  }

  .phone-leaf {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 32px 24px 56px;
    background-color: var(--paper);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='.08'/%3E%3C/svg%3E");
    color: var(--ink);
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  }

  .phone-leaf .chapter-title {
    font-size: 18px;
  }

  .phone-leaf .chapter-body p {
    font-size: 17px;
    line-height: 1.7;
    text-align: left;
  }

  .volume {
    transform: perspective(1400px) rotateY(-6deg) rotateX(3deg);
    width: min(280px, 72vw);
    height: min(420px, 58dvh);
  }

  .topbar,
  .folio {
    width: min(560px, calc(100% - 24px));
  }

  .folio {
    padding-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .silk-sheen,
  .volume,
  .leaf.turning,
  .bookmark {
    animation: none;
    transition: none;
  }
}

@media print {
  .scene {
    background: white;
  }

  .topbar,
  .folio,
  .nav-hit,
  .invite,
  .scene-grain,
  .scene-light {
    display: none !important;
  }
}
