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

html, body {
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  background: #000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#book {
  position: relative;
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
  perspective: 2000px;
  overflow: hidden;
}

/* ── Pages ── */

.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform;
  overflow: hidden;
  background: #3a3127;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 40px,
      rgba(0,0,0,0.02) 40px,
      rgba(0,0,0,0.02) 41px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(0,0,0,0.015) 40px,
      rgba(0,0,0,0.015) 41px
    );
}

.page .page-inner {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  bottom: 10px;
  border-radius: 4px;
  overflow: hidden;
  background: #3a3127;
  box-shadow:
    inset 0 0 8px rgba(0,0,0,0.3),
    0 0 4px rgba(0,0,0,0.2);
}

/* Paper edge highlight */
.page::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255,240,220,0.15);
  border-radius: 2px;
  pointer-events: none;
  z-index: 50;
  background:
    linear-gradient(to bottom, rgba(210,190,160,0.25) 0%, transparent 3%, transparent 97%, rgba(210,190,160,0.2) 100%),
    linear-gradient(to right, rgba(210,190,160,0.2) 0%, transparent 3%, transparent 97%, rgba(210,190,160,0.15) 100%);
}

.page.flipped {
  transform: rotateY(-180deg);
  pointer-events: none;
}

.page.animating {
  transition: transform 0.9s cubic-bezier(0.645, 0.045, 0.355, 1.0);
}

/* Shadow on the page being revealed during a flip */
.page::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.25) 0%,
    rgba(0, 0, 0, 0.08) 15%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.9s;
  pointer-events: none;
  z-index: 100;
}

.page.shadow-on::after {
  opacity: 1;
}

/* ── Layers ── */

.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* ── View 1: Video ── */

#view-1 video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#view-1 .last-frame {
  opacity: 0;
  transition: opacity 0.4s ease;
}

#view-1 .last-frame.visible {
  opacity: 1;
}

/* ── View 5: Jungle Book fade-in layers ── */

.jb-fade {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.jb-fade.visible {
  opacity: 1;
}

/* ── View 9: Explore button ── */

#v9-explore {
  cursor: pointer;
  pointer-events: auto !important;
}

/* ── Tap hint overlay ── */

#tap-hint {
  position: fixed;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#tap-hint.visible {
  opacity: 1;
}

#tap-hint span {
  color: rgba(255, 255, 255, 0.7);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 8px 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  background: rgba(0, 0, 0, 0.2);
  animation: pulse-hint 2s ease-in-out infinite;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}
