:root {
  color-scheme: light;
  --bg: #f5efe3;
  --bg-soft: rgba(255, 250, 241, 0.92);
  --ink: #3d2f24;
  --muted: #7d6552;
  --line: rgba(93, 68, 49, 0.14);
  --shadow: 0 20px 60px rgba(69, 47, 31, 0.14);
  --radius: 20px;
  --menu-width: min(86vw, 19rem);
  --transition: 420ms cubic-bezier(0.2, 0.9, 0.18, 1);
  font-family: "Assistant", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

html.reduced-motion {
  scroll-behavior: auto;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.9), rgba(245, 239, 227, 0.92)),
    var(--bg);
}

button {
  font: inherit;
}

.menu-toggle {
  position: fixed;
  inset-block-start: 1rem;
  inset-inline-start: 1rem;
  z-index: 60;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: rgba(255, 252, 246, 0.94);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.menu-toggle:focus-visible,
.nav-list button:focus-visible {
  outline: 3px solid #aa744d;
  outline-offset: 3px;
}

.book-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 5rem 1rem 5rem;
}

.book-section {
  scroll-margin-block-start: 1rem;
  margin-inline: auto;
  margin-block-end: 2rem;
}

.book-page {
  width: min(100%, 760px);
  margin-inline: auto;
}

.book-cover .book-page {
  max-width: min(100%, 560px);
}

.page-image {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 18px;
  box-shadow: var(--shadow);
  background: #fffaf2;
}

.book-section[data-section="cover"] {
  min-height: calc(100vh - 6rem);
  display: grid;
  place-items: center;
}

.section-title {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.side-menu {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--menu-width);
  max-width: 22rem;
  background: rgba(255, 251, 244, 0.98);
  border-inline-end: 1px solid var(--line);
  box-shadow: 14px 0 42px rgba(68, 47, 27, 0.18);
  transform: translateX(100%);
  transition: transform var(--transition);
  z-index: 80;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.side-menu.is-open {
  transform: translateX(0);
}

.side-menu__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.side-menu__eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
}

.nav-list button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0.8rem 0.95rem;
  background: transparent;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}

.nav-list button[aria-current="page"] {
  background: rgba(165, 112, 74, 0.12);
  border-color: rgba(165, 112, 74, 0.28);
}

.turn-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0) 10%, rgba(255, 250, 242, 0.9) 50%, rgba(255, 255, 255, 0) 90%),
    rgba(255, 250, 241, 0.4);
  transform-origin: right center;
}

.turn-overlay.is-active {
  animation: pageTurn 420ms ease-out;
}

@keyframes pageTurn {
  0% {
    opacity: 0;
    transform: perspective(1000px) rotateY(0deg) scaleX(0.8);
  }
  20% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: perspective(1000px) rotateY(-10deg) scaleX(1);
  }
}

html.reduced-motion .turn-overlay.is-active {
  animation: fadeTurn 160ms ease-out;
}

@keyframes fadeTurn {
  from {
    opacity: 0;
  }
  40% {
    opacity: 0.6;
  }
  to {
    opacity: 0;
  }
}

@media (max-width: 760px) {
  .book-shell {
    padding-inline: 0.6rem;
  }

  .book-section[data-section="cover"] {
    min-height: auto;
    padding-block-start: 1rem;
  }

  .side-menu {
    max-width: 100vw;
    width: 88vw;
  }
}
