/* ================================================================
   Physical 3D page-turn — single source of truth for viewer layout.
   ================================================================ */

/* ---- Stage: positioning context + perspective ---- */
.yb-stage{
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  perspective: 3000px;
  perspective-origin: 50% 50%;
  transform-style: preserve-3d;
  min-height: 320px;
}

/* ---- Pages: stacked. Only the active one is in flow. ----
   NO opacity transition — the JS controls visibility directly via
   the .is-active class. This stops the fade fighting the flip. */
.yb-page{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  transform-origin: left center;
}
.yb-page.is-active{
  position: relative;
  opacity: 1;
  pointer-events: auto;
}

/* Image sizing — big, magazine-like. */
.yb-page img{
  max-width: 100%;
  max-height: calc(100vh - 220px);
  max-height: calc(100dvh - 220px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  box-shadow: 0 30px 60px rgba(0,0,0,.55);
  background: #0b0a08;
}

.yb-caption{
  margin-top: 10px;
  color: var(--yb-muted);
  font-size: .85rem;
}

/* Do NOT animate the incoming page — it just appears fully formed. */
.yb-page.is-active.is-incoming{ animation: none; }

/* -------- The flipping layer (created by JS) -------- */
.yb-flip{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform;
  pointer-events: none;
  z-index: 20;
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    0 30px 60px rgba(0,0,0,.55),
    0 0 0 1px rgba(212,175,55,.10);
  background: #0b0a08;
}

.yb-flip img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0b0a08;
}

/* Soft shading on the front face as it turns away */
.yb-flip::before{
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0) 50%,
    rgba(0,0,0,.30) 100%);
  opacity: 0;
  transition: opacity .45s ease;
  pointer-events: none;
}
.yb-flip.is-shading::before{ opacity: 1; }

/* Gold spine line on the hinge */
.yb-flip::after{
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(
    to bottom,
    rgba(212,175,55,0) 0%,
    rgba(240,199,94,.55) 20%,
    rgba(240,199,94,.75) 50%,
    rgba(240,199,94,.55) 80%,
    rgba(212,175,55,0) 100%);
  pointer-events: none;
  opacity: .9;
}

/* ---- Forward turn: 1.4s, smoother ease, less aggressive finish ---- */
.yb-flip.turn-next{
  animation: flipNext 1.4s cubic-bezier(.55,.02,.25,1) forwards;
}
@keyframes flipNext{
  0%   { transform: rotateY(0deg);    }
  100% { transform: rotateY(-175deg); }
}

/* ---- Backward turn ---- */
.yb-flip.turn-prev{
  animation: flipPrev 1.4s cubic-bezier(.55,.02,.25,1) forwards;
}
@keyframes flipPrev{
  0%   { transform: rotateY(0deg);   }
  100% { transform: rotateY(175deg); }
}

/* Lazy-loading fade */
.yb-lazy{ opacity: .35; transition: opacity .4s ease; }
.yb-lazy.is-loaded{ opacity: 1; }

/* ---------- Print ---------- */
@media print{
  .yb-navbar,
  .yb-toolbar,
  .yb-footer,
  .yb-grid-overlay,
  .yb-flip{ display: none !important; }

  body{ background: #fff; color: #000; }
  .yb-viewer{ padding: 0; }
  .yb-stage{
    perspective: none;
    max-width: none;
    min-height: 0;
    transform-style: flat;
  }
  .yb-page{
    position: relative !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    page-break-after: always;
    break-after: page;
    inset: auto !important;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: none !important;
  }
  .yb-page img{
    max-width: 100%;
    max-height: 98vh;
    box-shadow: none;
    border-radius: 0;
  }
  .yb-caption{ display: none; }
  .yb-gallery-page{ max-height: none; overflow: visible; }
}