* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #2b2b3d;
  font-family: -apple-system, system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #fff;
  gap: 10px;
}

/* --- Estado de carga (Fase 4, prompt 4.1) --- */

.spinner {
  width: 48px;
  height: 48px;
  border: 6px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffd65c;
  border-radius: 50%;
  animation: girar 0.9s linear infinite;
}

@keyframes girar {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* --- Utilidad de accesibilidad (Fase 4, prompt 4.2) --- */
/* Oculta visualmente sin ocultar para lectores de pantalla. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Visor de páginas (Fase 2) --- */

#book-wrapper {
  position: relative;
  width: min(92vw, 700px);
  aspect-ratio: 4 / 5;
}

#book {
  width: 100%;
  height: 100%;
}

.nav-zone {
  position: absolute;
  /* Ojo: se deja libre el 27% superior e inferior -- es justo la zona de
     esquina que page-flip usa para el arrastre de volteo (ver
     isPointOnCorners en Flip.ts, ~diagonal/5). Si el nav-zone cubriera
     también las esquinas, se robaría el toque antes de que le llegue a
     page-flip: un arrastre iniciado ahí nunca voltearía la página.
     (Hallazgo de la POC de la Fase 0, prompt 0.4.) */
  top: 27%;
  bottom: 27%;
  width: 18%;
  background: transparent;
  border: none;
  padding: 0;
  z-index: 20;
  /* zona táctil grande e invisible para avanzar/retroceder con un tap simple */
}

.nav-zone.prev { left: 0; }
.nav-zone.next { right: 0; }
.nav-zone:active { background: rgba(255, 255, 255, 0.08); }

.big-btn {
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  border: none;
  background: #ffd65c;
  color: #2b2b3d;
  font-size: 28px;
  font-weight: bold;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.big-btn:disabled {
  opacity: 0.35;
}

#controls {
  display: flex;
  gap: 24px;
  align-items: center;
}

#status {
  color: #fff;
  font-size: 14px;
  min-width: 90px;
  text-align: center;
}

/* --- Lupa (Fase 3) --- */

#magnifier {
  position: fixed;
  /* pointer-events:none -- la lupa nunca debe robarle toques a nada; toda
     la interacción real ocurre sobre #book, la lupa solo se dibuja encima. */
  pointer-events: none;
  z-index: 50;
  display: none;
}

#magnifier.visible {
  display: block;
}

#magnifier .lupa-zoom {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
}

#magnifier .lupa-marco {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
