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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #000;
  min-height: 100vh;
  overflow: hidden;
}

.viewer-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #1a1a1a;
}

.book-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  perspective: 1000px;
  perspective-origin: center center;
  position: relative;
}

/* ── Flip card ─────────────────────────────────────────────────────────────── */
/* Absolutely positioned over one panel; rotates a full 180° for page turns.   */
#flipCard {
  position: absolute;
  top: 0;
  height: 100%;
  display: none; /* shown only during animation                       */
  transform-style: preserve-3d;
  z-index: 20;
  pointer-events: none;
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: #000; /* prevents bleed-through at exactly 90°             */
}

.flip-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

/* The back face is pre-rotated 180° so it appears un-mirrored when the        */
/* parent card reaches ±180°.                                                   */
.flip-back {
  transform: rotateY(180deg);
}

.book-panel {
  width: 50%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.book-panel img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.book-spine {
  width: 6px;
  height: 100%;
  background: linear-gradient(to right, #111, #444, #111);
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
}

.panel-shadow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

.panel-shadow-right {
  background: linear-gradient(
    to left,
    transparent 40%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

.panel-shadow-left {
  background: linear-gradient(
    to right,
    transparent 40%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

/* Hotspot overlay — sits on top of the image, sized to the image */
.hotspot-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Individual clickable hotspot */
.hotspot {
  position: absolute;
  background: rgba(52, 152, 219, 0.08);
  border: 1px solid rgba(52, 152, 219, 0.25);
  border-radius: 3px;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  backdrop-filter: none;
  transition:
    background 0.2s,
    border-color 0.2s;
  touch-action: manipulation;
}

.hotspot:hover {
  background: rgba(52, 152, 219, 0.22);
  border-color: rgba(52, 152, 219, 0.7);
  transform: none;
}

.hotspot:active {
  background: rgba(52, 152, 219, 0.4);
  transform: none;
}

.home-btn {
  position: fixed;
  left: 20px;
  bottom: 20px;
  transform: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(107, 107, 107, 0.2);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  touch-action: manipulation;
  z-index: 100;
}

.home-btn:hover {
  background: rgba(107, 107, 107, 0.5);
  transform: scale(1.1);
}

.home-btn:active {
  transform: scale(0.9);
}

.controls {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

.info {
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  backdrop-filter: blur(10px);
}

.buttons {
  display: flex;
  gap: 10px;
}

button {
  padding: 10px 16px;
  background: rgba(107, 107, 107, 0.2);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  touch-action: manipulation;
}

button:hover {
  background: rgba(107, 107, 107, 0.5);
  transform: scale(1.05);
}

button:active {
  transform: scale(0.95);
}

.fullscreen-btn {
  padding: 10px 12px;
}

.fullscreen-btn img,
.home-btn img {
  width: 24px;
  height: 24px;
  display: block;
  filter: brightness(0) invert(1);
}

.nav-arrows {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 15px;
  z-index: 100;
}

.nav-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(107, 107, 107, 0.2);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  touch-action: manipulation;
}

.nav-btn:hover {
  background: rgba(107, 107, 107, 0.5);
  transform: scale(1.1);
}

.nav-btn:active {
  transform: scale(0.9);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  z-index: 200;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.touch-hint {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .buttons {
    gap: 8px;
  }

  button {
    padding: 8px 12px;
    font-size: 12px;
  }

  .nav-arrows {
    bottom: 15px;
    gap: 10px;
  }

  .nav-btn {
    width: 45px;
    height: 45px;
    font-size: 18px;
  }

  .touch-hint {
    bottom: 75px;
    font-size: 11px;
  }
}
