/* ==========================================================================
   elevensies.ca — landing page: the Red Book, as in the films
   --------------------------------------------------------------------------
   The cover follows the film prop (per Michael, 2026-10-05): aged red
   cowhide, an embossed Elvish vine frame, a silver star and Bilbo's
   silver "BB" monogram in silver foil, leather tie straps on the
   fore-edge — and NO title text on the cover.
   The leather and parchment are generated photographic textures
   (assets/leather.webp, assets/parchment.webp), drawn over by hand-built
   SVG/CSS details, so the cover can still swing open in 3D.

   Stages:  closed -> opening (cover swings, page turns, camera zooms)
            -> open (a close-up of ONE page: title + Contents, scrolling)
   QR-code visitors never see this page: their codes point straight at
   chapter pages. Chapter "Contents" links use index.html#contents,
   which skips straight to the open page.
   ========================================================================== */

.landing {
  text-align: center;
  padding: 1.6rem 1rem 3rem;
}

.site-mark {
  font-family: "IM Fell English", serif;
  color: #d8c491;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.85rem;
  margin: 0 0 1.4rem;
}

/* ---------- The stage the book sits on ---------- */
.scene {
  perspective: 1600px;              /* gives the cover swing its 3D depth */
  display: flex;
  justify-content: center;
}

/* The whole book stage zooms toward the viewer as the opening finishes —
   the "stepping into the page" moment. */
#bookStage { transition: transform 0.85s ease, opacity 0.85s ease; }
#bookStage.zooming {
  transform: scale(1.45);
  opacity: 0;
  pointer-events: none;
}

/* ---------- The closed book ---------- */
.book {
  position: relative;
  width: min(400px, 86vw);
  aspect-ratio: 5 / 7;              /* the prop is about 8.5 x 12 inches */
  transform-style: preserve-3d;
  cursor: pointer;
  filter: drop-shadow(0 34px 30px rgba(0, 0, 0, 0.55));
}

/* The block of page edges peeking out on the right and bottom */
.page-block {
  position: absolute;
  inset: 4px -7px -6px 8px;
  background: repeating-linear-gradient(
    to right, #efe3c2 0 2px, #d9c491 2px 3px);
  border-radius: 2px 8px 8px 2px;
  z-index: 1;
}

/* The first parchment page, revealed as the cover opens */
.first-page {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(rgba(243, 228, 192, 0.25), rgba(243, 228, 192, 0.25)),
    url("assets/parchment.webp") center / cover;
  border-radius: 3px 10px 10px 3px;
  padding: 2.4rem 1.8rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.9rem;
}
.first-page h1 {
  font-family: "IM Fell English", serif;
  font-weight: normal;
  font-size: clamp(1.7rem, 6vw, 2.3rem);
  line-height: 1.15;
  margin: 0;
}
.first-page p { margin: 0; font-size: 1.1rem; font-style: italic; color: var(--ink-soft); }
.first-page .rule { border: none; border-top: 1px solid var(--ink-soft); width: 55%; margin: 0.2rem auto; }

/* One loose page that turns during the opening (pure decoration) */
.turning-page {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: url("assets/parchment.webp") center / cover;
  border-radius: 3px 10px 10px 3px;
  transform-origin: left center;
  opacity: 0;
  pointer-events: none;
}
.scene[data-stage="opening"] .turning-page {
  animation: page-turn 1.7s ease-in-out 0.85s forwards;
}
@keyframes page-turn {
  0%   { opacity: 1; transform: rotateY(0deg); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: rotateY(-160deg); }
}

/* ---------- The front cover, hinged on the spine (left edge) ---------- */
.cover {
  position: absolute;
  inset: 0;
  z-index: 4;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 2.3s cubic-bezier(0.3, 0.6, 0.3, 1);
}
.scene[data-stage="opening"] .cover,
.scene[data-stage="open"] .cover {
  transform: rotateY(-168deg);
}
.cover-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 5px 13px 13px 5px;
}
.cover-front {
  /* photographic aged red leather, shaded toward the spine */
  background:
    linear-gradient(100deg, rgba(0,0,0,0.42) 0 22px, rgba(0,0,0,0) 84px),
    radial-gradient(ellipse at 68% 30%, rgba(255, 190, 150, 0.13), rgba(0,0,0,0) 55%),
    url("assets/leather.webp") center / cover;
  box-shadow:
    inset 0 0 46px rgba(30, 2, 6, 0.5),
    inset -3px 0 6px rgba(0, 0, 0, 0.35);
}
.cover-back {  /* inside of the front cover: darker leather endpaper */
  transform: rotateY(180deg);
  background:
    linear-gradient(rgba(26, 2, 6, 0.55), rgba(26, 2, 6, 0.55)),
    url("assets/leather.webp") center / cover;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.65);
}

/* The embossed vine frame: one design, stamped twice — a dark pass and
   an offset light pass — which is what makes it read as pressed INTO
   the leather rather than printed on it. */
.vine-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.vine-frame .edge-line {
  fill: none;
  stroke: rgba(46, 8, 14, 0.5);
  stroke-width: 2;
  filter: drop-shadow(1.3px 1.5px 0 rgba(255, 214, 196, 0.14));
}
.vine-frame .deboss-dark {
  fill: none;
  stroke: rgba(46, 8, 14, 0.52);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.vine-frame .deboss-light {
  fill: none;
  stroke: rgba(255, 214, 196, 0.17);
  stroke-width: 2.4;
  stroke-linecap: round;
}

/* The silver star, top centre */
.cover-star {
  position: absolute;
  top: 10.5%;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 64px;
  filter: drop-shadow(0 1px 1px rgba(20, 0, 4, 0.6));
}

/* Bilbo's silver "BB" monogram, lower centre: two script B's,
   the second mirrored into the first, as on the prop. */
.bb-monogram {
  position: absolute;
  bottom: 9%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Pinyon Script", cursive;
  font-size: 62px;
  line-height: 1;
  white-space: nowrap;
  filter: drop-shadow(0 1px 1px rgba(20, 0, 4, 0.55));
}
/* The silver gradient is applied per letter: background-clip:text on the
   parent fails for the mirrored letter, which is its own transformed box. */
.bb-monogram span {
  background: linear-gradient(175deg, #fcfdff, #c6cfd7 45%, #8d99a4 62%, #e9eff4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bb-monogram .bb-flip {
  display: inline-block;
  transform: scaleX(-1);
  margin-left: -0.34em;
}

/* Leather tie straps, fastened through slits on the fore-edge.
   They belong to the cover, so they swing away with it. */
.tie {
  position: absolute;
  right: -58px;
  width: 112px;
  height: 15px;
  background:
    linear-gradient(rgba(43, 5, 11, 0.35), rgba(43, 5, 11, 0.35)),
    url("assets/leather.webp") center / cover;
  border-radius: 3px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.45), inset 0 0 6px rgba(0, 0, 0, 0.4);
  transform-origin: left center;
}
.tie::before {  /* the slit the strap comes through */
  content: "";
  position: absolute;
  left: -3px;
  top: -3px;
  width: 7px;
  height: 21px;
  background: rgba(24, 2, 6, 0.75);
  border-radius: 3px;
}
.tie-top    { top: 23%; transform: rotate(7deg); }
.tie-bottom { top: 66%; transform: rotate(-5deg); }

/* ---------- Buttons under the book ---------- */
.landing-controls { margin-top: 2rem; }
.landing-controls button {
  font-family: "IM Fell English", serif;
  font-size: 1.1rem;
  background: linear-gradient(160deg, var(--leather-light), var(--leather-dark));
  color: var(--gold-bright);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 0.65rem 1.6rem;
  cursor: pointer;
}
.landing-controls button:hover { filter: brightness(1.15); }
.landing-controls .hint { color: #b39b5e; margin-top: 0.7rem; }

/* ---------- The open book: a close-up of ONE page ----------
   One parchment page, as wide as it needs to be and as tall as the
   Contents make it — the web page itself scrolls, so there is no
   spread framing and no aspect ratio to contend with. */
.page-stage {
  display: none;               /* shown by book.js when the book opens */
  opacity: 0;
  transform: scale(0.965);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.page-stage.visible { display: block; opacity: 1; transform: scale(1); }

.single-page {
  max-width: 780px;
  margin: 0 auto;
  text-align: left;
  background:
    linear-gradient(rgba(243, 228, 192, 0.18), rgba(243, 228, 192, 0.18)),
    url("assets/parchment.webp") center / cover;
  padding: 3rem clamp(1.4rem, 6vw, 4rem) 3.5rem;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.5);
  border-radius: 3px;
}
.single-page h1 {
  font-family: "IM Fell English", serif;
  font-weight: normal;
  text-align: center;
  font-size: clamp(2rem, 6vw, 2.9rem);
  line-height: 1.15;
  margin: 0 0 0.8rem;
}
.single-page .intro {
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.18rem;
  margin: 0 0 0.6rem;
}
.single-page .page-rule {
  border: none;
  border-top: 1px solid rgba(87, 69, 47, 0.55);
  width: 60%;
  margin: 1.6rem auto;
}
.single-page h2 {
  font-family: "IM Fell English", serif;
  font-weight: normal;
  font-size: 1.8rem;
  text-align: center;
  margin: 0 0 1.1rem;
}

/* Contents list — the 40 chapters, flowing down the single page. */
.contents-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 1.12rem;
  line-height: 1.55;
}
.contents-list li { display: flex; align-items: baseline; gap: 0.5rem; }
.contents-list .ch-num {
  font-family: "IM Fell English", serif;
  min-width: 1.9rem;
  text-align: right;
  color: var(--ink-soft);
}
.contents-list .ch-title { font-family: "IM Fell English", serif; }
.contents-list .ch-signer { font-style: italic; color: var(--ink-soft); font-size: 1.02rem; text-align: right; }
.contents-list .leader { flex: 1; border-bottom: 1px dotted rgba(87, 69, 47, 0.55); transform: translateY(-3px); }
.contents-list a { color: var(--ink); text-decoration: none; }
.contents-list a:hover { text-decoration: underline; }
.contents-list .is-prototype .ch-title::after {
  content: " — prototype, read it";
  font-family: "Caveat", cursive;
  color: #7a5c2e;
  font-size: 1.05rem;
}

/* On phones the page is a true close-up: it fills the screen edge to
   edge (the .landing side padding is cancelled out). */
@media (max-width: 720px) {
  .single-page {
    margin: 0 -1rem;
    border-radius: 0;
    padding-top: 2.2rem;
  }
}

/* Respect visitors who prefer reduced motion: no swing, no zoom.
   book.js also checks this and jumps straight to the open page. */
@media (prefers-reduced-motion: reduce) {
  .cover, .page-stage, #bookStage { transition: none; }
  .turning-page { animation: none !important; }
}
