/* King James Bible (working name)
   Shell copied from the Buy Low, Sell High pattern: one fixed stage + one 9:16 frame.
   The art never moves. Only the controls inside .btn-wrap change on later pages. */

@font-face {
  font-family: "KJV Serif";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/source-serif-pro-700.woff2?v=20261129d") format("woff2");
}

:root {
  --bg: #120c06;              /* matches theme_color / background_color */
  --btn-band-height: 22%;
  --gold-hi: #ecd29a;
  --gold: #cfa25a;
  --gold-lo: #a97a36;
  --gold-edge: #5c3c14;
  --ink: #2a1806;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #fff;
  position: fixed;
  inset: 0;
}

.stage {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
  container-type: size;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
}

.frame {
  position: relative;
  width: min(100cqw, calc(100cqh * 9 / 16));
  aspect-ratio: 9 / 16;
  max-height: 100cqh;
  overflow: hidden;
  background: var(--bg);
  container-type: size;
}

.art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Dark fade from 68% down so the buttons sit on a calm, dark band. */
.bottom-fade {
  position: absolute;
  left: 0;
  right: 0;
  top: 68%;
  bottom: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(18, 12, 6, 0) 0%,
    rgba(18, 12, 6, 0.6) 24%,
    rgba(18, 12, 6, 0.92) 50%,
    #120c06 72%,
    #0d0804 100%
  );
}

/* Fixed button band: bottom 22% of the frame, same box on every page. */
.btn-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--btn-band-height);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 0 2.8cqw 1.2cqh;
  pointer-events: none;
}

.menu-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 1.8cqw;
  width: 100%;
  height: 16.5cqh;
}

.gold-btn {
  pointer-events: auto;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0 1.6cqw 0.6cqh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "KJV Serif", "Source Serif Pro", Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 6.3cqw;
  line-height: 1.12;
  letter-spacing: 0;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 238, 200, 0.55);
  cursor: pointer;
  border: 0.35cqw solid var(--gold-edge);
  border-radius: 3.2cqw;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 46%, var(--gold-lo) 100%);
  box-shadow:
    inset 0 0.35cqw 0 rgba(255, 246, 220, 0.65),
    inset 0 -0.9cqw 1.4cqw rgba(90, 55, 15, 0.38),
    0 1.3cqw 0 #4a300f,
    0 2.4cqw 3.2cqw rgba(0, 0, 0, 0.65);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Soft shine across the top of each button. */
.gold-btn::before {
  content: "";
  position: absolute;
  left: 5%;
  right: 5%;
  top: 4%;
  height: 40%;
  border-radius: 2.6cqw 2.6cqw 40% 40% / 2.6cqw 2.6cqw 30% 30%;
  background: linear-gradient(180deg, rgba(255, 250, 235, 0.5) 0%, rgba(255, 250, 235, 0) 100%);
  pointer-events: none;
}

/* Pressed: the button sinks down onto its edge. */
.gold-btn:active {
  transform: translateY(1cqw);
  box-shadow:
    inset 0 0.35cqw 0 rgba(255, 246, 220, 0.5),
    inset 0 -0.6cqw 1cqw rgba(90, 55, 15, 0.38),
    0 0.3cqw 0 #4a300f,
    0 1cqw 1.6cqw rgba(0, 0, 0, 0.6);
}

.gold-btn:focus-visible {
  outline: 0.6cqw solid #f3e2b5;
  outline-offset: 0.6cqw;
}

/* ---------------- Cover motion ----------------
   The JPEG never moves. Soft pieces are painted on top in a 720x1280 layer
   that is scaled to the frame (same pixel grid as cover.jpg). Transform/opacity only. */

@font-face {
  font-family: "KJV Page";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/source-serif-pro-400.woff2?v=20261129d") format("woff2");
}

.fx {
  position: absolute;
  left: 0;
  top: 0;
  width: 720px;
  height: 1280px;
  /* zoom (not transform) so the layer is not an isolated group and blend modes reach the art */
  zoom: var(--s, 0.5);
  pointer-events: none;
  overflow: hidden;
}

/* 4. Leaves outside the window: a slightly shifted copy of the glass area drifts and fades. */
.leaves {
  position: absolute;
  left: 4px;
  top: 0;
  width: 144px;
  height: 188px;
  overflow: hidden;
}
.leaves-img {
  position: absolute;
  left: -10px;
  top: -6px;
  width: 720px;
  height: 1280px;
  background: url("/cover.jpg?v=20261129d") no-repeat;
  background-size: 720px 1280px;
  background-position: 6px 6px;
  opacity: 0;
  animation: leafSway 7.5s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
@keyframes leafSway {
  0%   { transform: translate(0, 0);        opacity: 0; }
  35%  { transform: translate(2.5px, 1px);  opacity: 0.55; }
  70%  { transform: translate(-1.5px, 2px); opacity: 0.4; }
  100% { transform: translate(1px, -1px);   opacity: 0.6; }
}

/* 2. Breathing gold light: the window beam and a glow on the pages. */
.beam {
  position: absolute;
  left: 128px;
  top: -30px;
  width: 230px;
  height: 420px;
  transform-origin: 50% 0;
  transform: skewX(-13deg);
  background: linear-gradient(90deg, rgba(255, 214, 150, 0) 0%, rgba(255, 214, 150, 0.3) 30%, rgba(255, 222, 165, 0.38) 50%, rgba(255, 214, 150, 0.3) 70%, rgba(255, 214, 150, 0) 100%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, #000 45%, rgba(0,0,0,0.5) 80%, rgba(0,0,0,0) 100%);
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, #000 45%, rgba(0,0,0,0.5) 80%, rgba(0,0,0,0) 100%);
  mix-blend-mode: screen;
  opacity: 0.08;
  animation: breatheBeam 9s ease-in-out infinite;
  will-change: opacity;
}
@keyframes breatheBeam {
  0%, 100% { opacity: 0.06; }
  50%      { opacity: 0.3; }
}
.page-glow {
  position: absolute;
  left: 90px;
  top: 330px;
  width: 560px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 220, 160, 0.5), rgba(255, 210, 150, 0.18) 60%, rgba(255, 210, 150, 0) 100%);
  mix-blend-mode: soft-light;
  opacity: 0.25;
  animation: breathe 9s ease-in-out infinite;
  will-change: opacity;
}
@keyframes breathe {
  0%, 100% { opacity: 0.12; }
  50%      { opacity: 0.42; }
}

/* 1. Dust specks drifting in the beam. */
.dust i {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 238, 200, 0.95) 0 30%, rgba(255, 220, 160, 0) 70%);
  opacity: 0;
  animation: drift var(--t) linear infinite;
  animation-delay: var(--d);
  will-change: transform, opacity;
}
.dust i.sm { width: 3.5px; height: 3.5px; }
@keyframes drift {
  0%   { transform: translate(0, 0);                                  opacity: 0; }
  20%  { opacity: 0.55; }
  50%  { transform: translate(calc(var(--dx) * 0.6), calc(var(--dy) * 0.5)); opacity: 0.3; }
  80%  { opacity: 0.5; }
  100% { transform: translate(var(--dx), var(--dy));                  opacity: 0; }
}

/* 5. Real KJV words laid onto the two open pages (matrix3d set in app.js). */
.page {
  position: absolute;
  left: 0;
  top: 0;
  width: 340px;
  height: 300px;
  transform-origin: 0 0;
  mix-blend-mode: multiply;
}
.page-in {
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 2px 4px;
  color: #3a2614;
  font-family: "KJV Page", Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.3;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  opacity: 0.74;
  transition: opacity 0.7s ease;
}
.page .ref {
  font-family: "KJV Serif", Georgia, serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: #5a2e14;
  margin: 0 0 3px;
}
.page .txt + .ref { margin-top: 7px; }
.page .txt sup {
  font-size: 0.6em;
  font-weight: 700;
  color: #6b3a18;
  margin-right: 2px;
  vertical-align: 0.5em;
  line-height: 0;
}
.page.fading .page-in { opacity: 0; }
.page.settle .page-in { animation: settle 1.4s ease-out; }
@keyframes settle {
  0%   { transform: translateY(-3px); }
  55%  { transform: translateY(0.8px); }
  100% { transform: translateY(0); }
}

/* Page-turn sweep across the right page (a soft shadow + sheen band). */
.page .turn {
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: 0;
  width: 140px;
  background: linear-gradient(90deg, rgba(60, 35, 10, 0) 0%, rgba(60, 35, 10, 0.28) 45%, rgba(255, 245, 220, 0.25) 60%, rgba(255, 245, 220, 0) 100%);
  opacity: 0;
  transform: translateX(360px);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
}
.page.turning .turn { animation: sweep 1.5s ease-in-out; }
@keyframes sweep {
  0%   { transform: translateX(360px); opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateX(-160px); opacity: 0; }
}

/* 3. Pages settling: a faint gutter shadow that slowly deepens and eases. */
.gutter {
  position: absolute;
  inset: 0;
  clip-path: polygon(296px 368px, 340px 366px, 412px 500px, 368px 502px);
  background: linear-gradient(90deg, rgba(50, 28, 8, 0), rgba(50, 28, 8, 0.5), rgba(50, 28, 8, 0));
  mix-blend-mode: multiply;
  opacity: 0.1;
  animation: gutterSettle 11s ease-in-out infinite;
  will-change: opacity;
}
@keyframes gutterSettle {
  0%, 100% { opacity: 0.08; }
  50%      { opacity: 0.32; }
}

/* Pause everything while hidden, and keep a still picture for reduced motion. */
.fx.paused *,
.fx.paused .page-in { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  .fx *, .fx .page-in { animation: none !important; transition: none !important; }
  .leaves, .dust { display: none; }
  .beam, .page-glow { opacity: 0.2; }
  .gutter { opacity: 0.15; }
}
