:root { --flip-bg: #ffffff; --flip-controls: #1f1f1f; --flip-accent: #1f1f1f; }
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--flip-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--flip-controls);
}

/* Layout in stile "lettore di riviste": libro al centro, frecce ai lati,
   barra sottile in basso con numero di pagina, cursore e comandi. */
#flip-app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--flip-bg);
  overflow: hidden;
}
#flip-app.is-fullscreen { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 999999; }

.flip-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 64px 8px;
}
#flip-viewport {
  width: 100%;
  max-width: 1400px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.15s ease;
}
#flip-viewport.is-zoomed { cursor: grab; }
#flip-viewport.is-zoomed.is-panning { cursor: grabbing; transition: none; }

.flip-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 48px;
  height: 64px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--flip-controls);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity 0.15s ease, visibility 0.15s;
}
.flip-arrow:hover { opacity: 1; }
.flip-arrow svg { width: 34px; height: 34px; display: block; }
.flip-arrow-prev { left: 8px; }
.flip-arrow-next { right: 8px; }
.flip-arrow.is-hidden { opacity: 0; visibility: hidden; }

.flip-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 56px 16px;
  font-size: 17px;
  color: var(--flip-controls);
}
.flip-page-indicator { white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 64px; }

.flip-slider {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.flip-slider:focus { outline: none; }
.flip-slider::-webkit-slider-runnable-track { height: 3px; background: var(--flip-controls); border-radius: 2px; }
.flip-slider::-moz-range-track { height: 3px; background: var(--flip-controls); border-radius: 2px; }
.flip-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -7.5px;
  border-radius: 50%; background: var(--flip-controls); border: 0;
}
.flip-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--flip-controls); border: 0; }
.flip-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(0,0,0,0.15); }

.flip-actions { display: flex; align-items: center; gap: 6px; }
.flip-actions button, .flip-actions a {
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--flip-controls);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none;
}
.flip-actions button:hover, .flip-actions a:hover { background: rgba(0,0,0,0.06); }
.flip-actions button.is-active { background: var(--flip-controls); color: var(--flip-bg); }
.flip-actions svg { width: 24px; height: 24px; display: block; }

@media (max-width: 700px) {
  .flip-stage { padding: 8px 36px 4px; }
  .flip-arrow { width: 32px; }
  .flip-arrow svg { width: 26px; height: 26px; }
  .flip-arrow-prev { left: 2px; }
  .flip-arrow-next { right: 2px; }
  .flip-bar { padding: 6px 12px 10px; gap: 12px; font-size: 15px; }
  .flip-page-indicator { min-width: 52px; }
}

/* ---------- Libro e rotazione 3D delle pagine ---------- */
.fb-book {
  position: relative;
  perspective: 2400px;
  transition: transform 0.55s cubic-bezier(.45,.05,.35,1);
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.fb-page { position: absolute; top: 0; height: 100%; background: #fff; overflow: hidden; }
.fb-left { left: 0; width: 50%; }
.fb-right { left: 50%; width: 50%; }
.fb-single { left: 0; width: 100%; }
.fb-book.is-single .fb-left, .fb-book.is-single .fb-right { display: none; }
.fb-book.is-spread .fb-single { display: none; }
.fb-page.is-empty { background: transparent; }
.fb-page:not(.is-empty) { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16); }
.fb-page img, .fb-face img { width: 100%; height: 100%; display: block; pointer-events: none; }
/* leggera ombra del dorso */
.fb-left:not(.is-empty)::after, .fb-right:not(.is-empty)::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 6%; pointer-events: none;
}
.fb-left:not(.is-empty)::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,0.14), rgba(0,0,0,0)); }
.fb-right:not(.is-empty)::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,0.14), rgba(0,0,0,0)); }

.fb-turner { position: absolute; top: 0; height: 100%; width: 50%; transform-style: preserve-3d; z-index: 5; will-change: transform; }
.fb-turner-right { left: 50%; }
.fb-turner-left { left: 0; }
.fb-turner-single { left: 0; width: 100%; }
.fb-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #fff; overflow: hidden; }
.fb-face.is-empty { background: transparent; }
.fb-back { transform: rotateY(180deg); }
.fb-shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: linear-gradient(to right, rgba(0,0,0,0.28), rgba(0,0,0,0) 70%); }
.fb-back .fb-shade { background: linear-gradient(to left, rgba(0,0,0,0.28), rgba(0,0,0,0) 70%); }
.fb-turner-left .fb-front .fb-shade { background: linear-gradient(to left, rgba(0,0,0,0.28), rgba(0,0,0,0) 70%); }
.fb-turner-left .fb-back .fb-shade { background: linear-gradient(to right, rgba(0,0,0,0.28), rgba(0,0,0,0) 70%); }
.fb-turner.is-moving .fb-shade { animation: fb-shade 650ms ease-in-out; }
@keyframes fb-shade { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
.fb-turner-single.is-moving .fb-front { box-shadow: 0 4px 24px rgba(0,0,0,0.25); }

/* con lo zoom il libro resta dentro l'area di lettura e non copre la barra */
.flip-stage { overflow: hidden; }
.flip-bar { position: relative; z-index: 30; background: var(--flip-bg); }
.flip-arrow { z-index: 15; }
