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

html, body {
  width: 100%;
  height: 100%;
  background: #f0f0f0;
  overflow: hidden;
}

/* Loader */
#loader {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  transition: opacity 0.4s ease;
}
#loader.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 24px; height: 24px;
  border: 2px solid #e0e0e0;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* App — ocupa todo */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#flipbook-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Slides */
#flipbook {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1),
              opacity   0.38s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}

.slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 2px 40px rgba(0,0,0,0.10);
}

/* Tap zones — solo mobile */
#tap-prev,
#tap-next {
  display: none;
  position: fixed;
  top: 15%; bottom: 15%;
  width: 18%;
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
}
#tap-prev { left: 0; }
#tap-next  { right: 0; }

/* Flash feedback al tocar */
#tap-prev::after,
#tap-next::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.04);
  opacity: 0;
  transition: opacity 0.15s ease;
}
#tap-prev:active::after,
#tap-next:active::after { opacity: 1; }

@media (hover: none) and (pointer: coarse) {
  #tap-prev, #tap-next { display: block; }
}

/* Swipe hint — solo mobile */
#swipe-hint {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}

.hint-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 10px 18px 10px 14px;
  border-radius: 100px;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  animation: hintFadeIn 0.5s ease forwards;
}

.hint-hand {
  animation: swipeMotion 1.2s ease-in-out infinite;
  flex-shrink: 0;
  color: #fff;
}

@keyframes swipeMotion {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.88); }
}

@keyframes hintFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#swipe-hint.hiding {
  animation: hintFadeOut 0.4s ease forwards;
}

@keyframes hintFadeOut {
  to { opacity: 0; transform: translateY(6px); }
}

@media (hover: none) and (pointer: coarse) {
  #swipe-hint { display: block; }
}

/* Controles flotantes */
#controls {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 18px 0 22px;
  background: linear-gradient(to top, rgba(255,255,255,0.95) 60%, transparent);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Mostrar controles al hacer hover o tocar */
body:hover #controls,
#controls:hover {
  opacity: 1;
}

/* Siempre visibles en mobile */
@media (hover: none) and (pointer: coarse) {
  #controls { opacity: 1; }
}

#controls button {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  padding: 6px;
  display: flex;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
#controls button:hover {
  color: #111;
  background: rgba(0,0,0,0.05);
}
#controls button:disabled { opacity: 0.2; pointer-events: none; }

#page-info {
  font-size: 0.75rem;
  color: #bbb;
  letter-spacing: 0.1em;
  min-width: 56px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
