/* ============================================================
   READING ROOM HERO — paid-book.html only. Builds on the shared
   welcome-hero.css (loaded before this file) and turns it into a
   warm reading nook:

   - lamp light that breathes over the photo, and leaf shadow and
     gold motes drifting across the cream side;
   - the title arriving word by word, a gold sheen across "Room",
     and a hand-drawn flourish in place of the flat underline;
   - a fan of real covers from the shelf, floating over the arc's
     edge (filled by the page script; a cover opens its book page);
   - a gentle parallax that follows the pointer on desktop, and a
     "Step inside" cue down to the collection.

   Everything that moves sits behind prefers-reduced-motion.
   ============================================================ */
.rr-hero {
  --mx: 0;
  --my: 0;
  isolation: isolate;
}

/* ---------- Ambient light ---------- */
.rr-ambient { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.rr-glow {
  position: absolute; border-radius: 50%; will-change: transform, opacity;
  translate: calc(var(--mx) * -18px) calc(var(--my) * -12px);
  transition: translate 1200ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.rr-glow--warm {
  width: 62%; aspect-ratio: 1; top: -26%; left: -16%;
  background: radial-gradient(closest-side, rgba(229, 198, 151, 0.42), rgba(229, 198, 151, 0));
}
.rr-glow--low {
  width: 42%; aspect-ratio: 1; bottom: -30%; left: 26%;
  background: radial-gradient(closest-side, rgba(145, 117, 81, 0.16), rgba(145, 117, 81, 0));
}
/* Leaf shadow, as if a window sat just out of frame. */
.rr-leaves {
  position: absolute; top: -18%; left: -10%; width: max(440px, 44%); aspect-ratio: 1.4;
  transform-origin: 0 0; background: var(--dark-green); opacity: 0.045;
  -webkit-mask: url('/dx-leaves.webp') no-repeat center / contain;
  mask: url('/dx-leaves.webp') no-repeat center / contain;
}
/* Dust in the light. */
.rr-motes i {
  position: absolute; bottom: -8px; width: 4px; height: 4px; border-radius: 50%; opacity: 0;
  background: var(--gold-light); box-shadow: 0 0 10px 2px rgba(229, 198, 151, 0.55);
}
.rr-motes i:nth-child(odd) { background: var(--gold-dark); box-shadow: 0 0 8px 1px rgba(145, 117, 81, 0.35); width: 3px; height: 3px; }

/* ---------- Text ---------- */
.rr-hero .welcome-title { margin-bottom: 0.6rem; }
.rr-word { display: inline-block; }
.rr-hero .welcome-title em {
  padding-right: 0.08em; /* room for the italic overhang under background-clip */
  background: linear-gradient(100deg, var(--gold-dark) 0%, var(--gold-dark) 38%, #C9A774 48%, #F0D9B2 52%, #C9A774 56%, var(--gold-dark) 66%, var(--gold-dark) 100%);
  background-size: 260% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--gold-dark);
}

.rr-flourish { display: block; width: 168px; height: 18px; margin: 0 0 1.4rem -2px; overflow: visible; }
.rr-flourish path { fill: none; stroke: var(--gold-dark); stroke-width: 1.5; stroke-linecap: round; }
.rr-flourish .rr-flourish-tail { stroke-width: 1; opacity: 0.55; }
.rr-flourish .rr-flourish-leaf { fill: var(--gold-dark); stroke: none; transform-box: fill-box; transform-origin: 50% 100%; }

.rr-welcome {
  font-family: 'Playfair Display', serif; font-style: italic;
  font-size: clamp(1.15rem, 1.6vw, 1.35rem); color: var(--dark-green);
  margin: 0 0 0.55rem 0;
}

.rr-hero .welcome-facts li.rr-fact-count[hidden] { display: none; }

/* "Step inside" — a quiet cue down to the shelf. */
.rr-scroll {
  position: absolute; z-index: 2; left: 6%; bottom: 1.6rem;
  display: inline-flex; align-items: center; gap: 0.8rem;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-muted); text-decoration: none;
}
.rr-scroll-track { position: relative; width: 56px; height: 1px; background: rgba(145, 117, 81, 0.35); overflow: hidden; }
.rr-scroll-track::after {
  content: ''; position: absolute; top: 0; left: 0; width: 18px; height: 1px; background: var(--gold-dark);
  transform: translateX(-20px);
}
@media (hover: hover) and (pointer: fine) { .rr-scroll:hover { color: var(--gold-dark); } }

/* ---------- Photo ---------- */
.rr-photo-drift { position: absolute; inset: -3%; translate: calc(var(--mx) * -10px) calc(var(--my) * -7px); transition: translate 1200ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.rr-photo-drift img { width: 100%; height: 100%; object-fit: cover; display: block; transform-origin: 62% 50%; }
/* Warm lamp light over the reader's corner. */
.rr-photo-lamp {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(ellipse 55% 45% at 30% 24%, rgba(255, 214, 150, 0.42), rgba(255, 214, 150, 0) 70%),
    radial-gradient(ellipse 70% 60% at 80% 90%, rgba(255, 190, 120, 0.18), rgba(255, 190, 120, 0) 70%);
  mix-blend-mode: soft-light;
}

/* ---------- The fan of covers ---------- */
.rr-stack {
  position: absolute; z-index: 3; left: 2%; bottom: max(7%, 54px);
  width: clamp(210px, 20vw, 300px);
  translate: calc(var(--mx) * 16px) calc(var(--my) * 10px);
  transition: translate 900ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.rr-stack[hidden] { display: none; }
.rr-stack-books { position: relative; height: calc(clamp(210px, 20vw, 300px) * 0.46 * 1.5 + 18px); }
.rr-stack-item {
  position: absolute; bottom: 0; width: 46%;
  left: var(--x); z-index: var(--z, 1);
  transform: rotate(var(--r));
  transform-origin: 50% 100%;
  transition: left 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.rr-stack-item:nth-child(1) { --x: 0%;  --r: -9deg; --z: 1; bottom: 2%; }
.rr-stack-item:nth-child(2) { --x: 27%; --r: -1deg; --z: 3; bottom: 9%; }
.rr-stack-item:nth-child(3) { --x: 54%; --r: 8deg;  --z: 2; bottom: 1%; }
.rr-stack-books.rr-one .rr-stack-item { --x: 27%; }
.rr-stack-books.rr-two .rr-stack-item:nth-child(1) { --x: 10%; }
.rr-stack-books.rr-two .rr-stack-item:nth-child(2) { --x: 44%; --r: 6deg; }

.rr-stack-btn {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 3px 7px 7px 3px;
  transition: transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}
.rr-stack-btn .lib-cover {
  box-shadow:
    3px 3px 0 -1px #F6F1E7, 6px 6px 0 -1px #EFE8DA,
    0 30px 44px -18px rgba(12, 30, 20, 0.55), 0 10px 18px -10px rgba(12, 30, 20, 0.35);
}
.rr-stack-btn:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 4px; }
@media (hover: hover) and (pointer: fine) {
  .rr-stack-books:hover .rr-stack-item:nth-child(1) { --x: -12%; }
  .rr-stack-books:hover .rr-stack-item:nth-child(3) { --x: 66%; }
  .rr-stack-btn:hover { transform: translateY(-14px) rotate(1.5deg) scale(1.04); }
  .rr-stack-item:hover { z-index: 4; }
}

.rr-stack-label {
  position: absolute; left: 50%; bottom: -14px; z-index: 5; transform: translate(-50%, 100%);
  display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap;
  padding: 0.45rem 0.9rem; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--dark-green);
  background: rgba(250, 249, 246, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: 0 10px 24px -14px rgba(12, 30, 20, 0.5);
}
.rr-stack-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-dark); }

/* ============================================================
   MOTION
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  /* The title arrives word by word instead of as one block. */
  .rr-hero .welcome-hero-text > .welcome-title { animation: none; }
  .rr-word { animation: rr-word 1100ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .rr-word:nth-child(1) { animation-delay: 220ms; }
  .rr-word:nth-child(2) { animation-delay: 340ms; }
  .rr-word:nth-child(3) { animation-delay: 480ms; }
  .rr-hero .welcome-title em {
    animation: rr-word 1100ms 480ms cubic-bezier(0.16, 1, 0.3, 1) both,
               rr-sheen 2.6s 1500ms cubic-bezier(0.45, 0, 0.2, 1) both,
               rr-sheen-loop 11s 8s cubic-bezier(0.45, 0, 0.2, 1) infinite;
  }
  .rr-hero .welcome-hero-text > .rr-flourish { animation: none; }
  .rr-flourish path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: welcome-draw 1500ms 700ms cubic-bezier(0.65, 0, 0.35, 1) forwards; }
  .rr-flourish .rr-flourish-tail { animation-delay: 1100ms; }
  .rr-flourish .rr-flourish-leaf { stroke-dasharray: none; stroke-dashoffset: 0; animation: rr-pop 700ms 1900ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }

  .rr-glow--warm { animation: rr-breathe 9s ease-in-out infinite alternate; }
  .rr-glow--low { animation: rr-breathe 12s -4s ease-in-out infinite alternate; }
  .rr-leaves { animation: rr-sway 11s ease-in-out infinite alternate; }
  .rr-motes i { animation: rr-mote 18s linear infinite; }
  .rr-motes i:nth-child(1) { left: 6%;  animation-delay: -2s; }
  .rr-motes i:nth-child(2) { left: 17%; animation-delay: -9s;  animation-duration: 22s; }
  .rr-motes i:nth-child(3) { left: 29%; animation-delay: -14s; animation-duration: 20s; }
  .rr-motes i:nth-child(4) { left: 41%; animation-delay: -5s;  animation-duration: 24s; }
  .rr-motes i:nth-child(5) { left: 52%; animation-delay: -11s; animation-duration: 19s; }
  .rr-motes i:nth-child(6) { left: 63%; animation-delay: -1s;  animation-duration: 23s; }
  .rr-motes i:nth-child(7) { left: 74%; animation-delay: -16s; animation-duration: 21s; }
  .rr-motes i:nth-child(8) { left: 86%; animation-delay: -7s;  animation-duration: 25s; }
  .rr-motes i:nth-child(9) { left: 94%; animation-delay: -12s; animation-duration: 18s; }

  .rr-photo-drift img { animation: welcome-settle 9s cubic-bezier(0.16, 1, 0.3, 1) both; }
  .rr-photo-drift { animation: rr-drift 26s 9s ease-in-out infinite alternate; }
  .rr-photo-lamp { animation: rr-lamp 7s ease-in-out infinite alternate; }

  .rr-stack-item {
    animation: rr-arrive 1200ms var(--d, 0ms) cubic-bezier(0.16, 1, 0.3, 1) both,
               rr-float 6.5s calc(var(--d, 0ms) + 1200ms) ease-in-out infinite alternate;
  }
  .rr-stack-item:nth-child(1) { --d: 700ms; }
  .rr-stack-item:nth-child(2) { --d: 860ms; animation-duration: 1200ms, 7.5s; }
  .rr-stack-item:nth-child(3) { --d: 1020ms; animation-duration: 1200ms, 6s; }
  .rr-stack-label { animation: rr-label 900ms 1600ms cubic-bezier(0.16, 1, 0.3, 1) both; }

  .rr-scroll { animation: welcome-rise 900ms 1400ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .rr-scroll-track::after { animation: rr-scroll 2.4s 2.2s cubic-bezier(0.65, 0, 0.35, 1) infinite; }
}

@keyframes rr-word {
  from { opacity: 0; transform: translateY(0.45em) rotate(2deg); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes rr-sheen { 0% { background-position: 100% 0; } 100% { background-position: 0% 0; } }
@keyframes rr-sheen-loop { 0% { background-position: 100% 0; } 24%, 100% { background-position: 0% 0; } }
@keyframes rr-pop { from { opacity: 0; transform: scale(0) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes rr-breathe { from { opacity: 0.7; transform: scale(0.94); } to { opacity: 1; transform: scale(1.08) translate(3%, 2%); } }
@keyframes rr-sway { from { transform: rotate(-2.5deg); } to { transform: rotate(2deg) translate(12px, 8px); } }
@keyframes rr-mote {
  0% { transform: translate(0, 0); opacity: 0; }
  14% { opacity: 0.75; }
  50% { transform: translate(16px, -32vh); }
  86% { opacity: 0.4; }
  100% { transform: translate(-12px, -64vh); opacity: 0; }
}
@keyframes rr-drift { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.05) translate(-1.6%, -1%); } }
@keyframes rr-lamp { from { opacity: 0.65; } to { opacity: 1; } }
@keyframes rr-arrive {
  from { opacity: 0; transform: translateY(60px) rotate(calc(var(--r) * -1.6)) scale(0.92); }
  to { opacity: 1; transform: rotate(var(--r)); }
}
@keyframes rr-float {
  from { transform: rotate(var(--r)) translateY(0); }
  to { transform: rotate(calc(var(--r) + 1.4deg)) translateY(-9px); }
}
@keyframes rr-label { from { opacity: 0; transform: translate(-50%, 140%); } to { opacity: 1; transform: translate(-50%, 100%); } }
@keyframes rr-scroll { 0% { transform: translateX(-20px); } 60%, 100% { transform: translateX(60px); } }

/* ============================================================
   LAYOUT
   ============================================================ */
/* Short laptop screens: the cue would crowd the buttons. */
@media (min-width: 901px) and (max-height: 760px) {
  .rr-scroll { display: none; }
}
@media (min-width: 901px) and (max-height: 820px) {
  .rr-flourish { margin-bottom: 1.1rem; }
}

@media (max-width: 900px) {
  .rr-scroll { display: none; }
  .rr-photo-wrap { margin-bottom: 1.2rem; }
  .rr-stack { left: 4%; bottom: -18px; width: clamp(150px, 34vw, 210px); translate: none; }
  .rr-stack-books { height: calc(clamp(150px, 34vw, 210px) * 0.46 * 1.5 + 14px); }
  .rr-stack-label { display: none; }
  .rr-leaves { width: 120%; opacity: 0.035; }
}
@media (max-width: 480px) {
  .rr-welcome { font-size: 1.1rem; }
}
