/* bookshelf/viewer.css — shared flip viewer styles */

@font-face {
  font-family: 'GoodHand';
  src: url('../assets/fonts/GoodHandFont-Regular.ttf') format('truetype');
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:    #111110;
  --cream: #faf8f4;
  --muted: rgba(255, 255, 255, 0.35);
  --mono:  'Courier New', monospace;
  --hand:  'GoodHand', cursive;
}

body {
  background: var(--bg);
  color: var(--cream);
  height: 100dvh;
  overflow: hidden;
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* TOP BAR */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(to bottom, rgba(17,17,16,0.95), transparent);
}

.topbar-back {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.topbar-back:hover { color: var(--cream); }

.topbar-title {
  font-family: var(--hand);
  font-size: 1rem;
  color: var(--cream);
  opacity: 0.7;
}

.topbar-count {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* PAGE VIEWER */
.viewer {
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.page-img {
  max-width: 100%;
  max-height: 100dvh;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

/* TURNING LEAF — a page folding over the spine (left edge) */
.leaf {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  transform-origin: left center;
  transform: perspective(1600px) rotateY(0deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.48s cubic-bezier(0.3, 0.2, 0.2, 1);
  will-change: transform;
  box-shadow: 6px 0 18px rgba(0, 0, 0, 0.35);
}

.leaf.turned  { transform: perspective(1600px) rotateY(-130deg); }
.leaf.no-anim { transition: none; }

.leaf img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Shading that deepens as the page lifts */
.leaf-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 45%);
  opacity: 0;
  transition: opacity 0.48s ease;
}

.leaf.turned .leaf-shade { opacity: 1; }

/* FIRST-OPEN HINT */
.hint {
  position: fixed;
  bottom: 2.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream);
  background: rgba(17, 17, 16, 0.55);
  padding: 0.55rem 1rem;
  border-radius: 99px;
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.6s ease;
}

.hint-hide { opacity: 0; }

/* CLICK ZONES */
.zone {
  position: absolute;
  top: 0;
  height: 100%;
  width: 40%;
  cursor: pointer;
  z-index: 5;
}

.zone-prev { left: 0; }
.zone-next { right: 0; }

/* ARROWS — always visible, pulse on first load to signal interactivity */
@keyframes arrowReveal {
  0%   { opacity: 0; }
  40%  { opacity: 0.85; }
  100% { opacity: 0.28; }
}

.arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  font-size: 2.6rem;
  color: var(--cream);
  opacity: 0.28;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.2s;
  animation: arrowReveal 2s ease-out;
}

.arrow-prev { left: 0.9rem; }
.arrow-next { right: 0.9rem; animation-delay: 0.35s; animation-fill-mode: backwards; }

.arrow:hover             { opacity: 0.9; }
.zone-prev:hover ~ .arrow-prev { opacity: 0.75; }
.zone-next:hover ~ .arrow-next { opacity: 0.75; }

/* PROGRESS BAR */
.progress-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  z-index: 10;
}

.progress-fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.38);
  transition: width 0.25s ease;
}
