* { box-sizing: border-box; }

:root {
  --bg-1: #fff4e4;
  --bg-2: #f7d6c3;
  --ink: #4a3028;
  --soft: rgba(74, 48, 40, .18);

  /* AJUSTES IMPORTANTES */
  --book-height: min(68vh, 640px);          /* Alto de portada y libro abierto. Los dos usan EL MISMO. */
  --bookmark-height: 80%;                   /* Tamaño del marcapáginas abierto. */
  --bookmark-left: 61.8%;                   /* Posición horizontal del marcapáginas abierto. */
  --bookmark-top: -10%;                    /* Posición vertical del marcapáginas abierto. */
}

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

body {
  overflow: hidden;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  background:
    radial-gradient(circle at 22% 18%, rgba(255,255,255,.95), transparent 26rem),
    radial-gradient(circle at 78% 82%, rgba(255,255,255,.42), transparent 28rem),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

.page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  gap: 12px;
  padding: 24px 42px 30px;
}

.intro {
  text-align: center;
  max-width: 980px;
  z-index: 5;
}
.eyebrow { margin: 0 0 4px; letter-spacing: .28em; text-transform: uppercase; font-size: 13px; }
h1 { margin: 0; font-size: clamp(34px, 3.45vw, 58px); line-height: .98; }
.intro p:last-child { margin: 10px 0 0; font-size: clamp(15px, 1.05vw, 18px); opacity: .72; }

.stage {
  position: relative;
  width: min(94vw, 1380px);
  height: calc(100vh - 180px);
  min-height: 530px;
  display: grid;
  place-items: center;
  perspective: 1700px;
  user-select: none;
  overflow: visible;
  touch-action: pan-y;
}

.closed-book, .open-book {
  position: absolute;
  display: grid;
  place-items: center;
  transition: opacity .48s ease, transform .85s cubic-bezier(.2,.8,.2,1), filter .48s ease;
}

.closed-book {
  height: var(--book-height);
  aspect-ratio: 1335 / 2048;
  transform-style: preserve-3d;
  cursor: grab;
  z-index: 3;
}
.closed-book:active, .open-book:active { cursor: grabbing; }

.cover-wrap {
  position: relative;
  height: 100%;
  width: 100%;
  border-radius: 8px;
  overflow: hidden; /* Aquí el brillo ya NO se sale de la portada */
  filter: drop-shadow(0 26px 26px var(--soft));
  z-index: 2;
}
.cover {
  display: block;
  height: 100%;
  width: 100%;
  object-fit: cover;
  border-radius: 8px;
  transform-origin: left center;
  transition: transform 1s cubic-bezier(.16,.84,.25,1), opacity .75s ease;
}

/* Ventanita recortada: en cerrado SOLO se asoman las orejas */
.peek-window {
  position: absolute;
  width: 50%;
  height: 50%;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
  filter: drop-shadow(0 10px 9px rgba(0,0,0,.16));
  animation: peek 2.8s ease-in-out infinite;
}
.peek-window img {
  position: absolute;
  width: 100%;
  height: auto;
  left: 0;
  top: 0;
}

.shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 18%, rgba(255,255,255,.28) 45%, transparent 62%);
  transform: translateX(-120%);
  animation: shine 4.2s ease-in-out infinite;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
}

.open-book {
  height: var(--book-height);              /* Mismo alto exacto que la portada */
  aspect-ratio: 2048 / 1570;               /* Justo el doble visual de la portada */
  opacity: 0;
  transform: scale(.965) translateY(10px);
  pointer-events: none;
  z-index: 1;
  cursor: grab;
}
.pages {
  display: block;
  height: 100%;
  width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 28px 30px var(--soft));
}

.bookmark-button {
  position: absolute;
  left: var(--bookmark-left);
  top: var(--bookmark-top);
  height: var(--bookmark-height);
  width: auto;
  aspect-ratio: 557 / 1382;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  box-shadow: none;
  filter: drop-shadow(0 14px 11px rgba(0,0,0,.22));
  transition: transform .25s ease, filter .25s ease;
}
.bookmark-button img { height: 100%; width: 100%; object-fit: contain; display: block; }
.bookmark-button:hover { transform: translateY(-10px) rotate(-1.5deg) scale(1.035); }

body.book-is-open .closed-book {
  opacity: 0;
  transform: translateX(-34%) rotateY(-78deg) scale(.84);
  pointer-events: none;
  filter: blur(1.5px);
}
body.book-is-open .cover { transform: rotateY(-118deg); }
body.book-is-open .open-book {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  z-index: 2;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(32, 20, 18, .78);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 9999;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal img {
  height: 96vh;
  width: auto;
  max-height: 96vh;
  max-width: 92vw;
  object-fit: contain;
  filter: drop-shadow(0 22px 28px rgba(0,0,0,.38));
  animation: pop .25s ease both;
  cursor: grab;
  transform-style: preserve-3d;
  will-change: transform;
}
.modal-close {
  position: absolute;
  top: 24px;
  right: 30px;
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 36px;
  line-height: 1;
  color: white;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  cursor: pointer;
}

@keyframes peek {
  50% { transform: translateX(-50%) translateY(-5px) rotate(1deg); }
}
@keyframes shine { 55%, 100% { transform: translateX(135%); } }
@keyframes pop { from { transform: scale(.9); } to { transform: scale(1); } }

@media (max-height: 820px) {
  :root { --book-height: min(65vh, 580px); }
  .page { padding-top: 18px; gap: 8px; }
  h1 { font-size: clamp(30px, 3vw, 48px); }
  .stage { height: calc(100vh - 165px); min-height: 460px; }
}

@media (max-width: 900px) {
  :root { --book-height: min(62vh, 560px); --bookmark-height: 54%; }
  .page { padding-inline: 18px; }
  .stage { width: 96vw; min-height: 430px; }
  .open-book { width: 96vw; height: auto; }
  .modal img { max-width: 92vw; }
}
