:root {
  --page-bg: #050505;
  --paper: #efe7db;
  --paper-2: #e8ddd0;
  --paper-edge: #c8b8a5;
  --text: #efe9e2;
  --ink-soft: #b9aba4;
  --accent: #c9b288;
}

.notebook-site {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -12%, rgba(90, 70, 70, 0.12), transparent 35%),
    linear-gradient(180deg, #050505 0%, #080808 100%);
}

.notebook-main {
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 2.5vw, 2rem) 2rem;
}

.notebook-heading {
  width: min(1200px, 94vw);
  margin: 0 auto clamp(.8rem, 2.5vw, 1.25rem);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.notebook-heading h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.1rem);
  line-height: 1;
  color: var(--text);
}

.notebook-hint {
  margin: 0;
  color: var(--ink-soft);
  font: 400 clamp(.95rem, 1.2vw, 1.1rem)/1.4 "DM Sans", sans-serif;
}

.book-section { padding-bottom: 1rem; }
.book-desk {
  width: min(1200px, 96vw);
  margin: 0 auto;
}

.book {
  position: relative;
  width: min(1200px, 96vw);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.book-cover {
  width: min(500px, 38vw);
  height: min(690px, 52vw);
  margin: 0 auto;
  border-radius: 18px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.025), rgba(0,0,0,.1)),
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.04), transparent 30%),
    linear-gradient(180deg, #2c2627 0%, #1f1a1b 8%, #262122 54%, #1d191a 100%);
  box-shadow:
    0 28px 48px rgba(0,0,0,.58),
    0 9px 0 #0f0d0d,
    inset 0 0 0 1px rgba(255,255,255,.08),
    inset 0 0 40px rgba(255,255,255,.02),
    inset 0 -24px 36px rgba(0,0,0,.18);
}

.book-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .11;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='2' seed='8' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.book-cover::after {
  content: "";
  position: absolute;
  left: 7%;
  right: 8%;
  top: 4%;
  bottom: 4%;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  pointer-events: none;
}

.cover-spine {
  position: absolute;
  left: 0;
  top: 0;
  width: 13%;
  height: 100%;
  background: linear-gradient(90deg, #181314 0%, #322b2c 35%, #1f1a1b 78%, #292223 100%);
  box-shadow: inset -8px 0 12px rgba(0,0,0,.42), inset 1px 0 1px rgba(255,255,255,.05);
}

.cover-elastic {
  position: absolute;
  top: 0;
  right: 8%;
  width: 16px;
  height: 100%;
  background: linear-gradient(90deg, #0b0909, #2f2829 40%, #090808);
  opacity: .95;
}

.cover-label {
  position: absolute;
  right: 15%;
  bottom: 14%;
  display: inline-block;
  padding: .48rem .92rem;
  background: rgba(216, 197, 164, .9);
  color: #443930;
  border-radius: 2px;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  font: 600 .9rem/1.1 "DM Sans", sans-serif;
  letter-spacing: .16em;
  transform: rotate(-1.8deg);
}

.cover-flap {
  position: absolute;
  z-index: 6;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
}

.cover-flap .book-cover,
.cover-flap::after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  backface-visibility: hidden;
}

.cover-flap::after {
  content: "";
  border-radius: 18px;
  background: linear-gradient(90deg, #2b2324, #43393a 12%, #383031);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  transform: rotateY(180deg);
}

.book-open {
  width: min(940px, 82vw);
  height: min(640px, 48vw);
  margin: 0 auto;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  background: #262222;
  box-shadow:
    0 28px 48px rgba(0,0,0,.58),
    0 9px 0 #111,
    inset 0 0 0 1px rgba(255,255,255,.06);
}

.desk-pencil-image {
  position: absolute;
  right: max(1vw, -8px);
  top: 18%;
  width: clamp(140px, 16vw, 220px);
  transform: rotate(19deg);
  filter: drop-shadow(8px 12px 9px rgba(0,0,0,.68));
  pointer-events: none;
  user-select: none;
}

.book-pages {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  height: 100%;
  perspective: 2200px;
}

.paper-page,
.turn-face {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: clamp(22px, 2.2vw, 32px) clamp(20px, 2.8vw, 34px) clamp(14px, 1.5vw, 20px);
  border: 1px solid var(--paper-edge);
  background:
    linear-gradient(115deg, var(--paper), var(--paper-2) 62%, #e2d5c6),
    radial-gradient(circle at 26% 22%, rgba(255,255,255,.22), transparent 32%);
}

.paper-page::before,
.turn-face::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='2' seed='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.paper-page::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(97, 69, 32, .055);
  pointer-events: none;
}

.left-page {
  border-radius: 4px 0 0 4px;
  box-shadow: inset -16px 0 22px -14px rgba(57, 44, 35, .28);
}

.right-page {
  border-radius: 0 4px 4px 0;
  box-shadow: inset 16px 0 22px -14px rgba(57, 44, 35, .28);
}

.page-art-region {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.4rem 0 .7rem;
}

.artwork-open {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.artwork-open img {
  display: block;
  width: auto;
  height: auto;
  max-width: 80%;
  max-height: 68%;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(52, 40, 32, .16));
}

.artwork-open:focus-visible {
  outline: 3px solid #c9b288;
  outline-offset: 4px;
}

.page-number {
  position: relative;
  align-self: end;
  z-index: 2;
  color: #aa9c8f;
  font: 600 .64rem/1 "DM Sans", sans-serif;
  letter-spacing: .18em;
}

.book-gutter {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 0;
  width: 4%;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(28, 22, 20, .13) 30%, rgba(28, 22, 20, .4) 49%, rgba(243, 234, 222, .2) 53%, transparent);
  pointer-events: none;
}

.book-ribbon {
  position: absolute;
  left: 50%;
  bottom: -20px;
  width: 14px;
  height: 42px;
  transform: translateX(-50%);
  background: #b66b83;
  clip-path: polygon(0 0,100% 0,100% 100%,50% 78%,0 100%);
  z-index: -1;
}

.opening-page {
  background:
    linear-gradient(115deg, #efe7db, #e9dfd2 62%, #e1d5c5),
    radial-gradient(circle at 26% 22%, rgba(255,255,255,.22), transparent 32%);
}

.end-page {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.end-mark {
  width: 54px;
  height: 1px;
  max-width: 55%;
  background: #b67a87;
  margin: 1.3rem auto;
}

.end-head {
  margin: 0;
  font: italic normal clamp(2.6rem, 5vw, 4.8rem) Georgia, serif;
  color: #453c39;
}

.end-copy {
  margin: .5rem 0 0;
  font: italic clamp(.85rem, 1.3vw, 1.15rem) Georgia, serif;
  color: #80726c;
}

.page-turn-layer {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 0;
  width: 50%;
  height: 100%;
  display: none;
  pointer-events: none;
  transform-origin: left center;
  transform-style: preserve-3d;
}

.page-turn-layer.is-forward {
  display: block;
  animation: turnForward 680ms cubic-bezier(.55,.05,.45,1) both;
}

.page-turn-layer.is-backward {
  display: block;
  left: 0;
  transform-origin: right center;
  animation: turnBackward 680ms cubic-bezier(.55,.05,.45,1) both;
}

.turn-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: -2px 0 14px rgba(0,0,0,.12);
}

.turn-front { transform: rotateY(0); }
.turn-back { transform: rotateY(180deg); }

@keyframes turnForward {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(-180deg); }
}

@keyframes turnBackward {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(180deg); }
}

.book-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: min(760px, 86vw);
  margin: 20px auto 0;
  gap: .5rem;
}

.book-arrow {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: .8rem;
  min-height: 43px;
  padding: .5rem .8rem;
  background: transparent;
  border: 1px solid rgba(119, 112, 107, .42);
  border-radius: 4px;
  color: #e9e1d9;
  font: 600 .8rem "DM Sans", sans-serif;
  cursor: pointer;
  transition: background 170ms, border-color 170ms;
}

.book-next { justify-self: end; }
.book-arrow:hover:not(:disabled) { background: rgba(255,255,255,.05); border-color: rgba(201, 178, 136, .55); }
.book-arrow:disabled { opacity: .45; cursor: default; }

.book-progress {
  display: grid;
  gap: .35rem;
  min-width: 150px;
}

.book-progress-label {
  color: #cfc1be;
  font: 600 .88rem "DM Sans", sans-serif;
  letter-spacing: .06em;
  text-align: center;
}

.book-progress-track {
  display: block;
  width: min(220px, 35vw);
  height: 2px;
  background: rgba(255,255,255,.15);
}

.book-progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #d8c6a6, #b59669);
  transition: width 260ms ease;
}

.book-instructions {
  width: min(680px, 85vw);
  margin: 1rem auto 0;
  text-align: center;
  color: #a69691;
  font: 400 .82rem/1.55 "DM Sans", sans-serif;
}

.notebook-footer { margin-top: .5rem; }

.painting-lightbox {
  width: min(92vw, 1000px);
  max-width: 1000px;
  border: 0;
  padding: 0;
  background: transparent;
}

.painting-lightbox::backdrop {
  background: rgba(0,0,0,.86);
  backdrop-filter: blur(3px);
}

.painting-lightbox img {
  display: block;
  max-width: 92vw;
  max-height: 88vh;
  margin: 0 auto;
  box-shadow: 0 18px 40px rgba(0,0,0,.7);
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 20px;
  border: 0;
  border-radius: 999px;
  width: 42px;
  height: 42px;
  background: rgba(0,0,0,.54);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.noscript-notice {
  width: fit-content;
  margin: 1rem auto 0;
  color: #e6ded8;
  font: 500 .95rem "DM Sans", sans-serif;
}

@media (max-width: 980px) {
  .book-cover {
    width: min(440px, 43vw);
    height: min(620px, 60vw);
  }

  .book-open {
    width: min(860px, 86vw);
    height: min(600px, 56vw);
  }

  .desk-pencil-image {
    width: clamp(120px, 15vw, 180px);
    right: 0;
    top: 18%;
  }
}

@media (max-width: 700px) {
  .notebook-heading { display: block; }
  .notebook-hint { margin-top: .45rem; }

  .book {
    display: block;
  }

  .book-cover {
    width: 74vw;
    height: min(103vw, 620px);
  }

  .book-open {
    width: 91vw;
    height: min(124vw, 760px);
  }

  .desk-pencil-image { display: none; }

  /* Let users swipe sideways through the book without disabling page scrolling. */
  .book-pages { display: block; touch-action: pan-y; overscroll-behavior-x: contain; }

  .paper-page,
  .turn-face {
    width: 100%;
    padding: 7% 7% 6%;
  }

  .left-page { display: none; }

  .right-page {
    border-radius: 5px;
    box-shadow: inset 10px 0 17px -12px rgba(60, 48, 47, .27);
  }

  .book-gutter {
    left: 0;
    width: 6%;
    transform: none;
  }

  .artwork-open img {
    max-width: 86%;
    max-height: 76%;
  }

  .book-ribbon { left: 12%; }

  .book-toolbar {
    width: 91vw;
    gap: .2rem;
    margin-top: 22px;
  }

  .book-arrow {
    gap: .25rem;
    padding: .55rem .5rem;
    font-size: .72rem;
  }

  .book-progress { min-width: 80px; }
  .book-progress-label { font-size: .64rem; }
  .book-instructions { font-size: .65rem; line-height: 1.6; }

  .page-turn-layer {
    left: 0;
    width: 100%;
    transform-origin: left center;
  }

  .page-turn-layer.is-backward {
    left: 0;
    transform-origin: right center;
  }
}

@media (max-width: 365px) {
  .book-toolbar .book-arrow { font-size: 0; }
  .book-toolbar .book-arrow span[aria-hidden] { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .page-turn-layer.is-forward,
  .page-turn-layer.is-backward {
    animation-duration: 1ms;
  }

  .book-progress-track > span { transition: none; }
}

/* v7: horizontal touch gestures are handled by the notebook, while vertical
   gestures remain available for scrolling. Covers and mounted artwork included. */
.book,
.book-cover,
.book-open,
.book-pages,
.paper-page,
.artwork-open,
.artwork-open img {
  touch-action: pan-y pinch-zoom;
}
.book { overscroll-behavior-x: contain; }
.artwork-open img { -webkit-user-drag: none; user-select: none; }