/* ============================================================
   LIBRO 3D VOLANTE
   ============================================================ */

.flying-book {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9200;
  pointer-events: none;
  animation: bookFlyPath 22s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  will-change: transform;
}

/* Contenitore prospettico — crea la visione 3D */
.flying-book-inner {
  display: flex;
  align-items: stretch;
  transform: rotateX(25deg);
  filter:
    drop-shadow(0 18px 35px rgba(0, 0, 0, 0.55))
    drop-shadow(0 4px 8px rgba(255, 107, 60, 0.25));
}

/* ── Ali ── */
.flying-book-wing-l,
.flying-book-wing-r {
  width: 95px;
  height: 128px;
  flex-shrink: 0;
}

/* Ala sinistra: metà sinistra dell'immagine */
.flying-book-wing-l {
  transform-origin: right center;
  border-radius: 4px 0 0 4px;
  overflow: hidden;
  background-image: url('../asset/copertinadinosauri.png');
  background-size: 204px 128px;
  background-position: 0px center;
  background-repeat: no-repeat;
  background-color: #1a0800;
  animation: flapLeft 1.15s ease-in-out infinite;
}

/* Ala destra: metà destra dell'immagine */
.flying-book-wing-r {
  transform-origin: left center;
  border-radius: 0 4px 4px 0;
  overflow: hidden;
  background-image: url('../asset/copertinadinosauri.png');
  background-size: 204px 128px;
  background-position: -109px center;
  background-repeat: no-repeat;
  background-color: #1a0800;
  animation: flapRight 1.15s ease-in-out infinite;
}

/* Dorso */
.flying-book-spine {
  width: 14px;
  height: 128px;
  flex-shrink: 0;
  background: linear-gradient(
    180deg,
    #7a3310 0%,
    #4a1e08 40%,
    #7a3310 70%,
    #3a1506 100%
  );
  box-shadow: inset -2px 0 4px rgba(0,0,0,0.4), inset 2px 0 4px rgba(255,255,255,0.08);
}

/* Ombra proiettata sotto il libro */
.flying-book-shadow {
  width: 180px;
  height: 18px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.35) 0%, transparent 70%);
  margin: -4px auto 0;
  transform: scaleX(0.85);
  animation: shadowPulse 1.15s ease-in-out infinite;
}

/* ── Animazioni ali ── */
@keyframes flapLeft {
  0%, 100% { transform: perspective(420px) rotateY(28deg); }
  50%       { transform: perspective(420px) rotateY(-62deg); }
}

@keyframes flapRight {
  0%, 100% { transform: perspective(420px) rotateY(-28deg); }
  50%       { transform: perspective(420px) rotateY(62deg); }
}

@keyframes shadowPulse {
  0%, 100% { opacity: 0.9; transform: scaleX(0.85); }
  50%       { opacity: 0.35; transform: scaleX(0.45); }
}

/* ── Percorso di volo ── */
@keyframes bookFlyPath {
  0%   { transform: translate(12vw,  72vh) rotate( 0deg)  scale(1.00); }
  8%   { transform: translate(45vw,  58vh) rotate( 6deg)  scale(0.92); }
  16%  { transform: translate(78vw,  65vh) rotate(-4deg)  scale(1.05); }
  24%  { transform: translate(85vw,  28vh) rotate( 10deg) scale(0.95); }
  32%  { transform: translate(62vw,  8vh)  rotate(-8deg)  scale(1.02); }
  40%  { transform: translate(30vw,  5vh)  rotate( 5deg)  scale(0.90); }
  48%  { transform: translate(6vw,   20vh) rotate(-10deg) scale(1.00); }
  56%  { transform: translate(3vw,   55vh) rotate( 7deg)  scale(0.95); }
  64%  { transform: translate(22vw,  80vh) rotate(-5deg)  scale(1.04); }
  72%  { transform: translate(58vw,  82vh) rotate( 9deg)  scale(0.93); }
  80%  { transform: translate(88vw,  70vh) rotate(-3deg)  scale(1.00); }
  90%  { transform: translate(80vw,  40vh) rotate( 8deg)  scale(0.96); }
  100% { transform: translate(12vw,  72vh) rotate( 0deg)  scale(1.00); }
}

/* ── Responsive: più piccolo su mobile ── */
@media (max-width: 600px) {
  .flying-book-wing-l,
  .flying-book-wing-r { width: 60px; height: 82px; }
  .flying-book-spine  { width: 10px; height: 82px; }
  .flying-book-shadow { width: 118px; }
}
