/* Quiet Shelf — About / Support page.
   The lantern is the hero. Everything else is quiet around it.
   CSS-only: no images, no external assets. Pure gradients, shadows, and
   keyframe animation. Palette drawn straight from tokens/colors.css. */

/* ── Lantern scene ─────────────────────────────────────────────────── */

.qs-lantern-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-12) 0 var(--space-8);
  position: relative;
  /* Subtle vignette — the room beyond the shelf is dark */
  background: radial-gradient(ellipse 70% 60% at 50% 30%,
    rgba(197,137,59,0.07) 0%,
    transparent 70%);
}

/* ── Bookshelf ─────────────────────────────────────────────────────── */

/* Scoped to the lantern scene: these restyle the SHARED shelf classes for
   the About hero only. Unscoped they leaked into Home and the Format payoff
   (height:88px capped the books row, so the payoff book overflowed upward
   over the "It's your book now" announcement). */
.qs-lantern-scene .qs-shelf {
  position: relative;
  width: min(680px, 100%);
  margin: 0 auto;
}

/* The shelf plank — rustic wood via layered gradients */
.qs-lantern-scene .qs-shelf__plank {
  position: relative;
  width: 100%;
  height: 22px;
  border-radius: 2px 2px 4px 4px;
  /* Wood base: warm medium oak */
  background:
    /* grain lines */
    repeating-linear-gradient(
      92deg,
      transparent 0px, transparent 18px,
      rgba(0,0,0,0.04) 18px, rgba(0,0,0,0.04) 19px,
      transparent 19px, transparent 34px,
      rgba(255,255,255,0.03) 34px, rgba(255,255,255,0.03) 35px
    ),
    repeating-linear-gradient(
      89deg,
      transparent 0px, transparent 8px,
      rgba(0,0,0,0.03) 8px, rgba(0,0,0,0.03) 9px
    ),
    /* base wood tone */
    linear-gradient(180deg,
      #5c3d1e 0%,
      #6b4a26 30%,
      #7a5530 70%,
      #4e3218 100%
    );
  box-shadow:
    0 4px 12px rgba(0,0,0,0.6),
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -1px 0 rgba(0,0,0,0.3);
}

/* Shelf edge — darker lip at the front */
.qs-lantern-scene .qs-shelf__plank::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(180deg, #3d2610 0%, #2a1a0a 100%);
  border-radius: 0 0 4px 4px;
}

/* Books sitting on the shelf */
.qs-lantern-scene .qs-shelf__books {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 24px;
  height: 88px;
  min-height: 88px; /* out-specifies kit.css's min-height:150px */
  justify-content: center; /* center the books+lantern group on the shelf */
  overflow: visible; /* lantern is taller than the row — must not clip */
}

.qs-book-spine {
  width: var(--w, 18px);
  height: var(--h, 72px);
  border-radius: 1px 1px 0 0;
  background: var(--c, #3a2a4a);
  box-shadow:
    inset -2px 0 4px rgba(0,0,0,0.3),
    inset 1px 0 0 rgba(255,255,255,0.06),
    1px 0 2px rgba(0,0,0,0.4);
  position: relative;
  flex-shrink: 0;
}

/* Slight lean on a few books for realism */
.qs-book-spine:nth-child(3) { transform: rotate(-1.5deg); transform-origin: bottom center; }
.qs-book-spine:nth-child(7) { transform: rotate(1deg); transform-origin: bottom center; }
.qs-book-spine:nth-child(11) { transform: rotate(-0.8deg); transform-origin: bottom center; }

/* ── Lantern ───────────────────────────────────────────────────────── */

.qs-lantern {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
  /* Lift the lantern so it sits ON the shelf plank */
  margin-bottom: 0;
}

/* Glow cast on the shelf and books around the lantern */
.qs-lantern::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 40px;
  background: radial-gradient(ellipse, rgba(217,164,88,0.25) 0%, transparent 70%);
  border-radius: 50%;
  animation: qs-glow-pulse 3.5s ease-in-out infinite;
}

/* Hook at the top */
.qs-lantern__hook {
  width: 2px;
  height: 16px;
  background: linear-gradient(180deg, #6b5a3a 0%, #4a3d25 100%);
  border-radius: 1px;
  position: relative;
}
.qs-lantern__hook::before {
  content: '';
  position: absolute;
  top: -4px; left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 5px;
  border: 1.5px solid #6b5a3a;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

/* Cap */
.qs-lantern__cap {
  width: 42px;
  height: 10px;
  background: linear-gradient(180deg, #5a4a2a 0%, #3d3018 100%);
  border-radius: 2px 2px 0 0;
  box-shadow: 0 -1px 0 rgba(255,255,255,0.08), 0 2px 4px rgba(0,0,0,0.4);
  position: relative;
  z-index: 2;
}

/* Lantern body — the glass cage */
.qs-lantern__body {
  width: 38px;
  height: 56px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Glass panels — warm tinted */
  background: linear-gradient(135deg,
    rgba(217,164,88,0.15) 0%,
    rgba(217,164,88,0.08) 40%,
    rgba(217,164,88,0.18) 60%,
    rgba(217,164,88,0.10) 100%
  );
  border: 1px solid rgba(197,137,59,0.35);
  box-shadow:
    inset 0 0 12px rgba(217,164,88,0.2),
    0 0 24px rgba(217,164,88,0.3),
    0 0 48px rgba(197,137,59,0.15),
    0 0 80px rgba(197,137,59,0.08);
  animation: qs-lantern-glow 3.5s ease-in-out infinite;
}

/* Frame bars (the metal cage) */
.qs-lantern__body::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(90,74,42,0.8) 0px, transparent 1.5px, transparent 36.5px, rgba(90,74,42,0.8) 38px),
    linear-gradient(180deg, transparent 18px, rgba(90,74,42,0.4) 18px, rgba(90,74,42,0.4) 20px, transparent 20px,
      transparent 36px, rgba(90,74,42,0.4) 36px, rgba(90,74,42,0.4) 38px, transparent 38px);
  pointer-events: none;
}

/* The flame */
.qs-flame {
  width: 12px;
  height: 18px;
  position: relative;
  animation: qs-flame-flicker 2.1s ease-in-out infinite;
}

.qs-flame__inner {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 14px;
  background: radial-gradient(ellipse at 50% 80%,
    #fff8e0 0%,
    #ffd060 30%,
    #ff8c00 65%,
    transparent 100%
  );
  border-radius: 50% 50% 20% 20% / 60% 60% 30% 30%;
  filter: blur(0.5px);
}

.qs-flame__outer {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 19px;
  background: radial-gradient(ellipse at 50% 85%,
    rgba(255,180,0,0.6) 0%,
    rgba(255,100,0,0.3) 50%,
    transparent 80%
  );
  border-radius: 50% 50% 20% 20% / 60% 60% 30% 30%;
  filter: blur(1.5px);
  animation: qs-flame-outer 2.8s ease-in-out infinite;
}

/* Base */
.qs-lantern__base {
  width: 44px;
  height: 8px;
  background: linear-gradient(180deg, #4a3d25 0%, #2e2510 100%);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.06);
  position: relative;
  z-index: 2;
}

/* ── Glow cast on the page around the lantern ─────────────────────── */
.qs-lantern-scene__glow {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 180px;
  background: radial-gradient(ellipse at 50% 70%,
    rgba(217,164,88,0.12) 0%,
    rgba(197,137,59,0.06) 40%,
    transparent 70%
  );
  pointer-events: none;
  animation: qs-glow-pulse 3.5s ease-in-out infinite;
}

/* ── Keyframes ─────────────────────────────────────────────────────── */

@keyframes qs-flame-flicker {
  0%, 100% { transform: scaleX(1) scaleY(1) rotate(0deg); }
  20%       { transform: scaleX(0.92) scaleY(1.06) rotate(-1.5deg); }
  45%       { transform: scaleX(1.05) scaleY(0.97) rotate(1deg); }
  70%       { transform: scaleX(0.95) scaleY(1.04) rotate(-0.8deg); }
  85%       { transform: scaleX(1.03) scaleY(0.98) rotate(0.5deg); }
}

@keyframes qs-flame-outer {
  0%, 100% { opacity: 0.7; transform: translateX(-50%) scaleY(1); }
  33%      { opacity: 0.5; transform: translateX(-50%) scaleY(0.9) rotate(1deg); }
  66%      { opacity: 0.8; transform: translateX(-50%) scaleY(1.05) rotate(-0.5deg); }
}

@keyframes qs-lantern-glow {
  0%, 100% {
    box-shadow:
      inset 0 0 12px rgba(217,164,88,0.20),
      0 0 24px rgba(217,164,88,0.30),
      0 0 48px rgba(197,137,59,0.15),
      0 0 80px rgba(197,137,59,0.08);
  }
  50% {
    box-shadow:
      inset 0 0 16px rgba(217,164,88,0.28),
      0 0 32px rgba(217,164,88,0.40),
      0 0 60px rgba(197,137,59,0.20),
      0 0 100px rgba(197,137,59,0.10);
  }
}

@keyframes qs-glow-pulse {
  0%, 100% { opacity: 0.8; }
  50%      { opacity: 1.0; }
}

/* Dim state — when no donations received, flame shrinks and cools */
.qs-lantern--dim .qs-lantern__body {
  animation: qs-lantern-glow-dim 4s ease-in-out infinite;
}
.qs-lantern--dim .qs-flame__inner {
  background: radial-gradient(ellipse at 50% 80%,
    #ffe8a0 0%,
    #e0a020 30%,
    #b06000 65%,
    transparent 100%
  );
  opacity: 0.6;
}
.qs-lantern--dim .qs-flame__outer {
  opacity: 0.35;
}

@keyframes qs-lantern-glow-dim {
  0%, 100% {
    box-shadow:
      inset 0 0 6px rgba(217,164,88,0.10),
      0 0 12px rgba(217,164,88,0.15),
      0 0 24px rgba(197,137,59,0.06);
  }
  50% {
    box-shadow:
      inset 0 0 10px rgba(217,164,88,0.15),
      0 0 18px rgba(217,164,88,0.20),
      0 0 36px rgba(197,137,59,0.08);
  }
}

/* Roar state — donation click, flame surges */
.qs-lantern--roar .qs-lantern__body {
  animation: qs-lantern-roar 1.2s ease-out forwards;
}
.qs-lantern--roar .qs-flame {
  animation: qs-flame-roar 1.2s ease-out forwards;
}

@keyframes qs-lantern-roar {
  0%  {
    box-shadow:
      inset 0 0 30px rgba(255,220,80,0.6),
      0 0 60px rgba(255,200,50,0.8),
      0 0 120px rgba(217,164,88,0.5),
      0 0 200px rgba(197,137,59,0.3);
  }
  100% {
    box-shadow:
      inset 0 0 16px rgba(217,164,88,0.28),
      0 0 32px rgba(217,164,88,0.40),
      0 0 60px rgba(197,137,59,0.20),
      0 0 100px rgba(197,137,59,0.10);
  }
}

@keyframes qs-flame-roar {
  0%   { transform: scaleX(1.3) scaleY(1.5); }
  40%  { transform: scaleX(0.9) scaleY(1.2) rotate(-3deg); }
  100% { transform: scaleX(1) scaleY(1) rotate(0deg); }
}

/* ── Support copy ──────────────────────────────────────────────────── */

.qs-lantern-copy {
  text-align: center;
  max-width: 480px;
  margin: var(--space-8) auto 0;
  padding: 0 var(--space-4);
}

.qs-lantern-copy__headline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  color: var(--text-body);
  margin: 0 0 var(--space-4);
  line-height: 1.3;
}

.qs-lantern-copy__body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0 0 var(--space-6);
}

.qs-lantern-copy__body strong {
  color: var(--text-body);
  font-weight: 500;
}

.qs-donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 28px;
  background: none;
  border: 1px solid var(--ember-500);
  border-radius: var(--radius-xs);
  color: var(--ember-400);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  letter-spacing: 0.03em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.qs-donate-btn:hover {
  background: var(--wash-ember);
  border-color: var(--ember-400);
  color: var(--ember-400);
}

.qs-lantern-thankyou {
  margin-top: var(--space-4);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ember-400);
  opacity: 0;
  transition: opacity 0.6s ease;
  min-height: 1.4em;
}
.qs-lantern-thankyou--show { opacity: 1; }

/* ── Divider after lantern section ─────────────────────────────────── */
.qs-lantern-divider {
  width: min(480px, 90%);
  margin: var(--space-12) auto;
  height: 1px;
  background: var(--edge-soft);
}

/* Reduced motion — keep everything static, lantern just glows softly */
@media (prefers-reduced-motion: reduce) {
  .qs-flame, .qs-flame__inner, .qs-flame__outer,
  .qs-lantern__body, .qs-lantern-scene__glow,
  .qs-lantern::before {
    animation: none !important;
  }
}
