/* ————————————————————————————————————————————————
   spread.css: the signature moment — a spine becomes
   a book becomes an open spread, in one move
   ———————————————————————————————————————————————— */

.booklayer {
  position: fixed;
  inset: 0;
  z-index: 30;
  perspective: 1700px;
  perspective-origin: 50% 50%;
  pointer-events: none;
}

.bookveil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 60% at 50% 50%, rgba(8, 11, 32, 0.5) 0%, rgba(8, 11, 32, 0.86) 100%);
  opacity: 0;
}

.bookwrap {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  visibility: hidden;
}
.bookwrap.is-shown { visibility: visible; }
.bookwrap.is-open { pointer-events: auto; }

.bookpan {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.book {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pw, 520px);
  height: var(--ph, 680px);
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
}

/* spine face: visible while the book stands turned away */
.book__spineface {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--bt, 64px);
  height: 100%;
  transform-origin: left center;
  transform: rotateY(-90deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: var(--sg, linear-gradient(180deg, #1A2152, #10163F));
  box-shadow: inset 2px 0 3px rgba(246, 213, 92, 0.14), inset -3px 0 6px rgba(4, 6, 18, 0.8);
}
.book__spineface::before, .book__spineface::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  background: rgba(230, 188, 92, 0.55);
}
.book__spineface::before { top: 26px; }
.book__spineface::after { bottom: 30px; }
.book__spineface * { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.book__spinename {
  writing-mode: vertical-rl;
  font: 500 clamp(13px, 2.4vh, 19px)/1 var(--sans);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #10143A;
  max-height: 80%;
  overflow: hidden;
}

/* page block: the right page and the paper body */
.book__block {
  position: absolute;
  inset: 0;
  border-radius: 2px 6px 6px 2px;
  background: linear-gradient(165deg, #1B2358 0%, #141B4E 52%, #10163F 100%);
  box-shadow:
    inset 14px 0 34px rgba(8, 11, 32, 0.55),
    0 60px 140px rgba(4, 6, 18, 0.8);
}
/* fore-edge: massed page lines on the right */
.book__block::after {
  content: '';
  position: absolute;
  top: 3px;
  bottom: 3px;
  right: -7px;
  width: 7px;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(180deg,
    rgba(230, 205, 150, 0.28) 0px, rgba(230, 205, 150, 0.28) 1px,
    rgba(20, 27, 78, 0.9) 1px, rgba(20, 27, 78, 0.9) 3px);
}

/* the cover flap; its back is the left page */
.book__flap {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
}
.flapface {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 2px 6px 6px 2px;
  overflow: hidden;
}
.flapface--front {
  background:
    radial-gradient(120% 90% at 22% 8%, rgba(230, 188, 92, 0.1) 0%, rgba(230, 188, 92, 0) 46%),
    linear-gradient(150deg, #1D2560 0%, #141B4E 46%, #0E1340 100%);
  box-shadow: inset 0 0 0 1px rgba(230, 188, 92, 0.22), inset 0 0 60px rgba(8, 11, 32, 0.5);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.1rem;
  text-align: center;
  padding: 2rem;
}
.flapface--front::before {
  content: '';
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(230, 188, 92, 0.4);
  border-radius: 2px;
  pointer-events: none;
}
.flapface--front::after {
  content: '';
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(230, 188, 92, 0.16);
  border-radius: 1px;
  pointer-events: none;
}
.cover__mark { width: 44px; height: 44px; opacity: 0.9; }
.cover__name {
  font: 400 clamp(1.2rem, 2.4vw, 1.7rem)/1.25 var(--sans);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(230, 188, 92, 0.35);
  max-width: 12ch;
}
.cover__epithet {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  color: var(--ink2);
}
.cover__foot {
  position: absolute;
  bottom: 34px;
  left: 0;
  right: 0;
  font: 300 0.62rem/1 var(--sans);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: rgba(212, 165, 57, 0.75);
  padding-left: 0.5em;
}
.flapface--back {
  transform: rotateY(180deg);
  background: linear-gradient(195deg, #1B2358 0%, #141B4E 52%, #10163F 100%);
  box-shadow: inset -14px 0 34px rgba(8, 11, 32, 0.55);
}

/* ——— pages ——— */

.page {
  position: absolute;
  inset: 0;
  padding: clamp(1.3rem, 2.6vw, 2.2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.page::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}
.page--l::after, .page--r::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  pointer-events: none;
}
.page--l::after { right: 0; background: linear-gradient(90deg, rgba(8, 11, 32, 0) 0%, rgba(8, 11, 32, 0.4) 100%); }
.page--r::after { left: 0; background: linear-gradient(270deg, rgba(8, 11, 32, 0) 0%, rgba(8, 11, 32, 0.4) 100%); }

.page--l { align-items: center; justify-content: center; gap: 1rem; }
.page--l .mstexture {
  position: absolute;
  inset: 0;
  object-fit: cover;
  width: 100%;
  height: 100%;
  opacity: 0.1;
  mix-blend-mode: luminosity;
  pointer-events: none;
}

.plate {
  position: relative;
  width: min(76%, 320px);
  padding: 9px;
  background: #0C1136;
  border: 1px solid rgba(230, 188, 92, 0.32);
  box-shadow: 0 24px 60px rgba(4, 6, 18, 0.7);
}
.plate img {
  width: 100%;
  aspect-ratio: 744 / 900;
  object-fit: cover;
  filter: saturate(0.88) contrast(0.98) brightness(0.94);
}
.plate::after {
  content: '';
  position: absolute;
  inset: 9px;
  background: linear-gradient(180deg, rgba(12, 17, 51, 0) 55%, rgba(12, 17, 51, 0.38) 100%);
  pointer-events: none;
}
.plate--sm { width: min(64%, 250px); }

.page__name {
  font: 400 clamp(1.1rem, 2vw, 1.45rem)/1.3 var(--sans);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink);
  text-align: center;
}
.page__epithet {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.95rem, 1.7vw, 1.15rem);
  color: var(--gold);
  text-align: center;
}

.page--r { justify-content: center; gap: clamp(0.8rem, 1.8vh, 1.3rem); text-align: center; align-items: center; }
.page__ovl {
  font: 300 0.66rem/1.5 var(--sans);
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--goldui);
}

.stars {
  display: grid;
  grid-template-columns: repeat(6, auto);
  gap: clamp(0.55rem, 1.4vw, 0.95rem) clamp(0.7rem, 1.8vw, 1.15rem);
  justify-content: center;
}
.stars li { display: grid; place-items: center; }
.star {
  width: 11px;
  height: 11px;
  background: radial-gradient(circle at 50% 42%, #F6D55C 0%, #E6BC5C 55%, #B38B30 100%);
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
  filter: drop-shadow(0 0 5px rgba(246, 213, 92, 0.65));
  animation: seedtwinkle 3.4s ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * -0.42s);
}
@keyframes seedtwinkle {
  from { opacity: 0.55; transform: scale(0.86); }
  to   { opacity: 1; transform: scale(1.06); }
}

.page__wisdom {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.15rem, 2.3vw, 1.6rem);
  line-height: 1.55;
  color: var(--ink);
  max-width: 30ch;
  text-wrap: balance;
}
.page__honesty {
  font: 300 0.78rem/1.6 var(--sans);
  letter-spacing: 0.16em;
  color: var(--ink3);
}
.page__ask {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.95rem, 1.7vw, 1.1rem);
  color: var(--goldui);
  max-width: 38ch;
}

.mplate {
  position: relative;
  width: min(88%, 330px);
  padding: 8px;
  background: #0C1136;
  border: 1px solid rgba(230, 188, 92, 0.28);
  box-shadow: 0 18px 44px rgba(4, 6, 18, 0.65);
}
.mplate img {
  width: 100%;
  height: clamp(120px, 17vh, 170px);
  object-fit: cover;
  object-position: top;
  filter: brightness(0.9) saturate(0.9);
  transition: opacity 1s var(--soft);
}
.mplate img.mplate__alt {
  position: absolute;
  inset: 8px;
  height: calc(100% - 16px);
  opacity: 0;
}
.mplate.show-alt img.mplate__alt { opacity: 1; }
.mplate__cap {
  margin-top: 0.55rem;
  font: 300 0.68rem/1.5 var(--sans);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink3);
}

.player--page { width: min(100%, 360px); margin: 0.2rem auto 0; }
.player--page .player__btn { width: 46px; height: 46px; }
.player--page .player__btn svg { width: 16px; height: 16px; }

.book__hint {
  position: absolute;
  left: 50%;
  bottom: clamp(1rem, 3.4vh, 2.2rem);
  transform: translateX(-50%);
  font: 300 0.72rem/1 var(--sans);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink3);
  white-space: nowrap;
  opacity: 0;
}

/* aura around the open book */
.book__bloom {
  position: absolute;
  inset: -70px -90px;
  border-radius: 40px;
  background: radial-gradient(58% 58% at 50% 50%, rgba(230, 188, 92, 0.14) 0%, rgba(230, 188, 92, 0) 70%);
  opacity: 0;
  pointer-events: none;
  transform: translateZ(-40px);
}

/* stacked page content reveal handled by GSAP; initial states here */
.page [data-pi] { opacity: 0; transform: translateY(14px); }

@media (max-width: 720px) {
  .stars { grid-template-columns: repeat(6, auto); }
  .page { padding: 1.2rem 1.1rem; }
  .page__wisdom { font-size: 1.05rem; }
  .book__hint { bottom: 5.2rem; }
}
